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

2017/2/22

remove object

joshuadswa joshuadswa

2017/2/22

#
hello :) i need to ask you something guys, how to check if the object is removed from the world? well lets say theres 1 turret 1 minion and 1 Hero in my world. so my turret shooting at the minion, but then i tried to kill the minion first using my hero bullet .-. after that error appear because my turret's bullet is targeting the minion, but the minion got removed by the hero before the turret's bullet can reach .-. i tried to use isEmpty, but its no use because in my case i put many minion .... .-. help thx...
danpost danpost

2017/2/22

#
joshuadswa wrote...
how to check if the object is removed from the world?
If you have a reference to that object in a variable called 'object', then:
if (object.getWorld() == null)
will be true if the object is not in any world.
joshuadswa joshuadswa

2017/2/22

#
the problem is theres duplicate object, . -.
danpost danpost

2017/2/22

#
joshuadswa wrote...
my turret's bullet is targeting the minion, but the minion got removed by the hero before the turret's bullet can reach
If the bullet of the turret has a particular minion that it is going after, then:
if (minion.getWorld() == null)
would be true in the minion was removed from the world.
joshuadswa joshuadswa

2017/2/22

#
thx ::)
joshuadswa joshuadswa

2017/2/23

#
gonna try it :3
You need to login to post a reply.