Cocos2D iOS tour: How to Write a hamster game (I): HD screen display and UIKit

Source: Internet
Author: User

Cocos2D iOS tour: How to Write a hamster game (I): HD screen display and UIKit

 

MATERIALS: overview

Because we want this game to run on a regular iphone, HD iphone, and ipad, we need to take some time to make a detailed plan: how to set game materials before we continue.

To understand how to adapt to dimensions and set materials, we need to first involve three themes:

High-definition screen display and UIKit high-definition screen display and Cocos2D iPad, iPhone and screen aspect ratio

Let's get started!

HD screen display and UIKit

The difference between an iPhone and an HD iPhone is that the latter can display 2 times the pixel. therefore, as an alternative to a normal screen of 480x320 px, the resolution of the high-definition screen is 960x640 pixels.

"But wait a moment," you may wonder, "Why did the double increase of pixels make the previously written app suitable for 480x320 pixels fail ?", It may have (especially when you hardcoded the frame size in UIKit). Apart from setting the frame size in UIKit, you can actually set the size unit to a vertex rather than a pixel.

On an iPhone, a point is exactly the same as a pixel, but on an iphone, a point is defined as two pixels. so when you represent the position (10, 10) by a dot, the position is indeed (10, 10) in a normal iphone, and in a high-definition iphone, the position is actually in (20.20 ), so they all appear in the same relative position. Isn't it cool? <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> Coding/coding + 8tjsrvx9sjous7kwizu2jwfx + coding + DQo8cD48aW1nIGFsdD0 = "here write picture description" src = "http://www.bkjia.com/uploads/allimg/151202/0403395M0-1.jpg" title = "/>

So what you want to do is provide other versions for all your images: one normal version and the other high-resolution version. if you name your image at the end of "@ 2x", whenever you try to use [UIImage imageNamed:…] Or similar APIs will automatically load the @ 2x image on the HD screen device when loading an image.

Therefore, it is very easy for the UIKit app to run on the HD screen device-as long as you add @ 2x images, your main work will be completed.

But what about Cocos2D?

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.