繁体   English   中英

如何根据 Game Maker 中的移动方向更改 gamemaker 中的对象精灵?

[英]How do I change a objects sprite in gamemaker based on its direction on movement in Game Maker?

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

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

最简单的方法:

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事件中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM