jetlag2d
    Preparing search index...

    Class Counter

    Counter is a flexible, string-keyed registry of numeric values that can be used for anything a game needs to track.

    Index
    • Add to (or, with a negative amount, subtract from) a counter's value

      Parameters

      • key: string

        The counter to update

      • amount: number

        How much to add (negative to subtract)

      Returns void

    • Read a counter's current value

      Parameters

      • key: string

        The counter to read

      Returns number

      The counter's value, or 0 if it has never been set

    • Overwrite a counter's value

      Parameters

      • key: string

        The counter to set

      • value: number

        The new value

      Returns void