Label::create is deprecated but why.

78 views
Skip to first unread message

Nite Luo

unread,
Jul 15, 2014, 5:38:21 PM7/15/14
to cocos2d-...@googlegroups.com

Hi

I upgraded some code using old cocos2d-x API to the new one and realized that we have deprecated Label::create(text, font)

I think we should not deprecate that, reason been

  1. API consistency, all the other major Node classes have a functional create()function that is consistant across all cocos2d-x Sprite::create(filename)ParticleSystemQuad::create(filename)Follow::create(node)
  2. Easy to upgrade, LabelTTF and LabelBMFont both have create() function with same signature, it’s really easy and nature for me to upgrade them, just search and replace.
  3. Easy to use, when I create a label, I don’t really care if it’s a system font or it’s a TTF or BMFont, I know I have a font file that contains font info, and I want to use that font to create a label, I think the current API differentiate them is unnecessary, and actually make it harder for developer to understand.

-Nite

Ricardo Quesada

unread,
Jul 15, 2014, 5:40:29 PM7/15/14
to Nite Luo, cocos2d-...@googlegroups.com
What should Label::create() do ?

- should it create a bitmap font, ttf, or decide depending on the file extension ?
- if TTF, what should be its size ?



--
You received this message because you are subscribed to the Google Groups "cocos2d JS development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cocos2d-js-dev...@googlegroups.com.
To post to this group, send email to cocos2d-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

NiTe Luo

unread,
Jul 15, 2014, 5:59:17 PM7/15/14
to Ricardo Quesada, cocos2d-...@googlegroups.com
- should it create a bitmap font, ttf, or decide depending on the file extension ?
Ideally it should decide what to create based on the extension

- if TTF, what should be its size ?
We could have fontSize in constructor too, but either way we should provide an appropriate default value, 14 for example, and we should allow user to specify it with setFontSize() and log warnings if they accidentally set FontSize for BMFont.

-Nite
Reply all
Reply to author
Forward
0 new messages