game-maker - 如何根据 Game Maker 中的运动方向更改 GameMaker 中的对象 Sprite ?

标签 game-maker

我正在游戏制作器 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_leftspr_rightspr_upspr_down 是您的 Sprite 。 您可以将此代码放置在 Step End 事件中。

关于game-maker - 如何根据 Game Maker 中的运动方向更改 GameMaker 中的对象 Sprite ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41129134/

相关文章:

c++ - 如何使用 C++ 在 SFML 中播放播放器

java - 数据包从 Game Maker 到 Node,js 不分离

data-structures - 可从任何地方读取的类似队列的数据结构

java - 2 个物体之间的角度

用于 DLL 的 c++ Internet 交互

Python 服务器和游戏客户端 : Message overload?

path - 软件崩溃;设置路径时出错 : "rfPersonal"

memory - ds_map 会破坏子 map 吗?

java - 如何将 Java 放入 GameMaker Studio?

block 匹配游戏放置算法