Hi, I've been having some trouble finding a way to remove both a bullet and the actor if the bullet hits an actor.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 | public void act() { move( 100 ); //This should just be the bullet movement code checkForPlayer(); } public void checkForPlayer() { if (getOneIntersectingObject(Player. class ) != null ) { getWorld().removeObject(getOneIntersectingObject(Player. class )); getWorld().removeObject( this ); } } |
1 2 3 4 5 6 7 8 | public void checkForPlayer() { if (isTouching(Player. class )) { removeTouching(Player. class ); getWorld().removeObject( this ); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | public void act() { move( 100 ); checkForHit(); } private void checkForHit() { if (atWorldEdge()) { getWorld().removeObject( this ); } if (isTouching(Alien1. class )) { counter.add( 1 ); removeTouching(Alien1. class ); getWorld().removeObject( this ); } if (isTouching(Alien2. class )) { counter.add( 5 ); removeTouching(Alien2. class ); getWorld().removeObject( this ); } } |