-1
xキーボードボタンを押すと、何らかの理由でプレーヤーのスプライトが攻撃されません。スプライトプレイヤーの攻撃を助けるためにできることはありますか?ゲームメーカーの攻撃がうまくいかない
/// Obj_playerイベント作成
/// set fixed rotation for object player
event_inherited();
hp = 20;
spd = 4;
hspd = 0;
vspd = 0;
len = 0;
xaxis = 0;
yaxis = 0;
dir = 0;
attacked = false;
image_speed = 0;
scr_get_input();
state = scr_move_state;
/// Obj_playerアラーム0
/// This alarm is for the dash state
state = scr_dash_state;
state = scr_attack_state;
/// Obj_playerステップイベント
/// move the player in the step event
event_inherited();
script_execute(state);
state = scr_move_state;
scr_get_input();
/// Obj_Animationエンド
/// Change back to move state
if (state == scr_attack_state) {
state = scr_move_state;
attacked = false;
}
/// scr_get_input
right_key = keyboard_check(vk_right);
left_key = keyboard_check(vk_left);
up_key = keyboard_check(vk_up);
down_key = keyboard_check(vk_down);
dash_key = keyboard_check_pressed(ord('C'));
attack_key = keyboard_check_pressed(ord('X'));
// Get the axis
xaxis = (right_key - left_key);
yaxis = (down_key - up_key);
/// scr_move_state
scr_get_input();
if (dash_key) {
state = scr_dash_state;
alarm[0] = room_speed/7;
}
if (attack_key) {
image_index = 0;
state = scr_attack_state;
}
// get direction
dir = point_direction(0,0, xaxis, yaxis);
// Get the length
if (xaxis == 0 and yaxis = 0) {
len = 0;
} else {
len = spd;
}
// Get the hspd and vspd
hspd = lengthdir_x(len, dir);
vspd = lengthdir_y(len, dir);
// move
phy_position_x += hspd;
phy_position_y += vspd;
// Control the sprite
image_speed = sign(len)*.2;
if (len == 0) image_index = 0;
// Vertical sprites
if (vspd > 0) {
sprite_index = spr_player_down;
} else if (vspd < 0) {
sprite_index = spr_player_up;
}
// Horizontal sprites
if (hspd > 0) {
sprite_index = spr_player_right;
} else if (hspd < 0) {
sprite_index = spr_player_left;
}
/// scr_attack_state
image_speed = .5;
switch (sprite_index) {
case spr_player_down:
sprite_index = spr_player_attack_down;
break;
case spr_player_up:
sprite_index = spr_player_attack_up;
break;
case spr_player_right:
sprite_index = spr_player_attack_right;
break;
case spr_player_left:
sprite_index = spr_player_attack_left;
break;
}
私は攻撃のためにxキーボードボタンの代わりにXを使用しなければならないと思っていました。 –
Xのキャプション文字を小文字にして、何も変更しませんでした。 –
Obj_playerのアラーム0イベントで私のダッシュに同じソリューションを使用しようとしています。 –