我目前对为按钮命令和方向数组编写代码有一个大问题。我为水平按钮数组编写代码,其形式如下:
for (var i = 0; i < array_length_1d(left); i ++;){
if (keyboard_check(left[i])){
x -= spd;
break;
}
}
然后我创建垂直按钮数组,其中向上按钮数组是正确的,但在分发此代码时向下按钮数组不正确:
for (var i = 0; i < array_length_1d(down); i ++;){
if (keyboard_check(down[i])){
y += spd;
break;
}
}
当我尝试运行游戏时,它显示此错误:
FATAL ERROR in
action number 1
of Step Event0
for object obj_player:
Variable obj_player.down(100008, -2147483648) not set before reading it.
at gml_Object_obj_player_Step_0 (line 25) - for (var i = 0; i < array_length_1d(down); i ++;){
我究竟做错了什么?