So is there any reason why my scene manager class is not switching scenes from the ‘preloading-scene’ class to the ‘create-scene’ class then to the ‘lvl-1’ class?
Here’s what it’s doing :
It should alert the user that it’s Inside Create Scene in create ( ) function going to key :: lvl-1
/**
* A class that extends Phaser.Scene & wraps up
* the core logic for the preloader
*/
class PreloadingScene extends Phaser.Scene
{
constructor ( ) {
super ({
key : 'preloader',
});
}
__LoadAllAssets ( ) {
}
preload ( ) {
alert ( 'Inside Preloader Scene in preload ( ) function' + '...' );
this.__LoadAllAssets ( );
}
init ( ) {
alert ( 'Inside Preloader Scene in init ( ) function' + '...' );
}
create ( ) {
alert ( 'Inside Preloader Scene in create ( ) function' + '...' );
this.__level = new LevelManager ({
scene : this,
});
alert ( 'Inside Preloader Scene going to key' + ' :: ' + '`' + 'create-scene' + '`' + '...' );
this.__level.nextLevel ( this, 'create-scene' );
}
}
create-scene.js :
/**
* A class that extends Phaser.Scene & wraps up
* the core logic for the create scene
*/
class CreateScene extends Phaser.Scene {
constructor ( ) {
super ({
key : 'create-scene',
});
}
create ( ) {
alert ( 'Inside Create Scene in create ( ) function going to key :: lvl-1' );
this.__level.nextLevel ( this, 'lvl-1' );
}
}
lvl-1.js :
/**
* A class that extends Phaser.Scene & wraps up
* the core logic for the level
*/
class Level1 extends Phaser.Scene {
constructor ( ) {
super ({
key : 'lvl-1',
});
}
preload ( ) {
}
init ( ) {
// Set whether or not the Player is dead { Default :: false }
this.__isPlayerDead = false;
// Set whether or not the Player fell into a hole { Default :: false }
this.__playerFallsInHole = false;
// Set whether or not the Player has overlapped the Goal
this.__hasOverlapped = false;
}
create ( ) {
}
update ( ) {
stats.update ( );
if ( ( ! ( this.__playerFallsInHole ) ) && ( this.hero.sprite.y > this.__groundLayer.height ) )
{
// Flag that the player has fallen into hole so that we can
// stop update from running in the future
this.KillPlayer ({
scene : this.scene,
entity : this.hero,
});
this.__playerFallsInHole = true;
}
this.hero.stateMachine.step ( );
}
}
Hey @EddieOne. I have checked tour example above. Just curious. I see you have used the es6 import and export in browser.
But why did you not link the entry point javascript file index.js to the index.html file?
Hello, It is because Babel is used to give ES6 on the client side too. What happens behind the scenes, server.js will compile index.html and bundle all the client js into one package, adding a line to load it automatically.
I am stuggling with having a game system like a menu, menu bar and just under it a game playground. Clicking settings, pause etc in menu bar opens a modal like in web and. Playground background becomes darkened. Also there are other pages than playground like achievements view, player selection corousel etc.
I am an exprerinced JavaScript full stack developer developed with Node.js React Redux etc but never games. I worked with Three.js and Babylonjs as well but not with game engine or projects.
Do for those listed tasks I have many ideas but I am not sure which way would be better and not a bad design not an abuse. So it would be helpful to see similar wuestions and answers. I am reading devlogs 119 and 121 to solve those.