API Docs for: 1.4.0
Show:

Kiwi.HUD.HUDComponents.Counter Class

Extends Kiwi.Component
Module: HUDComponents
Parent Module: HUD

The Counter component handles a incrementation/decrementation of a singular numeric value. You can also specifiy maximum/minimum values that the numeric value has be within but by default there is no max/min.

Constructor

Kiwi.HUD.HUDComponents.Counter

(
  • owner
  • current
  • [max=null]
  • [min=null]
)
Kiwi.HUD.HUDComponents.Counter

Parameters:

  • owner Any

    The object that this Component belongs to.

  • current Number

    The current value.

  • [max=null] Number optional

    The maximum value it can be. Default is null which means no maximum.

  • [min=null] Number optional

    The minimum value that the current can be. Default is null which means no minium.

Methods

currentPercent

() Number public

Returns:

Number:

decrease

(
  • [val=1]
)
Number public

Decreases the current value by the amount past. If the new amount would be less than the minimun it goes to the min instead.

Parameters:

  • [val=1] Number optional

    The amount that you want to decrease the current value by. Default is 1.

Returns:

Number:

destroy

() public

Destroys this component and all of the properties that exist on it.

increase

(
  • [val=1]
)
Number public

Increases the current value by the amount past. If the new amount would be greater than the maximum it goes to the max instead.

Parameters:

  • [val=1] Number optional

    The amount that you want to increase the current value by. Default is 1.

Returns:

Number:

objType

() String public

Inherited from Kiwi.Component but overwritten in src\hud\components\Counter.ts:38

The type of object that this is.

Returns:

String:

'CounterComponent'

postUpdate

() public

Components can postUpdate, that is run an update after the parent has updated. This is to be overriden by subclasses.

preUpdate

() public

Components can preUpdate, that is update before the parent updates. This is to be overriden by subclasses.

update

() public

If the component is being added to a State rather than a Game Object then over-ride its update method to perform required tasks.

Properties

_current

Number private

The current value of the range.

_max

Number private

The maximum value that of the range.

_min

Number private

The minimum value that of the range.

Default: 0

active

Boolean public

An active Component is one that has its update method called by its parent.

Default: true

current

Number public

Set allows setting of the current value that the range can be in. The current value will only change if it is within the maximum/minimum values. Get returns the current value.

dirty

Boolean deprecated public

The state of this component.

Default: false

game

Kiwi.Game public

The game this Component belongs to

max

Number public

Set allows setting of the maximum value that the range can be in. Get returns the maximum value.

min

Number public

Set allows setting of the minimum value that the range can be in. Get returns the minimum value.

name

String public

The name of this component.

owner

Object public

The object that owns this entity

state

Kiwi.State public

Inherited from Kiwi.Component: src\core\Component.ts:56

Available since 1.3.1

The state which this component's owner belongs to.

updated

Kiwi.Signal public

A Kiwi.Signal that dispatches an event when a value has changed.