Clean the pieces position when restarting the game #82
@ -124,4 +124,13 @@ public class Map extends Shape{
 | 
				
			|||||||
            throw new RuntimeException(e);
 | 
					            throw new RuntimeException(e);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * set the position of each pieces in the map to null
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public void resetPiecesPositions(){
 | 
				
			||||||
 | 
					        for (Piece p : pieces) {
 | 
				
			||||||
 | 
					            p.setPosition(null);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -29,6 +29,7 @@ public class ScreenLevelFinish extends StackPane {
 | 
				
			|||||||
        ChooseLvl.setOnAction(event -> Controller.switchRoot(new MenuLevel(1)));
 | 
					        ChooseLvl.setOnAction(event -> Controller.switchRoot(new MenuLevel(1)));
 | 
				
			||||||
        retry.setOnAction(event -> {
 | 
					        retry.setOnAction(event -> {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
 | 
					                lastlevel.resetPiecesPositions();
 | 
				
			||||||
                Controller.switchRoot(new GameUI(lastlevel));
 | 
					                Controller.switchRoot(new GameUI(lastlevel));
 | 
				
			||||||
            } catch (FileNotFoundException e) {
 | 
					            } catch (FileNotFoundException e) {
 | 
				
			||||||
                throw new RuntimeException(e);
 | 
					                throw new RuntimeException(e);
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user