Jump to content

Passing variables when changing states/global variables?


Recommended Posts



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.



Link to comment
Share on other sites

  • 2 years later...

In the index.html put the variable as

<html lang="en"> 
	<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>
<script type="text/javascript">
var game = new Phaser.Game(1100, 550, Phaser.AUTO);
var game.variable = 0930211


Link to comment
Share on other sites


  • Recently Browsing   0 members

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