Thursday, 6 February 2014

How to enable multi touch in cocos2d-x ios game using c++

In order to enable multitouch just go to your AppController.mm. Then in the function didFinishLaunchingWithOptions after creating the EAGL View just add the following code.


[__glView setMultipleTouchEnabled:YES];
So now the function should look like this
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary      
*)launchOptions {
 
// Override point for customization after application launch.

// Add the view controller's view to the window and display.
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
                                 pixelFormat: kEAGLColorFormatRGBA8
                                 depthFormat: GL_DEPTH_COMPONENT16
                          preserveBackbuffer: NO
                                  sharegroup: nil
                               multiSampling: NO
                             numberOfSamples:0 ];
 
[__glView setMultipleTouchEnabled:YES];
// Use RootViewController manage EAGLView
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES;
viewController.view = __glView;
//continued.....