Class cc.LabelTTF

Class Summary
Constructor Attributes Constructor Name and Description
 
cc.LabelTTF is a subclass of cc.TextureNode that knows how to render text labels
All features from cc.TextureNode are valid in cc.LabelTTF
cc.LabelTTF objects are slow for js-binding on mobile devices.Consider using cc.LabelAtlas or cc.LabelBMFont instead.

Method Summary

Class Detail

cc.LabelTTF()
cc.LabelTTF is a subclass of cc.TextureNode that knows how to render text labels
All features from cc.TextureNode are valid in cc.LabelTTF
cc.LabelTTF objects are slow for js-binding on mobile devices.Consider using cc.LabelAtlas or cc.LabelBMFont instead.
Consider using cc.LabelAtlas or cc.LabelBMFont instead.

Field Detail

{Boolean} initWithStringAndTextDefinition
initializes the CCLabelTTF with a font name, alignment, dimension and font size
setFontFillColor
set text tinting

Method Detail

  • <static> {cc.LabelTTF|Null} cc.LabelTTF.create(label, fontName, fontSize, dimensions, hAlignment, vAlignment)
    creates a cc.LabelTTF from a font name, alignment, dimension and font size
    // Example
    var myLabel = cc.LabelTTF.create('label text',  'Times New Roman', 32, cc.size(32,16), cc.TEXT_ALIGNMENT_LEFT);
    Parameters:
    {String} label
    {String} fontName
    {Number} fontSize
    {cc.Size} dimensions Optional, Default: cc.SIZE_ZERO
    {Number} hAlignment Optional
    {Number} vAlignment Optional, Default: cc.VERTICAL_TEXT_ALIGNMENT_TOP
    Returns:
    {cc.LabelTTF|Null}
  • <static> {cc.LabelTTF|Null} cc.LabelTTF.createWithFontDefinition(text, textDefinition)
    Create a label with string and a font definition
    Parameters:
    {String} text
    {cc.FontDefinition} textDefinition
    Returns:
    {cc.LabelTTF|Null}
  • ctor()
    Constructor
  • {String} description()
    Prints out a description of this class
    Returns:
    {String}
  • disableShadow(mustUpdateTexture)
    disable shadow rendering
    Parameters:
    {Boolean} mustUpdateTexture Optional, Default: false
    This parameter is not used. It's kept for cocos2d-x JSB compatibility
  • disableStroke(mustUpdateTexture)
    disable stroke
    Parameters:
    {Boolean} mustUpdateTexture Optional, Default: false
    This parameter is not used. It's kept for cocos2d-x JSB compatibility
  • enableShadow(shadowOffset, shadowOpacity, shadowBlur, mustUpdateTexture)
    enable or disable shadow for the label
    Parameters:
    {cc.Size} shadowOffset
    {Number} shadowOpacity
    (0 to 1)
    {Number} shadowBlur
    {Boolean} mustUpdateTexture Optional, Default: false
    This parameter is not used. It's kept for cocos2d-x JSB compatibility
  • enableStroke(strokeColor, strokeSize, mustUpdateTexture)
    enable or disable stroke
    Parameters:
    {cc.Color3B} strokeColor
    {Number} strokeSize
    {Boolean} mustUpdateTexture Optional, Default: false
    This parameter is not used. It's kept for cocos2d-x JSB compatibility
  • {cc.Size} getDimensions()
    return Dimensions of cc.LabelTTF
    Returns:
    {cc.Size}
  • {String} getFontName()
    return font name of cc.LabelTTF
    Returns:
    {String}
  • {Number} getFontSize()
    return font size of cc.LabelTTF
    Returns:
    {Number}
  • return Horizontal Alignment of cc.LabelTTF
    Returns:
    {cc.TEXT_ALIGNMENT_LEFT|cc.TEXT_ALIGNMENT_CENTER|cc.TEXT_ALIGNMENT_RIGHT}
  • {String} getString()
    returns the text of the label
    Returns:
    {String}
  • {cc.FontDefinition} getTextDefinition()
    get the text definition used by this label
    Returns:
    {cc.FontDefinition}
  • return Vertical Alignment of cc.LabelTTF
    Returns:
    {cc.VERTICAL_TEXT_ALIGNMENT_TOP|cc.VERTICAL_TEXT_ALIGNMENT_CENTER|cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM}
  • {Boolean} initWithString(label, fontName, fontSize, dimensions, hAlignment, vAlignment)
    initializes the cc.LabelTTF with a font name, alignment, dimension and font size
    Parameters:
    {String} label
    string
    {String} fontName
    {Number} fontSize
    {cc.Size} dimensions Optional
    {Number} hAlignment Optional
    {Number} vAlignment Optional
    Returns:
    {Boolean} return false on error
  • setDimensions(dim)
    set Dimensions of cc.LabelTTF
    Parameters:
    {cc.Size} dim
  • setFontName(fontName)
    set font name of cc.LabelTTF
    Parameters:
    {String} fontName
  • setFontSize(fontSize)
    set font size of cc.LabelTTF
    Parameters:
    {Number} fontSize
  • setHorizontalAlignment(alignment)
    set Horizontal Alignment of cc.LabelTTF
    Parameters:
    {cc.TEXT_ALIGNMENT_LEFT|cc.TEXT_ALIGNMENT_CENTER|cc.TEXT_ALIGNMENT_RIGHT} alignment
    Horizontal Alignment
  • setString(text)
    changes the string to render
    Parameters:
    {String} text
    text for the label
  • setTextDefinition(theDefinition)
    set the text definition used by this label
    Parameters:
    {cc.FontDefinition} theDefinition
  • setVerticalAlignment(verticalAlignment)
    set Vertical Alignment of cc.LabelTTF
    Parameters:
    {cc.VERTICAL_TEXT_ALIGNMENT_TOP|cc.VERTICAL_TEXT_ALIGNMENT_CENTER|cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM} verticalAlignment