Hello,
I'm kinda new to game programming and OOP and I have a little problem in my game.I don't know how to modify de enemy health from the hero attack method.I get a error at "enemy.health -= damage;" and it says "cannot find symbol - var health" (The enemy class has that variable).
I tried to lower the enemy health when the player is near it and uses space every 50 frames(attackSpeed variable).
void attack(int _damage)
{
if(Greenfoot.isKeyDown("space"))
{
Actor enemy = getOneIntersectingObject(Enemy.class);
if(enemy != null && frameCounter >= attackSpeed)
{
enemy.health -= damage;
frameCounter = 0;
}
}
}