Hello, I am having some issues with the getWorld().removeObject(); comment.
I would like to remove my WinScreen for the first Level so that I can start a new Level whenever the next Level button is pressed.
That is my code in the nextLVL.class:


1 2 3 4 5 6 7 8 9 | public void nextLVL(){ if (Greenfoot.mouseClicked( this )){ getWorld().removeObject( this ); getWorld().removeObject(WinScreenLVL1. class ); } } |
1 2 3 4 5 6 7 8 | public void nextLVL(){ if (Greenfoot.mouseClicked( this )){ getWorld().removeObject(WinScreenLVL1. class ); getWorld().removeObject(); } } |
1 | getWorld().removeObjects(getWorld().getObjects(WinScreenLVL1. class )); |