labels (CCLabelTTF) are on iphone in different position (higher) than in previous version of cocos

labels (CCLabelTTF) are on iphone in different position (higher) than in previous version of cocos
0.0 0


It is working well on windows, ipad, but on iphone it is higher.
(I used iphone 3G.)

here is used code:

    // background
    CCSprite* background = CCSprite::spriteWithFile(FISHING_DIR"dialog_background.png");
    CCSize backSize = background->getContentSizeInPixels();
    float scale= sizeInPixels.height/768;         // 1 for ipad
    CCRect rect = background->boundingBoxInPixels();

    float leftX = 0.35f;
    float rightX = 0.9f;
    float upY = 0.72f;
    float downY = 0.1f;

        // text sprite
    CCSize dimension = CCSizeMake((rightX-leftX)*background->getContentSize().width * scale, 0);
    CCSprite* textSprite = CCLabelTTF::labelWithString(m_text.c_str(), "Berlin Sans FB Demi", 32*winSize.height/320);
    CCSize textSize = textSprite->getContentSize();

    textSprite->setAnchorPoint(ccp(0.5f, 0.5f));
    addChild(textSprite, 1);                 /////////// <<<<<<<<<<<<<< this sprite is higher <<<<<<<<<<<<<<<<<<<<<<<<<

    float downWeight = 0.4f;
    textSprite->setPosition(ccp(((leftX+rightX)/2-0.5f)* background->getContentSize().width,(downY*downWeight+upY*(1-downWeight)-0.5f)*background->getContentSize().height)); 


I should check for it.


Bug #762 is created.


I confirm this bug which drove me crazy. CCLabelTTF are higher on iPhone/iPad than on Android. I am running cocos2d-1.0.1-x-0.10.0 ; has it been corrected on last version of cocos2d-x ? Thanks !


By the way, Martin: which trick do you use to manage this bug according to the platform you are running on? Thanks


I had to return to version 0.9.1


Info for Cocos2d-x team: the problem is that:

  • when running on iOS device: the text is located at the top of its frame
  • when running on Android: the text is centered vertically in the middle of is frame


Yes. I’ve struggled with this bug last week.

I placed all my labels on the scene on win32. Then when I transfered to XCode IOS, the labels where higher then the ones in win32, almost out of the screen.


I’ve just experienced it in version 2.2.0.

It’s funny, because the labels on iOS6 are higher by 0.2 * font_size pixels, while on iOS7 they are higher only about 0.1.