c++cocos2d-xlagoutlinecclabelttf

Cocos2d-x CCLabelTTF enableStroke is time consuming


We're developing iOS application and encountered a problem with labels' outlines.

It seems, that creating outlines(for 20-30 labels) takes more time now, than anything else. The creating lag is about 2-3 seconds, what is too long.

Can anyone say what solution we could use, or why it is so?

Instruments' screen:

enter image description here

Thanks in advance


Solution

  • If the label's text needs to change at runtime, consider using bitmap fonts with pre-rendered outlines. Or create all labels up-front and re-use them if their text doesn't change.

    You'll find an explanation as to why changing text as well as shadow/outline properties are slow in the CCLabelTTF class reference (for Cocos2D-Swift but the same applies to cocos2d-x) and the Labels section in the dev guide (same here).

    Specifically consider that changing font size or padding enlarges the label's texture and that alone can increase the time it takes to render shadow/outline. So does changing the size of the shadow/outline itself. It needn't necessarily be because the font rendering in cocos2d-x might have changed.