Easy Animation Control

Let’s slow things down and take control of animation frequency.

GameMaker Studio has a great sprite editor we can use for drawing and animation. And by default, objects in GMS use the draw_self() function to draw the sprite asset assigned to it, playing each frame of animation for each frame based on the room’s speed.

Let’s slow things down and take control of animation frequency.

Setting Up

Let’s start with our objects. We are going to control every aspect of animation using the draw_sprite_ext() function.

  • x, y: Coordinates
  • Sprite: Sprite asset
  • Index: Frame of animation
  • XScale, YScale: stretch, squish, and reverse
  • Rotation: Spin it right round
  • Color: Overlay a color, c_white for default
  • Alpha: transparency in room


sprite = sprite_index;
frame = 0;
xscale = 1;
yscale = 1;
rot = 0;
col = c_white;
a = 1;



And to help things along, let’s create a global variable for the frame speed we want all our animation moving at.

global.framespeed = 0.35;

Helper Scripts

Now that our object is pointing to variables for each part of the animation, let’s write some scripts that can be reused to move things along!

frame += global.framespeed;
if(floor(frame) >= sprite_get_number(sprite)){
     frame = 0;

Now add these into the object’s step event.

The object’s sprite frame being displayed will only advance when the frame variable passes a whole number. Once it gets to the end, scr_frame_reset will put it back to zero.

Advanced Control

Using these scripts across all our objects is great, because this allows us to control the speed of animation for all objects at the same time.

Say during an explosion we want the run-cycle to slow down. Or during the pause menu you want the collectible coins to stop spinning. This is a great way to achieve that.

What’s Next?

Don’t limit your animation control to just frame speeds! Play around with cycling colors on your sprite, or spinning things around with the rotation variable for some cool effects. Have fun!

By Rob Nichols

Rob Nichols is an IT professional with years of experience creating games in GameMaker Studio, creating electronic music, and producing the weekly VGM podcast Rhythm and Pixels.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s