我目前正在尝试使用键盘输入来移动精灵。
我的代码中没有任何错误:
function create(){
cursors = Game.input.keyboard.createCursorKeys();
/* ... */
}
function update(){
var hitPlatform = Game.physics.arcade.collide(player, platforms);
player.body.velocity.x = 0;
if (cursors.left.isDown)
player.body.velocity.x = -150;
else if (cursors.right.isDown)
player.body.velocity.x = 150;
if (cursors.up.isDown && player.body.touching.down && hitPlatform)
player.body.velocity.y = -350;
}
当我按下光标键时,没有任何反应。
当键按下时,Phaser似乎没有检测到它(cursors.left.isDown
值不会改变)。