Hi, i'm trying to move my Hero back or forward depending on the direction he comes from when he collides with a particular object. I have got this:
But i'm finding that when the hero is moved back or forward it seems to far of a move. How do I stop the hero rom moving to far back / forward?
I have added this to the trees class to test. My scenario is located here: http://www.greenfoot.org/scenarios/11862
public void act()
{
Actor HeroLeft = getOneObjectAtOffset (8, 0, Hero.class);
Actor HeroRight = getOneObjectAtOffset (-8, 0, Hero.class);
if (HeroLeft != null)
{
HeroLeft.setLocation (HeroLeft.getX() + 1, HeroLeft.getY());
return;
}
if (HeroRight != null)
{
HeroRight.setLocation (HeroRight.getX() - 1, HeroRight.getY());
return;
}
}


