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

2013/6/8

Static fields

Gingervitis Gingervitis

2013/6/8

#
Is there a way to make a static int reset itself? I always have to set it back to 0 every time i want to replay my game.
bourne bourne

2013/6/9

#
Setting it back to 0 is pretty much how you do it.
private static int number = 0;

public void newGame()
{
    ...
    number = 0;
}
Gingervitis Gingervitis

2013/6/9

#
It is that simple? And you put that in the act method?
Gingervitis Gingervitis

2013/6/9

#
When I did that the value did not change at all. It stayed at zero.
danpost danpost

2013/6/9

#
bourne did not place it in the act method; he put it in the world constructor.
You need to login to post a reply.