Reputation: 14571
I want to enable multitouch mode in cocos2d-x using c++.There are answers related to how to enable it on cocos2d but I want to enable it in cocos2d-x.Any help will be appreciated
Upvotes: 1
Views: 1241
Reputation: 9950
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 RootViewController.mm
generated by the cocos new
commandline tool to enable multi-touch.
--- a/proj.ios_mac/ios/RootViewController.mm
+++ b/proj.ios_mac/ios/RootViewController.mm
@@ -52,7 +52,7 @@
numberOfSamples: 0 ];
// Enable or disable multiple touches
- [eaglView setMultipleTouchEnabled:NO];
+ [eaglView setMultipleTouchEnabled:YES];
Upvotes: 1
Reputation: 14571
I myself got the answer.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.....
Upvotes: 2