您的位置:首页 > 移动开发 > Cocos引擎

关于cocos2dx多点触控的问题

2014-02-10 22:54 239 查看

cocos2dx官网上对多点触控模式的说明

h1. How to Enable Multi-Touch 

如何开启多点触控?

Many people ask me how to enable multi-touch in cocos2d-x, so I write a document here. 

许多人询问如何开启cocos2dx的多点触控,所以我写了这篇文档。

Multi-touch feature is available in both ios & android port since the first version of cocos2d-x. But in iOS, apple turns the switcher off by default, and offers an API to enable it manually. 

从cocos2dx的第一个版本就有了多点触控特征,ios和android的设备都有多点触控。但是ios的框架中默认是关闭的。

h2. ios

苹果设备

Please refer to cocos2d-x/tests/test.ios/Classes/testsAppDelegate.mm, line 39 

请参考cocos2d-x/tests/test.ios/Classes/testsAppDelegate.mm, line 39 

 [__glView setMultipleTouchEnabled:YES] 

When you have a project created by xcode cocos2d-x templates, you can modify this file MyGame/ios/AppController.mm as below 


当你创建了一个xcode cocos2dx模板,你可以将MyGame/ios/AppController.mm 修改成一下代码:

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

preserveBackbuffer: NO 

sharegroup: nil 

multiSampling: NO 

numberOfSamples: 0 ]; 

[__glView setMultipletouchEnabled:YES]; // enable multi-touch here!! It's at about line 37 

// ... 

return YES; 

"Apple Apple official document about
setMultipletouchEnabled is here": 

http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instm/UIView/setMultipleTouchEnabled: 

上面的地址是苹果关于多点触控的官方文件。

h2. Android 

安卓设备

On android, the multi-touch is open by default. You don't need to open anything before get the touch coordinates in void MyLayer::ccTouchesBegan/Moved/Ended 

安卓上,默认是开启的,你不需要任何修改。

h2. Other platforms 

People usually debug cocos2d-x games on windows desktop system. But sadly, there's no multi-touch support on windows. You had to connect your mobile phones and test multi-touch feature on them. 

window平台没有多点触控。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  cocos2dx 多点触控 ios