How do I code this:
A Bullet collides with another Object and the Object dissapears and the Bullet dissapears too so that It doesnt collete more Objects.


1 2 3 4 5 6 | public void act() { if (Remove()) { getWorld().removeObject( this ); } } |
1 2 3 4 5 6 7 8 9 | public boolean Remove() { Object obj= (Object)getOneIntersectingObject(Object. class ); if (obj != null ) { return true ; getWorld().removeObject(obj); } return false ; } |
1 2 3 4 5 6 7 8 9 10 11 | import greenfoot.*; public class Object extends Actor { public boolean Hit = false ; public void act() { if (Hit == true ) { getWorld().removeObject( this ); Hit = false ; } } } |