Class CCLabelTTF

#include <Geode/cocos/label_nodes/CCLabelTTF.h>
classCCLabelTTF:publiccocos2d::CCSprite,publiccocos2d::CCLabelProtocol{ ... }

CCLabelTTF is a subclass of CCTextureNode that knows how to render text labels

All features from CCTextureNode are valid in CCLabelTTF

CCLabelTTF objects are slow. Consider using CCLabelAtlas or CCLabelBMFont instead.

Custom ttf file can be put in assets/ or external storage that the Application can access.

Examples1
CCLabelTTF *label1 = CCLabelTTF::create("alignment left", "A Damn Mess", fontSize, blockSize, 
                                         kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
CCLabelTTF *label2 = CCLabelTTF::create("alignment right", "/mnt/sdcard/Scissor Cuts.ttf", fontSize, blockSize,
                                         kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
Public static methods5
staticcocos2d::CCLabelTTF*create(,
charconst*fontName
,
floatfontSize
)

Since v2.0.1

creates a CCLabelTTF with a font name and font size in points

staticcocos2d::CCLabelTTF*create(,
charconst*fontName
,
floatfontSize
,,)

Since v2.0.1

creates a CCLabelTTF from a fontname, horizontal alignment, dimension in points, and font size in points.

staticcocos2d::CCLabelTTF*create(,
charconst*fontName
,
floatfontSize
,,,)

Since v2.0.1

creates a CCLabel from a fontname, alignment, dimension in points and font size in points

staticcocos2d::CCLabelTTF*createWithFontDefinition(,)

Create a lable with string and a font definition

staticcocos2d::CCLabelTTF*create()

Creates an label.

Public member functions25
charconst*description()
No description provided
boolinitWithString(,
charconst*fontName
,
floatfontSize
)

initializes the CCLabelTTF with a font name and font size

boolinitWithString(,
charconst*fontName
,
floatfontSize
,,)

initializes the CCLabelTTF with a font name, alignment, dimension and font size

boolinitWithString(,
charconst*fontName
,
floatfontSize
,,,)

initializes the CCLabelTTF with a font name, alignment, dimension and font size

boolinitWithStringAndTextDefinition(,)

initializes the CCLabelTTF with a font name, alignment, dimension and font size

voidsetTextDefinition()

set the text definition used by this label

cocos2d::ccFontDefinition*getTextDefinition()

get the text definition used by this label

voidenableShadow(,
floatshadowOpacity
,
floatshadowBlur
,
boolmustUpdateTexture
)

enable or disable shadow for the label

voiddisableShadow(
boolmustUpdateTexture
)

disable shadow rendering

voidenableStroke(,
floatstrokeSize
,
boolmustUpdateTexture
)

enable or disable stroke

voiddisableStroke(
boolmustUpdateTexture
)

disable stroke

voidsetFontFillColor(,
boolmustUpdateTexture
)

set text tinting

virtualboolinit()

initializes the CCLabelTTF

virtualvoidsetString()

changes the string to render

⚠️ Changing the string is as expensive as creating a new CCLabelTTF. To obtain better performance use CCLabelAtlas

virtualcharconst*getString()
No description provided
cocos2d::CCTextAlignmentgetHorizontalAlignment()
No description provided
voidsetHorizontalAlignment()
No description provided
cocos2d::CCVerticalTextAlignmentgetVerticalAlignment()
No description provided
voidsetVerticalAlignment()
No description provided
cocos2d::CCSizegetDimensions()
No description provided
voidsetDimensions()
No description provided
floatgetFontSize()
No description provided
voidsetFontSize(
floatfontSize
)
No description provided
charconst*getFontName()
No description provided
voidsetFontName(
charconst*fontName
)
No description provided
Fields0
Protected member functions2
void_updateWithTextDefinition(,
boolmustUpdateTexture
)

set the text definition for this label

cocos2d::ccFontDefinition_prepareTextDefinition(
booladjustForResolution
)
No description provided
Protected fields14
cocos2d::CCSizem_tDimensions
;

Dimensions of the label in Points

;

The alignment of the label

;

The vertical alignment of the label

gd::string*m_pFontName
;

Font name used in the label

floatm_fFontSize
;

Font size of the label

gd::stringm_string
;

label’s string

boolm_shadowEnabled
;

font shadow

cocos2d::CCSizem_shadowOffset
;
No description provided
floatm_shadowOpacity
;
No description provided
floatm_shadowBlur
;
No description provided
boolm_strokeEnabled
;

font stroke

cocos2d::ccColor3Bm_strokeColor
;
No description provided
floatm_strokeSize
;
No description provided
cocos2d::ccColor3Bm_textFillColor
;

font tint