The
draw_self() and the "-1 in the second argument of
draw_sprite()" solutions won't work if the sprite in
sprite_index doesn't have the same number of frames as the sprite you're about to draw.
Either you emulate the frame animation process yourself like this:
Create:
Code:
my_sprite = spr_example;
my_sprite_frame = 0;
my_sprite_speed = 1;
Draw GUI:
Code:
my_sprite_frame += my_sprite_speed;
draw_sprite(my_sprite, my_sprite_frame, 32, 32);
Or create a new blank object with a comment-only Draw event and a Draw GUI event with
draw_self(), then create an instance of that and set its sprite.
Code:
var inst = instance_create_layer(32, 32, layer, obj_sprite_placeholder);
inst.sprite_index = spr_example;
I've recently started to delegate background tasks to workers (the second approach) instead of hogging it all in the Step event like most others here do (the first approach). The performance impact on my code has thus far been negligible, but the maintainability gains far outweigh the runtime costs.