Hi there, i'm having problem with the collision detection, the player is supposed to stop when he reaches the wall, either by approaching it from the right or the left, but when he approaches it from the left he just teleports to the right! Here's the code:
private void checkIsOnWall(){ Actor wall=getOneIntersectingObject(VerticalWall.class); if(wall!=null){ if(velocityX>=0){ velocityX=0; setLocation(wall.getX()-getImage().getWidth()+15, getY()); }//this part doesn't work if(velocityX<=0){ velocityX=0; setLocation(wall.getX()+getImage().getWidth()-15, getY()); } } } }