Jump to content

Passing variables when changing states/global variables?


Soule
 Share

Recommended Posts

Hi,

 

I was wondering if there's any way to pass variables when you change states, or if it's possible to set global variables?

 

I'm using codevinsky's generator (https://github.com/codevinsky/generator-phaser-official), if it makes any difference.

 

Specifically, I want to tell my Game scene what difficulty level to use when the user picks it in the intro scene.

 

Thanks

Link to comment
Share on other sites

  • 2 years later...

In the index.html put the variable as

<html lang="en"> 
<head>
	<meta charset="UTF-8" />
	<title>Your Game</title>
	
	<script type="text/javascript" src="code/phaser.min.js"></script>
	<script type="text/javascript" src="code/Level1.js"></script>
</head>
<body>
<script type="text/javascript">
var game = new Phaser.Game(1100, 550, Phaser.AUTO);
var game.variable = 0930211
</script>
</body>
</html> 

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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