Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Scheduler

Scheduler is responsible of triggering the scheduled callbacks.
You should not use NSTimer. Instead use this class.

There are 2 different types of callbacks (selectors):
- update callback: the 'update' callback will be called every frame. You can customize the priority.
- custom callback: A custom callback will be called every frame, or with a custom interval of time

The 'custom selectors' should be avoided when possible. It is faster,
and consumes less memory to use the 'update callback'. *

Hierarchy

  • System
    • Scheduler

Implements

Index

Constructors

constructor

Properties

Private _arrayForTimers

_arrayForTimers: any

Private _currentTarget

_currentTarget: any

Private _currentTargetSalvaged

_currentTargetSalvaged: boolean

Protected _executeInEditMode

_executeInEditMode: boolean = false

Private _hashForTimers

_hashForTimers: any

Private _hashForUpdates

_hashForUpdates: any

Protected _id

_id: string = ""

Protected _priority

_priority: number = 0

Private _timeScale

_timeScale: number

Private _updateHashLocked

_updateHashLocked: boolean

Private _updates0List

_updates0List: any[]

Private _updatesNegList

_updatesNegList: any[]

Private _updatesPosList

_updatesPosList: any[]

Static ID

ID: string = "scheduler"

Static PRIORITY_NON_SYSTEM

PRIORITY_NON_SYSTEM: number = Scheduler.PRIORITY_SYSTEM + 1

Minimum priority level for user scheduling.

Static PRIORITY_SYSTEM

PRIORITY_SYSTEM: number = 1 << 31

Priority level reserved for system services.

Accessors

id

  • get id(): string
  • set id(id: string): void

priority

  • get priority(): number
  • set priority(value: number): void

Methods

Private appendIn

  • appendIn(ppList: any, listElement: any): void

Private priorityIn

  • priorityIn(ppList: any, listElement: any, priority: any): void

Private removeHashElement

  • removeHashElement(element: any): void

Private removeUpdateFromHash

  • removeUpdateFromHash(entry: any): void

getTimeScale

  • getTimeScale(): number

init

  • init(): void

isScheduled

  • isScheduled(callback: any, target: ISchedulable): undefined | false | true
  • Checks whether a callback for a given target is scheduled.

    Parameters

    • callback: any

      The callback to check.

    • target: ISchedulable

      The target of the callback.

    Returns undefined | false | true

    True if the specified callback is invoked, false if not.

isTargetPaused

pauseAllTargets

  • pauseAllTargets(): any
  • Pause all selectors from all targets.
    You should NEVER call this method, unless you know what you are doing.

    Returns any

pauseAllTargetsWithMinPriority

  • pauseAllTargetsWithMinPriority(minPriority: number): any
  • Pause all selectors from all targets with a minimum priority.
    You should only call this with kCCPriorityNonSystemMin or higher.

    Parameters

    • minPriority: number

    Returns any

pauseTarget

  • Pauses the target.
    All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.
    If the target is not present, nothing happens.

    Parameters

    Returns void

postUpdate

  • postUpdate(dt: number): void
  • Post update function of the system, it will be invoked after all components late update phase and before the rendering process.

    Parameters

    • dt: number

      Delta time after the last frame

    Returns void

resumeTarget

  • Resumes the target.
    The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.
    If the target is not present, nothing happens.

    Parameters

    Returns void

resumeTargets

  • resumeTargets(targetsToResume: any): void
  • Resume selectors on a set of targets.
    This can be useful for undoing a call to pauseAllCallbacks.

    Parameters

    • targetsToResume: any

    Returns void

schedule

  • schedule(callback: Function, target: ISchedulable, interval: number, repeat?: undefined | number, delay?: undefined | number, paused?: undefined | false | true): void
  • The scheduled method will be called every 'interval' seconds.
    If paused is YES, then it won't be called until it is resumed.
    If 'interval' is 0, it will be called every frame, but if so, it recommended to use 'scheduleUpdateForTarget:' instead.
    If the callback function is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
    repeat let the action be repeated repeat + 1 times, use `macro.REPEAT_FOREVER` to let the action run continuously
    delay is the amount of time the action will wait before it'll start

    Parameters

    • callback: Function
    • target: ISchedulable
    • interval: number
    • Optional repeat: undefined | number
    • Optional delay: undefined | number
    • Optional paused: undefined | false | true

    Returns void

scheduleUpdate

  • scheduleUpdate(target: ISchedulable, priority: Number, paused: Boolean): void
  • Schedules the update callback for a given target, During every frame after schedule started, the "update" function of target will be invoked.

    Parameters

    Returns void

setTimeScale

  • setTimeScale(timeScale: any): void
  • Modifies the time of all scheduled callbacks.
    You can use this property to create a 'slow motion' or 'fast forward' effect.
    Default is 1.0. To create a 'slow motion' effect, use values below 1.0.
    To create a 'fast forward' effect, use values higher than 1.0.
    Note:It will affect EVERY scheduled selector / action.

    Parameters

    • timeScale: any

    Returns void

unschedule

  • Unschedules a callback for a callback and a given target.
    If you want to unschedule the "update", use unscheduleUpdate()

    Parameters

    • callback: any

      The callback to be unscheduled

    • target: ISchedulable

      The target bound to the callback.

    Returns void

unscheduleAll

  • unscheduleAll(): void
  • Unschedules all scheduled callbacks from all targets including the system callbacks.
    You should NEVER call this method, unless you know what you are doing.

    Returns void

unscheduleAllForTarget

  • unscheduleAllForTarget(target: any): void
  • Unschedules all scheduled callbacks for a given target. This also includes the "update" callback.

    Parameters

    • target: any

      The target to be unscheduled.

    Returns void

unscheduleAllWithMinPriority

  • unscheduleAllWithMinPriority(minPriority: number): void
  • Unschedules all callbacks from all targets with a minimum priority.
    You should only call this with PRIORITY_NON_SYSTEM_MIN or higher.

    Parameters

    • minPriority: number

      The minimum priority of selector to be unscheduled. Which means, all selectors which priority is higher than minPriority will be unscheduled.

    Returns void

unscheduleUpdate

update

  • update(dt: any): void
  • 'update' the scheduler. (You should NEVER call this method, unless you know what you are doing.)

    Parameters

    • dt: any

      delta time

    Returns void

Static enableForTarget

  • This method should be called for any target which needs to schedule tasks, and this method should be called before any scheduler API usage. This method will add a id property if it doesn't exist.

    Parameters

    Returns void

Static sortByPriority

  • sortByPriority(a: System, b: System): 1 | 0 | -1

Generated using TypeDoc