I'm making a little zombie game. I made an animation for the zombies, but they're most of the time upside down...I don't really know how to fix it.
The code below is the code of my zombie (it is called "Target").
import greenfoot.*;
import java.awt.Color;
import java.lang.Object;
/**
* Write a description of class Target here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Target extends Actor
{
public int Health = 999;
Poppetje1 poppetje1;
public int frame = 0;
int aantalZombiesGedood = 0;
/**
* Act - do whatever the Target wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
gebruikHealth();
setLocation();
updateStatusBar();
animatie();
}
public void addHealth (int amountOfHealth)
{
Health += amountOfHealth-350;
if (Health < 999) {
gebruikHealth();
}
updateStatusBar();
}
private void gebruikHealth(){
updateStatusBar();
if (Health <= 0) {
getWorld().removeObject(this);
}
}
private void updateStatusBar()
{
if( frame == 0){
GreenfootImage newImage = new GreenfootImage("ZombieWalk1.png");
newImage.setColor (Color.RED);
newImage.fillRect(39-(Health/60 + 10), 3, Health/60 + 1, 5);
setImage (newImage);
}
if( frame == 15){
GreenfootImage newImage = new GreenfootImage("ZombieWalk2.png");
newImage.setColor (Color.RED);
newImage.fillRect(39-(Health/60 + 10), 3, Health/60 + 1, 5);
setImage (newImage);
}
if( frame == 30){
GreenfootImage newImage = new GreenfootImage("ZombieWalk3.png");
newImage.setColor (Color.RED);
newImage.fillRect(39-(Health/60 + 10), 3, Health/60 + 1, 5);
setImage (newImage);
}
if( frame == 45){
GreenfootImage newImage = new GreenfootImage("ZombieWalk4.png");
newImage.setColor (Color.RED);
newImage.fillRect(39-(Health/60 + 10), 3, Health/60 + 1, 5);
setImage (newImage);
}
if( frame == 60){
GreenfootImage newImage = new GreenfootImage("ZombieWalk5.png");
newImage.setColor (Color.RED);
newImage.fillRect(39-(Health/60 + 10), 3, Health/60 + 1, 5);
setImage (newImage);
frame = 0;
}
}
public void setLocation()
{
turnTowards(Poppetje1.Poppetje1X, Poppetje1.Poppetje1Y);
move(1);
}
public void animatie()
{
frame++;
}
}

