Hi Guys,
i´m really new with programming and i want to write a little Tank programm.
If a rocket which was fired from a tank hits a target i want them both to be removed.
And after i hit all targets, 5 in my case, the world should change.
The problem is that my programm stucks and i get an error if my rocket dont hits a target and is beeing deleted by my "atWorldEdge" method also i dont know why the counter doesnt get higher...
The error message is
Please help me :(
public class Targets extends Exercises
{
int counter = 0;
/**
* Act - do whatever the Ziele wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
hit();
}
private void hit()
{
Actor rocket = getOneIntersectingObject(Rocket.class);
if (rocket != null)
{
getWorld().removeObject(rocket);
getWorld().removeObject(this);
counter++;
}
}
}java.lang.IllegalStateException: Actor not in world. An attempt was made to use the actor's location while it is not in the world. Either it has not yet been inserted, or it has been removed. and java.lang.NullPointerException
