Cocos2d-x  v4
EventMouse Class Reference

The mouse event. More...

Inherits Event.

Public Types

enum  MouseEventType
 MouseEventType Different types of MouseEvent. More...
 
- Public Types inherited from Event
enum  Type
 Type Event type.
 

Public Member Functions

 EventMouse (MouseEventType mouseEventCode)
 Constructor. More...
 
void setScrollData (float scrollX, float scrollY)
 Set mouse scroll data. More...
 
float getScrollX () const
 Get mouse scroll data of x axis. More...
 
float getScrollY () const
 Get mouse scroll data of y axis. More...
 
void setCursorPosition (float x, float y)
 Set the cursor position. More...
 
void setMouseButton (MouseButton button)
 Set mouse button. More...
 
MouseButton getMouseButton () const
 Get mouse button. More...
 
float getCursorX () const
 Get the cursor position of x axis. More...
 
float getCursorY () const
 Get the cursor position of y axis. More...
 
Vec2 getLocation () const
 Returns the current touch location in OpenGL coordinates. More...
 
Vec2 getPreviousLocation () const
 Returns the previous touch location in OpenGL coordinates. More...
 
Vec2 getStartLocation () const
 Returns the start touch location in OpenGL coordinates. More...
 
Vec2 getDelta () const
 Returns the delta of 2 current touches locations in screen coordinates. More...
 
Vec2 getLocationInView () const
 Returns the current touch location in screen coordinates. More...
 
Vec2 getPreviousLocationInView () const
 Returns the previous touch location in screen coordinates. More...
 
Vec2 getStartLocationInView () const
 Returns the start touch location in screen coordinates. More...
 
- Public Member Functions inherited from Event
virtual ~Event ()
 Destructor.
 
Type getType () const
 Gets the event type. More...
 
void stopPropagation ()
 Stops propagation for current event.
 
bool isStopped () const
 Checks whether the event has been stopped. More...
 
NodegetCurrentTarget ()
 Gets current target of the event. More...
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()
 Destructor. More...
 

Additional Inherited Members

- Public Attributes inherited from Ref
unsigned int _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 
void * _scriptObject
 scriptObject, support for swift
 
bool _rooted
 When true, it means that the object was already rooted.
 
- Protected Member Functions inherited from Event
 Event (Type type)
 Constructor.
 

Detailed Description

The mouse event.

Member Enumeration Documentation

◆ MouseEventType

enum MouseEventType
strong

MouseEventType Different types of MouseEvent.

@js NA

Constructor & Destructor Documentation

◆ EventMouse()

EventMouse ( MouseEventType  mouseEventCode)

Constructor.

Parameters
mouseEventCodeA given mouse event type. @js ctor

Member Function Documentation

◆ setScrollData()

void setScrollData ( float  scrollX,
float  scrollY 
)
inline

Set mouse scroll data.

Parameters
scrollXThe scroll data of x axis.
scrollYThe scroll data of y axis.

◆ getScrollX()

float getScrollX ( ) const
inline

Get mouse scroll data of x axis.

Returns
The scroll data of x axis.

◆ getScrollY()

float getScrollY ( ) const
inline

Get mouse scroll data of y axis.

Returns
The scroll data of y axis.

◆ setCursorPosition()

void setCursorPosition ( float  x,
float  y 
)
inline

Set the cursor position.

Parameters
xThe x coordinate of cursor position.
yThe y coordinate of cursor position. @js setLocation

◆ setMouseButton()

void setMouseButton ( MouseButton  button)
inline

Set mouse button.

Parameters
buttona given mouse button. @js setButton

◆ getMouseButton()

MouseButton getMouseButton ( ) const
inline

Get mouse button.

Returns
The mouse button. @js getButton

◆ getCursorX()

float getCursorX ( ) const
inline

Get the cursor position of x axis.

Returns
The x coordinate of cursor position. @js getLocationX

◆ getCursorY()

float getCursorY ( ) const
inline

Get the cursor position of y axis.

Returns
The y coordinate of cursor position. @js getLocationY

◆ getLocation()

Vec2 getLocation ( ) const

Returns the current touch location in OpenGL coordinates.

Returns
The current touch location in OpenGL coordinates.

◆ getPreviousLocation()

Vec2 getPreviousLocation ( ) const

Returns the previous touch location in OpenGL coordinates.

Returns
The previous touch location in OpenGL coordinates. @js NA

◆ getStartLocation()

Vec2 getStartLocation ( ) const

Returns the start touch location in OpenGL coordinates.

Returns
The start touch location in OpenGL coordinates. @js NA

◆ getDelta()

Vec2 getDelta ( ) const

Returns the delta of 2 current touches locations in screen coordinates.

Returns
The delta of 2 current touches locations in screen coordinates.

◆ getLocationInView()

Vec2 getLocationInView ( ) const

Returns the current touch location in screen coordinates.

Returns
The current touch location in screen coordinates.

◆ getPreviousLocationInView()

Vec2 getPreviousLocationInView ( ) const

Returns the previous touch location in screen coordinates.

Returns
The previous touch location in screen coordinates. @js NA

◆ getStartLocationInView()

Vec2 getStartLocationInView ( ) const

Returns the start touch location in screen coordinates.

Returns
The start touch location in screen coordinates. @js NA

The documentation for this class was generated from the following file: