[Solved] Sprites walking animation and movement synchronisation

S

Scott97

Guest
Hi!

So I have a walking animation in game maker that runs at 6 frames per second. My game runs at 60 frames per second. What I would like is if the character only moved forward every 10 frames (when the next frame appears).

Is there a way to get an event of some sort when the object displays the next frame?

At the moment, I am using in the step event,
Code:
if floor(image_index) != image_index_previous
{ 
      event_user(1);
}

image_index_previous = floor(image_index);
Kind of clunky and I don't like it but it is the best I have got at the moment.

Any suggestions would be very much welcome

Thanks!
 
Last edited by a moderator:

Simon Gust

Member
I would use alarms or a manual timer.
Code:
if (moving) // check if pressing a key or something
{
 if (alarm[0] <= 0)
 {
  // move here
  alarm[0] = 10;
 }
}
Add the alarm[0] event and add a code block with a comment in it so it doesn't vanish.
 
Top