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

2021/11/30

Timer code

siizwee siizwee

2021/11/30

#
how to i make a timer for my game, its supposed to work like a countdown and after which the countdown gets to zero the entire game comes to an end.
salim5112 salim5112

2021/11/30

#
Write this in your world class : private int timer = 7200; // roughly 2 minutes ( each minute is 3600 act cycles) then this in your act method public void act() { showText("Time left: " + timer/60, x, y); // replace x and y by where you want the timer placed if (timer > 0) { timer--; if (timer == 0) Greenfoot.stop(); } this will display the timer in second
siizwee siizwee

2021/11/30

#
thanks alot, your're thr best!!!!!
You need to login to post a reply.