Hi guys,
please help me find the error in my code. I get a null pointer exception error every time the bomb reaches the left edge.
Thanks!
/*
*each time a bomb approaches the left edge of the World it disappears, a new bomb is added to the right edge of the World
*and the counter is raised by 1
*/
public void removeBomb()
{
TurtleWorld turtleWorld = (TurtleWorld) getWorld();
if ( getX() <= turtleWorld.getWidth() -turtleWorld.getWidth() +10 )
{
turtleWorld.removeObject(this);
turtleWorld.addObject( new Bomb(), turtleWorld.getWidth() -10, Greenfoot.getRandomNumber( turtleWorld.getHeight() ) );
turtleWorld.getCounter().add(1);
}
}
