(Solved!) How to start an animated sprite from a random number?

Hi Folks,

I try to make a sprite-animation, starting from a random number.
But I wasn´t successful. I have a walking zombie, spawning in a level
up to 6 instances, maximum. The sprite has 32 images. Now I just
want for each added zombie a new randomized number, where the
its animation has to start, and then repeating (random number just
at the beginning).

Hope I could explain it well!?
greetings, Archie.


couldnt you do something like this..

obj_zombie create event
image_speed = 1;
image_index = irandom(0,32);

or set a variable in the spawner step event to pick a random number and use irandom()


You could set the index based on the max number of 'sprite indexes' and then irandomize it to the nearest whole number. You subtract 1 because sprite_index starts at 0, not 1

image_index = irandom( image_number-1 );
Hi Woods.

So simple! I just set one number (maximum image number of sprite) into the brackets of irandom. Works! Thank you for your help! :)

Best wishes.