Class cc.LabelAtlas

Class Summary
Constructor Attributes Constructor Name and Description
 
using image file to print text label on the screen, might be a bit slower than cc.Label, similar to cc.LabelBMFont

Method Summary

Class Detail

cc.LabelAtlas()
using image file to print text label on the screen, might be a bit slower than cc.Label, similar to cc.LabelBMFont

Field Detail

setString
set the display string
updateAtlasValues
Atlas generation

Method Detail

  • addLoadedEventListener(callback, target)
    add texture loaded event listener
    Parameters:
    {Function} callback
    {Object} target
  • <static> {cc.LabelAtlas|Null} cc.LabelAtlas.create(strText, charMapFile, itemWidth, itemHeight, startCharMap)

    It accepts two groups of parameters:
    a) string, fntFile
    b) label, textureFilename, width, height, startChar

    //Example
    //creates the cc.LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas
    var myLabel = cc.LabelAtlas.create('Text to display', 'CharMapfile.png', 12, 20, ' ')
    
    //creates the cc.LabelAtlas with a string, a fnt file
    var myLabel = cc.LabelAtlas.create('Text to display', 'CharMapFile.plist‘);
    Parameters:
    {String} strText
    {String} charMapFile
    charMapFile or fntFile
    {Number} itemWidth Optional, Default: 0
    {Number} itemHeight Optional, Default: 0
    {Number} startCharMap Optional, Default: ""
    Returns:
    {cc.LabelAtlas|Null} returns the LabelAtlas object on success
  • draw(ctx)
    draw the label
    Parameters:
    ctx
  • {String} getString()
    return the text of this label
    Returns:
    {String}
  • {Boolean} initWithString(strText, charMapFile, itemWidth, itemHeight, startCharMap)

    initializes the cc.LabelAtlas with a string, a char map file(the atlas),
    the width and height of each element and the starting char of the atlas
    It accepts two groups of parameters:
    a) string, fntFile
    b) label, textureFilename, width, height, startChar

    Parameters:
    {String} strText
    {String|cc.Texture2D} charMapFile
    charMapFile or fntFile or texture file
    {Number} itemWidth Optional, Default: 0
    {Number} itemHeight Optional, Default: 0
    {Number} startCharMap Optional, Default: ""
    Returns:
    {Boolean} returns true on success
  • setColor(color3)
    Parameters:
    {cc.Color3B} color3
  • {boolean} textureLoaded()
    return texture is loaded
    Returns:
    {boolean}