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

2015/12/4

getWorld().removeObject(Shot);

A2O A2O

2015/12/4

#
I have a problem with one thing. I couldnt really find it online or rather not exactly what I wanted. Its like this. public void checkForShot() { Actor w = getOneIntersectingObject(Shot.class); if(w != null) { health = health -50; getWorld().removeObject("""""""SHOT""""""""""); } if(health <= 0) { getWorld().removeObject(this); } } notice the """""""SHOT"""""", because thats what needs to be removed, an object of a whole other class. But how do I do it? :o
A2O A2O

2015/12/4

#
nvm, I'm just stupid. public void checkForShot() { Actor w = getOneIntersectingObject(Shot.class); if(w != null) { health = health -50; getWorld().removeObject(w); } if(health <= 0) { getWorld().removeObject(this); } } w = the Actor I just set instead of the actual Object for those of you who face the same problem
Super_Hippo Super_Hippo

2015/12/4

#
By the way, please use the 'code' tags when posting code. It makes it much easier to read.
You need to login to post a reply.