Worked on hours on LabelBMFont to much frustration
A couple of questions I have:
- It works fine if we purposed it as… well… a label. The problem arises when I’ve tried to use labelBMFont in a menu. The text refuses to be aligned centrally. I tried the following despite being an otiose attempt:
-
initializing labelBMFont with the default calls and even the following:
var label = cc.LabelBMFont.create("label text",s_pixel_fnt, winSize.width, cc.TEXT_ALIGNMENT_CENTER);
<— regardless, my labels are aligned LEFT. -
Also, with labelTTF, the menu is nicely positioned in the center. When I use labelBMFont and wrap it around menuItemLabel, the menu is no longer the center of the screen but shifted to the right, making half of the menu not visible. I’ve attached an image to let the pics do the talking. the issue is revolved when I setPosition (0, winSize.height/2) but this seems a bit more of rushed fix. Regardless, text is still not centrally aligned.
-
When I call contentSize on the label, it returns 0. Does labelBmFont not have any physical sizing?
-
not sure if this is the result of the previous issue raised: i am unable to click on any of the labels to trigger the callback. I was able to click - and even have a nice zoomed in animation - with LabelTTF in menu.
-
I’ve also experimented with MenuItemFontAtlas. I thought this would be the perfect approach with .fnt files - generated using BMFont app.
var continueGame = cc.MenuItemAtlasFont.create("Continue", s_pixel_fnt, 32, 32, ' ',this.onContinueLastGame, this);
However, the console states "cocos2d:Failed loading resource: res/pixel.fnt
This got me confused. If the resource failed to load, how was I able to generate the title with s_pixel_fnt?
Sorry for the long post. It is a testimony of the number of hours I’ve spent on fonts and menu alone
Please help
Decki
issue.PNG (15.4 KB)