-
Notifications
You must be signed in to change notification settings - Fork 0
/
LifeBar.as
35 lines (32 loc) · 931 Bytes
/
LifeBar.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package
{
import net.flashpunk.Entity;
import net.flashpunk.FP;
import net.flashpunk.graphics.Image;
public class LifeBar extends Entity
{
public var bar:Image = Image.createRect(((Player.hp-1)*5),10, 0x0000FF);
public function LifeBar()
{
layer = -2;
super(80, FP.height-15, bar);
}
override public function update():void
{
if (Player.hpIncrease)
{
bar.clipRect.width = FP.approach(bar.clipRect.width, bar.width, 5);
bar.clear();
bar.updateBuffer();
Player.hpIncrease = false;
}
if (Player.hpDecrease)
{
bar.clipRect.width = FP.approach(bar.clipRect.width, 0, 5);
bar.clear();
bar.updateBuffer();
Player.hpDecrease = false;
}
}
}
}