Im trying to have my bullet removed after it hits one "Öl". If I just use removeObject(this) in the same code in which I remove the Öl it gives me a red error window.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Projectile here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Projectile extends Animal
{
/**
* Act - do whatever the Projectile wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
Garten thisGame;
public void act()
{
move();
hit1();
//hit2();
Wall();
//despawn();
}
public void move()
{
move(10);
}
public void hit1()
{
Actor Projectile = getOneIntersectingObject(Öl.class); //Kein plan wie die 2 zeilen funktionieren
if (Projectile != null) {
getWorld().removeObject(Projectile);
thisGame.score++;
}
}
public void hit2()
{
Actor Öl = getOneIntersectingObject(Projectile.class);
if (Öl != null) {
getWorld().removeObject(Öl);
}
}
public void despawn()
{if(isTouching(Öl.class));
getWorld().removeObject(this);
}
public void Wall()
{
Actor Projectile_Wall = getOneIntersectingObject(Projectile.class); //Kein plan wie die 2 zeilen funktionieren
if (Projectile_Wall != null) {
getWorld().removeObject(Projectile_Wall);
}
}
}
