如何使用c ++在cocos2d-x ios游戏中启用多点触控

时间:2014-02-05 11:34:03

标签: c++ cocos2d-x

我想在cocos2d-x中使用c ++启用多点触控模式。有关如何在cocos2d上启用它的答案,但我想在cocos2d-x中启用它。任何帮助将不胜感激

2 个答案:

答案 0 :(得分:1)

我自己得到了答案。为了启用多点触控,只需转到AppController.mm即可 然后在创建EAGL View后的函数didFinishLaunchingWithOptions中添加以下代码。

[__glView setMultipleTouchEnabled:YES];

所以现在这个函数应该是这样的

(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.....

答案 1 :(得分:1)

对于其他平台,默认情况下应启用此选项,但对于iOS,您需要启用它。从Cocos2d-x 3.16开始,修改RootViewController.mm命令行工具生成的cocos new的单行以启用多点触控。

--- 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];