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

2016/6/13

How can an object hide or remove itself?

JohnOfStony JohnOfStony

2016/6/13

#
I want an object to disappear when it reaches the edge of the world. I cannot figure out how to do this. Help. I've tried to edit the World constructor by making the World unbounded but the Editor won't open for a World object. I cannot find how to make an object hide/remove itself. I've tried objectRemove with the following parameters: the name of the object, me and self. All cause errors. It doesn't even recognise its own name!
Super_Hippo Super_Hippo

2016/6/13

#
To make the world unbounded: Double click your world subclass. Find the first line in the world constructor and add another parameter 'false', e.g.:
1
super(600, 400, 1, false);
To make an object remove itself from the world, use the 'this' keyworld:
1
getWorld().removeObject(this);
You need to login to post a reply.