Scene.sys is undefined

Hi everyone, I’m new on forum.
I am currently trying to make a game with Phaser3 and I am following an online tutorial (Zenva academy). The guy in the video does not get this error even though we have the same code. He uses Phaser v3.16.2 and I use Phaser v3.24.1. The console shows me:
Uncaught TypeError: scene.sys is undefined phaser.js:3022:9
Here is my code from main.js:

    var config = {
        type: Phaser.AUTO,
        width: 800,
        height: 600,
        scene: [
            BootScene,
            TitleScene,
            GameScene,
            UiScene
        ],
        physics: {
            default: 'arcade',
            arcade: {
                debug: true,
                gravity: {
                    y: 5
                }
            }
        }
    };

    var game = new Phaser.Game(config);

BootScene.js:

class BootScene extends Phaser.Scene {
constructor() {
super(‘Boot’);
}

preload() {
    this.load.image('button1', 'assets/images/ui/blue_button01.png');
    this.load.spritesheet('items', 'assets/images/items.png', {
        frameWidth: 32,
        frameHeight: 32
    });
    this.load.spritesheet('characters', 'assets/images/characters.png', {
        frameWidth: 32,
        frameHeight: 32
    });
    this.load.audio('goldSound', ['assets/audio/Pickup.wav']);
}

create() {
    this.scene.start('Game');
}

}

Player.js:

class Player extends Phaser.Physics.Arcade.Image {
constructor(scene, x, y, key, frame) {
super(scene, x, y, key, frame);
this.scene = scene;
this.velocity = 160;

    this.scene.physics.world.enable(this);
    this.setImmovable(false);
    this.setScale(2);
    this.setCollideWorldBounds(true);
    scene.add.existing(this);
}

update(cursors) {
    this.body.setVelocity(0);

    if (cursors.left.isDown) {
        this.body.setVelocityX(-this.velocity);
    } else if (cursors.right.isDown) {
        this.body.setVelocityX(this.velocity);
    }

    if (cursors.up.isDown) {
        this.body.setVelocityY(-this.velocity)
    } else if (cursors.down.isDown) {
        this.body.setVelocityY(this.velocity)
    }
}

}

GameScene.js:

class GameScene extends Phaser.Scene {
constructor() {
super(‘Game’);
}

create() {
    var goldPickupAudio = this.sound.add('goldSound', {
        loop: false,
        volume: 0.2
    }); 


    var button = this.add.image(100, 100, 'button1'); 
    button.setOrigin(0.5, 0.5);

    this.add.sprite(300, 100, 'button1'); 

    this.chest = this.physics.add.image(300, 300, 'items', 0);

    this.wall = this.physics.add.image(500, 100, 'button1');
    this.wall.setImmovable();

    this.player = new Player(32, 32, 'characters', 0);

    this.physics.add.collider(this.player, this.wall);
    this.physics.add.overlap(this.player, this.chest, function (player, chest) {
        goldPickupAudio.play();
        chest.destroy();
    });

    this.cursors = this.input.keyboard.createCursorKeys();
}

update() {
    this.player.update(this.cursors);
}

}

What is it that causes this error? What am I doing wrong?

Open the stack trace.

How can I do it?

Something like that?

GameObject (http://127.0.0.1/games/zenva/js/library/phaser.js#3022)
Image (http://127.0.0.1/games/zenva/js/library/phaser.js#23315)
ArcadeImage (http://127.0.0.1/games/zenva/js/library/phaser.js#100415)
Player (http://127.0.0.1/games/zenva/js/classes/Player.js#3)
create (http://127.0.0.1/games/zenva/js/scenes/GameScene.js#24)
create (http://127.0.0.1/games/zenva/js/library/phaser.js#80508)
bootScene (http://127.0.0.1/games/zenva/js/library/phaser.js#80394)
start (http://127.0.0.1/games/zenva/js/library/phaser.js#81090)
processQueue (http://127.0.0.1/games/zenva/js/library/phaser.js#80185)
update (http://127.0.0.1/games/zenva/js/library/phaser.js#80448)
step (http://127.0.0.1/games/zenva/js/library/phaser.js#142730)
step (http://127.0.0.1/games/zenva/js/library/phaser.js#69815)
step (http://127.0.0.1/games/zenva/js/library/phaser.js#70062)
step (http://127.0.0.1/games/zenva/js/library/phaser.js#70064)
step (http://127.0.0.1/games/zenva/js/library/phaser.js#70064)
step (http://127.0.0.1/games/zenva/js/library/phaser.js#70064)
step (http://127.0.0.1/games/zenva/js/library/phaser.js#70064)
step (http://127.0.0.1/games/zenva/js/library/phaser.js#70064)
step (http://127.0.0.1/games/zenva/js/library/phaser.js#70064)
start (http://127.0.0.1/games/zenva/js/library/phaser.js#70116)
start (http://127.0.0.1/games/zenva/js/library/phaser.js#69685)
start (http://127.0.0.1/games/zenva/js/library/phaser.js#142675)
texturesReady (http://127.0.0.1/games/zenva/js/library/phaser.js#142655)
emit (http://127.0.0.1/games/zenva/js/library/phaser.js#2044)
updatePending (http://127.0.0.1/games/zenva/js/library/phaser.js#82067)
emit (http://127.0.0.1/games/zenva/js/library/phaser.js#2025)
onload (http://127.0.0.1/games/zenva/js/library/phaser.js#82193)
addBase64 (http://127.0.0.1/games/zenva/js/library/phaser.js#82185)
boot (http://127.0.0.1/games/zenva/js/library/phaser.js#82046)
emit (http://127.0.0.1/games/zenva/js/library/phaser.js#2044)
boot (http://127.0.0.1/games/zenva/js/library/phaser.js#142638)
check (http://127.0.0.1/games/zenva/js/library/phaser.js#72289)
DOMContentLoaded (http://127.0.0.1/games/zenva/js/library/phaser.js#72303)
Game (http://127.0.0.1/games/zenva/js/library/phaser.js#142598)
<anonimowa> (http://127.0.0.1/games/zenva/js/main.js#22)

Yes. Which line is this?

Problem is here. Check the arguments.

1 Like

Yes, now it works! I have added this

this.player = new Player(this, 32, 32, 'characters', 0);

I didn’t see it in the tutorial :frowning:
Thank you very much