如何根据Game Maker中的移动方向更改游戏制作者中的对象精灵?

时间:2016-12-13 19:32:43

标签: game-maker

我正在制作游戏制作者v1.4.1763中的迷宫游戏,并需要一些帮助根据其移动方向更改对象精灵。我目前有一个跟踪鼠标的对象,使用游戏制造商拖放'走向"行动。我有从4个不同视角(前,后,左,右)为对象设置动画的精灵。对象可以向任何方向移动(它不必坚持基本方向。)

我希望对象能够根据女孩的方式改变它的精灵状态"主要是"移动。我真的不知道如何使用游戏制作者语言编程,但我知道如何让它来执行代码。我已经尝试使用拖放编码几乎所有东西,这只能使用一些代码来完成。如果有人可以帮我提出那些代码,那就太棒了。

1 个答案:

答案 0 :(得分: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事件中。