Event.EventTouch Class
Extends Event
Module: cc
The touch event
Index
Properties
- touch- TouchThe current touch object
- type- StringThe name of the event (case-sensitive), e.g.
- bubbles- BooleanIndicate whether the event bubbles up through the tree or not.
- target- ObjectA reference to the target to which the event was originally dispatched.
- currentTarget- ObjectA reference to the currently registered target for the event.
- eventPhase- NumberIndicates which phase of the event flow is currently being evaluated.
Methods
- constructor
- getEventCodeReturns event code.
- getTouchesReturns touches of event.
- setLocationSets touch location.
- getLocationReturns touch location.
- getLocationInViewReturns the current touch location in screen coordinates.
- getPreviousLocationReturns the previous touch location.
- getStartLocationReturns the start touch location.
- getIDReturns the id of cc.Touch.
- getDeltaReturns the delta distance from the previous location to current location.
- getDeltaXReturns the X axis delta distance from the previous location to current location.
- getDeltaYReturns the Y axis delta distance from the previous location to current location.
- getLocationXReturns location X axis data.
- getLocationYReturns location Y axis data.
- unuseReset 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
touch
The current touch object
| meta | description | 
|---|---|
| Type | Touch | 
| Defined in | cocos2d/core/event-manager/CCEvent.js:337 | 
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 | 
Methods
constructor
| meta | description | 
|---|---|
| Defined in | cocos2d/core/event-manager/CCEvent.js:328 | 
Parameters
- touchArrArray The array of the touches
- bubblesBoolean A boolean indicating whether the event bubbles up through the tree or not
getEventCode
Returns event code.
| meta | description | 
|---|---|
| Returns | Number | 
| Defined in | cocos2d/core/event-manager/CCEvent.js:352 | 
getTouches
Returns touches of event.
| meta | description | 
|---|---|
| Returns | Array | 
| Defined in | cocos2d/core/event-manager/CCEvent.js:362 | 
setLocation
Sets touch location.
| meta | description | 
|---|---|
| Defined in | cocos2d/core/event-manager/CCEvent.js:380 | 
Parameters
getLocation
Returns touch location.
| meta | description | 
|---|---|
| Returns | Vec2 | 
| Defined in | cocos2d/core/event-manager/CCEvent.js:391 | 
getLocationInView
Returns the current touch location in screen coordinates.
| meta | description | 
|---|---|
| Returns | Vec2 | 
| Defined in | cocos2d/core/event-manager/CCEvent.js:401 | 
getPreviousLocation
Returns the previous touch location.
| meta | description | 
|---|---|
| Returns | Vec2 | 
| Defined in | cocos2d/core/event-manager/CCEvent.js:411 | 
getStartLocation
Returns the start touch location.
| meta | description | 
|---|---|
| Returns | Vec2 | 
| Defined in | cocos2d/core/event-manager/CCEvent.js:421 | 
getID
Returns the id of cc.Touch.
| meta | description | 
|---|---|
| Returns | Number | 
| Defined in | cocos2d/core/event-manager/CCEvent.js:431 | 
getDelta
Returns the delta distance from the previous location to current location.
| meta | description | 
|---|---|
| Returns | Vec2 | 
| Defined in | cocos2d/core/event-manager/CCEvent.js:441 | 
getDeltaX
Returns the X axis delta distance from the previous location to current location.
| meta | description | 
|---|---|
| Returns | Number | 
| Defined in | cocos2d/core/event-manager/CCEvent.js:451 | 
getDeltaY
Returns the Y axis delta distance from the previous location to current location.
| meta | description | 
|---|---|
| Returns | Number | 
| Defined in | cocos2d/core/event-manager/CCEvent.js:461 | 
getLocationX
Returns location X axis data.
| meta | description | 
|---|---|
| Returns | Number | 
| Defined in | cocos2d/core/event-manager/CCEvent.js:471 | 
getLocationY
Returns location Y axis data.
| meta | description | 
|---|---|
| Returns | Number | 
| Defined in | cocos2d/core/event-manager/CCEvent.js:481 | 
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 | 
