Jump to content

Help with Scenes


iagnkankadlg
 Share

Recommended Posts

I am a Noob please pardon by lack of knowledge.

Anyway, I am trying to create menus in my game. Basically, I have tried different methods to create scenes, but often there are differences between what I have used and what I see other people using. I am using Es5, and my game config looks like this:

    var config = {
        type: Phaser.AUTO,
        width: 600,
        height: 400,
        backgroundColor: '#A0A0A0',
        physics: {
            default: 'arcade',
            arcade: {
                gravity: { y: 0 },
                debug: false,
            }
        },
        scene: {
            preload: preload,
            create: create,
            update: update,
        }
    };

Then I have the 'plugins'(?) Organized as such:

var game = new Phaser.Game(config);

//OTHER VARIABLES...

function preload () {
//PRELOAD STUFF
}
function create () {
//PRELOAD STUFF
}
function update () {
//PRELOAD STUFF
}

//OTHER FUNCTIONS...

I have created a lot with by only adding this, but now I want to add menus and a help screen etc...

I have tried to look at examples at https://labs.phaser.io/ such as https://labs.phaser.io/edit.html?src=src\scenes\change scene from create.js

But again, this doesn't show how you declare scenes as part of your config etc..

Ideally, I would want to have a separate set of 'function preload/create/update' that I can call upon when in a specific scenes. But with that being said, you can see that I have 'OTHER VARIABLES' and 'OTHER FUNCTIONS' sitting within my game that I may also want to keep independent across scenes. By doing e.g. this.scene.start('sceneB');

I don't mind creating scenes in the same document, or referencing an external .js

 

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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