cocos2d-x3.2 enable multi-touch under iOS

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.