I am making a side-scrolling game and have run into a problem.
The code is supposed to remove the object that the bullet intersects.
The error that pops up is:
java.lang.NullPointerException
at Bullet.hit(Bullet.java:53)
at Bullet.act(Bullet.java:30)
public void hit()
{
getWorld().addObject(this, getX()+45, getY()+14);
List <Actor> objects = this.getIntersectingObjects(null);
for (int i = 0; i < objects.size(); i++)
{
if (objects.get(i) instanceof Jumper && !(objects.get(i) instanceof Player))
{
this.getWorld().removeObject(objects.get(i));
this.getWorld().removeObject(this);
i--;
count++; // monster is killed, kill count +1
}
}
}