it kept on saying that it cant find the variable 'healthbar' and nonstatic method
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Bloctopus here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Bloctopus extends Actor
{
int health= 3;
boolean touchingEnemies = false;
GreenfootImage photo2 = new GreenfootImage("photo2.png");
GreenfootImage photo3 = new GreenfootImage("photo3.png");
GreenfootImage photo4 = new GreenfootImage("photo4.png");
GreenfootImage photo5 = new GreenfootImage("photo5.png");
GreenfootImage photo6 = new GreenfootImage("photo6.png");
GreenfootImage photo7 = new GreenfootImage("photo7.png");
GreenfootImage pat1 = new GreenfootImage("pat1.png");
GreenfootImage pat2 = new GreenfootImage("pat2.png");
GreenfootImage pat3 = new GreenfootImage("pat3.png");
GreenfootImage pat4 = new GreenfootImage("pat4.png");
GreenfootImage pat5 = new GreenfootImage("pat5.png");
GreenfootImage pat6 = new GreenfootImage("pat6.png");
public int frame = 1;
public int animationCounter = 0;
/**
* Act - do whatever the Bloctopus wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
movements();
animationCounter = animationCounter + 1;
hitEnemies();
}
public void movements ()
{
if (Greenfoot.isKeyDown("d"))
{
move(3);
if(animationCounter % 6 == 0)
animate();
if ("space".equals(Greenfoot.getKey()))
{
getWorld().addObject (new Bullet(), getX(), getY());
Greenfoot.playSound("Silencer.mp3");
}
}
if ( Greenfoot.isKeyDown("a"))
{
move (-3);
if(animationCounter % 6 == 0)
animatee();
if ("space".equals(Greenfoot.getKey()))
{
getWorld().addObject (new Bullet2(), getX(), getY());
Greenfoot.playSound("Silencer.mp3");
}
}
}
public void animate ()
{
if (frame == 1)
{
setImage(photo2);
frame = 2;
}
else if (frame ==2)
{
setImage(photo3);
frame = 3;
}
else if (frame == 3)
{
setImage(photo4);
frame = 4;
}
else if (frame == 4)
{
setImage(photo5);
frame = 5;
}
else if (frame == 5)
{
setImage(photo6);
frame = 6;
}
else if (frame == 6)
{
setImage(photo7);
frame = 1;
}
}
public void animatee ()
{
if (frame == 1)
{
setImage(pat1);
frame = 2;
}
else if (frame ==2)
{
setImage(pat2);
frame = 3;
}
else if (frame == 3)
{
setImage(pat3);
frame = 4;
}
else if (frame == 4)
{
setImage(pat4);
frame = 5;
}
else if (frame == 5)
{
setImage(pat5);
frame = 6;
}
else if (frame == 6)
{
setImage(pat6);
frame = 1;
}
}
public void hitEnemies()
{
Actor health = getOneIntersectingObject(HealthBar.class);
Actor enemy = getOneIntersectingObject (Enemy1.class);
if (enemy != null)
{
World myWorld = getWorld();
City city = (City) myWorld;
if(touchingEnemies == false)
{
HealthBar. loseHealth();
touchingEnemies = true;
if (healthbar.health <=0)
{
GameOver gameover = new GameOver();
myWorld.addObject(gameover, myWorld.getWidth()/2, myWorld.getHeight()/2);
myWorld.removeObject(this);
}
}
} else
{
touchingEnemies = false;
}
}
}


