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平臺沒有多點觸控。