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

2012/9/19

Removing lobster class from world

DPD4AU DPD4AU

2012/9/19

#
I've made several changes to my code creating new methods and such, but i need one method that removes a lobster from the world after it has eaten two mushrooms. I've already made it to where it finds the mushroom an eats it, but i cannot find a way to make the crab disappear(dies because it is poisoned)... i was thinking mushroomEaten = mushroomsEaten +1 if (mushroomsEaten == 2) then to make it disappear when it is equal to 2, but i just can't figure it out... any suggestions??
danpost danpost

2012/9/19

#
Check out the Greenfoot 'Documentation' for 'online' API and search through the classes to find what method(s) you will need. Once you find a method you think will work to 'disappear' the object, think about what class you found it in and what you might need to do to run the method from the class you are writing the code in. Of interest might be the Java tutorial page on Using the 'this' keyword.
DPD4AU DPD4AU

2012/9/19

#
Thank you!! I coded using this statement, getWorld().removeObject(this); and it worked!
danpost danpost

2012/9/19

#
That is the one (or two)! Good job.
You need to login to post a reply.