【问题标题】:How do I change a objects sprite in gamemaker based on its direction on movement in Game Maker?如何根据 Game Maker 中的运动方向更改 gamemaker 中的对象精灵?
【发布时间】:2017-04-28 23:43:11
【问题描述】:

我正在 game maker v1.4.1763 中制作迷宫游戏,需要一些帮助来根据其运动方向更改对象精灵。我目前有一个对象跟随鼠标使用游戏制造商拖放“移向”动作。我有从 4 个不同角度(前、后、左和右)为对象动画的精灵。对象可以移动任何方向(不必拘泥于大方向。)

我希望对象根据“大部分”移动的女巫方式来更改其精灵。我真的不知道如何使用游戏制作者语言进行编程,但我知道如何让它执行代码。我已经尝试了几乎所有使用拖放编码的方法,而这只能使用一些代码来完成。如果有人能帮我想出那个代码,那就太棒了。

【问题讨论】:

    标签: game-maker


    【解决方案1】:

    最简单的方法:

    if direction > 45 and direction <= 135 and sprite_index != spr_up
        sprite_index = spr_up;
    else if direction > 135 and direction <= 225 and sprite_index != spr_left
        sprite_index = spr_left;
    else if direction > 225 and direction <= 315 and sprite_index != spr_down
        sprite_index = spr_down;
    else if sprite_index != spr_right
        sprite_index = spr_right;
    

    spr_leftspr_rightspr_upspr_down 是您的精灵。 您可以将此代码放在Step End 事件中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-26
      • 1970-01-01
      相关资源
      最近更新 更多