I think you need to work on explaining what you want. It's unclear to me.
int rand = Greenfoot.getRandomNumber(locs.length);
int x = locs[rand][0];
int y = locs[rand][1];
addObject(new VirusWASD(), x, y); // or setLocation of existing object
a.setLocation(x, y);
public void kill(Class clss)
{
Actor actor = getOneObjectAtOffset(0,0, clss);
if(actor != null)
{
actor.setLocation(300, 400);
}
}
public void respawnLocation()
{
int[][] locs = { { 585, 201}, { 1148, 161 }, { 574, 536 } };
int rand = Greenfoot.getRandomNumber(locs.length);
int x = locs[rand][0];
int y = locs[rand][1];
virusARROW.setLocation(x, y); // <---- NULL POINTER EXCEPTION
}
public void respawn(Class clss)
{
Actor actor = getOneObjectAtOffset(0,0, clss);
if(actor != null)
{
respawnLocation();
}
}
} private VirusARROW virusARROW;
private VirusPL virusPL;
private VirusWASD virusWASD;
private VirusYGHJ virusYGHJ;