So let me put in some snippets of code
Here is the method from my world class
and here it is when I call it in my actor class
The idea behind the method is:
1) game is running w/ a start actor image that pops up
2) click the start image for it to go away --> then objects from startMission() can start appearing randomly
There is no error message popping up when I run the game, but the startMission() method doesn't work. The removeObject works fine though. Any ideas?
public void startMission()
{
addRandomFood();
addRandomPeople();
addRandomTreasures();
noFuel();
}
public void addRandomFood()
{
if(Greenfoot.getRandomNumber(300)<1)
{
addObject(new Food(), getWidth (), Greenfoot.getRandomNumber(getHeight()));
}
}
public void addRandomTreasures()
{
if(Greenfoot.getRandomNumber(600)<1)
{
addObject(new Treasures(), getWidth (), Greenfoot.getRandomNumber(getHeight()));
}
}
public void addRandomPeople()
{
if(Greenfoot.getRandomNumber(100)<1)
{
addObject(new Person(), Greenfoot.getRandomNumber(getWidth()), 0 );
}
}
public void noFuel()
{
if (fuelCounter.getValue()==-1)
{
gameOver();
Greenfoot.stop();
}
} public void act()
{
starting2();
}
private void starting1()
{
if (Greenfoot.mouseClicked(this))
{
CarWorld w = (CarWorld) getWorld();
w.startMission();
getWorld().removeObject(this);
}
}
