I have made multiple different variations of this, so I turned to a book example. (Asteroids 3) in which when the Spaceship gets destroyed after running into an asteroid, so I used that as a base:
This still causes me to get a null actor error (From the explosion getting x and y. What am I doing wrong here?
Any and all help is greatly appreciated!
private void checkHit(){
EnergyBeam a = (EnergyBeam) getOneIntersectingObject(EnergyBeam.class);
if (a != null)
{
Namek namek = (Namek) getWorld();
namek.addObject(new Explosion(), getX(), getY());
health -= 1;
Greenfoot.playSound("explode.wav");
removeTouching(EnergyBeam.class);
if(health <= 0){
namek.removeObject(this);
}
}
}
