I have a meteor that gets smaller every time it is hit by a missile and i want to make it so that when it is a certain size it would get deleted from the world.
if(size < 5) // size being your Variable 5 Being the Biggest size to remove getWorld().removeObject(this);
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Cloud here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Meteor extends Mover
{
/**
* Act - do whatever the Cloud wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move (4);
if (this.atWorldEdge())
{
turn (180);
}
if (Greenfoot.getRandomNumber(100) < 10)
{
turn (Greenfoot.getRandomNumber(90) - 45);
}
Actor missle;
missle = getOneObjectAtOffset(0, 0, Missle.class);
if (missle != null)
{
GreenfootImage image = getImage();
image.scale(image.getWidth() - 10, image.getHeight() - 10);
setImage(image);
{
World world;
world = getWorld();
world.removeObject(missle);
}
if(getImage().getWidth() < 1)
{
getWorld().removeObject(this);
}
}
}
}
image.scale(image.getWidth() - 10, image.getHeight() - 10);
int width = image.getWidth() -10;
int height = image.getHeight() -10;
if (width > 0 && height > 0) {
image.scale(width, height
}if(getImage().getWidth() < *)