在 player.hx 中:
public function new(X, Y, _upKey:String, _downKey:String){
super(X, Y);
makeGraphic(20, 20, FlxColor.RED);
immovable = true;
}
在 PlayState.hx 中:
override public function create():Void
{
super.create();
add(new Enemy(300, FlxG.height - 20, 10, 20));
add(new Enemy(500, FlxG.height - 40, 10, 40));
add(player = new Player(60, FlxG.height - 40, "UP", "DOWN"));
}
即使我已经在函数中设置了这些错误,它也会在 Player.hx 文件中返回错误“未知标识符:upKey”和“未知标识符:downKey”。我该如何解决?