Class me.HUD_Object
Extends
Object.
Defined in: <build/melonJS-0.9.3.js>.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
HUD Object
There is no constructor function for me.HUD_Object Object instance is accessible through me.game.HUD if previously initialized using me.game.addHUD(. |
| Method Attributes | Method Name and Description |
|---|---|
|
addItem(name, item)
add an item to the me.game.HUD Object
|
|
|
getItemValue(name)
return the value of the specified item
|
|
|
removeItem(name)
remove an item from the me.game.HUD Object
|
|
|
reset(name)
reset the specified item to default value
|
|
|
setItemValue(name, val)
set the value of the specified item
|
|
|
updateItemValue(name, val)
update (add) the value of the specified item
|
Class Detail
me.HUD_Object()
HUD Object
There is no constructor function for me.HUD_Object
Object instance is accessible through me.game.HUD if previously initialized using me.game.addHUD(...);
There is no constructor function for me.HUD_Object
Object instance is accessible through me.game.HUD if previously initialized using me.game.addHUD(...);
// 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));
Method Detail
addItem(name, item)
add an item to the me.game.HUD Object
// add a "score" HUD item
me.game.HUD.addItem("score", new ScoreObject(470,10));
- Parameters:
- {String} name
- name of the item
- {me.HUD_Item} item
- HUD Item to be added
{int}
getItemValue(name)
return the value of the specified item
// return the value of the "score" item
score = me.game.HUD.getItemValue("score");
- Parameters:
- {String} name
- name of the item
- Returns:
- {int}
removeItem(name)
remove an item from the me.game.HUD Object
// remove the "score" HUD item
me.game.HUD.removeItem("score");
- Parameters:
- {String} name
- name of the item
reset(name)
reset the specified item to default value
- Parameters:
- {String} name Optional, Default: "all"
- name of the item
setItemValue(name, val)
set the value of the specified item
// set the "score" item value to 100
me.game.HUD.setItemValue("score", 100);
- Parameters:
- {String} name
- name of the item
- {int} val
- value to be set
updateItemValue(name, val)
update (add) the value of the specified item
// add 10 to the current "score" item value
me.game.HUD.setItemValue("score", 10);
- Parameters:
- {String} name
- name of the item
- {int} val
- value to be set