How to Enable Multi-Touch

来源:互联网 发布:java gbk转utf8 乱码 编辑:程序博客网 时间:2024/04/30 23:01

How to Enable Multi-Touch

  • How to Enable Multi-Touch
    • iOS
    • Android
    • Other platforms
    • Multi-touch Test Case

The Multi-touch features have been available on both iOS & Android since the first version of cocos2d-x. In iOS, Apple turns multi-touch off by default. Use the API to enable it manually.

iOS

Please refer to cocos2d-x/tests/cpp-tests/proj.ios/Classes/testsAppDelegate.mm, line 60:

1
[eaglView setMultipleTouchEnabled:YES];

You can modify this file MyGame/proj.ios/AppController.mm:

12345678910111213141516171819
- application:application didFinishLaunchingWithOptions:launchOptions {     // Override point for customization after application launch.    // Add the view controller’s view to the window and display.    window = initWithFrame: 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 official document about setMultipleTouchEnabled.

Android

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

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.

Multi-touch Test Case

We added a test case for multi-touch since v2.0. After launching TestCpp, you can enter this test case from “MultiTouchTest”. There is avideo.

0 0