Cocos2d-x Simple recording of the engagement on iOS

Source: Internet
Author: User

Compare apps;

The start-up process for an app is:

int Main (intChar * argv[]) {    @autoreleasepool {        return@ "  appdelegate");}    }

Corresponding

@interface Appdelegate:uiresponder <UIApplicationDelegate>*window; @end

In the

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions {     // Override point for customization after application launch.     // Create window    Self.window = [[UIWindow alloc] Initwithframe:[uiscreen mainscreen].bounds];    [Self.window makekeyandvisible];     *view = [[Maintableviewcontroller alloc]init];     // Root View    Self.window.rootViewController = view;         return YES;}

Can see the key is

Window.rootviewcontroller

The start-up process in cocos2d-x is basically the same:
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {cocos2d::application*app =cocos2d::application::getinstance ();        ... Cceaglview*eaglview =[Cceaglview viewwithframe: [window bounds] ...//Eaglview Inheritance UIView[Eaglview Setmultipletouchenabled:yes]; Viewcontroller.view= Eaglview;//Place to joinCocos2d::glview*glview =Cocos2d::glviewimpl::createwitheaglview (Eaglview); //TODO: The need to encapsulate more than one layer needs to be understood in conjunction with AndroidCocos2d::D irector::getinstance ()Setopenglview (Glview); App->run ();//Go in here and enter the game loop .    returnYES;}

There are 3 somewhat confusing classes:

AppController is iOS, it's better to differentiate

Application and Appdelegate:

Application: Personal understanding is equivalent to MFC in the APP class, there is a similar run interface, corresponding to the game main loop.

And then

Class Appdelegate:private Cocos2d::application

Then there is the Director is mainly the operation of the corresponding Glview.

Run and go in.

-(void) startmainloop{        //  Director::setanimationinterval () is called, we should Invalidate itfirst    [self stopmainloop];         = [Nsclassfromstring (@ "cadisplaylink") displaylinkwithtarget:self selector:@ Selector (docaller:)];    [DisplayLink SetFrameInterval:self.interval];    [DisplayLink Addtorunloop:[nsrunloop Currentrunloop] formode:nsdefaultrunloopmode];}

[DisplayLink Addtorunloop:[nsrunloop Currentrunloop] formode:nsdefaultrunloopmode];

Understand:

Nsrunloop is in the Foundation framework




Cocos2d-x Simple recording of the engagement on iOS

Related Article

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.