Im making a fake pokemon with a couple of friends of me, and my charachter wont stop moving at 2 certain objects. A tree and a house. I dont know how to make a code of that. Below here is the code.I know that i should use the 'move(int)' code but it doesnt work for me somehow.
public void act()
{
if (Greenfoot.isKeyDown ("up") || Greenfoot.isKeyDown ("w"))
{
setLocation(getExactX(), getExactY()-moveSpeed);
setImage("roodkapjeachter.gif");
if (isTouching(Tree.class))
{
move(0);
}
}
if (Greenfoot.isKeyDown ("down") || Greenfoot.isKeyDown ("s"))
{
setLocation(getExactX(), getExactY()+moveSpeed);
setImage("roodkapjevoor.gif");
if (isTouching(Obstacle.class))
{
move(0);
}
}
if (Greenfoot.isKeyDown ("left") || Greenfoot.isKeyDown ("a"))
{
setLocation(getExactX()-moveSpeed, getExactY());
setImage("roodkapjelinks.gif");
if (isTouching(Tree.class))
{
}
}
if (Greenfoot.isKeyDown ("right") || Greenfoot.isKeyDown ("d"))
{
setLocation(getExactX()+moveSpeed, getExactY());
setImage("roodkapjerechts.gif");
if (isTouching(Tree.class))
{
move(0);
}
}
}


