Trying to build a engery blask (named kiBlast) for my game im making and I keep getting that errior
My code for the kiBlast class
My Player Class (named Goku):
my Ground class is empty and my World class is:
import greenfoot.*;
public KiBlast extends Actor
{
public void act()
{
setLocation(getX() + speed, getY());
checkBoundaries();
destroyEnemies();
}
public void checkBoundaries()
{
if(getX() > getWorld().getWidth() - 1)
{
getWorld().removeObject(this);
}
else if(getX() < 1)
{
getWorld().removeObject(this);
}
if(getY() > getWorld().getHeight() - 1)
{
getWorld().removeObject(this);
}
else if(getY() < 1)
{
getWorld().removeObject(this);
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class Goku extends Actor
{
private int vSpeed = 0;
private int acceleration = 1;
private int jumpStrength = 20;
GifImage moveRight = new GifImage("moveRight.gif");
GifImage moveLeft = new GifImage("moveLeft.gif");
public void act()
{
checkFall();
checkFire();
if (Greenfoot.isKeyDown ("right"))
{
move(5);
setImage (moveRight.getCurrentImage());
}
if (Greenfoot.isKeyDown ("left"))
{
move(-5);
setImage (moveLeft.getCurrentImage());
}
if(Greenfoot.isKeyDown("up") && Greenfoot.isKeyDown("right"))
{
if(onGround())
{
jump();
}
else
{
}
}
if(Greenfoot.isKeyDown("up") && Greenfoot.isKeyDown("left"))
{
if(onGround())
{
jump();
}
else
{
}
}
if(Greenfoot.isKeyDown("up"))
{
if(onGround())
{
jump();
}
else
{
}
}
}
public void fall()
{
setLocation(getX(), getY() + vSpeed);
vSpeed = vSpeed + acceleration;
}
public void checkFire()
{
if(Greenfoot.isKeyDown("space"))
{
getWorld().addObject(new kiBlast(), getX(), getY());
}
}
public boolean onGround()
{
int spriteHeight = getImage().getHeight();
int lookForGround = spriteHeight/2;
Actor ground = getOneObjectAtOffset(0, lookForGround, Ground.class);
if(ground == null)
{
return false;
}
else
{
return true;
}
}
public void checkFall()
{
if(onGround())
{
vSpeed = 0;
}
else
{
fall();
}
}
public void jump()
{
vSpeed = -jumpStrength;
fall();
}
}import greenfoot.*;
public class Earth extends World
{
/**
* Constructor for objects of class Namek.
*
*/
public Earth()
{
super(1056, 683, 1);
addObject( new Goku(), 40, 480);
addObject( new Ground(), 528, 600);
addObject( new kiBlast());
}
}