Legacy GM Animation Frames Missing in Idle Animation (Please Help!)

T

Tyler

Guest
Hello,

I have been trying to create code that plays an animation if the player is inactive for an extended period of time (similar to how Mario will fall asleep if you put the controller down for a while). So far I have been successful in making the animation play after a variable counter reaches 0, but every time the animation plays there are frames missing! I have tested the animation under normal circumstances and as far as I can tell the animation only skips frames in the context of my variable counter. I would greatly appreciate it if anyone knows the solution to my problem. Here are the basics to my code:

//Create Event
image_speed = 0.1;
timer = 60;
stopped = spr_player_stopped;
wait = spr_player_wait;

//Step Event
if (keyboard_check(vk_nokey))
{
sprite_index = stopped;
timer -= 1;
if (timer <= 0) sprite_index = wait;
}
else timer = 60;

I hope this code is clear enough. I am not sure if this is also useful information, but spr_player_stopped has 4 frames of animation, spr_player_wait has 8 frames of animation, and the game runs at 60 frames per second.

Thank you!
 

wamingo

Member
The image_index is retained despite switching sprite_index, so you have to set the image_index to zero ONCE upon timer reaching 0.
now you can figure it out.
 
T

Tyler

Guest
Hmmm... I see your point. However, even with the prescribed changes, the last four frames of the spr_player_wait animation are still missing. Luckily, I figured out that I could fix my problem by doubling the number of frames of the spr_player_stopped animation. Though I have to admit that this is not a very elegant solution. Thank you for your help!
 
Top