Im trying to make it that when a bullet hits the plane, it waits a second, and then loads a new world how do i do that?
import greenfoot.*;
/**
* Write a description of class Airplane here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Airplane extends Actor
{
private static final int max_acts_between_shots = 10;
private int actsBetweenShots = Integer.MAX_VALUE;
private GreenfootImage Explosion = new GreenfootImage("Explosion.png");
public static int score1;
/**
* Act - do whatever the Airplane wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
getImage().scale(60,60);
move(2);
if(Greenfoot.isKeyDown("A"))
{
turn(-5);
}
if(Greenfoot.isKeyDown("D"))
{
turn(5);
}
if(((MyWorld) getWorld()).getCountDown().isCountDownFinished())
{
if(Greenfoot.isKeyDown("SPACE"))
{
if(actsBetweenShots > max_acts_between_shots) {
bullet b = new bullet();
getWorld().addObject(b, getX(), getY());
actsBetweenShots = 0;
b.setRotation(getRotation());
}
actsBetweenShots++;
}
}
if(isTouching(bullet2.class))
{
World MyWorld = getWorld();
MyWorld world = (MyWorld)MyWorld;
score score = world.getScore();
score.addScore1();
Explosion Explosion = new Explosion();
getWorld().addObject(Explosion, getX(),getY());
getWorld().removeObject(this);
Greenfoot.setWorld(new MyWorld());
}
}
}
