Cocos2d-x  v4
Touch Class Reference

Encapsulates the Touch information, such as touch point, id and so on, and provides the methods that commonly used. More...

Inherits Ref.

Public Types

enum  DispatchMode { , ONE_BY_ONE }
 Dispatch mode, how the touches are dispatched. More...
 

Public Member Functions

 Touch ()
 Constructor. 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...
 
void setTouchInfo (int id, float x, float y)
 Set the touch information. More...
 
void setTouchInfo (int id, float x, float y, float force, float maxForce)
 Set the touch information. More...
 
int getID () const
 Get touch id. More...
 
float getCurrentForce () const
 Returns the current touch force for 3d touch. More...
 
float getMaxForce () const
 Returns the maximum touch force for 3d touch. 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.
 

Detailed Description

Encapsulates the Touch information, such as touch point, id and so on, and provides the methods that commonly used.

Member Enumeration Documentation

◆ DispatchMode

enum DispatchMode
strong

Dispatch mode, how the touches are dispatched.

@js NA

Enumerator
ONE_BY_ONE 

All at once.

Constructor & Destructor Documentation

◆ Touch()

Touch ( )
inline

Constructor.

@js ctor

Member Function Documentation

◆ 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.

◆ getStartLocation()

Vec2 getStartLocation ( ) const

Returns the start touch location in OpenGL coordinates.

Returns
The start touch location in OpenGL coordinates.

◆ 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.

◆ getStartLocationInView()

Vec2 getStartLocationInView ( ) const

Returns the start touch location in screen coordinates.

Returns
The start touch location in screen coordinates.

◆ setTouchInfo() [1/2]

void setTouchInfo ( int  id,
float  x,
float  y 
)
inline

Set the touch information.

It always used to monitor touch event.

Parameters
idA given id
xA given x coordinate.
yA given y coordinate.

◆ setTouchInfo() [2/2]

void setTouchInfo ( int  id,
float  x,
float  y,
float  force,
float  maxForce 
)
inline

Set the touch information.

It always used to monitor touch event.

Parameters
idA given id
xA given x coordinate.
yA given y coordinate.
forceCurrent force for 3d touch.
maxForcemaximum possible force for 3d touch.

◆ getID()

int getID ( ) const
inline

Get touch id.

@js getId @lua getId

Returns
The id of touch.

◆ getCurrentForce()

float getCurrentForce ( ) const

Returns the current touch force for 3d touch.

Returns
The current touch force for 3d touch.

◆ getMaxForce()

float getMaxForce ( ) const

Returns the maximum touch force for 3d touch.

Returns
The maximum touch force for 3d touch.

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