The default is not to turn on multi-touch under iOS, we want to use the following content:
iOS folder: appcontroller.mm
Need to add a line of code:
just add this line of code and you can use multi-touch. [Eaglview Setmultipletouchenabled:yes];
See below for specific locations:
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {//O Verride point to 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:n IL]; _viewcontroller.wantsfullscreenlayout = YES; _viewcontroller.view = Eaglview;You just need to add a new line of code to use multi-touch. [Eaglview Setmultipletouchenabled:yes]; Set Rootviewcontroller to Window if ([[Uidevice currentdevice].systemversion Floatvalue] < 6.0) {//W Arning:addsubview doesn ' t work on iOS6 [window addsubview: _viewcontroller.view]; } else {//Use this method on IOS6 [window Setrootviewcontroller:_viewcontroller]; } [window makekeyandvisible]; [[UIApplication sharedapplication] setstatusbarhidden:true]; Important:setting The Glview should be do after creating the Rootviewcontroller cocos2d::glview *glview = cocos2d :: Glview::createwitheaglview (Eaglview); Cocos2d::D irector::getinstance ()->setopenglview (Glview); Cocos2d::application::getinstance ()->run (); return YES;}
Test:
Auto Listener1 = Eventlistenertouchallatonce::create (); Listener1->setenabled (true); Listener1->ontouchesbegan = [=] (const std::vector<touch*>& touches, event* Event) { log ("%lu", Touches.size ()); }; _eventdispatcher->addeventlistenerwithfixedpriority (Listener1, 1);
cocos2d-x3.2 enable multi-touch under iOS