Enabling multitouch

Now, let's try the same with two fingers; we touch both fingers at the same time, anywhere on the screen. We see that the TouchesBegan() function got called twice, and when we remove each finger one by one, the TouchesEnded() function gets called one after the other.

In Windows Phone and Android, multitouch is enabled automatically. On iOS, we will have to enable it separately by adding the following below the line EAGLView *__glView in the function, (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions in the AppController.mm file:

[__glView setMultipleTouchEnabled:YES]; 

Get Learning Cocos2d-x Game Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.