Supporting multiple resolutions with Cocos2d-x and Marmalade

Supporting multiple resolutions with Cocos2d-x and Marmalade
0.0 0


Thanks to Giovanni Zito and Francis Styck’s and their support for the marmalade side of Cocos2d-x I have pretty much got my android port good to go but I have a few questions regarding supporting different screen resolutions.

Whats the best way of handling this via marmalade and cocos2d-x? Is the best way to have different asset sets and on startup loading in the relevant one for that screen size? My current graphics work fine on a HTC Wildfire S but as soon as I load the game on something like a Samsung Wave it only takes up a quarter of the screen. I wasn’t sure what the proper workflow was and guess its quite a common question.



Hi Dave,

I think there are many approaches to this and you will have to find the one that best fits what you are comfortable with.

There are a couple of threads in one of the forums here that discuss some solutions and many outside this forum, a few are below.



Specific to Marmalade:




Cheers Francis, I know its not ideal but I have just used the graphics from my iOS version and using the screen width I scale the graphics to fit.

This works fine with slight black borders on all the devices I have tested on which is fine and as I would expect but I just cant get the graphics to position themselves correctly in Y. I use a similar function to what I do on iPad:

CCPoint MainMenu::screenPosition(CCPoint iPhonePos) { CCPoint pos = iPhonePos; if( CCDirector::sharedDirector()->getDisplaySizeInPixels().width > 320) { float scaleX = CCDirector::sharedDirector()->getDisplaySizeInPixels().width/320; float scaleY = CCDirector::sharedDirector()->getDisplaySizeInPixels().height/480; //scale point to device pos = ccp(iPhonePos.x * scaleX, iPhonePos.y * scaleY); } return pos; }

This works fine in X but stretches out in Y, I am guessing I am missing something obvious but can’t put my finger on it. Any ideas? Once this is fixed my game is good to go :slight_smile:



The simplest method that I found is to add all of the objects to a “root” node, then scale this node based on your “design resolution” and the actual resolution. For a project that I am currently working on that is what we’ve done. We’ve designed for the iPad and then scaled the “root” node down for the iPhone/iPod Touch. Very easy and we haven’t run into any memory issues yet.