-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhud.js
43 lines (39 loc) · 989 Bytes
/
hud.js
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
36
37
38
39
40
41
42
43
/**
* @author RCordeiro
*/
// create a "score object" that will use a Bitmap font
// to display the score value
var hpObject = me.HUD_Item.extend(
{
// constructor
init: function(x, y)
{
// call the parent constructor
this.parent(x, y);
// create a font
this.font = new me.BitmapFont("font8", 8);
this.icon = me.loader.getImage("hp")
},
// draw function
draw : function (context, x, y)
{
context.drawImage(this.icon, this.pos.x + x, this.pos.y + y);
this.font.draw(context, this.value, this.pos.x + x + 36, this.pos.y + y + 4);
}
});
var borderObject = me.HUD_Item.extend(
{
// constructor
init: function(x, y)
{
// call the parent constructor
this.parent(x, y);
// create a font
this.border = me.loader.getImage("border")
},
// draw function
draw : function (context, x, y)
{
context.drawImage(this.border, this.pos.x + x, this.pos.y + y);
}
});