Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by danicor

I have created a results screen as follows:

BasketResults = ig.Game.extend({ });

From the game screen I do:

ig.system.setGame(BasketResults);

Now I need to access from the result screen to the variables of the game and I can not. The only option is to use global variables like ig.global.xxxx?

1 decade ago by stillen

Depending on how your game is set up theres a few ways to handle this. It looks like you have multiple game instances so you could do something similar to what I am doing.

I keep my level/game specific variables in that game instance. So ig.game.totalBadKilled for example.

When I load the Results Screen I pass that variable to the Results Game.

When I exit the Results Screen Game, I save the results to localstorage, so I can access them at anytime.

Theres a plugin to easily access local storage out there and one for passing data between game instances too, or you could spin your own too.

1 decade ago by dungeonmaster

I'm sure there may be better ways but here is what works for me:

I'm using a global object like you suggested, let's say player

I extend the class just as normal: ig.Player : ig.Class.extend (......)

then in main.js:
ig.global.myPlayer = new ig.Player();

Then I stuff everything that should be permanent in it, like scores, level info etc.. You can also write functions for that global class.

1 decade ago by danicor

Thanks to all

For now I will use the option given by dungeonmaster. Another related question:

Now if I create a pause screen with a menu and do the same as before:

ig.system.setGame (BasketPause);

You can exit the pause screen and return to the game screen? I have to create the pause screen in another way?
Page 1 of 1
« first « previous next › last »