【问题标题】:How to freeze sprite animation on last frame?如何在最后一帧冻结精灵动画?
【发布时间】:2016-08-03 06:43:18
【问题描述】:

我想在游戏制作器中制作一个包含 5 个子图像的精灵,当它到达最后一个时停止我如何使用代码来做到这一点?

【问题讨论】:

    标签: game-maker gml


    【解决方案1】:

    Animation End 事件中:

    image_speed = 0;
    image_index = image_number - 1;
    

    【讨论】:

    • 当我使用这段代码时,动画甚至没有开始
    • 此代码在动画播放一次后停止动画。见example
    • 你必须把它放在动画结束事件中......我假设你把它放在一步中
    【解决方案2】:

    在您的对象的 Step 中运行它:

    If image_index == 4 Then image_speed = 0;
    

    image_index 是对象精灵动画中当前帧的索引,image_speed 是动画的速度(以每步帧数为单位)。此代码仅检查动画是否在最后一帧(帧索引为 0,因此第 5 帧索引为 4。),如果是,则将速度设置为 0

    【讨论】:

    • 它给了我这个错误:无法在 gml_Object_obj_magnet_StepNormalEvent_3(第 13 行)找到对象索引“12”名称“obj_arrow_move_one_direction”的任何实例 - if(obj_arrow_move_one_direction.image_index==4)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-07
    • 2020-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多