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

2022/3/13

simple implement that my game stops after some timer

Flipper3000 Flipper3000

2022/3/13

#
Hello, i need some help can somebody give me a simple way to stop my game after some time with a timer or something like that i really need it for school.
Roshan123 Roshan123

2022/3/14

#
Probably the most simplest way:
int timer=600;
public void act()
{  
  timer--;
  if(timer<1) Greenfoot.stop();
  getWorld().showText("Time: "+timer/60, 150,  150);
}
Aaron-aid Aaron-aid

2022/3/17

#
do you want to stop the program or change the scene to say they failed a mission? because you can change scenes by doing Greenfoot. int def_Val = 20; int timer = def_Val; act(){ timer--; if(timer <= 0) { Greenfoot.setWorld(new newWorld();) timer = def_Val; }
Aaron-aid Aaron-aid

2022/3/17

#
do you want to stop the program or change the scene to say they failed a mission? because you can change scenes by doing Greenfoot. int def_Val = 20; int timer = def_Val; act(){ timer--; if(timer <= 0) { Greenfoot.setWorld(new newWorld();) timer = def_Val; } }
Aaron-aid Aaron-aid

2022/3/17

#
Aaron-aid wrote...
do you want to stop the program or change the scene to say they failed a mission? because you can change scenes by doing Greenfoot. int def_Val = 20; int timer = def_Val; act(){ timer--; if(timer <= 0) { Greenfoot.setWorld(new newWorld();) timer = def_Val; }
ignore this, the second one is right
You need to login to post a reply.