如何保证在玩家移动和播放动作动画后,上架的动画(Idle)
How to make sure that after the player’s movement and playing the motion animation, the animation of the rack (Idle)
如何确保在玩家移动并播放运动动画后,机架(Idle)的动画开始,这应该在两个方向(右,左)都起作用
我找到了解决办法,需要用keyboard_check_released
var right_move = (keyboard_check(ord("D")));
var left_move = (keyboard_check(ord("A")));
var right_move_release = (keyboard_check_released(ord("D")));
var left_move_release = (keyboard_check_released(ord("A")));
if (right_move) {
phy_position_x += 10;
sprite_index = Move_right;
image_speed = 1;
}
if (right_move_release) {
sprite_index = Idle_right;
}
if (left_move) {
phy_position_x -= 10;
sprite_index = Move_left;
image_speed = 1;
}
if (left_move_release) {
sprite_index = Idle_left;
}
我认为您也可以使用 else
而不是 if 语句,这样可以使代码更简洁:
var right_move = (keyboard_check(ord("D")));
var left_move = (keyboard_check(ord("A")));
if (right_move) {
phy_position_x += 10;
sprite_index = Move_right;
image_speed = 1;
} else {
sprite_index = Idle_right;
}
if (left_move) {
phy_position_x -= 10;
sprite_index = Move_left;
image_speed = 1;
} else {
sprite_index = Idle_left;
}
如果左精灵与右精灵相同,那么您也可以使用image_xscale
并将比例更改为1
或-1
来翻转精灵。
如何确保在玩家移动并播放运动动画后,机架(Idle)的动画开始,这应该在两个方向(右,左)都起作用
我找到了解决办法,需要用keyboard_check_released
var right_move = (keyboard_check(ord("D")));
var left_move = (keyboard_check(ord("A")));
var right_move_release = (keyboard_check_released(ord("D")));
var left_move_release = (keyboard_check_released(ord("A")));
if (right_move) {
phy_position_x += 10;
sprite_index = Move_right;
image_speed = 1;
}
if (right_move_release) {
sprite_index = Idle_right;
}
if (left_move) {
phy_position_x -= 10;
sprite_index = Move_left;
image_speed = 1;
}
if (left_move_release) {
sprite_index = Idle_left;
}
我认为您也可以使用 else
而不是 if 语句,这样可以使代码更简洁:
var right_move = (keyboard_check(ord("D")));
var left_move = (keyboard_check(ord("A")));
if (right_move) {
phy_position_x += 10;
sprite_index = Move_right;
image_speed = 1;
} else {
sprite_index = Idle_right;
}
if (left_move) {
phy_position_x -= 10;
sprite_index = Move_left;
image_speed = 1;
} else {
sprite_index = Idle_left;
}
如果左精灵与右精灵相同,那么您也可以使用image_xscale
并将比例更改为1
或-1
来翻转精灵。