zoukankan      html  css  js  c++  java
  • How to Enable Multi-Touch

    This is a frequently asked question. Multi-touch feature is available on 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.

    iOS

    Please refer to cocos2d-x/samples/Cpp/TestCpp/proj.ios/Classes/testAppDelegate.mm, line 39

    [__glView setMultipleTouchEnabled:YES]

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

    1- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    2

    3 // Override point for customization after application launch.

    4

    5 // Add the view controller's view to the window and display.

    6 window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];

    7 EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]

    8 pixelFormat: kEAGLColorFormatRGBA8

    9 depthFormat: GL_DEPTH_COMPONENT16_OES

    10 preserveBackbuffer: NO

    11 sharegroup: nil

    12 multiSampling: NO

    13 numberOfSamples: 0 ];

    14

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

    16

    17 // ...

    18

    19 return YES;

    20}


    Apple official document about setMultipleTouchEnabled is HERE:

    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". The video looks like this


  • 相关阅读:
    读REDIS数据结构
    一致性哈希虚节点解决雪崩问题
    TCP的建立和关闭
    nginx和apache的比较
    进程和线程的区别
    acm过河卒
    搭建centos7 的php环境
    navicat 中 oracle数据传输到mysql上
    安装虚拟机精简版centos7
    整合tomcat的一些配置
  • 原文地址:https://www.cnblogs.com/yssgyw/p/3438621.html
Copyright © 2011-2022 走看看