Hi, everyone. I have a question about Retina support in Cocos2d-x.
I’m stuck in HelloWorld example - in HelloWorldAppDelegate.mm i’m declared enableRetinaSupport(true) like this:
pDirector~~>setDisplayFPS;
pDirector~~>enableRetinaDisplay(true); //enable retina here
So, as i understand, my resolution now MUST be 960x640, BUT in HelloWorldScene.cpp in line:
CGSize size = CCDirector::sharedDirector()->getWinSize();
i’m still get size variable at 480x320.
When i add HelloWorld-hd.png with 960x640 resolution, it not stretch on screen in Retina mode (as SHOULD), but looks like sprite with lower resolution, with black borders.
Thanks for your post. I checked and found it’s a bug here.
At fist, CCDirector::getWinSize() will always return 480x320 on iPhone. Plz ref to How to develop retina display games in cocos2d by RicardoQuesada.
If you want to get 960x640, you must call CCDirector::sharedDirector()>getWinSizeInPixels
And another hand, thehd suffix in cocos2d-x isn’t work well, I created a bug here #352
You can call
// hi res
CCDirector::sharedDirector()->enableRetinaDisplay(true);
// add "HelloWorld" splash screen"
CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld-hd.png");
to load a 960x480 png manually. After #352 fixed, the aim is the source
// hi res
CCDirector::sharedDirector()->enableRetinaDisplay(true);
// add "HelloWorld" splash screen"
CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png");