having this error when pressing z to create the projectile class from another actor class.
"java.lang.NullPointerException
at Guy.shoot(Guy.java:57)
at Guy.act(Guy.java:25)
at greenfoot.core.Simulation.actActor(Simulation.java:567)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:530)
at greenfoot.core.Simulation.runContent(Simulation.java:193)
at greenfoot.core.Simulation.run(Simulation.java:183)"
here is part of the code from the actor launching the projectile and the actual projectile.
public void act()
{
movement();
if(Greenfoot.isKeyDown("z")){
shoot();
}
private void shoot(){
if(delay != 0){
delay--;
}
//defines world and returns it to this actor
//defines projectile and returns it to this actor
if(delay == 0) {
world.addObject(projectile,100,100);
delay= 70;
}public void act()
{
move(1);
}