2

I have strange problem in cocos2d v3, probably some misconfiguration which I was unable to find in google.

I'm adding background for iphone5 which is 640X1136

CCSprite *background = [CCSprite spriteWithImageNamed:@"background_iphone5.png"];
background.positionType = CCPositionTypeNormalized;
background.position = ccp(0.5f, 0.5f); 
[self addChild:background];

but it is scaled up about 2x times so doesn't fits the screen. Same image worked perfectly in cocos2d v2

Please help

James Webster
  • 31,873
  • 11
  • 70
  • 114
Grixol
  • 63
  • 5
  • I think you have to add the necessary suffix. Check out this answer for naming conventions : http://stackoverflow.com/questions/22286153/multiple-screen-resolution-support-in-cocos2d-v3 . This is probably a feature because if you do not include the hd image than you would want your images to scale up. – Tibor Udvari Mar 25 '14 at 18:13
  • Cool. I will add an answer in order for other people experiencing similar issues in the future to be able to get the info faster. – Tibor Udvari Mar 26 '14 at 21:24

1 Answers1

1

Cocos2d, like UIKits @2x uses suffixes to differentiate images intended for different screen sizes and resolutions.

These are the ones used by Cocos2d :

  • ipad
  • ipadhd
  • hd
  • iphone5hd

So you would have to add the appropriate image for your display with the suffix into your bundle like background_iphone5.png.

In your use case Cocos2d is resizing your non-retina image to a retina size (2x height, 2x width).

For consistency reasons this is a desired behaviour. Consider the case of somebody not non-retina resources exclusively: all the sprites would be 2 times smaller on retina displays, which would probably get your game logics out of whack.

I highly suggest using SpriteBuiler because all this resizing and naming behaviour is integrated into the tool and works seamlessly. You only create retina ipad resolution images and it resizes them for you automatically.

Tibor Udvari
  • 2,932
  • 3
  • 23
  • 39