cocos2d iOS Tour: How to write a gopher game (a): HD screen display and Uikit

Source: Internet
Author: User
Tags gopher uikit

Panda Pig • Patty original or translated works. Welcome reprint, Reprint please indicate the source.
If you feel that the writing is not good please tell me, if you feel good please support a lot of praise. Thank you! Hopy;)

Disclaimer: All translations provided by this blog are from the Internet and are for learning and communication purposes only. Also, do not remove this statement when reproduced. In case of any dispute, there is no relationship between the blogger and the person who published the translation. Thank you for your cooperation!

Originally written by Ray Wunderlich, the address is:

Http://www.raywenderlich.com/2560/cocos2d-tutorial-for-ios-how-to-create-a-mole-whacking-game-part-1

The translation of cats and pigs has limitations, but does not affect the overall understanding of the project, thanks to Reading;]

Prepare material: Overview

Because we want this game to run on a regular iphone, HD screen iphone and ipad, so we need to take some time to do some careful planning: how to set up the game footage before we continue.

To understand how to fit the dimensions and set the footage, we need to first cover 3 topics:

    • HD Screen display and Uikit
    • HD Screen display and cocos2d
    • Ipad,iphone and screen aspect ratio

Let's get started!

HD Screen display and Uikit

The difference between the ordinary iphone and the HD screen iphone is that it can display twice times as many pixels. So (in a horizontal screen) as an alternative to the normal screen 480x320 px, the HD screen has a resolution of 960x640 pixels.

"But wait a minute," You might think, "Why does doubling the pixel don't make the app that was written for 480x320 pixels a problem?", it might have (especially when you hardcode the frame size in uikit), except when you set the frame size in Uikit, You can actually set the dimension units to dots instead of pixels.

On a regular iphone, a point is exactly equal to one pixel, but on an HD screen iphone, a point is defined as 2 pixels. So when you point to the position (10,10), in the normal iphone the position is indeed (10,10), And in the HD iphone the location is actually (20.20), so they all appear in the same relative position, cool isn't it?

When you use Apple's space or core graphics, Apple has helped you write code that makes things beautiful and simple on a high-definition screen.

The real magic is when you use a picture. For example, you use a 200x200 image in an iphone app. If you don't do anything in the HD screen it will just enlarge the image to twice times the size-it doesn't look good because you don't get any benefit from high resolution.

So what you're going to do is provide the other versions for all your pictures: one regular version and one for the high-resolution version. If you use the "@2x" end to name your picture, whenever you try to use [UIImage imagenamed: ...] or similar APIs when loading a picture, it will automatically load the @2x image on the HD screen device.

So it's easy to make the Uikit app run on a high-definition screen-just add the @2x picture and your main job is done.

But on the cocos2d?

cocos2d iOS Tour: How to write a gopher game (a): HD screen display and Uikit

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.