我正在游戏制作器 v1.4.1763 中制作迷宫游戏,并且需要一些帮助来根据对象的运动方向更改对象 Sprite 。我目前有一个使用游戏制作者拖放“移向” Action 跟随鼠标的对象。我有从 4 个不同视角(前、后、左、右)为该对象制作动画的 Sprite 。该对象可以移动任何方向(不必遵循基本方向。)
我希望该对象根据其“主要”移动的方式来更改其 Sprite 。我真的不知道如何使用游戏制作者语言进行编程,但我知道如何让它执行代码。我已经尝试了几乎所有使用拖放编码的方法,但这只能使用一些代码来完成。如果有人可以帮助我编写该代码,那就太棒了。
最佳答案
最简单的方法:
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_left
、spr_right
、spr_up
、spr_down
是您的 Sprite 。
您可以将此代码放置在 Step End
事件中。
关于game-maker - 如何根据 Game Maker 中的运动方向更改 GameMaker 中的对象 Sprite ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41129134/