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

2014/4/29

Insisting problem

Onilika Onilika

2014/4/29

#
hello, I'm freaking out with a stupid error that I don't know what is. I want to remove an object, but the object is never removed. I want that, when the bad class intersects the bomb class, to be removed BOTH. what happens is that only bad class is removed. // method from Bad.class public void explodeBad() { Actor bomb = getOneIntersectingObject(Bomb.class); pacWorld pacworld = (pacWorld)getWorld(); if(bomb != null) { getWorld().removeObject(this); } } //method from Bomb.class public void retiraBomba() { Actor bad3 = getOneIntersectingObject(Bad3.class); pacWorld pacworld = (pacWorld)getWorld(); if( bad3 != null) { pacworld.removeObject(this); } } Why ain't this working!? I really need help with this
bourne bourne

2014/4/29

#
Because one is removing itself, then when the other acts it doesn't remove itself since the first is no longer there.
Nagoya Nagoya

2014/4/29

#
bourne wrote...
Because one is removing itself, then when the other acts it doesn't remove itself since the first is no longer there.
How could I fix this problem then?
Nagoya Nagoya

2014/4/29

#
bourne wrote...
Because one is removing itself, then when the other acts it doesn't remove itself since the first is no longer there.
Bourne, could you please help me out? Need help badly /: could you add me on Skype please? Akilino3
Onilika Onilika

2014/4/29

#
Nagoya is my other account .
davmac davmac

2014/4/29

#
Nagoya, you just need to remove both objects at once. Also, please don't create multiple accounts. I have disabled the second one.
Nagoya Nagoya

2014/4/29

#
But I can't remove both objects at one. It only removes the bad.class. The bomb class persists.
danpost danpost

2014/4/29

#
Remove the 'explodeBad' method from the Bad class and add a line in the 'retiraBomba' method in the Bomb class within the 'if' block to remove the Bad3 object found (place the line before the line that removes the bomb).
You need to login to post a reply.