[IOS-Cocos2d Game Development 8] Turn on high definition (960*640) mode questions and answers, picture adaptation and Set iPhone portrait Screen

Source: Internet
Author: User

Recently, my book has been printed. I did not expect the signed shoes to meet the three-digit conference. Thank you for your support and encouragement as always. Today, I will introduce you to the three details of cocos2d development; first, we will introduce the first point: how to enable the HD mode. We all know that the resolution of iPhone 4 is 960*640, Which is exactly twice as big as the previous 480*320, if you want to test the game effect in HD mode, you must first know that the IOS simulator is set to iPhone (retina) mode, but you will surely find problems when setting only the children's shoes here, after running, you will find that the resolution printed on the console is still 480*320. After this setting, the simulator size is only doubled, but the resolution remains unchanged. In fact, this is because of the cocos2d engine problem, since you use the cocos2d engine, you should know that the entire control right is handed over to cocos2d after the program runs, you should also set and enable the high-definition mode from cocos2d; the enabling method is very easy, first open your appdelegate. M (here I use cocos 2d1-1.0.0 creates a class automatically generated by the cocos2d project by default.) OK, and then manually search for the following code: [CPP] view plaincopy [Director enableretinadisplay: Yes] OK. The found code is as follows; [CPP] view plaincopy /// enables high res mode (Retina Display) on iPhone 4 and maintains low res on all other devices // If (! [Director enableretinadisplay: Yes]) // cclog (@ "retina display not supported"); yes, these lines are commented out. OK, remove the comments, after the HD mode is enabled, set the IOS simulator to iPhone (retina), and then run the project to make the resolution 960*640. OK. Then, let's talk about the image adaptation problem: IOS kids shoes should not have the so-called adaptation concept before ios4 (aside from the iPad). Now that ios4 comes out, the iPhone has different resolutions, then the pictures used in the program also need to be designed. In fact, Apple has already taken into account for developers, So it provides a very convenient way: Pull ", then, when the program runs in iPhone 4, it will automatically index the corresponding image of @ 2x. Therefore, himi should remind you of the important point: success. There must be no mistakes here; it is difficult to apply for an IPD recently, but I should have applied for it over the past few days. I have also purchased an image packaging tool "texturepacker" over the past few days. cocos2d is certainly a good choice, this editor is mainly used to package most of the images, saving the package size, saving the running memory, and improving the running efficiency. We will not detail it here. You can use it on your own; "texturepacker" has two important functions. One is to automatically add an image package of @ 2x or-hd to your image package, the second is to package images into PVR and PVR. the CCZ format is quite easy to use. This tool is recommended here for himi. $19 + is not expensive. (However, it reminds you to use $ for payment when purchasing the tool, because RMB is not required, the purchase has failed many times, but it is a tragedy). Two editors are recommended here (himi has been purchased and is in use) 1. particle effects editor http://particledesigner.71squared.com/2. physicseditor (physical Editor) http://www.physicseditor.de/features/ so nothing to say, about the recommended editor we should be very familiar with, not familiar with can be customized to open the connection, the following describes how to set the horizontal and vertical screen of the iPhone running program. The cocos2d engine uses a horizontal screen by default, and the framework has changed in version 1.0.0, the setting method I described here is for cocos2d-1.0.0; Enable rootviewcontroller. m, and then search for the following code: [CPP] view plaincopyuiinterfaceorientationislandscape. Then the complete code is as follows: [CPP] view plaincopy # Elif game_autorotation = kgameautorotationuiviewcontroller /// eaglview will be rotated by the uiviewcontroller /// sample: autorotate only in landscpe mode // return YES For the supported orientations return (uiinterfaceorientationislandscape (interfaceorientation); Modify the final return to the following code to portrait: [CPP] view plaincopyreturn (uiinterfaceorientationisportrait (interfaceorientation ));
Related Article

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.