2.0.4 MultiResolution kResolutionShowAll policy help [Solved]

2.0.4 MultiResolution kResolutionShowAll policy help [Solved]
0.0 0


I am using 2.0.4 Multi resolution functionality and i must say it is a great enhancement to cocos2dx…
I need one help for kResolutionShowAll

In my project it is ok in ipad retina and non retina…
In Android devices in most of the devices it is scaling based on device resolution and keeping all resources in mid screen which is just as expected…

So in android is there any way to put one background image to cover whole screen and other component as that kResolutionShowAll…

Just want to cover blank part of the screen in such devices…

Thank you

androidbackground.png (26.8 KB)

Background of SHOW_ALL

I think you can offer a big background picture to cover whole screen on all devices.


Thank you very much for the response @Minggo Zhang…
I have tried to put big image but as per this policy that big image also scales to fit its edges and that blank part left as it is…
For temporary solution i have changed displayResolution Policy in android to some different value (960 x 640) but that only reduced some of the blank part but not fitting in the real solution…
So still trying some solution…

Thank you


I’ve tried kResolutionShowAll too, Viraj is right. There is no way to fill the black borders with an image… It should be great and very practically to have possibility to cover the side border with a custom background…


Also seeking this functionality. I have a background that scales nicely, and would like to stretch it over the whole screen and letterbox the content.
Are there any other solutions? Or stuck with black bars / letterboxing everything?


What’s the size of your background music?
What’ the resolution you set?
What’s the screen size?


Hi Minggo, in my case it’s:

  • Background image is set to full screen scale (set my scaleX/Y really high to stretch as far as possible)
  • Design res is 320x480
  • Device res is 640x1136 (iPhone 5)

So what we’re looking for is a background that scales the full screen (i.e. outside of design resolution aspect), while the content is still tied to the design resolution.
At the moment there’s no way to specify a background that scales the whole device rather than just the aspect.

It’d be nice to be able to position the content to the top / middle or bottom of the screen as well dependant on configuration.


In hybrid app of ipad and android tablet :
(Same display resolution for both)

Background image :
2048 x 1536 / 1024 x 768

Display Resolution :
1024 x 768

Screen Size(Android) :
800 x 480 // Black part on edges
1200 x 800 // Black part on edges

Different app :

Background image :
2048 x 1536 / 1024 x 768

Display Resolution :
960 x 640

Screen Size(Android) :
800 x 480 // less black part on edges
1200 x 800 // less black part on edges


Viraj, Daniel,

I have quick solution. It’s not perfect but it’s working in my game. I added new CCSprite object to CCDirector to draw background. So, add two new members to CCDirector.h:

void setBackground(const char *bg); // to public section
CCSprite* m_Background; // to private section

Then add implementation of setBackground to CCDirector.cpp:

void CCDirector::setBackground(const char *bg)
    if (m_Background)

    if (bg == NULL) {
        m_Background = NULL;

    m_Background = CCSprite::create(bg);

    CCSize cs = m_Background->getContentSize();
    m_Background->setPosition(ccp(cs.width / 2.0f, cs.height / 2.0f));

Don’t forget to setup m_Background to the NULL, e.g. in ctor of CCDirector:

    m_Background = NULL;

Finally, insert drawing code for m_Background in CCDirector. The best place should be immediately above kmGLPushMatrix in CCDirector::drawScene:

// Draw the Scene
void CCDirector::drawScene(void)
    // calculate "global" dt

    //tick before glClear: issue #533
    if (! m_bPaused)


    /* to avoid flickr, nextScene MUST be here: after tick and before draw.
     XXX: Which bug is this one. It seems that it can't be reproduced with v0.9 */
    if (m_pNextScene)

    if (m_Background) {
        ResolutionPolicy rp = m_pobOpenGLView->getResolutionPolicy();
        CCSize rs = m_pobOpenGLView->getDesignResolutionSize();
        if (rp == kResolutionShowAll) {
            CCSize cs = m_Background->getContentSize();
            m_pobOpenGLView->setDesignResolutionSize(cs.width, cs.height, kResolutionNoBorder);
            m_pobOpenGLView->setDesignResolutionSize(rs.width, rs.height, rp);


    // draw the scene
    if (m_pRunningScene)

    // draw the notifications node
    if (m_pNotificationNode)

    if (m_bDisplayStats)



    // swap buffers
    if (m_pobOpenGLView)

    if (m_bDisplayStats)

I hope, it will help…



Perfect solution as i wanted…
Thanks a lot @Josef