CCLabelBMFont error

Hi,

When i init the CCLabelBMFont using labelWithString, it doesn’t show right. I must call setString() again. I think it has some problems with init.

levelLabel = CCLabelBMFont::labelWithString(" “,”ITC_50.fnt“);
levelLabel->setString(”LV.1AAAAAAAAAAAAAA");
You can try to change the space amount.

Yann


ITC_50.fnt.zip (2.4 KB)


ITC_50.png (24.8 KB)

A bug in CCLabelBMFont::labelWithString is just fix in the last Friday
Bug #668, and the diff http://www.cocos2d-x.org/projects/cocos2d-x/repository/revisions/a84ba6d059275b5626a31005e929d40bfd2a875e/diff/cocos2dx/label_nodes/CCLabelBMFont.cpp

But I’m not sure if this can help you.
Which platform do you run the code,
* iOS in RetinaMode?
* iOS without RetinaMode?
* Android with auto-scale enabled?
* Android without auto-scale enabled?

hi walzer,
I’m run in IOS Retina. My friend has the same problem with android, But i don’t know about auto-scale. I will try your fix, if have any problem I will tell you.

Best
Yann

It’s mainly caused by

line492, fontChar~~>initWithBatchNode;
which should be
bq. fontChar~~>initWithBatchNodeRectInPixels(this, rect);

Wish you a good luck!

Yann Zhao
You should not use CCLabelBMFont with ttf files. You should offer png file to CCLabelBMFont. ttf files work with CCLabelTTF.

hi walzer,

It’s fixed. Thanks a lot.

I think Minggo misunderstand me.

Best
Yann