From the course: Building a Physics-Based Platformer in GameMaker Studio Using GML

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Control logic: Idle and run animations

Control logic: Idle and run animations

- [Instructor] Clearly, our idle and running animations are working correctly, so let's go in and fix those up. I'll open up the player object, go to the create event, and let's go back to our initialization code. Since the initial sprite for our player object is the idle sprite, let's go ahead and set the image speed here. We'll use the function image underscore speed, and I'll set this to something small like 0.12. I've tested this and it looks like it'll work pretty well. Usually I just set these by trial and error, though. Let's close this out, and go to our state machine. I'll go to the step event, click on the state machine, and let's go into the idle event. We've already set up the image speed in the create event, but we want to set it up here as well in case we transition into the idle state from another state in our state machine. So let's do a check. Let's see if our current sprite index, with sprite underscore index, is not equal to our idle sprite, S underscore player…

Contents