Working with multi screen resolution in Android

I have these questions

1. Is it able to create an Android game which can run in multi screen resolution with Cocos2d-x?

2. If yes, how can I do? - Do I need all resources such as images, sprites for all screen resolution? For example, when I create sprite, it requires the rect size, so how can I get the exact size for the specific screen? - How can I tell Cocos2d-x know which the screen use its type of resources?

Thanks all! :slight_smile:

In big shortcut:

  1. I use CocosBuilder to publish resources for multi-screen resolution.
  2. I modified AppDelegate.cpp to use fixed resources path for every resolution.
  3. If you use texturePacker and .plist files, you have to put proper files to proper directiories (for example images.plist & images-hd.png files to resources-large).
    Try this: http://2sa-studio.blogspot.fr/2013/04/setup-cross-platform-project-with.html

There are a number of ways, one is setting the design resolution - see this tutorial :

The way I like to do it is to make 3 sets of artwork, using 960 x 640 as a “base”. One set is for the base, one for 2x base and one 0.5x base.

Then on appstartup, I have a GameManager singleton class, and that takes the visible size from the CCDirector.

Depending on the size, I set a file suffix for which graphic set I want to use, and I also set various parameters, such as scaleX, scaleY, offsetX, offsetY.

All this is initialised on startup.

Then when initialising items on the screen, their initial scalefactors are set using ScaleX and ScaleY, and their positions using ScaleXx + OffsetX,ScaleYy + OffsetY.

I did this when porting an iPhone game, and it worked fine.

The really good thing, as the post above points out, is that cocos2d-x has windows & mac projects where you can set the resolution in the app-controlller which makes it quick to test different screens.

Hello Richard Allbert. Thank you for useful reply.
I have a little question.
You said convert position using scale_x + offset_x, scale_y + offset_y, but isnt it scale_x * offset_x, scale_y * offset_y? (I’m really wondering about it.)

Richard Allbert wrote:

Then when initialising items on the screen, their initial scalefactors are set using ScaleX and ScaleY, and their positions using ScaleXx + OffsetX,ScaleYy + OffsetY.

Sorry, my post read badly.

Should have been scaleX * x + offsetx etc