Hello everybody,
i have a timer in my world that will count down from 20 and when it gets to 0 greenfoot stops.
but when it stops i want to add an gameoverscreen.
Is there someone that could help me???


1 2 3 4 5 6 7 8 9 | if (timer> 0 ) { timer--; if (timer== 0 ) Greenfoot.stop(); } addObject(timerText, 95 , 25 ); timerText.setcc_Text( "Time left:" + (timer/ 60 )); if (timer% 60 == 0 ) timerText.setcc_Text( "Time left:" + (timer/ 60 )); |
1 2 3 4 5 6 7 8 9 10 11 12 | public void act() { if (timer> 0 ) { timer--; if (timer== 0 ) Greenfoot.stop(); } addObject(timerText, 95 , 25 ); timerText.setcc_Text( "Time left:" + (timer/ 60 )); if (timer% 60 == 0 ) timerText.setcc_Text( "Time left:" + (timer/ 60 )); } |
1 2 3 4 5 6 7 8 9 10 11 12 | public class cc_GameOver extends Actor { /** * Act - do whatever the cc_GameOver wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public cc_GameOver() { setImage( new GreenfootImage( "Game Over" , 48 , Color.WHITE, Color.BLACK)); } } |
1 2 3 4 5 6 | if (timer> 0 ) { timer--; if (timer% 60 == 0 ) timerText.setcc_Text( "Time left:" + (timer/ 60 )); if (timer== 0 ) Greenfoot.stop(); } |
1 2 3 4 5 6 7 8 9 10 | if (timer> 0 ) { timer--; if (timer% 60 == 0 ) timerText.setcc_Text( "Time left:" + (timer/ 60 )); if (timer== 0 ) { addObject( new cc_GameOver(),getWidth()/ 2 , getHeight()/ 2 ); Greenfoot.stop(); } } |