[Widgets] Label
Adding A Label
Drag a Label from the Widgets section onto the middle canvas.

Selecting The Label
You can select the Label if it isn't already selected from the Animation Editor at the bottom. The Label doesn't appear in the resources as it's part of the Scene or other object that you are using.

Modifying The Label
You can change the Label font file. Setting the Label's font file can be done by double clicking on the section or dragging an image from the Resources section.

Accessing The Label In Code
Label's can be accessed via their Name or Tag which can be set in the Properties section.

To access the Label from a scene for example, in code it is simple. You either access it as a Node or cast it to a Label allowing you to use Label methods along with Node methods.
Node *rootNode = CSLoader::createNode( "Filepath to .csb file" );
this->addChild( rootNode );
// label accessed as a node using it's name
Node *label = rootNode->getChildByName( "Name set in Cocos Studio" );
// label cast to a label using it's name
cocos2d::ui::Text *label = ( cocos2d::ui::Text * )rootNode->getChildByName( "Name set in Cocos Studio" );
// label accessed as a node using it's tag
Node *label = rootNode->getChildByTag( 5 );
// label cast to a label using it's tag
cocos2d::ui::Text *label = ( cocos2d::ui::Text * )rootNode->getChildByTag( 5 );
var rootNode = ccs.load( "Filepath to .json file" );
this.addChild( rootNode.node );
// get the label by name
var label = rootNode.node.getChildByName( "Name set in Cocos Studio" );
// get the label by tag
var label = rootNode.node.getChildByTag( 5 );
Note: Cocos2d-JS doesn't require casting to use Label methods.
Updated about 2 months ago