Select frames from an animation?



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!


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)

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.