Event Class
Module: cc
Base class of all kinds of events.
Index
Properties
typeStringThe name of the event (case-sensitive), e.g.bubblesBooleanIndicate whether the event bubbles up through the tree or not.targetObjectA reference to the target to which the event was originally dispatched.currentTargetObjectA reference to the currently registered target for the event.eventPhaseNumberIndicates which phase of the event flow is currently being evaluated.NO_TYPEStringCode for event without type.TOUCHStringThe type code of Touch event.MOUSEStringThe type code of Mouse event.KEYBOARDStringThe type code of Keyboard event.ACCELERATIONStringThe type code of Acceleration event.NONENumberEvents not currently dispatched are in this phaseCAPTURING_PHASENumberThe capturing phase comprises the journey from the root to the last node before the event target's nodeAT_TARGETNumberThe target phase comprises only the event target nodeBUBBLING_PHASENumberThe bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy
Methods
constructorunuseReset the event for being stored in the object pool.reuseReuse the event for being used again by the object pool.stopPropagationStops propagation for current event.stopPropagationImmediateStops propagation for current event immediately,...isStoppedChecks whether the event has been stopped.getCurrentTargetnote: It only be available when the event listener is associated with node.getTypeGets the event type.
Details
Properties
type
The name of the event (case-sensitive), e.g. "click", "fire", or "submit".
| meta | description |
|---|---|
| Type | String |
| Defined in | cocos2d/core/event/event.js:44 |
bubbles
Indicate whether the event bubbles up through the tree or not.
| meta | description |
|---|---|
| Type | Boolean |
| Defined in | cocos2d/core/event/event.js:52 |
target
A reference to the target to which the event was originally dispatched.
| meta | description |
|---|---|
| Type | Object |
| Defined in | cocos2d/core/event/event.js:60 |
currentTarget
A reference to the currently registered target for the event.
| meta | description |
|---|---|
| Type | Object |
| Defined in | cocos2d/core/event/event.js:68 |
eventPhase
Indicates which phase of the event flow is currently being evaluated. Returns an integer value represented by 4 constants:
- Event.NONE = 0
- Event.CAPTURING_PHASE = 1
- Event.AT_TARGET = 2
- Event.BUBBLING_PHASE = 3 The phases are explained in the [section 3.1, Event dispatch and DOM event flow] (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification.
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/event/event.js:76 |
NO_TYPE
Code for event without type.
| meta | description |
|---|---|
| Type | String |
| Defined in | cocos2d/core/event/event.js:193 |
TOUCH
The type code of Touch event.
| meta | description |
|---|---|
| Type | String |
| Defined in | cocos2d/core/event/event.js:202 |
MOUSE
The type code of Mouse event.
| meta | description |
|---|---|
| Type | String |
| Defined in | cocos2d/core/event/event.js:210 |
KEYBOARD
The type code of Keyboard event.
| meta | description |
|---|---|
| Type | String |
| Defined in | cocos2d/core/event/event.js:218 |
ACCELERATION
The type code of Acceleration event.
| meta | description |
|---|---|
| Type | String |
| Defined in | cocos2d/core/event/event.js:226 |
NONE
Events not currently dispatched are in this phase
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/event/event.js:236 |
CAPTURING_PHASE
The capturing phase comprises the journey from the root to the last node before the event target's node see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/event/event.js:244 |
AT_TARGET
The target phase comprises only the event target node see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/event/event.js:254 |
BUBBLING_PHASE
The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/event/event.js:264 |
Methods
constructor
| meta | description |
|---|---|
| Defined in | cocos2d/core/event/event.js:38 |
Parameters
typeString The name of the event (case-sensitive), e.g. "click", "fire", or "submit"bubblesBoolean A boolean indicating whether the event bubbles up through the tree or not
unuse
Reset the event for being stored in the object pool.
| meta | description |
|---|---|
| Returns | String |
| Defined in | cocos2d/core/event/event.js:111 |
reuse
Reuse the event for being used again by the object pool.
| meta | description |
|---|---|
| Returns | String |
| Defined in | cocos2d/core/event/event.js:126 |
stopPropagation
Stops propagation for current event.
| meta | description |
|---|---|
| Defined in | cocos2d/core/event/event.js:137 |
stopPropagationImmediate
Stops propagation for current event immediately, the event won't even be dispatched to the listeners attached in the current target.
| meta | description |
|---|---|
| Defined in | cocos2d/core/event/event.js:146 |
isStopped
Checks whether the event has been stopped.
| meta | description |
|---|---|
| Returns | Boolean |
| Defined in | cocos2d/core/event/event.js:156 |
getCurrentTarget
Gets current target of the event
note: It only be available when the event listener is associated with node.
It returns 0 when the listener is associated with fixed priority.
| meta | description |
|---|---|
| Returns | Node |
| Defined in | cocos2d/core/event/event.js:166 |
getType
Gets the event type.
| meta | description |
|---|---|
| Returns | String |
| Defined in | cocos2d/core/event/event.js:181 |