I tried to insert a screen-shot of my 'Actor classes' but couldn't, but this is mostly what it looks like:
-World classes-
World
Background
...
-Actor classes-
Actor
Menu
Start
Buttons
Back
Controls
Credits
Levels
Level1
Pause
Ready
Settings
...
On the line ‘getWorldaddObject(start, 300, 200);’ I got the error:
cannot find symbol – variable getWorld
If I take this out I get
cannot find symbol – method addObject(Start,int,int)
Yes the “s” was capitalized, I then tried making it a capital “s” and got
cannot find symbol – Start
I then simply put everything into the Background (preferred not to because I would like to simply call on ‘start’ and put up my main menu) and in my Levels:
I got the error: in ‘getWorld().removeObject(Controls.class);’
method removeObject in class greenfoot.world cannot be applied to given types;
required: greenfoot.Actor
found: java.lang.Class<Controls>
reason: actual argument java.lang.Class<Controls> cannot be converted to greenfoot.Actor by method invocation conversion
then I took out ‘getWorld().’ And go the error
cannot find symbol – method removeObject(java.lang.Class<Controls>)
by the way I do have a lot of code in my other actors and know how to reference other actors(just not when they are in subclasses), but I have noted all of them from being created so as not to interfere.
Please help me correct these bugs (or if you can’t maybe just tell me what I am doing wrong or how to reference things in sub-classes)
Thank you,
:)
public class Start extends Menu { /** * Act - do whatever the Start wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { Start start = new Start(); getWorldaddObject(start, 300, 200); Levels levels = new Levels(); addObject(levels, 175, 75); Controls controls = new Controls(); addObject(controls, 425, 75); Settings settings = new Settings(); addObject(settings, 425, 325); Credits credits = new Credits(); addObject(credits, 175, 325); } }
public class Levels extends Buttons { /** * Act - do whatever the Levels wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { click(); } public void click() { if (Greenfoot.mouseClicked(this)) { getWorld().removeObject(Controls.class); getWorld().removeObject(Credits.class); getWorld().removeObject(Settings.class); Level1 level1 = new Level1(); getWorld().addObject(level1, 100, 375); Ready ready = new Ready(); getWorld().addObject(ready, 500, 375); Back back = new Back(); getWorld().addObject(back, 100, 375); setLocation(175, 75); } } }