Hi,
I have a plane, a bullet, a red balloon and a blue balloon.
The plane moves and shoots bullets.
When a bullet hits a blue balloon both the bullet and the balloon are removed, which is what I want.
When a bullet hits a red balloon both the bullet and the balloon are removed but the game freezes, what have I got wrong?
Here is the bullet code:
import greenfoot.*;
public class Bullet extends Actor
{
public Bullet(int rotation)
{
setRotation(rotation);
}
public void act()
{
move(10);
destroyRedBalloon();
destroyBlueBalloon();
}
public void destroyRedBalloon()
{
Actor RedBalloon;
RedBalloon = getOneObjectAtOffset(0, 0, RedBalloon.class);
if(RedBalloon != null)
{
getWorld().removeObject(RedBalloon);
getWorld().removeObject(this);
}
}
public void destroyBlueBalloon()
{
Actor BlueBalloon;
BlueBalloon = getOneObjectAtOffset(0, 0, BlueBalloon.class);
if(BlueBalloon != null)
{
getWorld().removeObject(BlueBalloon);
getWorld().removeObject(this);
}
}
}
Thanks

