Every iOS appProgramEach has an appdelegate class that implements the uiapplicationdelegate protocol. In the helloworld project, its name is helloworldappdelegate.
This appdelegate is used to track application status changes by receiving messages from IOS. For example, it allows you to determine when the user receives the call or when the memory is full. The first message received by your application is the applicationdidfinishlaunching method. This place is all startedCodeIt is also the place where cocos2d is initialized.
If you want to learn more about the appdelegate method, you can use the uiapplicationdelegate protocol to view Apple's reference documents,
Http://developer.apple.com/iphone/library/documentation/uikit/reference/UIAppli cationdelegate_protocol
In most cases, you only need to modify three items during cocos2d initialization:
[[Ccdirector shareddirector] setdeviceorientation: ccdeviceorientationlandscapeleft];
[[Ccdirector shareddirector] setanimationinterval:1.0/60];
[[Ccdirector shareddire] setdisplayfps: Yes];
Next we will introduce the details of each place:
1. device Orientation Device direction mode
Set the device direction. This helloworld application adopts the horizontal mode. If you change this option
Ccdeviceorientationlandscapeleft is changed to ccdeviceorientationlandscaperight, and you will find that "Hello world" is displayed upside down.
Here is a list of device modes:
Ccdeviceorientationportrait
Ccdeviceorientationportraitupsidedown
Ccdeviceorientationlandscapeleft
Ccdeviceorientationlandscaperight
2. animation Interval
Animation interval determines how often cocos2d refreshes the screen. In fact, it affects the maximum frame rate that your game can reach. However, this animation interval is not given in the format of frame/second, but is opposite to second/frame. The coefficients are 1.0/60.
3. Display FPS display of frames per second
After "display FPS" is enabled, a small number is displayed in the lower left corner of the screen. This is your frame rate. Ideally, your game can run at 60fps at any time. This FPS display helps you track frame rates and any snoring and stuttering situations in the game.