Cocos Creator API

0.7.1

Cocos Creator is a highly customizable game development tool that utilizes the power of cocos2d-x.

eventManager

Module: cc

cc.eventManager is a singleton object which manages event listener subscriptions and event dispatching.

The EventListener list is managed in such way so that event listeners can be added and removed
while events are being dispatched.

Methods

pauseTarget
(
  • node
  • [recursive =false]
)

Pauses all listeners which are associated the specified target.

name type description
node Node
recursive optional Boolean false

resumeTarget
(
  • node
  • [recursive =false]
)

Resumes all listeners which are associated the specified target.

name type description
node Node
recursive optional Boolean false

addListener
(
  • listener
  • nodeOrPriority
)
EventListener

Adds a event listener for a specified event.
if the parameter "nodeOrPriority" is a node, it means to add a event listener for a specified event with the priority of scene graph.
if the parameter "nodeOrPriority" is a Number, it means to add a event listener for a specified event with the fixed priority.

name type description
listener EventListener | Object

The listener of a specified event or a object of some event parameters.

nodeOrPriority Node | Number

The priority of the listener is based on the draw order of this node or fixedPriority The fixed priority of the listener.

returns:

type: EventListener

Return the listener. Needed in order to remove the event from the dispatcher.

addCustomListener
(
  • eventName
  • callback
)
EventListener

Adds a Custom event listener. It will use a fixed priority of 1.

name type description
eventName String
callback Function

returns:

type: EventListener

the generated event. Needed in order to remove the event from the dispatcher

removeListener
(
  • listener
)

Remove a listener.

name type description
listener EventListener

an event listener or a registered node target

removeListeners
(
  • listenerType
  • [recursive =false]
)

Removes all listeners with the same event listener type or removes all listeners of a node

name type description
listenerType Number | Node

listenerType or a node

recursive optional Boolean false

removeCustomListeners
(
  • customEventName
)

Removes all custom listeners with the same event name

name type description
customEventName String

removeAllListeners ( )

Removes all listeners

setPriority
(
  • listener
  • fixedPriority
)

Sets listener's priority with fixed value.

name type description
listener EventListener
fixedPriority Number

setEnabled
(
  • enabled
)

Whether to enable dispatching events

name type description
enabled Boolean

isEnabled ( ) Boolean

Checks whether dispatching events is enabled

returns:

type: Boolean

dispatchEvent
(
  • event
)

Dispatches the event, also removes all EventListeners marked for deletion from the event dispatcher list.

name type description
event Event

dispatchCustomEvent
(
  • eventName
  • optionalUserData
)

Dispatches a Custom Event with a event name an optional user data

name type description
eventName String
optionalUserData

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index