This site requires JavaScript, please enable it in your browser!
Greenfoot back
Richter
Richter wrote ...

2024/12/12

Static variables are not resetting?

Richter Richter

2024/12/12

#
I programmed a game in Greenfoot and used static variables. When I press on reset to reset the game, the static variables are not resetting to their “default” value (here boolean). Further in the code I made that when clicked on this object (here start button) to set the value of the static variable (here called startgame) to true but this doesn’t happen. Does someone know why this is not working or have a link where I can read about this?
danpost danpost

2024/12/13

#
Richter wrote...
I programmed a game in Greenfoot and used static variables. When I press on reset to reset the game, the static variables are not resetting to their “default” value (here boolean). Further in the code I made that when clicked on this object (here start button) to set the value of the static variable (here called startgame) to true but this doesn’t happen. Does someone know why this is not working or have a link where I can read about this?
Static variables are initialized during compilation. Resetting the scenario does not re-compile the program. Set the initial values to those static variables in your initial world constructor.
You need to login to post a reply.