Quick Guide
- Animation - general animation page
- Animation End Event - the event that happens to an object when a sprite displays it's last subimage
- Change Sprite Action - can affect various properties of an animating sprite
- image_index - the current frame of the animation
- image_number - the number of subimages of a sprite
- image_speed - the speed at which a sprite animates
- room_speed - the image_speed will appear faster or slower at the same value depending on the room_speed.
- Sprite - general sprite page.
Subimages
A sprite can be a single image, an animated sprite that is composed of a series of images that change. Each of these images are numbered starting at 0. You can access and change the currently displayed subimage by the variable image_index
Above is a visual example of the subimages that are a part of the sprite and the final animating sprite itself. The above example assumes a 4 frame animation.
Animation Loop
The subimages of a sprite animate in a loop automatically. After the last subimage is displayed, the animation loops back to the first.
Timing
Animation Speed
In Game Maker, sprites animate at a speed according to the value of image_speed. If image_speed is set to 0 then the sprite does not animate at all. If image_speed is set to 1 then the sprite animates at 1 frame per step, which is very fast — if the room_speed of the current room is set to 30, it will animate at 30 frames per second.
Slowing Down the Sprite Animation
Setting the image_speed to a number less than 1 will slow down the animation. Setting image_speed to 0.10 will cause the sprite to animate at 1 subimage for every 10 steps. To find the ratio you need quickly, you can use this simple formula :
1 sprite frame
--------------
no. of steps
You do not need to calculate this, as you can put the raw math right into your code. For example, if you wanted a sprite to animate at 1 sprite frame per 24 steps (for whatever reason) this code would work :
image_speed = 1 / 24;
Related Pages
Backlinks
These pages link back to this page. You may find them helpful.
| Categories: Graphics : Sprites |