Hi everyone! So I am creating a game which involves a player moving up, down, left, and right, and the game is in eagle eye view so all you see is the player's head. I gave this player an animation in Greenfoot, which the code for looks like this:
However, this animation only happens when the player is moving, so when he is stationary, I had to get it to set the player back to the original picture. This is how I did that:
Then I have my problem. The picture I use has the player facing a certain direction, toward the bottom of the screen. This means that if you are moving left, and facing left when you stop moving, then it will make it look like you turned back toward the bottom of the screen. Basically what I am trying to do is make the image set to the standing image while facing the direction in which you stopped, instead of facing downward. If need be I can post the rest of my code for the player.
Thank you very much for any help, and I am sorry if my code is junk, just starting out with Greenfoot :)
if(Greenfoot.isKeyDown("w") || Greenfoot.isKeyDown("a") || Greenfoot.isKeyDown("s") || Greenfoot.isKeyDown("d")) //These are the images for my player's animation.
{
image++;
if(image == 0)
{
setImage("Player4.png");
}
if(image == 10)
{
setImage("Player5.png");
}
if(image == 20)
{
setImage("Player6.png");
}
if(image == 30)
{
setImage("Player5.png");
}
if(image == 40)
{
setImage("Player4.png");
}
if(image == 50)
{
setImage("Player3.png");
}
if(image == 60)
{
setImage("Player2.png");
}
if(image == 70)
{
setImage("Player3.png");
}
if(image == 80)
{
setImage("Player4.png");
image=0;
}
}
if(!Greenfoot.isKeyDown("w") && !Greenfoot.isKeyDown("a") && !Greenfoot.isKeyDown("s") && !Greenfoot.isKeyDown("d")) //Sets image to normal standing image.
{
setImage("Player.png");
}
