Hi,
I am trying to create a simple menu system that allows a user to select a level in my game. I have got this to work by creating a public variable called level in the world and then changing the number when the user presses a button. From here populate is run and IF functions set up the games level - it may not be the most optomised way but it seems to be holding up. The problem I am having now is actually removing the other actors. The actor I click on is easy but as for the others I have never been told how to remove them. I am used to getOneObjectAtOffset and ofcourse this wont work. Below is the code for the menu.
Where the //remove other menus here is where I want to remove the other two menus
level2select
level3select
I know I need a class to define that single actor but I havent any clue on how to get this to work. Thanks in advance, Connor
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Easy level menu selection * * @author (Connor) * @version (1) */ public class level1select extends Actor { public void act() { if (Greenfoot.mouseClicked(this)) { mainwindow fighterWorld = (mainwindow)getWorld();// create a specific world name for mainwindow fighterWorld.level = 1; //level selected is 1 (easy) fighterWorld.populate(); //add objects to game //remove the other menus here fighterWorld.removeObject (this);//remove the menu } } }