我的 Phaser 语法有问题吗?

Is there something wrong with my Phaser syntax?

所以我已经尝试让这段代码正常工作,但无论我多么努力,它仍然无法正常工作。我的目标是使用光标让我的精灵移动,但它不起作用。同样出于某种原因,如果我的精灵依赖于此:

 gameState.cursors.this.input.keyboard.
 createCursorKeys();

我知道我的代码有误,但我不知道如何修复它,它在下面:

   if (gameState.cursors.left.isDown) {
        gameState.player.setVelocityX(-160);
  } else if (gameState.cursors.right.isDown) {
        gameState.player.setVelocityX(160);
  } else {
        gameState.player.setVelocityX(0);
  }
        
    }    

再次感谢堆栈社区!

应该是 gameState.cursors = this.input.keyboard.createCursorKeys();,这样它们才能正确分配。这是假设 gameState 是一个全局变量,可以从当前范围看到。