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

Report as inappropriate.

Zamoht
Zamoht presents ...

2013/9/20

Animated Health Bar (demo)

I looked at my old Stat Bar Demo and wanted to update it a little and optimize the performance.

The goal is to create a completely customizable health bar or stat bar. The customization should be done only through subclassing. So please tell me if I should add any constructors or methods to the super class.

Showed here is a HealthBar subclass created with this constructor:
public HealthBar(int max, int current)
{
super(new Color(0, 255, 0), 140, 24, Style.ROUND, max, current);
setSpeed(5);
}

A few methods:
setColor(java.awt.Color color)
setSpeed(double speed)
setTarget(int target)

6394 views / 1069 in the last 7 days

3 votes | 0 in the last 7 days

Tags: mouse game demo with-source bar health smooth stat animate

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

2013/11/21

How do you add a color?
ZamohtZamoht

2013/11/21

You can change the color of the bar in the constructor or by using the setColor(java.awt.Color) method. If you want to change the color depending on the current bar value you should override the updateColor() method.
A new version of this scenario was uploaded on Sun Jan 05 20:23:57 UTC 2014 Fixed string positioning.
A new version of this scenario was uploaded on Sun Jan 05 21:34:52 UTC 2014 Minor bug fixes.
DogeDoge

2014/1/5

Can I use this in some projects of mine?
ZamohtZamoht

2014/1/5

Sure. That was the point of this scenario :) Please tell me if some of the methods aren't understandable, so I can improve the commentary.
A new version of this scenario was uploaded on Sun Jan 05 21:41:48 UTC 2014 Last changes for now.
DogeDoge

2014/1/5

Alright thank you!
davemib123davemib123

2014/6/2

this looks great. I'll be using this :D
ZamohtZamoht

2014/6/3

Glad to hear that!

See all comments

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

Who likes this?

boyercam davemib123 David.Budnick