Sabha B
Sabha B

Reputation: 2089

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

enter image description here

Screen Shot from iPhone 4 enter image description here

Upvotes: 0

Views: 724

Answers (2)

erkanyildiz
erkanyildiz

Reputation: 13204

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"

Upvotes: 1

user529758
user529758

Reputation:

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.

Upvotes: 1

Related Questions