I'm trying to program a bar which should decrease when an object of another class is shooting.
Here's my code to shoot:
now in my bar class i want to get the BarValue..
now in updateImage() i want to use the DroneBarValue but my bar class doesn't get it. I works when i return this:
return BarValue = 10;
But the Value changes and i dont know why it doesnt work...
public class Ship extends Actor
{
int BarValue = 118;
public void act()
{
if(Greenfoot.isKeyDown("f")
{
shoot();
}
}
public void shoot()
{
Drone Drone2 = new Drone();
getWorld().addObject(Drone2, getX() - 13, getY() - 13);
BarValue--;
}
public int getBarValue()
{
return BarValue;
}
}public class DroneBar
{
int DroneBarValue = 118;
private Ship ship = new Ship();
public void act()
{
if(ship.getBarValue() != DroneBarValue)
{
DroneBarValue = jumper.getShotEnergy();
updateImage();
}
}
