I have a life counter. It's called aCounterLives. This is meant for the lives (numOfBuckets). I'm not why, but I think it's because of the counter's methods.
This is the method that deals with the players lives. numOfBuckets is a dynamic variable for now, though I think it being set would likely fix the problem.
aCounterLives (whole class)
private void playerLives()
{
numOfBuckets = 3;
boolean bombHasHitArea = ((MyWorld)getWorld()).getBoomArea().bombBoom();
MyWorld kaboomWorld = (MyWorld) getWorld();
aCounterLives bucketsCounter = kaboomWorld.getBucketsCounter();
if (bombHasHitArea == true)
{
numOfBuckets = numOfBuckets - 1;
bucketsCounter.decCount(1);
}
}public class aCounterLives extends Actor
{
private int totalCount = 0;
/**
* This is a counter. Counts up.
* Most code is from https://www.greenfoot.org/doc/howto-1
*/
public aCounterLives ()
{
setImage(new GreenfootImage("0", 20, Color.BLACK, Color.WHITE));
}
public void bumpCount(int amount)
{
totalCount += amount;
setImage(new GreenfootImage("" + totalCount, 20, Color.BLACK, Color.WHITE));
}
public void decCount(int amount)
{
totalCount -= amount;
setImage(new GreenfootImage("" + totalCount, 20, Color.BLACK, Color.WHITE));
}
}
