Cocos2d project framework and Startup Process

Source: Internet
Author: User

Framework

Cocos2d sources: stores cocos2d source code

Classes: stores the source code of this application.

Other sources: main function of the program entry

Resources: Stores project images, icons, sound files, etc.

Frameworks: Framework

 

Start Process

Int main (INT argc, char * argv []) {
NSAID utoreleasepool * Pool = [NSAID utoreleasepool new]; // control of the program is passed to the application proxy object xappdelegate
Int retval = uiapplicationmain (argc, argv, nil, @ "xxappdelegate"); [pool release];
Return retval;
} @ Interface xxappdelegate: nsobject <uiapplicationdelegate> {complies with the application protocol defined by the system.
Uiwindow * window;
} Xxappdelegate: // discard Control
-(Void) applicationwillresignactive :( uiapplication *) Application {
[[Ccdirector shareddire] pause];
}

// Obtain control
-(Void) applicationdidbecomeactive :( uiapplication *) Application {
[[Ccdirector shareddire] Resume];
}

// Memory alarm
-(Void) applicationdidreceivememorywarning :( uiapplication *) Application {
[[Ccdirector shareddire] purgecacheddata];
}

// Press the Home Key to run the program in the background
-(Void) applicationdidenterbackground :( uiapplication *) Application {
[[Ccdirector shareddire] stopanimation];
}

// The program returns to the foreground
-(Void) applicationwillenterforeground :( uiapplication *) Application {
[[Ccdirector shareddire] startanimation];
}

// Exit the program
-(Void) applicationwillterminate :( uiapplication *) Application {
[[Ccdirector shareddire] end];
}

// System time change
-(Void) applicationsignificanttimechange :( uiapplication *) Application {
[[Ccdirector shareddirector] setnextdeltatimezero: Yes];
}

Pass control of the program to the Cocos2D-iPhone class library through the counts applicationdidfinishlaunching

The Cocos2D-iPhone then begins preparing to boot the main screen:

1. Get the main window object (handle) Saved by the member window, bind the "director" Object of the Cocos2D-iPhone to it.
2. Set the basic attributes of the "director" object. It is best to start and run the scenario.

-(Void) applicationdidfinishlaunching :( uiapplication *) Application
{
Ccdirector * Director = [ccdirector shareddire];

// Set the attributes of the "director" object...

// The scenario where the Director object starts and runs
[[Ccdirector shareddire] runwithscene: [helloworld scene];
}

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.