Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package {
- import flash.display.Sprite;
- public class HealthBar extends Sprite{
- var colour1;
- var colour2;
- var barWidth:int;
- var barHeight:int;
- public function HealthBar() {
- // constructor code
- }
- function initBar(col1,col2,barW,barH){
- this.colour1 = col1
- this.colour2 = col2;
- this.barHeight = barH
- this.barWidth = barW;
- }
- function updateBar(currentHP:Number,maxHP){
- this.graphics.clear();
- this.graphics.beginFill(colour2,1)
- this.graphics.drawRect(0,0, barWidth,barHeight)
- this.graphics.beginFill(colour1,1)
- this.graphics.drawRect(0,0,barWidth *(currentHP/maxHP),barHeight)
- //this.graphics.lineStyle(1,0xFF0000,1)
- this.graphics.endFill();
- this.graphics.drawRect(-1,-1, barWidth+1,barHeight+1)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement