Hey Guys,
A friend of mine and me used the Progress and Health Bar which is published by danpost (http://www.greenfoot.org/scenarios/4114).
We included it into our Project and started using it. Now we added an object which is shooting at our main Character. We want to let the main character take damage everytime when he gets shot. We tried to do it with the subtract method but it´s still not working.
We would appreciate it if one of you can help us and send us a solution
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) / * Write a description of class feuer here. * * @author (your name) * @version (a version number or a date) */ public class feuer extends Actor { / * Act - do whatever the feuer wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ Bar bar = new Bar("Jeff","HP",100,100); public void act() { move(-8); hit(); } public void hit() { if(isTouching(Main.class)) { bar.subtract(10); getWorld().removeObject(this); } else if(isAtEdge()) { getWorld().removeObject(this); } } }