I got this piece of code where i make actor A move up and down. I only want this to happen when actor B intersects actor A, there is only one problem when actor B intersects with actor A it removes from the world.
protected void craneMove() { if(getOneIntersectingObject(CraneStopBottom.class)!= null){ Counter = 0; } else if(getOneIntersectingObject(CraneStopTop.class)!= null){ Counter = 1; } if(Counter == 0){ setLocation(getX(), getY()-1); } else if (Counter == 1){ setLocation(getX(), getY()+1); } }