Post the line it happens on.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Bullet here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Bullet extends Others
{
/**
* Act - do whatever the Bullet wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
scrollingMethods();
fired();
kill();
}
public void fired()
{
move(50);
}
public int hits2=0;
public int hits3=0;
public int hits5=0;
public boolean atWorldEdge()
{
if (getX() > getWorld().getWidth() - getImage().getWidth()
|| getY() > getWorld().getHeight() - getImage().getHeight())
{
return true;
}
else
{
return false;
}
}
public void kill()
{
Actor Enemy2;
Enemy2 = getOneObjectAtOffset(50, 50, Enemy2.class);
if (Enemy2 != null)
{
hits2++;
if(atWorldEdge())
{
getWorld().removeObject(this);
}
if(hits2>=2)
{
getWorld().removeObject(Enemy2);
}
}
Actor Enemy3;
Enemy3 = getOneObjectAtOffset(50, 50, Enemy3.class);
if (Enemy3 != null)
{
hits3++;
if(atWorldEdge())
{
getWorld().removeObject(this);
}
if(hits3>=5)
{
getWorld().removeObject(Enemy3);
}
}
Actor Enemy5;
Enemy5 = getOneObjectAtOffset(50, 50, Enemy5.class);
if (Enemy5 != null)
{
hits5++;
if(atWorldEdge())
{
getWorld().removeObject(this);
}
if(hits5>=15)
{
getWorld().removeObject(Enemy5);
}
}
}
}
public void kill()
{
if (atWorldEdge())
{
getWorld().removeObject(this);
return;
}
Actor Enemy2;
Enemy2 = getOneObjectAtOffset(50, 50, Enemy2.class);
if (Enemy2 != null)
{
hits2++;
if(hits2>=2) getWorld().removeObject(Enemy2);
}
Actor Enemy3;
Enemy3 = getOneObjectAtOffset(50, 50, Enemy3.class);
if (Enemy3 != null)
{
hits3++;
if(hits3>=5) getWorld().removeObject(Enemy3);
}
Actor Enemy5;
Enemy5 = getOneObjectAtOffset(50, 50, Enemy5.class);
if (Enemy5 != null)
{
hits5++;
if(hits5>=15) getWorld().removeObject(Enemy5);
}
}