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];
}