This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

danpost presents ...


Progress bar/Health bar class

Bar class with no editing required. All needed methods are available to suit most needs.

Download, and while NOT running, right click on the bar and experiment with some (or all) of the methods provided.

Also, check out some sub-classes you can use with the bar (to allow it to be adjustable; to make a switch; or to make a timer display) located in the following scenario:

15760 views / 76 in the last 7 days

23 votes | 0 in the last 7 days

Tags: demo with-source bar danpost progress-bar support-class health-bar

This scenario is a member of: Support Classes by danpost

open in greenfoot
Your browser does not support the canvas tag.


I figured it out based on a different discussion thread you answered haha, I was trying to add the bar object into the world from the constructor of the unit.


@Liamb2179, it is possible to do so; but, the world object must be passed to the constructor (directly or indirectly) like a method argument. What I mean by indirectly, is an Actor object ( 'Actor actor' )that is in the world could be passed instead because it has a reference to the world that can be retrieved with 'actor.getWorld()'.


how would I make the bar go down by making a different class touch a different class?


it doesnt find bar.subtract in my other class


public void hit(){ Actor actor = getOneObjectAtOffset(0, 0, Ennemies.class); if(actor != null) { Bar.subtract(1); } }


@SullyFish, start a discussion thread, show how you create the bar and how you are trying to use the bar (code posting is better in discussion threads).


nvm sorry I found it
A new version of this scenario was uploaded on 2017-01-20 23:18:50 UTC
A new version of this scenario was uploaded on 2017-10-16 02:02:20 UTC


This is pretty cool

See all comments

Want to leave a comment? You must first log in.

Who likes this?

tjoepapke JerHowden Ariadia hugtvy SPower arinb kikumaru818 ndrwdslv FlyingRabidUnicornPig dianefayeparajes Poli solokeh rhddpcks Cocky davemib123 erdelf limefortheworld SkyLark tylers Gazzzah