Kiwi.HUD.Widget.Icon Class
Used to display a cell from a TextureAtlas in the HUD. This could be used for portraits of the character, e.t.c. You can change the current cell that is being used in the TextureAtlas by modifing the cellIndex property.
Constructor
Kiwi.HUD.Widget.Icon
-
game
-
atlas
-
x
-
y
Parameters:
-
game
Kiwi.GameThe game that this icon belongs to.
-
atlas
Kiwi.Textures.TextureAtlasThe image that you would like displayed.
-
x
NumberThe coordinate of the icon on the x-axis.
-
y
NumberThe coordinate of the icon on the y-axis.
Returns:
Item Index
Methods
_applyCSS
()
protected
Applys the css to the HTMLElement that is to be affected.
_removeCSS
()
protected
Removes the CSS from the Icon. This can happen when setting/removing a template and is public to allow for overriding from subclasses.
destroy
()
public
objType
()
String
public
Returns the type of object that this is.
Returns:
"HUDWidget"
removeTemplate
()
public
Used to remove any the template HTML from this HUDWidget.
setTemplate
-
main
-
icon
This method is used to remove existing DOM elements and place them inside a HUDWidget's container element. Useful so that when making HUD Widgets the developer can style HUDWidgets without having to create/write to much javascript. Currently not supported.
Parameters:
-
main
Stringmain - ID of an HTMLElement. This element should contain all of the elements you would like to place inside the HUDWidget.
-
icon
Stringicon - ID of an HTMLElement that resides inside of the main param. This is the element that the HUDWidget can use to populate with information. E.g. Your score, health remaining, the icon, e.t.c.
update
()
public
The game update loop.
Properties
_cellIndex
Number
private
The cell inside the texture atlas that this icon is using
Default: 0
_device
_device
protected
The type of device that this game is being targeted at. Same as the deviceTargetOption on the game class. Used to detirmine how the HUD is to be managed behind the scenes. This is mainly indented for INTERNAL Kiwi use only and is public so that sub classes can have a reference to it.
_horizontalOrigin
String
protected
Contains the current CSS style that will used for the x position.
Should either be LEFT
or RIGHT
but these values are not checked upon assignment.
Default: 'left'
_manager
Kiwi.HUD.HUDManager
protected
The HUDManager that this widget 'belongs' to. This is mainly indented for INTERNAL Kiwi use only and is public so that sub classes can have a reference to it.
_tempContainer
HTMLElement
private
The container element for the template Currently doesn't have that great support.
_tempParent
HTMLElement
private
The parent of the template container. So that when removing a template we can place it in the right spot Currently doesn't have that great support.
_verticalOrigin
String
protected
Contains the current CSS style that will used for the y position.
Should either be TOP
or BOTTOM
but these values are not checked upon assignment.
Default: 'top'
_x
Number
private
The x coordinate of the widget
_y
Number
private
The y coordinate of the widget
cellIndex
Number
public
Gets the cell index that is being used.
Default: 0
class
String
public
The class name/s that the container element that this HUDWidget current has.
height
Number
public
Returns the height of the cell that is being used.
horizontalOrigin
String
public
Contains the current CSS style that will used for the x position.
Should either be LEFT
or RIGHT
but these values are not checked upon assignment.
Default: 'left'
icon
HTMLElement
public
Is a reference to the element that the icon CSS is being applyed to.
style
Any
public
A quick way to reference the style object that exists on the container element of this widget.
tempElement
HTMLElement
public
When a template has been set, this property will have a reference to the HTMLElement we can place the HUDWidget information into. Currently doesn't have that great support.
The HTMLDivElement that this widget is using.
vertical
String
public
Contains the current CSS style that will used for the y position.
Should either be TOP
or BOTTOM
but these values are not checked upon assignment.
Default: 'top'
width
Number
public
Returns the width of the cell that is being used.
x
Number
public
Get the x coordinate of the widget
y
Number
public
Get the y coordinate of the widget