API Docs for: 1.4.0
Show:

Kiwi.HUD.HUDComponents.Time Class

Extends Kiwi.Component
Module: HUDComponents
Parent Module: HUD

A Component to manage and display a Time in a particular format. The Time Component creates a new clock on the Time Manager and it uses that clock to keep track of the time. When you create a new Time Component you can specify a format that you want the time to display in, which is a string based on keywords. Current supported keywords for the format are: 's' = 'seconds' 'm' = 'minutes' 'ms' = milliseconds' 'ss' = 'seconds with leading zero' 'mm' = 'minutes with leading zero'

Constructor

Kiwi.HUD.HUDComponents.Time

(
  • owner
  • [format='']
)
Kiwi.HUD.HUDComponents.Counter

Parameters:

  • owner Any

    The object that this component belongs to.

  • [format=''] String optional

    The format that the time is to be displayed in. Leave blank for the default time.

Methods

addTime

(
  • milli
  • [sec=0]
  • [minutes=0]
)
public

Increases the current time by the amount passed.

Parameters:

  • milli Number

    The number of milliseconds.

  • [sec=0] Number optional

    The number of seconds to add.

  • [minutes=0] Number optional

    The number of minutes to add.

destroy

() public

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

objType

() String public

Inherited from Kiwi.Component but overwritten in src\hud\components\Time.ts:39

The type of object that this is.

Returns:

String:

'TimeComponent'

pause

() public

Pauses the clock where is stands. Calls the pause method on the clock.

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.

removeTime

(
  • milli
  • [sec=0]
  • [minutes=0]
)
public

Decreases the current time by the amount passed.

Parameters:

  • milli Number

    The number of milliseconds.

  • [sec=0] Number optional

    The number of seconds to add.

  • [minutes=0] Number optional

    The number of minutes to add.

resume

() public

Resumes the clock and thus the time.

setTime

(
  • milli
  • [sec=0]
  • [minutes=0]
)
public

Sets the current time of the timer.

Parameters:

  • milli Number

    The number of milliseconds.

  • [sec=0] Number optional

    The number of seconds to add.

  • [minutes=0] Number optional

    The number of minutes to add.

start

() public

Starts the clock and thus the time.

stop

() public

Stops the clock and thus the time. Calls the stop method of the clock.

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.

updateTime

() public

Returns a string with the current time that this component is upto in the format that was passed.

Returns:

string

Properties

_currentTime

Number private

The current time in seconds.

_displayString

String private

Used during the formatting stage of displaying the time.

_format

String private

The format that they want the time to be displayed.

_speed

Number private

The speed at which the time will increase/decrease by. Modify this property to make the time count down slower/faster.

Default: 1

_timeBefore

Number private

The last time that the timer update. Used to calculate the time delta.

active

Boolean public

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

Default: true

clock

Kiwi.Time.Clock private

The clock that this component creates and uses to manage the current time.

countDown

Boolean public

If the clock should 'count down' instead of up.

Default: false

currentTime

Number public

The current time in seconds. This is READ ONLY.

dirty

Boolean deprecated public

The state of this component.

Default: false

format

String public

The format that you want the time to be displayed in.

game

Kiwi.Game public

The game this Component belongs to

isRunning

Boolean public

Indicates whether or not the clock is currently running or not, and thus whether or not the time is playing or not.

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.