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

2013/5/26

HELP

SWAG SWAG

2013/5/26

#
How would I say if actor has been removed then //code...................//
Gevater_Tod4711 Gevater_Tod4711

2013/5/26

#
Well that's not easy. I think therefore you need to overwrite the removeObject method in your world like this:
public void removeObject(Actor object) {
    if (object instanceof ObjectA) {
        ((ObjectA) object).removed();
    }
    super.removeObject(object);
}
Instead of ObjectA you will have to use the classname of the object that you want to execute a specific code when it get's removed. Also in this class the method removed() has to be declared. This method will be called when the object get's removed.
danpost danpost

2013/5/26

#
What action(s) are you going to perform when the actor is removed? I ask because there may be an easier way.
SWAG SWAG

2013/5/26

#
danpost wrote...
What action(s) are you going to perform when the actor is removed? I ask because there may be an easier way.
The action preforming is a ''for' statement which checks how kill the enemy. The problem with that is my bullet isn't removed when it hits the enemy and this because us the "for" statement (worked fine before the statement), so I want the bullet to be removed then execute the for statement.
You need to login to post a reply.