How to Enable Multi-Touch

How to Enable Multi-Touch

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:


 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
- 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 in void 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 a video.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值