Cocos Creator API

1.5.x

Cocos Creator is the game engine for the future.

Event.EventMouse

Extends Event
Module: cc

The mouse event

Properties

NONE Number static

The none event code of mouse event.

DOWN Number static

The event type code of mouse down event.

UP Number static

The event type code of mouse up event.

MOVE Number static

The event type code of mouse move event.

SCROLL Number static

The event type code of mouse scroll event.

BUTTON_LEFT Number static

The tag of Mouse left button.

BUTTON_RIGHT Number static

The tag of Mouse right button (The right button number is 2 on browser).

BUTTON_MIDDLE Number static

The tag of Mouse middle button (The right button number is 1 on browser).

BUTTON_4 Number static

The tag of Mouse button 4.

BUTTON_5 Number static

The tag of Mouse button 5.

BUTTON_6 Number static

The tag of Mouse button 6.

BUTTON_7 Number static

The tag of Mouse button 7.

BUTTON_8 Number static

The tag of Mouse button 8.

type String

Inherited from Event:

The name of the event (case-sensitive), e.g. "click", "fire", or "submit".

bubbles Boolean

Inherited from Event:

Indicate whether the event bubbles up through the tree or not.

target Object

Inherited from Event:

A reference to the target to which the event was originally dispatched.

currentTarget Object

Inherited from Event:

A reference to the currently registered target for the event.

eventPhase Number

Inherited from Event:

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.

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

Methods

setScrollData
(
  • scrollX
  • scrollY
)

Sets scroll data.

name type description
scrollX Number
scrollY Number

getScrollX ( ) Number

Returns the x axis scroll value.

returns:

type: Number

getScrollY ( ) Number

Returns the y axis scroll value.

returns:

type: Number

setLocation
(
  • x
  • y
)

Sets cursor location.

name type description
x Number
y Number

getLocation ( ) Vec2

Returns cursor location.

returns:

type: Vec2

location

getLocationInView ( ) Vec2

Returns the current cursor location in screen coordinates.

returns:

type: Vec2

getPreviousLocation ( ) Vec2

Returns the previous touch location.

returns:

type: Vec2

getDelta ( ) Vec2

Returns the delta distance from the previous location to current location.

returns:

type: Vec2

getDeltaX ( ) Number

Returns the X axis delta distance from the previous location to current location.

returns:

type: Number

getDeltaY ( ) Number

Returns the Y axis delta distance from the previous location to current location.

returns:

type: Number

setButton
(
  • button
)

Sets mouse button.

name type description
button Number

getButton ( ) Number

Returns mouse button.

returns:

type: Number

getLocationX ( ) Number

Returns location X axis data.

returns:

type: Number

getLocationY ( ) Number

Returns location Y axis data.

returns:

type: Number

constructor
(
  • type
  • bubbles
)

Inherited from Event:

name type description
type String

The name of the event (case-sensitive), e.g. "click", "fire", or "submit"

bubbles Boolean

A boolean indicating whether the event bubbles up through the tree or not

unuse ( ) String

Inherited from Event:

Reset the event for being stored in the object pool.

returns:

type: String

reuse ( ) String

Inherited from Event:

Reuse the event for being used again by the object pool.

returns:

type: String

stopPropagation ( )

Inherited from Event:

Stops propagation for current event.

stopPropagationImmediate ( )

Inherited from Event:

Stops propagation for current event immediately, the event won't even be dispatched to the listeners attached in the current target.

isStopped ( ) Boolean

Inherited from Event:

Checks whether the event has been stopped.

returns:

type: Boolean

getCurrentTarget ( ) Node

Inherited from Event:

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.

returns:

type: Node

The target with which the event associates.

getType ( ) String

Inherited from Event:

Gets the event type.

returns:

type: String

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