I have right now a problem with left check... My right check is good.. And no problems
But my left have a problem, my actor is going through walls from the left.
Right wall check (Works perfectly fine)
public boolean checkRightWalls()
{
int spriteWidth = getImage().getWidth();
int xDistance = (int)(spriteWidth/2);
Actor rightWall = getOneObjectAtOffset(xDistance, 0, Platform.class);
if(rightWall == null)
{
return false;
}
else
{
stopByRightWall(rightWall);
return true;
}
}
public void stopByRightWall(Actor rightWall)
{
int wallWidth = rightWall.getImage().getWidth();
int newX = rightWall.getX() -(wallWidth + getImage().getWidth())/2;
setLocation(newX -1, getY());
}
Here is the left check code.. (Doesn't work)
public boolean checkLeftWalls()
{
int spriteWidth = getImage().getWidth();
int xDistance = (int)(spriteWidth/-2);
Actor leftWall = getOneObjectAtOffset(-xDistance, -1, Platform.class);
if(leftWall == null)
{
return false;
}
else
{
stopByLeftWall(leftWall);
return true;
}
}
public void stopByLeftWall(Actor leftWall)
{
int wallWidth = leftWall.getImage().getWidth();
int newX = leftWall.getX() - (wallWidth - getImage().getWidth())/-2;
setLocation(newX +1, getY());
}
Please tell me exactly what to change so I can understand because I am still a beginner.

