Cocos2d-x v3 rc1 - Label issues.

Cocos2d-x v3 rc1

in rc0 things looked correct:

in rc1 things dont look correct anymore:

I’m using:

    // label
    cocos2d::LabelBMFont* _label = cocos2d::LabelBMFont::create("", AppConstants::AppFont);
    _label->setAlignment(cocos2d::TextHAlignment::RIGHT);
    _label->setFntFile("Marker Felt Small.fnt");
    _label->setColor(cocos2d::Color3B(105, 190, 83));

    _icon->addChild(_label, 2);
    
    int s = std::string("Harvesting... (99 mins and 30 secs)").size();
    
    _label->setContentSize(cocos2d::Size::Size(s, _background->getContentSize().height / 2));
    
    _label->setPosition((35 * APPDIRECTORINSTANCE->getScaleFactor()) +
                        APPDIRECTORINSTANCE->getMaxIconSize(),
                        _icon->getContentSize().height / 2);


rc0.png (87.7 KB)


rc1.png (118.0 KB)

Suggest you using Label::createWithBMFont substitute LabelBMFont::create.LabelBMFont was re-implemented as a wrapper of Label yet.

What I have noticed in RC1 that the “Anchor Point” of labels set default to “Point::ANCHOR_MIDDLE”

So we do not have to subtract half of content size of the interested side, for example:

In RC0

label->setPositionX(sprite->getPositionX()- label->getContentSize().width * label->getScale()/2)

in RC1 this will do the same thing.

label->setPositionX( sprite->getPositionX() )

@victory144 - Thank you very much. This is perfect.

@slackmoehrle You are welcome :slight_smile:

Please mark it as resolved.

@victory144 - I’m not sure how to mark it as resolved.

@slackmoehrle Maybe just add [Solved] to the title.
Good luck…