Have i said something wrong?
public class Vile extends Enemy
{
private int vSpeed = 0;
private int acceleration = 1;
private int shootingCounter = 10;
private int spriteHeight = getImage().getHeight();
private int spriteWidth = getImage().getWidth();
private int lookForGroundDistance = (int)spriteHeight/2;
private int lookForEdge = (int)spriteWidth/2;
private int speed = 15;
private int animCount; // counter for animations
private int animDelay = 6; // initially set for standing animation (frame rate field)
private static GreenfootImage[] VileStandAnim = new GreenfootImage[1];
private static GreenfootImage[] VileStandLeftAnim = new GreenfootImage[1];
private static GreenfootImage[] rightAnim = new GreenfootImage[2];
private static GreenfootImage[] leftAnim = new GreenfootImage[2];
private static GreenfootImage[] shootAnim = new GreenfootImage[1];
private static GreenfootImage[] shootLeftAnim = new GreenfootImage[1];
static
{
for (int i=0; i<VileStandAnim.length; i++) VileStandAnim[i] = new GreenfootImage("VileStand_0"+(i+1)+".png");
for (int i=0; i<VileStandLeftAnim.length; i++) VileStandLeftAnim[i] = new GreenfootImage("VileStandLeft_0"+(i+1)+".png");
for (int i=0; i<rightAnim.length; i++) rightAnim[i] = new GreenfootImage("VileDash_0"+(i+1)+".png");
for (int i=0; i<leftAnim.length; i++) leftAnim[i] = new GreenfootImage("VileDashLeft_0"+(i+1)+".png");
for (int i=0; i<shootAnim.length; i++) shootAnim[i] = new GreenfootImage("VileShoot_0"+(i+1)+".png");
for (int i=0; i<shootLeftAnim.length; i++) shootLeftAnim[i] = new GreenfootImage("VileShootLeft_0"+(i+1)+".png");
}
private void setAnim(GreenfootImage[] anim, int frameRate)
{
animSet = anim;
animCount = -1; // prepares to set first image when incremented
animDelay = frameRate;
animate(); // calls a method to set a frame of this newly set animation
}
private GreenfootImage[] animSet = VileStandLeftAnim;
/**
* Act - do whatever the Vile wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
animate();
checkAnim();
move();
}
public void move()
{
Actor ground = getOneObjectAtOffset(lookForEdge, lookForGroundDistance, Collider.class);
if(ground == null)
{
speed *= -1;
lookForEdge *= -1;
}
else
{
move(speed);
}
}
public void checkAnim()
{
if(speed == 15 && animSet != rightAnim )setAnim(rightAnim, 2);
else if(speed == -15 && animSet != leftAnim) setAnim(leftAnim, 2);
}