简体   繁体   中英

Cocos2d v2 CCSprite Background Image dimension

I have created a new Cocos2d project and I deleted the 'Hello World' label. I have added this image (320x480 px) and tested on iPhone 4, here is the result. The image's dimensions have been reduced to 1/4th of their original size, not sure what's going on. I never had this problem before with the previous version.

Source Image

在此输入图像描述

Screen Shot from iPhone 4 在此输入图像描述

The reason is that iPhone 4 and 4S have retina displays - a display with a 4 times higher resolution as the previous models. Cocos2D, as opposed to iOS, doesn't use logical but physical screen sizes - you need to load another image with a 4 times higher resolution on iPhone 4 and 4S.

You should enable retina display if it's not already enabled:

[director enableRetinaDisplay:YES];

And provide the retina version of the background image using the "-hd" suffix.

backgroundImage.png (320 x 480 px)

backgroundImage-hd.png (640 x 960 px)

By the way you can set your own suffix:

#define CC_RETINA_DISPLAY_FILENAME_SUFFIX @"-hd"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM