What I expect to happen: I would like my fruit to loop across the screen and change animations from one of five possible sprites every time they loop. If they touch each other, or Kirby, I would also like them to change animation. I saw this post that shows how to randomize a die on a mouse click, so I tried to adapt that code to fit my needs, but it’s not working.
What actually happens: The fruit loops, but it does not change animations.
What I’ve tried: I have used watchers in the debug console to see that the variable I made for the fruit is randomizing, but it is not affecting the fruit’s animation.
It seems to be working now for some reason. I’m really not sure what I changed. I had previously not declared the variable inside the loop, as had been done in the example link, and it didn’t seem to work. I took that out and it seems to be working now. I must have had some other bug earlier that I fixed in the meantime. I will leave this up for others who might also have this issue/question.
Glad you figured it out! Yeah, generally, declaring a variable inside a loop can cause issues so you typically want to declare it outside the loop and update it inside the loop.