Hi i am having trouble getting the world to remove all objects and then adding the game objects to the world if the mouse clicked on this actor.
Right now i am failing, this is my overall code for the actor being pressed.
Edit: The add object part does not work and removing the objects doesnt work as well.
Oh and in this im trying to run a method inside the world and removing all the other items there are. Is this possible? or do i have to create two worlds and make it so it runs one world then removes the other?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.util.List; public class Play1 extends Buttons { private boolean selected; public void act() { checkMouse(); } public void checkMouse() { if (Greenfoot.mouseMoved(null)) { if (Greenfoot.mouseMoved(this) && !selected) { setImage(new GreenfootImage("1 player selected.png")); selected =true; enterGame(); } if (!Greenfoot.mouseMoved(this) && selected) { setImage(new GreenfootImage("1 player.png")); selected = false; } } } public void enterGame() { MouseInfo press = Greenfoot.getMouseInfo(); if(press!=null) { int button = press.getButton(); if(button==1 && Greenfoot.mouseClicked(null)) { List all = getWorld().getObjects(Menu.class); int game = (Pacman) getWorld().menu; getWorld().addObjects(game); getWorld().removeObjects(all); } } } }