Hi everyone. I'm having a problem accessing a counter I created in a World subclass that keeps score in my game. I'm able to access it with the following code:Unfortunately, this code ONLY works in this World and I have two more World subclasses, used as levels, to use. The entire method goes like this:
I appreciate any help y'all can give me.
this.getWorldOfType(Battleground.class).counter.add(5);
int enemyFighterDamage = 50;
/**
* fighterHit method is executed when a phaser hits an enemy fighter
* in order to clear them from the battleground.
* @param enemyFighterDamage adds five points of damage to the fighter
* until it reaches 50, when it is then removed from the world.
*/
public void fighterHit()
{
enemyFighterDamage -= 5;
this.getWorldOfType(Battleground.class).counter.add(5);
//this.getWorldOfType(Battleground2.class).counter.add(5);
//this.getWorldOfType(Battleground3.class).counter.add(5);
removeTouching(Phaser.class);
if(enemyFighterDamage < 5)
{
this.getWorld().removeObject(this);
}
}

