why my shooting animation only show until frames 6-7. My shooting animation supposed to have 18 frames.
import greenfoot.*;
public class Wraith extends Mover
{
private int shotTimer = 15;
private int SpaceTimer = 15;
private int AnyPressed = 0;
private int ShootFrames = 18;
private int ShootTime;
private int ShootAnimate;
private int LeftFrames = 9;
private int LeftTime;
private int RightFrames = 9;
private int RightTime;
Wraith()
{
}
public void act()
{
shotTimer++;
AnyPressed --;
SpaceTimer --;
ShootAnimate --;
checkKeys();
}
private void checkKeys()
{
if (Greenfoot.isKeyDown("w"))
{
moveUp();
}
if(Greenfoot.isKeyDown("s"))
{
moveDown();
}
if (Greenfoot.isKeyDown("a"))
{
animateLeft();
moveLeft();
AnyPressed = 50;
}
else{
AnyPressed = 0;
}
if (Greenfoot.isKeyDown("d"))
{
animateRight();
moveRight();
AnyPressed =50;
}
else {
AnyPressed = 0;
}
if(Greenfoot.isKeyDown("space") && SpaceTimer <=0)
{
ShootAnimate = 1;
if(shotTimer > 25)
{
ShootTime =0;
this.shoot();
shotTimer = 0;
AnyPressed = 50;
}
SpaceTimer = 25;
}
else{
AnyPressed = 0;
}
if(ShootAnimate >=1){
animateShoot();
}
}
public void animateShoot(){
setImage(animateShootx()[ShootTime]);
if(ShootFrames < 18){
ShootTime++;
}
}
public void animateLeft(){
setImage(animateLeftx()[LeftTime]);
LeftTime++;
if(LeftTime== LeftFrames){
LeftTime=0;
}
}
public void animateRight(){
setImage(animateRightx()[RightTime]);
RightTime ++;
if(RightTime == RightFrames){
RightTime = 0;
}
}
public void shoot()
{
this.getWorld().addObject(new Fireball(), this.getX()+30, this.getY()-45);
}
public GreenfootImage[] animateShootx(){
GreenfootImage[] images = new GreenfootImage[ShootFrames];
for(int i=0; i<18; i++){
if(ShootAnimate >=0){
images[i] = new GreenfootImage("S_Right" +i+ ".png");
}
}
return images;
}
public GreenfootImage[] animateLeftx(){
GreenfootImage[] images = new GreenfootImage[LeftFrames];
for(int i=0; i<9; i++){
images[i] = new GreenfootImage("W_Left" + i + ".png");
}
return images;
}
public GreenfootImage[] animateRightx(){
GreenfootImage[] images = new GreenfootImage[RightFrames];
for(int i=0; i<9; i++){
images[i] = new GreenfootImage("W_Right" + i + ".png");
}
return images;
}
}
