Coordinate and positioning problem on iOS with cocos2d-x

Posted by Vexille on Game Development See other posts from Game Development or by Vexille
Published on 2013-07-09T15:31:54Z Indexed on 2013/10/28 22:15 UTC
Read the original article Hit count: 251

Filed under:
|
|

I'm using cocos2d-x alongside with Marmalade and running some tests and tutorials before starting an actual project with them. So far things are working reasonably well on the windows simulator, Android and even on Blackberry's Playbook, but on iOS devices (iPhone and iPad) the positioning seems to be off.

To make things clearer, I put together a scene that just draws an image in the middle of the screen. It worked as expected on everything else, but this is the result I got on an iPhone:

Resized iPhone Screenshot

To get the coordinates for the center of the screen I'm using the VisibleRect class from the TestCpp sample. It just uses sharedOpenGLView to get the visible size and visible origin, and calculate the center from that.

CCSprite* test = CCSprite::create("Ball.png", CCRectMake(0, 0, 80, 80) );
test->setPosition( ccp(VisibleRect::center().x, VisibleRect::center().y) );

this->addChild(test);

Also I have a noBorder policy set on AppDelegate:

CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);

One funny thing is that I tried to deploy the TestCpp sample project to some iOS devices and it worked reasonably well on the iPhone, but on the iPad the application was only being drawn on a small portion of the screen - just like what happened on the iPhone when I tried using the ShowAll policy.

© Game Development or respective owner

Related posts about ios

Related posts about cocos2d-x