Is it possible to make a function that will give my images(25 tiles, 5x5) a random value(RNG)?
The idea is the images have to change randomly after x seconds, and until a Sprite collides with it.
However, not all of the images have to change simultaneously only some.
Thats why i have to give it a random value first, right?
My first project in Phaser, so i donāt have alot of experience in it so far. Thanks for understanding.
If you donāt undertand my question, please let me know!
Basically what iām trying to do, is to give every image a number from 1-25,
then make a function which Randomly selects a number from 1-25.
That number which is randomly selected is a image, that has to change to another image.
As you can see on the picture, iāve 25 images on the canvas.
I want some of the images to randomly change. Iāve the 25 other images ready.
My idea is to give every image a number,
then use the RandomNumber function so that ex. if 12 is selected, it will make image change.
Iāve been positioning every image by x and y, like this:
this.walls.create(61,61, āgametilelava1ā); //A1
this.walls.create(61,178,āgametilelava1ā); //B1
this.walls.create(61,295,āgametilelava1ā); //C1
Iām sorry if iām not being clear, iām not even sure if what iām asking to do is possible.
Yes, you can load 25 images (āgametilelava1ā through āgametilelava25ā) and then switch them on a game object with setTexture().
Or if they arenāt too large you can combine all of them in your image editor and the load 1 spritesheet with 25 frames (0 through 24) and then switch them with setFrame().
Thanks for the demonstration, very nice of you to show the solution.
However, being honest with you, i donāt understand everything in that code. I must read/see some more tutorials in order to implent in my own project.