How to freeze sprite animation on last frame?

本小妞迷上赌 提交于 2019-12-13 02:55:48

问题


I want to make a sprite in game maker that contains 5 sub images to stop when it reaches the last one how can I do this using code?


回答1:


In Animation End event:

image_speed = 0;
image_index = image_number - 1;



回答2:


Run this in the Step even of your object:

If image_index == 4 Then image_speed = 0;

image_index is the index of the current frame in the object's sprite's animation, image_speed is the speed of the animation (in frames per step). This code just checks if the animation is at the final frame (the frames are 0-indexed, so the 5th frame is index 4.), and if so sets the speed to 0.



来源:https://stackoverflow.com/questions/36576900/how-to-freeze-sprite-animation-on-last-frame

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!