Jump to content

Global Variables across states


wamballa
 Share

Recommended Posts

Hi

I've created a game which is pretty cool ( for me ) but I'm stuck now on the simplest of things. How do I run global variables across the different level states.

the variables I want to use are; highscore, score, lives

Where in the code do i declare these variables? I've tried a load of things but can't seem to crack it.

https://github.com/wamballa/games/tree/master/arcade/category/jetpac3

Any help would be appreciatd and let me know if I need to explain more.

Thanks

Link to comment
Share on other sites

Look at the templates included with Phaser.  One of them, I forget which, shows one way to do this.  It is in the boot state and essentially involves declaring Basicgame.highscore or whatever.  That variable is global.  It doesn't have to be declared in boot but that makes it available right from the offset so is a good place.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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