How to detect multi-touch?

How to detect multi-touch?
0.0 0


If I touched screen with one finger and didn’t release.
When I touched screen with another finger I can’t receive touch events.
Whether use addStandardDelegate or addTargetedDelegate, ccTouchesBegan and ccTouchBegan both didn’t be called.
In fact, in method ccTouchesBegan(CCSet* pTouches,…) pTouches allways contain only one Touch.
How to detect the second touch begin? Please help.


I think you should debug it.
In android, the touchBegan event is called in cocos2dx/platform/android/Cocos2dJni.cpp::Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesBegin().
If ios, it is called in cocos2dx/platform/ios/ *)touches withEvent:(UIEvent *)event).


cocos2d doesn’t enable multi-touch by default.
enable it after create EAGLView.

EAGLView *glView = [EAGLView viewWithFrame:[window bounds]
pixelFormat:kEAGLColorFormatRGB565 // kEAGLColorFormatRGBA8
depthFormat:0 // GL_DEPTH_COMPONENT16_OES

[glView setMultipleTouchEnabled:YES];


Want to know how to get each touch in CCSet. CCSet is not the same as NSSet, and always has only one element in it. Do any one know how to use it?


@Harrison Xi
You can refer to tests/Box2DTest/Box2dTest.cpp, Box2DTestLayer::ccTouchesEnded(…)
This function shows how to traverse touch points in CCSet.


Hey i’m stuck with the same problem… the CCSet always contains one element.

When i press a button and then i press another button. So now on releasing the button 1, the ccTouchesEnded function doesn’t get called.

Same is happening with ccTouchesMove.

Only the ccTouchesBegan is working correctly.


Try this:


Yes the CCSet always has only one element, but you can figure out which touch is calling the function by checking the CCTouch id:

touch->id() == 0 //first touch touch->id() == 1 //second touch touch->id() == 2 //third touch

and so on…


How can we enable Multi-touch in webos devices (Touchpad) ?


Kool 4u,
please let us know which webos port you are using,we can then help to let you know how to enable multi touch on it.

WebOS Fan


For other platforms this should be on by default but for iOS you need to enable it. As of Cocos2d-x 3.16, modify a single line of the generated by the cocos new commandline tool to enable multi-touch.

--- a/proj.ios_mac/ios/
+++ b/proj.ios_mac/ios/
@@ -52,7 +52,7 @@
                                      numberOfSamples: 0 ];
     // Enable or disable multiple touches
-    [eaglView setMultipleTouchEnabled:NO];
+    [eaglView setMultipleTouchEnabled:YES];