Class Clock

The Clock class is the basis on which many other classes throughout the shimi library rely upon to receive frequent and regular updates.

The clock contains a list of references to objects that implement IClockChild. Each time the clock receives an update, it forwards the message to all of its children.

Hierarchy

  • Clock

Constructors

  • Parameters

    • msPerTick: number = 5

      How many milliseconds from one tick to the next.

      Please note that the clock will not necessarily update exactly as often as defined here, but it should be pretty close.

      The default value is 5.

    Returns Clock

Properties

default: Clock = null

If set, then classes implementing the IClockChild interface should automatically add themselves to the default clock.

Accessors

  • get children(): IClockChild[]
  • List of objects that get updated by the clock each update cycle.

    Returns IClockChild[]

  • get msPerTick(): number
  • How many milliseconds from one tick to the next.

    Please note that the clock will not necessarily update exactly as often as defined here, but it should be pretty close.

    Returns number

  • get running(): boolean
  • Returns whether the clock is already running.

    Returns boolean

  • get typeName(): string
  • Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable.

    Returns string

Methods

  • Starts the clock running regular updates. Returns false if the clock was already running, otherwise returns true.

    Returns boolean

  • Stops the clock from running regular updates. Returns false if the clock was already stopped, otherwise returns true.

    Returns boolean

  • Calls the finish() method of all children which meet the passed in filter criteria.

    Parameters

    • filter: ((child: IClockChild) => boolean)

      Accepts a function which takes in an IClockChild, and returns a boolean, signifying whether the passed in IClockChild should be stopped.

    Returns void

  • Updates all active children which belong to the clock, as well removing any that have been stopped.

    You shouldn't really need to call this, once you call start(), this will begin getting called regularly anyway.

    Returns void

Generated using TypeDoc