Hello,
My actor is going through walls when approaching it from the left side but from the right side it works fine.
When he comes to the right side he stops, but when he gets to the left side he jumps to the other side of the wall.
I think the problem is in "StopByLeftWall"
public boolean checkLeftWall()
{
int spriteWidth = getImage().getWidth();
int xDistance = (int)(spriteWidth/2);
Actor leftWall = getOneObjectAtOffset(xDistance, 0, 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 + 5, getY());
}
public boolean checkRightWall()
{
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 - 5, getY());
}

