Does Cocos2d X support multi resolution AND virtual resolution?

Hi guys. First, just want to say what an amazing project! It seems to be coming along really, really well.

I am looking to do my next project as a cross platform one (First was Cocos2d on iOS). However with the variation in resolutions with all these devices now, I wanted to know if C2dX has support for making life with multiple resolutions a little easier.

Things I’d like to know:

  • Can I load from a particular set of resources depending on the resolution of the device?
  • When using atlases, do I have to multiply sizes of sprite rects, or does it take care of all that for me?
  • Can I code my game as if it was a set resolution and have C2dX just scale everything up? For instance, if I wrote my game as if everything was 960x640, and someone ran it on an original iPhone at 480x320, would it all work and would all objects be positioned correctly and the game work correctly?

Essentially I want to be able to scale all drawing by some factor to fit the resolution of the screen and also for screens that have a different aspect ratio to how I want my game to run, can it letterbox or pillar box?

Would love to know the best way to tackle all this.

Cheers

  1. Please take a look at samples/HelloCpp/Classes/AppDelegate.cpp, it’s a good sample of dealing with multi-resolution
  2. Loading different set of resources: @ CCFileUtils::sharedFileUtils()->setResourceDirectory(“particular-folder-name”); @
  3. Multiply sizes and coordinations: @ CCDirector::sharedDirector()->enableRetinaDisplay(true); @
  4. code in a resolution and 2dx scale everything for you: CCEGLView::sharedOpenGLView()->setDesignResolutionSize(960, 640, kResolutionNoBorder);

Take it easy, have fun :stuck_out_tongue:

I have recently joined the “family”, and your posts are helping me a lot, Wang!

I would like to point out that the forums here are the best place to start tackling cocos2d-x, or tackling any problem or bug encountered.

Cheers!