(Original) cocos2d notes -- Analysis of helloworldappdelegate

Source: Internet
Author: User

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.


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.