setDesignResolution on Retina devices

setDesignResolution on Retina devices
0.0 0



I’ve a Cocos2D-X project for which I used a Design Resolution of 1900x1200. What I want to accomplish is that on Retina devices the 1900x1200 is scaled down/up to the native retina resolution (i.e. 960x640 on iphone and not to 480x320).

I’ve been playing with and I’m pretty sure it is possible, but I did not manage to get it to work yet. What changes do I need to make to the Cocos2d-x sources to get this to work ?

Rgds. Pinky


I managed to get it to work (the plus being that I now can just design in high res and have the game scale down on smaller screens, which is ok for the type of app I’m working on):

In add just after the creation of the EAGLView:
@ if ([**glView respondsToSelector:selector(setContentScaleFactor:)]) __glView.contentScaleFactor = 2.0;

In AppDelegate.cpp don’t call pDirector->enableRetinaDisplay(true) , just call:
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(1900, 1200, kResolutionShowAll);
In CCEGLViewProtocol.cpp change :
pTouch->setTouchInfo(nUnusedIndex, (x - m_obViewPortRect.origin.x) / (m_fScaleX), (y - m_obViewPortRect.origin.y) / (m_fScaleY));

pTouch->setTouchInfo(nUnusedIndex, (x*2 - m_obViewPortRect.origin.x) / (m_fScaleX), (y*2 - m_obViewPortRect.origin.y) / (m_fScaleY));

That’s is (I think). On all platforms the game now runs in the a scaled down (or up, when the screen is larger than 1900x1200).