He gets stuck on walls, also in the air when he does his little 10 pixel jump.
Here's a very basic way to make your character turn when he's moving. Assuming you have two images, imageOne and imageTwo.
GreenfootImage RightOne = new GreenfootImage("imageOne.png");
GreenfootImage RightTwo = new GreenfootImage("imageTwo.png");
GreenfootImage LeftOne = new GreenfootImage("imageOne.png");
GreenfootImage LeftTwo = new GreenfootImage("imageTwo.png");
public character()
{
/**
* Mirror the images for moving right horizontally.
**/
RightOne.mirrorHorizontally();
RightTwo.mirrorHorizontally();
}
public void move()
{
if(Greenfoot.isKeyDown("right"))
{
setImage(RightOne);
setLocation(getX()+2, getY())
setImage(RightTwo);
}
if(Greenfoot.isKeyDown("left"))
{
setImage(LeftOne);
setLocation(getX()-2, getY());
setImage(LeftTwo);
}
}
That's reallly basic but it should work.
A new version of this scenario was uploaded on Sun Nov 14 17:28:12 UTC 2010
A new version of this scenario was uploaded on Sun Nov 14 17:33:53 UTC 2010
A new version of this scenario was uploaded on Sun Nov 14 21:17:47 UTC 2010
2010/11/14
2010/11/14
2010/11/15