Class me.HUD_Item
Extends
Object.
Defined in: <build/melonJS-0.9.3.js>.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
me.HUD_Item(x, y, val)
Item skeleton for HUD element
|
| Field Attributes | Field Name and Description |
|---|---|
|
position of the item
|
|
|
value of the item
|
| Method Attributes | Method Name and Description |
|---|---|
|
draw(context, x, y)
draw the HUD item
|
|
|
init(x, y, val)
|
|
|
reset()
reset the item to the default value
|
|
|
set(value)
set the item value to the specified one
|
|
|
update(value)
update the item value
|
Class Detail
me.HUD_Item(x, y, val)
Item skeleton for HUD element
// create a "score object" that will use a Bitmap font
// to display the score value
ScoreObject = 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("font16px", 16);
},
// draw function
draw : function (context, x, y)
{
this.font.draw (context, this.value, this.pos.x +x, this.pos.y +y);
}
});
// add a default HUD to the game mngr (with no background)
me.game.addHUD(0,0,480,100);
// add the "score" HUD item
me.game.HUD.addItem("score", new ScoreObject(470,10));
- Parameters:
- {int} x
- x position (relative to the HUD position)
- {int} y
- y position (relative to the HUD position)
- {int} val Optional, Default: "0"
- default value
Field Detail
{me.Vector2d}
pos
position of the item
{Int}
value
value of the item
Method Detail
draw(context, x, y)
draw the HUD item
- Parameters:
- {Context2D} context
- 2D context
- {x} x
- {y} y
init(x, y, val)
- Parameters:
- x
- y
- val
reset()
reset the item to the default value
set(value)
set the item value to the specified one
- Parameters:
- value
update(value)
update the item value
- Parameters:
- {int} value
- add the specified value