So I want a bullet to be shot and when its y cord is equal to 0 I want it to disappear. Here is my bullet class.
import greenfoot.*;
/**
* Write a description of class Bullet here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Bullet extends Actor
{
/**
* 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);
if(getY() == 0)
{
//Code to remove itself here.
}
}
public Bullet()
{
setRotation(-90);
}
}
So how could I do this?