我是新手,正在使用GML,目前遇到一个问题。我想让玩家角色图像根据鼠标方向变化,目前已经实现了,除了右方向外,其他方向都正常工作。但是,我无法理解为什么第一条条件语句不能正常工作。
我的代码如下:
// 设置方向为鼠标位置
direction = point_direction(x, y, mouse_x, mouse_y)
// 根据方向设置图像
if direction <= 30 && direction >= 330 { charge_sprite_sword = 6 }
if direction > 30 && direction <= 150 { charge_sprite_sword = 8 }
if direction >= 150 && direction < 210 { charge_sprite_sword = 4 }
if direction >= 210 && direction < 330 { charge_sprite_sword = 2 }
但是,第一条条件语句没有生效。其他条件语句都正常工作。
我已经尝试了以下方法:
- 使用“清理”选项
- 将值更改为90和270
- 删除设置方向的行,并手动设置方向,如下所示:
if point_direction(x, y, mouse_x, mouse_y) <= 30 && point_direction(x, y, mouse_x, mouse_y) >= 330 { show_debug_message("left") }
但是,问题仍然没有解决。因此,我希望有人能帮助我解决这个问题。
评论 (0)