I'm creating a game where a bee flies around and catches flowers which increases the pollen count and this can be stored in the hive, putting the pollen's number into the hive and putting the hive to zero.
Here's what i have for emptying the pollen into the hive:
public void empty()
{
Actor hive;
hive = getOneObjectAtOffset (0,0,hive.class);
if (hive!=null)
{
BG bg = (BG) getWorld();
counter counter1 = bg.getCounter();
hive_counter hive_counter = new hive_counter();
hive_counter counter2 = bg.getPollen();
int pollenCount = counter1.getPollen();
hive_counter.stored = pollenCount;
Greenfoot.playSound("poll.wav");
counter1.pollen = 0;
}
}
it runs with no errors, but does not add the pollen count into the hive counter
Here's my code for adding to the pollen counter when hitting a yellow flower:
Actor yellow;
yellow = getOneObjectAtOffset (0,0,yellow.class);
if (yellow!=null)
{
World myWorld = getWorld();
myWorld .removeObject(yellow);
BG bg = (BG) getWorld();
counter counter = bg.getCounter();
counter.addPollen(1);
Greenfoot.playSound("poll.wav");
int randX = Greenfoot.getRandomNumber(getWorld().getWidth());
int randY = Greenfoot.getRandomNumber(getWorld().getHeight());
myWorld.addObject(new yellow(), randX, randY);