[*] boot.js:
< /ul>
Код: Выделить всё
import { Scene } from 'phaser';
export class Boot extends Scene
{
constructor ()
{
super('Boot');
}
preload ()
{
this.load.image('background', 'assets/bg.png');
}
create ()
{
this.scene.start('Preloader');
}
}
< /code>
[*]game.js:
< /ul>
export class Game extends Scene
{
constructor ()
{
super('Game');
this.W = window.innerWidth;
this.H = window.innerHeight;
}
create () {
let player = this.add.rectangle(this.W / 2, this.H / 2, 25, 25, 0xfafafa);
this.physics.add.existing(player);
const cursors = this.input.keyboard.createCursorKeys();
this.cameras.main.setBackgroundColor(0x0a0a0a);
}
update () {
if (cursors.left.isDown) { // Error happens here
player.body.setVelocityX(-20);
}
}
}
Я пытался сделать переменную игрока и вариацию Cursors и в разных местах в файле Game.js, но он не работал. Ошибка вообще не изменилась.
Подробнее здесь: https://stackoverflow.com/questions/796 ... e-phaser-3