如何使用c ++在cocos2d-x ios游戏中启用多点触控 [英] How to enable multitouch in cocos2d-x ios game using c++
本文介绍了如何使用c ++在cocos2d-x ios游戏中启用多点触控的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用c ++在cocos2d-x中启用多点触控模式。有关如何在cocos2d上启用它的答案,但是我想在cocos2d-x中启用它。任何帮助都将受到赞赏
解决方案
当您下载cocos2d-x时,您应该已经下载了所有测试 - 这些包括(我认为)多点触控测试 - 所以您可以运行测试并查看源代码。
我自己得到了答案。为了启用多点触控,只需转到你的AppController.mm,然后在创建EAGL视图后的函数didFinishLaunchingWithOptions中添加以下代码。
[__ glView setMultipleTouchEnabled:YES];
所以现在函数应该是这样的
(BOOL)应用程序:(UIApplication *)应用程序didFinishLaunchingWithOptions :( NSDictionary
*)launchOptions {
// 覆盖点应用程序启动后的自定义。
// 将视图控制器的视图添加到窗口和显示。
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];
// 使用RootViewController管理EAGLView
viewController = [[RootViewController alloc] initWithNibName :nil bundle:nil];
viewController.wantsFullScreenLayout = YES;
viewController.view = __glView;
// 续.....
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
解决方案
When you downloaded cocos2d-x you should have downloaded all the tests - and these include (I think) multitouch tests - so you can run the test and look at the source there.
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.....
这篇关于如何使用c ++在cocos2d-x ios游戏中启用多点触控的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文