Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 键盘控制不工作_Javascript_Phaser Framework - Fatal编程技术网

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没有,没有错误,现在我认为问题来自我的浏览器。