Javascript 键盘控制不工作
我目前正在尝试使用键盘输入移动精灵 我的代码中没有任何错误:Javascript 键盘控制不工作,javascript,phaser-framework,Javascript,Phaser Framework,我目前正在尝试使用键盘输入移动精灵 我的代码中没有任何错误: function create(){ cursors = Game.input.keyboard.createCursorKeys(); /* ... */ } function update(){ var hitPlatform = Game.physics.arcade.collide(player, platforms); player.body.velocity.x = 0; if
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
值没有变化)。在浏览器控制台中按任何键都没有错误吗?@Julián没有,没有错误,现在我想问题来自我的浏览器。在浏览器控制台中按任何键都没有错误吗?@Julián没有,没有错误,现在我认为问题来自我的浏览器。