Hey guys i want to make this "NyanClone" get deleted 60 seconds after it is spawned in by a power up so how do i do it exactly the code i have so far in the clone class is Thanks in advance :)
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class NyanClone here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class NyanClone extends Actor
{
private int timer = 0;
private int shotTimer = 0;
int objectsX;
int objectsY;
/**
* Act - do whatever the NyanClone wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if (shotTimer > 0)
{
shotTimer = shotTimer - 7;
}
else if (Greenfoot.isKeyDown("space"))
{
Greenfoot.playSound("Lazer.wav");
getWorld().addObject(new ShotClone(this), getX(), getY());
shotTimer = 400;
}
if (Greenfoot.isKeyDown ("Left"))
{
move(-1);
}
if (Greenfoot.isKeyDown ("Right"))
{
move(1);
}
if (Greenfoot.isKeyDown ("up"))
{
setLocation(getX(),getY()-1);
}
if (Greenfoot.isKeyDown ("down"))
{
setLocation(getX(),getY()+1);
}
checkCollision();
}
public void checkCollision()
{ Actor GameOver;
GameOver = getOneIntersectingObject(Asteroid.class);
if(GameOver != null)
{
getWorld().removeObject(this);
}
}
public void deleteClone()
{
if(this.getClass() != null)
{
if (timer ==60)
{
timer--;
if(timer == 0)
{
getWorld().removeObject(this);
}
}
}
}
}

