This is a frequently asked question. Multi-touch feature is available on both iOS & Android port since the first version of cocos2d-x. But in iOS, apple turns the switcher off by default, and offers an API to enable it manually.
iOS
Please refer to cocos2d-x/samples/Cpp/TestCpp/proj.ios/Classes/testAppDelegate.mm, line 39
[__glView setMultipleTouchEnabled:YES]
When you have a project created by xcode cocos2d-x templates, you can modify this file MyGame/proj.ios/AppController.mm as below
1- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
2
// Override point for customization after application launch.
4
// Add the view controller's view to the window and display.
6 window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
7 EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
8 pixelFormat: kEAGLColorFormatRGBA8
9 depthFormat: GL_DEPTH_COMPONENT16_OES
10 preserveBackbuffer: NO
11 sharegroup: nil
12 multiSampling: NO
13 numberOfSamples: ];
14
[__glView setMultipleTouchEnabled:YES]; // enable multi-touch here!! It's at about line 37
16
17 // ...
18
19 return YES;
20}
Apple official document about setMultipleTouchEnabled is HERE:
Android
On android, the multi-touch is open by default. You don't need to open anything before get the touch coordinates in void MyLayer::ccTouchesBegan/Moved/Ended
Other platforms
People usually debug cocos2d-x games on windows desktop system. But sadly, there's no multi-touch support on windows. You had to connect your mobile phones and test multi-touch feature on them.
Multi-touch Test Case
We added a test case for multi-touch since v2.0. After launching TestCpp, you can enter this test case from "MultiTouchTest". The video looks like this