Please help me to create an explosion when i shooting an enemy.
public void shoot()
{ if ("space".equals(Greenfoot.getKey()))
{
bullet shot=new bullet();
getWorld().addObject(shot,getX(),getY());
shot.setRotation(getRotation());
}
}
public void act()
{
move(5);
kill();
remove();
}
public void kill()
{
Actor rocket=getOneIntersectingObject(rocket.class);
if (rocket != null)
{
World myWorld = getWorld();
getWorld().removeObject(rocket);
}
}
public void remove()
{
Actor rocket = getOneObjectAtOffset(0, 0, rocket.class);
if (rocket != null)
{
World world;
World myWorld = getWorld();
getWorld().removeObject(this);
}
else
{
if(getX()==599||getX()==0||getY()==0||getY()==399)
{
getWorld().removeObject(this);
}
}
}getWorld().addObject(new explosion(), getX(), getY());
public void shoot()
{ if ("space".equals(Greenfoot.getKey()))
{
bullet shot=new bullet();
getWorld().addObject(shot,getX(),getY());
shot.setRotation(getRotation());
}
}{
/**
* Act - do whatever the bullet wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(5);
remove();
}
public void remove()
{
Actor rocket=getOneIntersectingObject(rocket.class);
if (rocket != null)
{
getWorld().addObject(new explosion(), getX(), getY());
getWorld().removeObject(this);
getWorld().removeObject(rocket);
}
else
{
if(getX()==599||getX()==0||getY()==0||getY()==399)
{
getWorld().removeObject(this);
}
}
}
}