Cocos2dx startup process 1: Rendering

Source: Internet
Author: User

Cocos2dx startup process 1: Rendering
Today let's take a look at the overall Starting Process of cocos2d-x:

Cocos2d-x in each platform implementation code is the same, as long as the corresponding configuration for different platforms can be. I. Start the prelude. Now let's take a look at the relevant structure on the ios platform: Open the built-in project in the source code, and you will see a main file. Here, there is a main function in main, this is the entry function of the program. Here he loads the AppController back and enters this class. Here there is the initialization code for the ios platform Hua Jing, but the first execution is as follows: // cocos2d application instance
Static AppDelegate s_sharedApplication;
Here, cocos2dx creates an appDelegare object. Of course, the object will be initialized during the creation process. The code shows :/**
@ Brief The cocos2d Application.

The reason to implement with private inheritance is to hide some interface details of CCDirector.
*/
Class AppDelegate: private cocos2d: CCApplication


Here we will call the CCApplicaiton constructor: CCApplication ()
{
CC_ASSERT (! Sm_pSharedApplication );
Sm_pSharedApplication = this; // global shared Instance Object
}
Here, this is assigned to sm_pSharedApplication. What is this? In fact, this is AppDeletegate, because there is no parent class object involved in the call process here. If it is necessary to involve CCApplication: CCApplication (); c ++ does not create a parent class object after creating a derived class object. It only displays or implicitly calls the constructor of the parent class.

But why is there a useless global variable here? The answer is as follows:


Click to continue reading more highlights

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.