This site requires JavaScript, please enable it in your browser!
Greenfoot back
sajmon1998
sajmon1998 wrote ...

2018/9/1

Removing object after some action

sajmon1998 sajmon1998

2018/9/1

#
I have the assignment in which my animal(Wombat) after 50 steps must disappear. I did something like this: public void removeWombat() { if(stepsTaken>50) { getWorld().removeObject(Wombat); } } And i got error: "cannot find symbol - variable Wombat". How to make this work?
xtay2 xtay2

2018/9/1

#
You have to write "getWorld().removeObject(Wombat.class)"
sajmon1998 sajmon1998

2018/9/1

#
In this case program shows error: " incompatibile types java.lang.Class<Wombat> cannot be converted to greenfoot.Actor".
danpost danpost

2018/9/1

#
sajmon1998 wrote...
I have the assignment in which my animal(Wombat) after 50 steps must disappear. I did something like this: << Code Omitted >> And i got error: "cannot find symbol - variable Wombat". How to make this work?
If your code above is in the Wombat class, then use this instead of Wombat.
You need to login to post a reply.