API Docs for: 1.4.0
Show:

Kiwi.HUD.Widget.Bar Class

Module: Widget
Parent Module: HUD

Used for displaying of information in a bar like of format. Example: Amount of health remaining for a character. This class creates a 'innerbar' div inside of its main container which you can apply styles to. You can control the minimum/maximum and current values of the bar through the Counter widget.

Constructor

Kiwi.HUD.Widget.Bar

(
  • game
  • current
  • max
  • x
  • y
  • [width=120]
  • [height=20]
  • [color='#000']
)
Kiwi.HUD.Widget.Bar

Parameters:

  • game Kiwi.Game

    The game that this bar belongs to.

  • current Number

    The current value of the bar.

  • max Number

    The maximum value that there can be.

  • x Number

    The coordinates of this widget on the x-axis.

  • y Number

    The cooridnates of this widget on the y-axis.

  • [width=120] Number optional

    The width of the widget. Defaults to 120.

  • [height=20] Number optional

    The height of the widget. Defaults to 20.

  • [color='#000'] String optional

    The default color of the inner bar. Defaults to #000 (black).

Methods

destroy

() public

objType

() String public

Inherited from Kiwi.HUD.HUDWidget but overwritten in src\hud\widgets\Bar.ts:56

Returns the type of object that this is.

Returns:

String:

"BarWidget"

removeTemplate

() public

Inherited from Kiwi.HUD.HUDWidget but overwritten in src\hud\widgets\Bar.ts:196

Used to remove any the template HTML from this HUDWidget. Current not supported.

setTemplate

(
  • main
  • innerbar
)
public

Inherited from Kiwi.HUD.HUDWidget but overwritten in src\hud\widgets\Bar.ts:175

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 String

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

  • innerbar String

    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.

updateCSS

() public

Will be called when the range has been updated and thus you will want to preform the render of the bar here. This should be overriden by subclasses so that you have your own custom bars.

Properties

_bar

HTMLElement private

A reference to the HTMLElement that this class always generates.

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

_height

Number private

The height of the container

_horizontal

Boolean private

Knows if this bar is ment to be horizontal or veritical

_horizontalOrigin

String protected

Inherited from Kiwi.HUD.HUDWidget: src\hud\HUDWidget.ts:296

Available since 1.3.0

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

Inherited from Kiwi.HUD.HUDWidget: src\hud\HUDWidget.ts:333

Available since 1.3.0

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 private

The width of the container

_x

Number private

The x coordinate of the widget

_y

Number private

The y coordinate of the widget

bar

HTMLElement public

The HTMLElement that is currently being used as the 'bar'.

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.

counter

Kiwi.HUD.HUDComponents.Counter public

The counter component.

game

Kiwi.Game public

The game that this HUDWidget belongs to.

height

Number public

The height of the container

horizontal

Boolean public

Used to set the bar to be horizontal or vertical by passing a boolean.

horizontalOrigin

String public

Inherited from Kiwi.HUD.HUDWidget: src\hud\HUDWidget.ts:308

Available since 1.3.0

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'

HTMLDivElement public

Inherited from Kiwi.HUD.HUDWidget but overwritten in src\hud\HUDWidget.ts:170

The HTMLDivElement that this widget is using.

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.

vertical

String public

Inherited from Kiwi.HUD.HUDWidget: src\hud\HUDWidget.ts:345

Available since 1.3.0

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'

verticle

Boolean public

Used to set the bar to be horizontal or vertical by passing a boolean.

width

Number public

The width of the container

x

Number public

Get the x coordinate of the widget

y

Number public

Get the y coordinate of the widget