set an instance's sprite at random

H

Huy

Guest
Hi,

When my 'human' instance is created i want it to choose, at random, from 3 different human Idle animation.

right now, in the create event of the instance, it executes:
sprite_index = choose(m1Idle, m2Idle,m3Idle);

//(m1Idle,M2Idle.... are the names of my sprites)


but when the game starts, there's nothing there. What do i need?

also, after the instance choose a sprite, can i set the sprite somewhere so later if i do change the sprite of the instance, i can change it back by referring to the old sprite.
 

CloseRange

Member
make sure you have 'visible' checked. Also if you have a draw event in the object then add the line:
draw_self();
to the start of the draw event.

If you want to remember the original sprite do this in the create event:
Code:
start_sprite = choose(m1Idle, m2Idle, m3Idle);
sprite_index = start_sprite;
then whenever you want to go back to the original sprite just say:
sprite_index = start_sprite;
 
H

Huy

Guest
make sure you have 'visible' checked. Also if you have a draw event in the object then add the line:
draw_self();
to the start of the draw event.

If you want to remember the original sprite do this in the create event:
Code:
start_sprite = choose(m1Idle, m2Idle, m3Idle);
sprite_index = start_sprite;
then whenever you want to go back to the original sprite just say:
sprite_index = start_sprite;
Works like a charm, thanks.
 
Top