What does it really do?
Why shouldn't we using it always?
I had a scenario in which I used many variables with static but don't really understand how it works. Can someone explain me?


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | public void checkIfBlockIsDestructible() { Actor destructibleBlock =(Block) getOneObjectAtOffset( 0 , 0 ,DestructibleBlock. class ); Actor undestructibleBlock =(Block) getOneObjectAtOffset( 0 , 0 ,UndestructibleBlock. class ); if (destructibleBlock != null ) { destructibleBlock.remove(); //getWorld().removeObject(destructibleBlock); } if (undestructibleBlock != null ) { getWorld().removeObject( this ); return ; } } |
1 2 3 4 5 6 7 8 9 10 11 12 | // in Pacman class Actor bigdot = getOneIntersectingObject(BigDot. class ); if (bigdot != null ) { getWorld().removeObject(bigdot); // add to score for eating big dot // play sound for eating dot for (Object obj : getWorld().getObjects(Ghost. class )) { ((Ghost)obj).setVulnerable(); } } |