我正在 GMS 2 中开发 2D 平台游戏,当我按下应该让他改变射击和蹲伏姿势的按钮时,我的玩家对象不会改变精灵。我尝试将不同的姿势放入不同的精灵中,并将姿势放入同一精灵中的不同帧中。这些解决方案都没有奏效,我迫切需要一些帮助。
目前,姿势在单独的精灵中,代码如下所示:
// Movement
key_right = keyboard_check(ord(“D”))
key_left = keyboard_check(ord(“A”))
key_jump = keyboard_check(ord(“W”))
key_crouch = keyboard_check(ord(“S”)) // This button doesn’t work
// Attacks
key_shoot = keyboard_check(vk_space) // Neither does this one
key_punch = keyboard_check(ord(“J”))
key_kick = keyboard_check(ord(“K”))
...
if (!key_left) and (!key_right) {
sprite_index = spr_player_stand
image_speed = 0
image_index = 0
} else if (key_left) and (key_right) {
sprite_index = spr_player_stand
image_speed = 0
image_index = 0
} else if (key_left) {
xscale = -0.6
sprite_index = spr_player_run
} else if (key_right) {
xscale = 0.6
sprite_index = spr_player_run
} else if (key_crouch) {
sprite_index = spr_player_crouch
} else if (key_shoot) {
sprite_index = spr_player_shoot
} else if (key_punch) {
sprite_index = spr_player_punch
} else if (key_kick) {
sprite_index = spr_player_kick
}
PS请不要费心纠正我缺少“;” 在行尾。我知道这是一个坏习惯,我知道我正在这样做,所以不要费心告诉我停止它。