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

2011/11/10

The reset button

kiarocks kiarocks

2011/11/10

#
Why do some variables not reset after pushing the reset button?
bourne bourne

2011/11/10

#
Are they static?
ImFerocious ImFerocious

2011/11/10

#
Well if they are static variables then they won't be reset to there original starting value. A way I reset variables in my scenarios is like this
public static int Number;

public myWorld() {  
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(600, 400, 1); 
        resetStaticVariables();
    }

private void resetStaticVariables() {
       //then you just set your static variables to the value you want them to start at.
      Number = 10;
}
so every time the world resets it also resets static variables
You need to login to post a reply.