Jump to content

Help, i dont know how to do


imLeyenda
 Share

Recommended Posts

Now works the call but game is not defined

 

I have this:

game = new Phaser.Game(config);game.state.add('Boot', warpgalaxy.Boot);game.state.add('Preloader', warpgalaxy.Preloader);game.state.add('Game', warpgalaxy.Game);Server.bind('message', function( data ) {	data = JSON.parse(data);	requestType = data['requestType'];	if (requestType == "userLogged") {		$('#window_login').toggle();		startWarpgalaxy(data['username'], data['x'], data['y'], data['frame']);		wpgame = new warpgalaxy.Game(game);		wpgame.myFunction();	}});
Var game is global defined.
Link to comment
Share on other sites

It's a normal thing as Server.bind declares a new function. When the code runs in this function, it can't access variables outside its scope 

So you can't read "game" variable in a local function, you have to access it by classname.game (where classname is the class containing variable alled "game")

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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