I'm trying to make my player do damage to an enemy, but I cannot seem to figure out how to edit variables across classes. It compiles with no syntax errors, but does not appear to make any changes to the variable. Here is the related code of both the enemy and player class. Any help would be appreciated.
Enemy:
Player:
I have a small animation, just by changing the image, which is why there is that && in the if statement for the player, to make sure it is in the attack.
public int enemyHealth = 2; public void act() { if(enemyHealth == 0) { die(); } } public void die() { getWorld().removeObject(this); }
public void enemyDamage() { if(isTouching(enemy.class) && (getImage() == atkRight || getImage() == atkLeft)) { enemy Enemy = (enemy) getOneIntersectingObject(enemy.class); Enemy.enemyHealth -= 1; } }