Class Index | File Index

Classes


Class cc.LabelBMFont


Extends cc..

Defined in: CCLabelBMFont.js.

Class Summary
Constructor Attributes Constructor Name and Description
 

cc.LabelBMFont is a subclass of cc.SpriteSheet.

Method Summary
Method Attributes Method Name and Description
<static>  
cc.LabelBMFont.create(str, fntFile, width, alignment, imageOffset)
creates a bitmap font altas with an initial string and the FNT file
 
updates the font chars based on the string to render
 
draw(ctx)
 
conforms to cc.RGBAProtocol protocol
 
 
conforms to cc.RGBAProtocol protocol
 
get the text of this label
 
init()
init LabelBMFont
 
initWithString(str, fntFile, width, alignment, imageOffset)
init a bitmap font altas with an initial string and the FNT file
 
conforms to cc.RGBAProtocol protocol
 
setAlignment(alignment)
Set text vertical alignment
 
set the anchorpoint of the label
 
setColor(Var)
tint this label
 
setCString(label)
 
setFntFile(fntFile)
set fnt file path
 
setLineBreakWithoutSpace(breakWithoutSpace)
 
set the opacity of this label
 
 
setScale(scale, scaleY)
 
setScaleX(scaleX)
 
setScaleY(scaleY)
 
setString(newString, fromUpdate)
set the text
 
setWidth(width)
 
update Label
 
updateString(fromUpdate)
update String
Class Detail
cc.LabelBMFont()

cc.LabelBMFont is a subclass of cc.SpriteSheet.

Features:

  • - Treats each character like a cc.Sprite. This means that each individual character can be:
  • - rotated
  • - scaled
  • - translated
  • - tinted
  • - chage the opacity
  • - It can be used as part of a menu item.
  • - anchorPoint can be used to align the "label"
  • - Supports AngelCode text format

Limitations:
- All inner characters are using an anchorPoint of (0.5, 0.5) and it is not recommend to change it because it might affect the rendering

cc.LabelBMFont implements the protocol cc.LabelProtocol, like cc.Label and cc.LabelAtlas.
cc.LabelBMFont has the flexibility of cc.Label, the speed of cc.LabelAtlas and all the features of cc.Sprite.
If in doubt, use cc.LabelBMFont instead of cc.LabelAtlas / cc.Label.

Supported editors:
http://glyphdesigner.71squared.com/ (Commercial, Mac OS X)
http://www.n4te.com/hiero/hiero.jnlp (Free, Java)
http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java)
http://www.angelcode.com/products/bmfont/ (Free, Windows only)

Method Detail
<static> {cc.LabelBMFont|Null} cc.LabelBMFont.create(str, fntFile, width, alignment, imageOffset)
creates a bitmap font altas with an initial string and the FNT file
// Example 01
var label1 = cc.LabelBMFont.create("Test case", "test.fnt");

// Example 02
var label2 = cc.LabelBMFont.create("test case", "test.fnt", 200, cc.TEXT_ALIGNMENT_LEFT);

// Example 03
var label3 = cc.LabelBMFont.create("This is a \n test case", "test.fnt", 200, cc.TEXT_ALIGNMENT_LEFT, cc.PointZero());
Parameters:
{String} str
{String} fntFile
{String} width
{Number} alignment
{Number} imageOffset
Returns:
{cc.LabelBMFont|Null}

createFontChars()
updates the font chars based on the string to render

draw(ctx)
Parameters:
{CanvasContext} ctx

{cc.Color3B} getColor()
conforms to cc.RGBAProtocol protocol
Returns:
{cc.Color3B}

{String} getFntFile()
Returns:
{String}

{Number} getOpacity()
conforms to cc.RGBAProtocol protocol
Returns:
{Number}

{String} getString()
get the text of this label
Returns:
{String}

init()
init LabelBMFont

{Boolean} initWithString(str, fntFile, width, alignment, imageOffset)
init a bitmap font altas with an initial string and the FNT file
Parameters:
{String} str
{String} fntFile
{String} width
{Number} alignment
{Number} imageOffset
Returns:
{Boolean}

{Boolean} isOpacityModifyRGB()
conforms to cc.RGBAProtocol protocol
Returns:
{Boolean}

setAlignment(alignment)
Set text vertical alignment
Parameters:
{Number} alignment

setAnchorPoint(point)
set the anchorpoint of the label
Parameters:
{cc.Point} point

setColor(Var)
tint this label
Parameters:
{cc.Color3B} Var

setCString(label)
Parameters:
label

setFntFile(fntFile)
set fnt file path
Parameters:
{String} fntFile

setLineBreakWithoutSpace(breakWithoutSpace)
Parameters:
{Boolean} breakWithoutSpace

setOpacity(Var)
set the opacity of this label
Parameters:
{Number} Var

setOpacityModifyRGB(Var)
Parameters:
{Boolean} Var

setScale(scale, scaleY)
Parameters:
{Number} scale
scaleY

setScaleX(scaleX)
Parameters:
{Number} scaleX

setScaleY(scaleY)
Parameters:
{Number} scaleY

setString(newString, fromUpdate)
set the text
Parameters:
newString
fromUpdate

setWidth(width)
Parameters:
{Number} width

updateLabel()
update Label

updateString(fromUpdate)
update String
Parameters:
{Boolean} fromUpdate

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Jan 09 2013 07:51:51 GMT-0800 (PST)