Center Sprites at bottom of screen Cocos2dx

Hi guys. I need a bit of help, migrating into Cocos2d-x is a little bit different from what I expected.

So first this is what I need to accomplish. Align a bunch of CCSprites at the bottom of the screen (centered).

Now first CCDirector winsize is not returning the expected size on iPhone. I know this is because of resoultion independecy so design resoultion is what will be returned. So I used this code to retrieve the windows:

CCPoint visibleOrigin = CCDirector::sharedDirector()>getVisibleOrigin;
CCSize visibleSize = CCDirector::sharedDirector
>getVisibleSize;
Then centering is done in the following way:

float spritesWidth = 0;
for
{
std::string spriteFileName ;
CCSprite *mySprite = CCSprite::create);
//Keep reference to sprites
spritesArray~~>addObject;
spritesWidth = mySprite~~>getContentSize.width;
this~~>addChild;
}
//Scale down sprites if they are bigger than screen
float factor = 1;
//80 is an offset to make it look good
if {
factor = /lettersWidth;
spritesWidth = factor;
CCObject
oneSprite;
CCARRAY_FOREACH
{
oneSprite)>setScale;
}
}
//Centered sprites new origin
float centeredXOrigin = + visibleOrigin.x;
CCObject object;
CCARRAY_FOREACH
{
CCSprite
mySprite = object;
mySprite
>setPosition.size.height / 2)));
centeredXOrigin
= mySprite~~>boundingBox().size.width;
}

This is not working, not sure why. Some sprites are overlapping and they are not centered correctly.

What I’m trying to do is simply add all sprite widths, then scale them and position accordingly. However the visibleOrigin and visibleSize are really confusing me. In fact, resolution independency mechanism confuses me as well. Should I use contentSize or boundingBox? Will it return the size of appropriate file (iPhone,iPad…retina?). Or it will always return the design size?

Need a little bit of explanation and help here. I’m just starting with Cocos2d-x

Thanks a lot.

First, if you set a design resolution, your cocos2d world will be known to be that size now.

but keep in mind, when using show all policy and no border policy, your design resolution ratio might differ from the actual screen width/height ratio.

thus comes the Visible rect, it is the rectangle after the cropping by design resolution and screen width/height ratio.

visible origin will always be moved if you are using show all policy (the bordered one)

please refer to more here http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Multi_resolution_support

This is the link
http://www.cocos2d-x.org/wiki/Multi_resolution_support

and here
http://www.cocos2d-x.org/wiki/Detailed_explanation_of_Cocos2d-x_Multi-resolution_adaptation