Class: EventsManager

DKTools.EventsManager

Event manager class

new DKTools.EventsManager ()

Since:
  • 9.0.0

Members

_events Object privatereadonly

_target DKTools.Sprite | DKTools.Window | DKTools.Scene privatereadonly

Methods

_checkEvent (event)Boolean private

Checks the event
Name Type Description
event DKTools.Event | DKTools.Animation Event
Returns:
Type Description
Boolean

_checkEvents () private

Checks the events

_checkEventsContainer (container)Array private

Checks a container with the events and removes the completed events
Name Type Description
container Array Container for the events
Returns:
Type Description
Array Filtered array

addAnimation (animation)DKTools.Animation | null

Adds the animation
Name Type Description
animation DKTools.Animation Animation to add
Version:
  • 6.0.0
Returns:
Type Description
DKTools.Animation | null Added animation or null

addEvent (object)DKTools.Event | DKTools.Animation | null

Adds the event
Name Type Description
object DKTools.Event | DKTools.Animation | Object Event or object with parameters for the event
Name Type Description
id Number | String | * optional ID of the event
type String optional Type of the event
repeatTime Number optional Time of one repeat
repeats Number optional Amount of repeats
remainingPauseTime Number optional Remaining time of pause
onStart function optional Handler of the event start
onUpdate function optional Handler of the event update
onPause function optional Handler of the event pause
onReset function optional Handler of the event reset
onRepeat function optional Handler of the event repeat
onSuccess function optional Handler of the event success
onFail function optional Handler of the event fail
Version:
  • 6.0.0
Returns:
Type Description
DKTools.Event | DKTools.Animation | null Added event or null

addEventToContainer (event)DKTools.Event | DKTools.Animation | null

Adds the event to container
Name Type Description
event DKTools.Event | DKTools.Animation Event
Version:
  • 6.0.0
Returns:
Type Description
DKTools.Event | DKTools.Animation | null Added event or null

addOneTimeEvent (object)DKTools.Event

Adds the one time event
Name Type Description
object DKTools.Event | Object Event or object with parameters for the event
Name Type Description
id Number | String | * optional ID of the event
type String optional Type of the event
remainingPauseTime Number optional Remaining time of pause
onStart function optional Handler of the event start
onUpdate function optional Handler of the event update
onPause function optional Handler of the event pause
onReset function optional Handler of the event reset
onRepeat function optional Handler of the event repeat
onSuccess function optional Handler of the event success
onFail function optional Handler of the event fail
Version:
  • 6.0.0
Returns:
Type Description
DKTools.Event Added event

clearEvents (object)

Clears the events
Name Type Description
object Array.<String> | String optional Array with event types or event type

createEventsContainer (type)Array

Creates a container for the events
Name Type Description
type String Type of the events
Version:
  • 9.0.0
Returns:
Type Description
Array Container for the events

failEvents (type, data)

Fails the events
Name Type Description
type String Type of the events
data * optional Data
Version:
  • 10.0.5

findAnimation (id, type)DKTools.Animation | undefined

Returns the found animation
Name Type Description
id Number | String | * ID of the animation
type String optional Type of the animation
Since:
  • 6.0.0
Returns:
Type Description
DKTools.Animation | undefined Animation

findEvent (id, type)DKTools.Event | DKTools.Animation | undefined

Returns the found event
Name Type Description
id Number | String | * ID of the event
type String optional Type of the event
Since:
  • 6.0.0
Returns:
Type Description
DKTools.Event | DKTools.Animation | undefined Event

finishEvents (type, forcedSuccess, data)

Finishes the events
Name Type Default Description
type String Type of the events
forcedSuccess Boolean false optional Forced success for the finish of the events
data * optional Data
Version:
  • 10.0.5

getAnimations (type)Array

Returns an array with the all animations or animations of a certain type
Name Type Description
type String optional Type of animation
Returns:
Type Description
Array Array with the animations

getEventIndex (event)Number

Returns an index of the event in its container
Name Type Description
event DKTools.Event | DKTools.Animation Event
Returns:
Type Description
Number Index of the event in its container

getEvents (type)Array

Returns an array with the all events or events of a certain type
Name Type Description
type String optional Type of the events
Returns:
Type Description
Array Array with the events

getEventsContainerByType (type)Array

Returns a container for the events by event type
Name Type Description
type String Type of the events
Returns:
Type Description
Array Container for the events

hasAnimation (animation)Boolean

Checks for existence of the animation in the object Returns true if the animation exists
Name Type Description
animation DKTools.Animation Animation
Returns:
Type Description
Boolean Animation exists

hasAnimations (type)Boolean

Checks for existence of the animations of a certain type Returns true if the animations exists
Name Type Description
type String optional Type of the animations
Returns:
Type Description
Boolean Animations exists

hasEvent (event)Boolean

Checks for existence of the event in the object Returns true if the event exists
Name Type Description
event DKTools.Event | DKTools.Animation Event
Returns:
Type Description
Boolean Event exists

hasEvents (type)Boolean

Checks for existence of the events of a certain type Returns true if the events exists
Name Type Description
type String optional Type of the events
Returns:
Type Description
Boolean Events exists

initialize (target)

Initializes the event manager
Name Type Description
target DKTools.Sprite | DKTools.Window | DKTools.Scene Target

isEventsPaused (type)Boolean

Checks the events for pause Returns the conjunction of pauses of the events
Name Type Description
type String Type of the events
Returns:
Type Description
Boolean Conjunction of pauses of the events

iterateEventsContainer (type, callback)

Performs a callback function for the events
Name Type Description
type String Type of the events
callback function Event processing function

pauseEvents (type, duration)

Pauses the events
Name Type Default Description
type String Type of the events
duration Number -1 optional Duration of the pause

removeEvent (event)Boolean

Removes the event from a container Returns true if the event was removed
Name Type Description
event DKTools.Event | DKTools.Animation Event
Returns:
Type Description
Boolean Event was removed

resumeEvents (type)

Resumes the events
Name Type Description
type String Type of the events

stopEvents (type, forcedSuccess)

Stops the events
Name Type Default Description
type String Type of the events
forcedSuccess Boolean false optional Forced success for the finish of the events

update ()

Updates the manager

updateEventsContainer (type, data)

Updates the events from container
Name Type Description
type String Type of the events
data * optional Data