Reloading same game? [SOLVED]


(s corneil) #1

Hi,

Another question for you guys …

At the end of the game, a player has the choice to either go to the menu & select another game, or, replay the same game. I’m using a different world for every game.

The way I have been trying to implement the ‘replay’ option, is by using : FP.world= new Game1(); It was my understanding that this would complete destroy the game I just played, and recreate the the same game from scratch.

To my surprise, things like the score (Text entity), and transformations on entities are not reset at all … So, what is my error in understanding here ? Or could it have something to do with the fact that I refer to these entities through static variables ?

Thank you for helping !


(Jacob Albano) #2

This is 100% a problem with static variables, and it’s why I keep saying they’re a bad idea. Reduce the number of statics in use, or reset each and every one in the constructor of each World that needs to use them.


(s corneil) #3

OK … Makes sense … Thanks again !