I have the problem that my player can walk through the walls.class from the left side when the screen starts to scroll.
Before the screen starts scrolling my method works. (player can't walk through walls from the left and right direction).
thats my Player code
public void checkWallR()
{
Actor wall = getOneIntersectingObject (Wall.class);
if (wall !=null)
{
move (X -10);
}
}
/**
* Checks if the Player touches a Wall and sets the Player back
*/
public void checkWallL()
{
Actor wall = getOneIntersectingObject (Wall.class);
if (wall !=null)
{
move (X +10);
}
}
/**
* The animation method that Herman changes the frames by walking
*/
public void mAnimation()
{
if (Greenfoot.isKeyDown("Right"))
{
if(animationCount % 6 == 0) //slows the animation down
animation1(); //calls the animation method
animationCount += 1;
}
else if (Greenfoot.isKeyDown("Left"))
{
if (animationCount % 6 == 0) //slows the animation down
animation2(); //calls the animation method
animationCount += 1;
}
}
/**
* This is the Method for the left and right movement of the Player
* it checks if the left or right button is pressed and moves the Player left or right with an animation of the walking
*/
public void checkKeys ()
{
Level1 theWorld = (Level1) getWorld();
Scroll scroll = (Scroll) theWorld.getScroll();
if(Greenfoot.isKeyDown("Right") && scroll.shouldScroll == false) //checks if the right Key is Pressed and the Scroll method from class Scroll
{
moveRight(); //moves the Player right by pressing left arrow
checkWallR();
}
else if(Greenfoot.isKeyDown("Left") && scroll.shouldScroll == false) //checks if the left Key is Pressed and the Scroll method from class Scroll
{
moveLeft(); //moves the Player left by pressing left arrow
checkWallL();
}
}

