• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Select frames from an animation?

Z

Zeltos

Guest
Is there a way to select frames from an animation and only play those? For example, I have 3 animations in 1 sprite, 8 different frames (cause the free game maker version only allows 20 sprites) and I only want to play frame 3 to 6.

Thanks in advance!
 

Binsk

Member
Not directly, but you could code it manually to skip frames.

Every object has a built-in variable called image_index. This contains the current frame being drawn. It can also be used to SET the current frame. You could do something like this to limit it between 3 and 6 (inclusively)

Code:
image_index = (max(3, image_index % 7));
If that code is called before you draw the sprite or in the step event or something it will keep the subimage in the range of [3..6].

How It Works:
The image_index % 7 takes the value and wraps it back around starting at 0 any time it passes 6. So a value of 7 would be changed to 0, value of 8 to 1, etc. Then we say pick the larger of the two numbers, 3 or our result. So if it wrapped to 1 we would instead jump to 3.
 
Top