API Docs for: 1.2.1
Show:

Kiwi.HUD.HUDWidget Class

Module: HUD
Parent Module: Kiwi

The HUDWidget is an abstract class containing the fundamental properties and methods that every HUDWidget needs to have. This class is designed to be extended from and thus objects should not directly instantiate it.

Constructor

Kiwi.HUD.HUDWidget

(
  • game
  • name
  • x
  • y
)
Kiwi.HUD.HUDWidget

Parameters:

  • game Kiwi.Game

    The game that this HUDWidget belongs to.

  • name String

    Name of the type of HUDWidget.

  • x Number

    The coordinates of this HUDWidget on the x-axis.

  • y Number

    The coordinates of this HUDWidget on the y-axis.

Returns:

Methods

destroy

() public

objType

() String public

Returns the type of object that this is.

Returns:

String:

"HUDWidget"

removeTemplate

() public

Used to remove any the template HTML from this HUDWidget. Currently doesn't have that great support.

setTemplate

(
  • main
  • [element]
)
public

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.

Can be used by itself but maybe more useful if you customise it to suit your own needs. Currently doesn't have that great support.

Parameters:

  • main String

    main - ID of an HTMLElement. This element should contain all of the elements you would like to place inside the HUDWidget.

  • [element] String optional

    element - 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

_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.

_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.

_x

Number private

The x coordinate of the widget

_y

Number private

The y coordinate of the widget

HTMLDivElement public

The HTMLDivElement that this widget is using.

String public

The name of the widget which is used to identify the type of widget.

class

String public

The class name/s that the container element that this HUDWidget current has.

components

Kiwi.ComponentManager public

The list of components that the HUDWidget use's.

game

Kiwi.Game public

The game that this HUDWidget belongs to.

onCoordsUpdate

Kiwi.Signal public

Called when the coordinates of the HUD Widget updates.

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.

x

Number public

Get the x coordinate of the widget

y

Number public

Get the y coordinate of the widget