GameMaker Sprite Setup Guide
Setting Up Sprites in GameMaker Studio 2
GameMaker Studio 2 has one of the most streamlined sprite workflows in the 2D game engine world. Setting up a gamemaker sprite correctly from the start saves hours of debugging later. This guide walks through importing images, configuring sub-images for animation, tuning animation speed, and setting precise collision masks. Whether you are using a hand-drawn character or an AI-generated animated sprite, the process is the same.
The gamemaker sprite system is built around the Sprite Resource. Every visual object in your game — characters, enemies, items, UI elements — references a Sprite Resource. Understanding how to configure these resources properly is foundational to GameMaker development.
Creating a New Sprite Resource
In the Asset Browser (right side of the IDE by default), right-click on the Sprites folder and select Create > Sprite. A new sprite resource opens in the Sprite Editor. You can also import an existing image by clicking Import in the Sprite Editor toolbar and selecting your PNG file.
For a sprite sheet containing multiple animation frames, use Import Strip instead of the standard import. This opens a dialog where you specify:
- Number of frames - How many images are in the strip
- Images per row - Columns in your grid layout
- Images per column - Rows in your grid layout
- Frame width / height - Pixel dimensions of each individual frame
- Horizontal / vertical offset - If frames do not start at pixel 0,0
- Horizontal / vertical separation - Pixel gap between frames, if any
GameMaker slices the sheet and creates individual sub-images from the strip. Each sub-image becomes one frame of the animation.
Understanding Sub-Images
In GameMaker, individual animation frames are called sub-images. When you play a sprite in a Game Object, GameMaker cycles through sub-images at a rate you control. The sub-image index starts at 0, so a sprite with 8 frames has sub-images 0 through 7.
You can access and control the current sub-image in GML code:
image_index- The currently displayed sub-image (can be fractional for smooth animation)image_number- Total number of sub-images in the sprite (read-only)image_speed- How fast sub-images advance per game step
To manually set which frame displays, set image_index = 3 in your Step event. To stop animation entirely, set image_speed = 0 and control image_index yourself. This is useful for cutscenes or state-based animation logic.
Configuring Animation Speed
Animation speed in GameMaker is controlled by the Speed value in the Sprite Editor. You will find it in the left panel of the Sprite Editor, below the sprite name. There are two speed modes:
- Frames per second (FPS) - Sets an absolute frame rate regardless of game speed. Recommended for most cases.
- Frames per game frame - Ties animation speed to your game's step rate (typically 60 steps per second). A value of 0.2 means one new sub-image every 5 game frames.
Recommended FPS values by animation type:
- Idle animation - 6 to 8 FPS (slow breathing or subtle movement)
- Walk cycle - 8 to 12 FPS (natural footstep rhythm)
- Run cycle - 12 to 16 FPS (fast, energetic movement)
- Attack animation - 16 to 24 FPS (snappy, impactful feel)
- Pixel art general - 8 FPS is a classic retro feel
You can override the sprite's default speed per object instance by setting image_speed in code. For example, image_speed = 0.5 halves the speed set in the Sprite Editor. A value of 2 doubles it.
Setting Collision Masks
Collision detection in GameMaker relies on the sprite's collision mask, not the visible pixels. Getting this right prevents frustrating bugs where collisions fire too early or enemies clip through walls.
In the Sprite Editor, click the Edit Collision Mask button (the shield icon). You can choose from several mask shapes:
- Automatic - GameMaker calculates the bounding box of non-transparent pixels. Fine for simple sprites.
- Full Image - The entire image rectangle, including transparent areas. Rarely what you want.
- Ellipse - Oval mask good for round objects or top-down characters.
- Diamond - Rotated square, useful for isometric games.
- Rectangle - Manually set a rectangular region. Most common choice for platformers.
- Precise - Pixel-perfect collision based on actual non-transparent pixels. Accurate but expensive for complex sprites or large numbers of objects.
For platformer characters, a Rectangle mask set slightly inside the visible sprite edges reduces edge-catch collisions. Shrink the mask by 2 to 4 pixels on each side. For circular projectiles, the Ellipse mask gives natural hit detection.
Important: For animated sprites, the collision mask is applied based on the settings of the first frame (sub-image 0) unless you check Separate Collision Masks for per-frame masks. Per-frame masks are useful for attack animations where the hitbox should only appear during specific frames.
Sprite Origins and Positioning
The origin point determines where the sprite anchors relative to an object's position coordinates. By default GameMaker places the origin at the top-left corner (0,0 of the image). For most game objects you want a different origin:
- Characters - Bottom-center so the character's feet sit at their Y coordinate
- Projectiles - Center for even rotation and symmetric hit detection
- Items / pickups - Center for clean placement on tiles
Click the origin preview in the Sprite Editor and drag it, or type coordinates directly in the X and Y fields. Use the preset buttons (Top Left, Top Center, Middle Center, Bottom Center, etc.) for common positions.
Organizing Multiple Sprite Animations
A typical player character needs separate sprite resources for each animation state: idle, walk, run, jump, fall, attack, hurt, and death. Create one sprite resource per animation. In your Object's Step event, switch the object's sprite with sprite_index = spr_player_walk.
A clean way to manage this is with a state machine:
- Idle state →
sprite_index = spr_player_idle - Walking state →
sprite_index = spr_player_walk - Jumping state →
sprite_index = spr_player_jump
Reset image_index = 0 whenever you switch states to prevent the animation from starting mid-cycle.
Ready to Build Your GameMaker Game?
Good sprites are the foundation of any great 2D game. Use our AI Sprite Generator to create pixel art characters and animations in seconds, then use this guide to import and configure them in GameMaker Studio 2. Generate a full character sprite set or build a complete sprite sheet with all your animation frames, and you will be ready to start building your game today.