Event.EventMouse Class
Extends Event
Module: cc
The mouse event
Index
Properties
NONENumberThe none event code of mouse event.DOWNNumberThe event type code of mouse down event.UPNumberThe event type code of mouse up event.MOVENumberThe event type code of mouse move event.SCROLLNumberThe event type code of mouse scroll event.BUTTON_LEFTNumberThe tag of Mouse left button.BUTTON_RIGHTNumberThe tag of Mouse right button (The right button number is 2 on browser).BUTTON_MIDDLENumberThe tag of Mouse middle button (The right button number is 1 on browser).BUTTON_4NumberThe tag of Mouse button 4.BUTTON_5NumberThe tag of Mouse button 5.BUTTON_6NumberThe tag of Mouse button 6.BUTTON_7NumberThe tag of Mouse button 7.BUTTON_8NumberThe tag of Mouse button 8.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.
Methods
setScrollDataSets scroll data.getScrollXReturns the x axis scroll value.getScrollYReturns the y axis scroll value.setLocationSets cursor location.getLocationReturns cursor location.getLocationInViewReturns the current cursor location in screen coordinates.getPreviousLocationReturns the previous touch location.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.setButtonSets mouse button.getButtonReturns mouse button.getLocationXReturns location X axis data.getLocationYReturns location Y axis data.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
NONE
The none event code of mouse event.
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/event-manager/CCEvent.js:208 |
DOWN
The event type code of mouse down event.
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/event-manager/CCEvent.js:216 |
UP
The event type code of mouse up event.
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/event-manager/CCEvent.js:224 |
MOVE
The event type code of mouse move event.
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/event-manager/CCEvent.js:232 |
SCROLL
The event type code of mouse scroll event.
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/event-manager/CCEvent.js:240 |
BUTTON_LEFT
The tag of Mouse left button.
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/event-manager/CCEvent.js:249 |
BUTTON_RIGHT
The tag of Mouse right button (The right button number is 2 on browser).
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/event-manager/CCEvent.js:258 |
BUTTON_MIDDLE
The tag of Mouse middle button (The right button number is 1 on browser).
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/event-manager/CCEvent.js:267 |
BUTTON_4
The tag of Mouse button 4.
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/event-manager/CCEvent.js:276 |
BUTTON_5
The tag of Mouse button 5.
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/event-manager/CCEvent.js:285 |
BUTTON_6
The tag of Mouse button 6.
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/event-manager/CCEvent.js:294 |
BUTTON_7
The tag of Mouse button 7.
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/event-manager/CCEvent.js:303 |
BUTTON_8
The tag of Mouse button 8.
| meta | description |
|---|---|
| Type | Number |
| Defined in | cocos2d/core/event-manager/CCEvent.js:312 |
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
setScrollData
Sets scroll data.
| meta | description |
|---|---|
| Defined in | cocos2d/core/event-manager/CCEvent.js:58 |
Parameters
getScrollX
Returns the x axis scroll value.
| meta | description |
|---|---|
| Returns | Number |
| Defined in | cocos2d/core/event-manager/CCEvent.js:70 |
getScrollY
Returns the y axis scroll value.
| meta | description |
|---|---|
| Returns | Number |
| Defined in | cocos2d/core/event-manager/CCEvent.js:80 |
setLocation
Sets cursor location.
| meta | description |
|---|---|
| Defined in | cocos2d/core/event-manager/CCEvent.js:90 |
Parameters
getLocation
Returns cursor location.
| meta | description |
|---|---|
| Returns | Vec2 |
| Defined in | cocos2d/core/event-manager/CCEvent.js:102 |
getLocationInView
Returns the current cursor location in screen coordinates.
| meta | description |
|---|---|
| Returns | Vec2 |
| Defined in | cocos2d/core/event-manager/CCEvent.js:112 |
getPreviousLocation
Returns the previous touch location.
| meta | description |
|---|---|
| Returns | Vec2 |
| Defined in | cocos2d/core/event-manager/CCEvent.js:127 |
getDelta
Returns the delta distance from the previous location to current location.
| meta | description |
|---|---|
| Returns | Vec2 |
| Defined in | cocos2d/core/event-manager/CCEvent.js:137 |
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:147 |
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:157 |
setButton
Sets mouse button.
| meta | description |
|---|---|
| Defined in | cocos2d/core/event-manager/CCEvent.js:167 |
Parameters
buttonNumber
getButton
Returns mouse button.
| meta | description |
|---|---|
| Returns | Number |
| Defined in | cocos2d/core/event-manager/CCEvent.js:177 |
getLocationX
Returns location X axis data.
| meta | description |
|---|---|
| Returns | Number |
| Defined in | cocos2d/core/event-manager/CCEvent.js:187 |
getLocationY
Returns location Y axis data.
| meta | description |
|---|---|
| Returns | Number |
| Defined in | cocos2d/core/event-manager/CCEvent.js:197 |
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 |