API Docs for: 1.4.0
Show:

Kiwi.HUD.Widget.IconBar Class

Module: Widget
Parent Module: HUD

The IconBar used to display a series of icons which represent a number of 'something' the user may have. Example: If you had a shooter style game you might want to display the amount of 'ammo' left in the gun using a series of bullet icons. You could then use this IconBar to display that series. The amount is based of a counter components current value, so you can set a maximum and minimum number of images to be displayed.

Constructor

Kiwi.HUD.Widget.IconBar

(
  • game
  • atlas
  • current
  • max
  • x
  • y
)
Kiwi.HUD.Widget.IconBar

Parameters:

  • game Kiwi.Game

    The game that this icon bar belongs to.

  • atlas Kiwi.Textures.TextureAtlas

    The texture atlas that the icons will have.

  • current Number

    The current amount of icons in the bar.

  • max Number

    The maximum number of icons.

  • x Number

    The x coordinates of the first icon.

  • y Number

    The y coordinates of the last icon.

Methods

_addIcon

() private

Creates a new Icon and adds it to this IconBar.

_changeSize

() private

Gets called when the range has updated and then it updates the size of the bar.

_removeIcon

(
  • icon
)
private

Removes a Icon from the container.

Parameters:

destroy

() public

objType

() String public

Inherited from Kiwi.HUD.HUDWidget but overwritten in src\hud\widgets\IconBar.ts:45

The type of object that this is.

Returns:

String:

"IconBarWidget"

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.

_horizontal

Boolean private

Knowledge of whether the icons should be horizontal or vertical

Default: true

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

_x

Number private

The x coordinate of the widget

_y

Number private

The y coordinate of the widget

atlas

Kiwi.Textures.TextureAtlas public

The texture atlas that each Icon inside the IconBar will use.

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

Holds the counter component.

game

Kiwi.Game public

The game that this HUDWidget belongs to.

height

Number private

The height of a single Icon in the bar. This is based on the height of the first cell in the atlas.

horizontal

Boolean public

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

Default: true

horizontalOrigin

String public

Inherited from Kiwi.HUD.HUDWidget but overwritten in src\hud\widgets\IconBar.ts:213

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.

iconGap

Number public

The amount of spacing you want between each icon in the bar. Defaults to 0.

Default: 0

icons

Array private

An array of all of the icons on the screen. Each item in the array is of the type Kiwi.HUD.Widget.Icon

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

Defined in src\hud\widgets\IconBar.ts:245

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'

vertical

Boolean public

Inherited from Kiwi.HUD.HUDWidget but overwritten in src\hud\widgets\IconBar.ts:197

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

Default: false

width

Number private

The width of a single Icon in the bar. This is based on the width of the first cell in the atlas.

x

Number public

Get the x coordinate of the widget

y

Number public

Get the y coordinate of the widget