In my Act method, I want to remove a bullet from the scene if it:
(A) Reaches the edge of the screen
or
(B) Hits something.
I have a method 'collision' which deals with, and removes the bullet and the object it collides with and an if-statement check to see if it's at world edge.
My issue is if the object collides with something, it no longer exists, and cannot therefore be tested in 'atWorldEdge()'.
I have tried encapsulating the if-statement in an if not null like below but to no avail.
and
1 2 3 | collision(); if (atWorldEdge()) getWorld().removeObject( this ); |
1 2 3 | if (! this .equals( null )) if (atWorldEdge()) getWorld().removeObject( this ); |
1 2 | if ( this != null && atWorldEdge()) getWorld().removeObject( this ); |