展会信息港展会大全

Cocos2d-x3.2 iOS下开启多点触控
来源:互联网   发布日期:2015-09-27 15:02:13   浏览:1659次  

导读: iOS下默认是不开启多点触控的,我们要想要使用需要做如下的内容: iOS文件夹下:AppController.mm 需要加一行代码: // 只需要新增这样一行代码就可以使用多点触控啦。...

iOS下默认是不开启多点触控的,我们要想要使用需要做如下的内容:

iOS文件夹下:AppController.mm

需要加一行代码:

//只需要新增这样一行代码就可以使用多点触控啦。

[eaglView setMultipleTouchEnabled:YES];

具体位置见下面:

- (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]];

// Init the CCEAGLView

CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]

pixelFormat: kEAGLColorFormatRGBA8

depthFormat: GL_DEPTH24_STENCIL8_OES

preserveBackbuffer: NO

sharegroup: nil

multiSampling: NO

numberOfSamples: 0];

// Use RootViewController manage CCEAGLView

_viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];

_viewController.wantsFullScreenLayout = YES;

_viewController.view = eaglView;

//只需要新增这样一行代码就可以使用多点触控啦。

[eaglView setMultipleTouchEnabled:YES];

// Set RootViewController to window

if ( [[UIDevice currentDevice].systemVersion floatValue] setOpenGLView(glview);

cocos2d::Application::getInstance()->run();

return YES;

}

测试:

auto listener1 = EventListenerTouchAllAtOnce::create();

listener1->setEnabled(true);

listener1->onTouchesBegan = [ = ](const std::vector& touches, Event* event)

{

log("%lu",touches.size());

};

_eventDispatcher->addEventListenerWithFixedPriority(listener1, 1);

赞助本站

人工智能实验室
AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港