Jump to content

'Scene1' is undefined error in console- Phaser


AmbitiousIndie
 Share

Recommended Posts

I keep on getting this error while starting my project - 'scene1 is undefined'. what is the problem in the code? I'm quite new PHASER, so a help would be really appreciated :)
Also, I've used seperate files for each function. The code is written below, check it  out:

// the main.js file

const config = {
	type: Phaser.AUTO,
	width: 800,
	height: 600,
	backgroundColor: 0x000000,
	scene: [scene1, scene2]
};

const game = new Phaser.Game(config);


// scene1 file
class scene1 extends Phaser.Scene{
	constructor(){
		super({key: 'loading'});
	}
}

preload(){
	
}


// scene2 file

class scene2 extends Phaser.Scene{
	constructor(){
		super({key: 'playing'});
	}
};

function create(){
	this.add.text(20, 20,'loading');
}
	
}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...