I am trying to create a reset button to appear after the scenario stops so that when I click on the reset button it sets the world again, but when I try to click on the button I made to reset the world, I cannot because the scenario is stopped and the mouse click does not work. Here is my coding for my actor that when he touches any of the methods below it will end the game and the end screen (scoreboard) appears with the reset button:
Is there a way to stop the game while being able to click the reset button. I tried changing the code so that instead of Greenfoot.stop() it would remove all the objects in the world, but then I couldn't add the scoreBoard and resetButton and error messages would pop up for some reason.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | /** * touchLine() - if touching line stop game */ public void touchBlueLine() { int range = 1 ; //set the range to 1 pixel List<Dot1> dots = getObjectsInRange (range, Dot1. class ); //Make a list for dots to getObjectsInRange of dots for (Dot1 d : dots) { if (d != null ) //if d is not equal to null { Greenfoot.stop(); //stop the game getWorld().addObject( new ScoreBoard(), 400 , 300 ); getWorld().addObject( new ResetButton(), 440 , 340 ); } } } /** * touchLine2() - if touching line stop game */ public void touchRedLine() { if (isTouching(Dot2. class )) //Code 3.2 - if Player is touching dot do the following { Greenfoot.stop(); //stop the game getWorld().addObject( new ScoreBoard(), 400 , 300 ); getWorld().addObject( new ResetButton(), 440 , 340 ); } } /** * isAtEdge() */ private void touchesEdge() { if (isAtEdge()) //if actor is at the edge of the world do the following { Greenfoot.stop(); //end game getWorld().addObject( new ScoreBoard(), 400 , 300 ); getWorld().addObject( new ResetButton(), 440 , 340 ); } } |