{"_id":"547b1cc57eec0f080099e1e5","category":{"_id":"5463e333447e0a100024a08b","project":"5463e333447e0a100024a087","pages":["5463e334447e0a100024a08d","54646a285871e90800f50174","54667e7af2b6390800dfd82a","54679c8c98b6840800268982","54679d8498b6840800268987","546a2ed0394c861a00c3a413","546b6a4862515a14007ebbba","547b1c2e7eec0f080099e1dd","55d33d90b9ef4435006dec70","56570c764d1c720d001f51bb"],"version":"5463e333447e0a100024a08a","__v":10,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-11-12T22:46:11.951Z","from_sync":false,"order":1,"slug":"documentation","title":"Documentation"},"__v":7,"project":"5463e333447e0a100024a087","user":"54639d06447e0a1000249f7f","version":{"_id":"5463e333447e0a100024a08a","project":"5463e333447e0a100024a087","__v":6,"createdAt":"2014-11-12T22:46:11.486Z","releaseDate":"2014-11-12T22:46:11.486Z","categories":["5463e333447e0a100024a08b","54645c365871e90800f50151","547b1c5a4366a708001b3b50","547b1cdf4366a708001b3b5a","54e3bef8464a9c3700f7ca67","54ec651d7ab3172d00c01ab7"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-11-30T13:33:57.847Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"basic_auth":false,"results":{"codes":[]},"try":true,"auth":"never","params":[],"url":""},"isReference":false,"order":10,"body":"Labels provide a means for displaying text to the user and methods for easily modifying the text as well.\n\n##**Atlas Label** - a label which uses an atlas file for the characters\n\n*Example format:*\n\n*Label( stringToDisplay, characterMapToUse, characterWidth, characterHeight, startingCharacterInTheMap );*\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"LabelAtlas *label = LabelAtlas::create( \\\"String to display\\\", \\\"Filepath of the character map\\\", 5, 5, 3 );\",\n      \"language\": \"cplusplus\",\n      \"name\": \"Cocos2d-x C++\"\n    },\n    {\n      \"code\": \"var label = new cc.LabelAtlas( \\\"String to display\\\", \\\"Filepath of the character map\\\", 5, 5 );\",\n      \"language\": \"javascript\",\n      \"name\": \"Cocos2d-JS\"\n    }\n  ]\n}\n[/block]\nNote: *Glypth Designer can be used to create atlas fonts **[https://71squared.com/en/glyphdesigner](https://71squared.com/en/glyphdesigner)**\n*\n\n##**BMFont Label** - a label which uses an BMFont file for the characters\n\n*Example format:*\n\n*Label( bmFontFilePath, stringToDisplay );*\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Label *label = Label::createWithBMFont(  );\",\n      \"language\": \"cplusplus\",\n      \"name\": \"Cocos2d-x C++\"\n    },\n    {\n      \"code\": \"var label = new cc.LabelBMFont( \\\"String to display\\\", \\\"Filepath of the bmfont\\\" );\",\n      \"language\": \"javascript\",\n      \"name\": \"Cocos2d-JS\"\n    }\n  ]\n}\n[/block]\nNote: *Glypth Designer can be used to create BMFonts **[https://71squared.com/en/glyphdesigner](https://71squared.com/en/glyphdesigner)**\n*\n\n##**TTF Label** - a label which uses a regular font file\n\n*Example format:*\n\n*Label( stringToDisplay, fontFilepath, fontSize );*\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Label *label = Label::createWithTTF( \\\"String to display\\\", \\\"Font filepath\\\", 5.5 );\",\n      \"language\": \"cplusplus\",\n      \"name\": \"Cocos2d-x C++\"\n    },\n    {\n      \"code\": \"var label = new cc.LabelTTF( \\\"String to display\\\", \\\"Font filepath\\\" );\",\n      \"language\": \"javascript\",\n      \"name\": \"Cocos2d-JS\"\n    }\n  ]\n}\n[/block]","excerpt":"This page will cover the various labels that Cocos provides","slug":"labels","type":"basic","title":"Labels"}

Labels

This page will cover the various labels that Cocos provides

Labels provide a means for displaying text to the user and methods for easily modifying the text as well. ##**Atlas Label** - a label which uses an atlas file for the characters *Example format:* *Label( stringToDisplay, characterMapToUse, characterWidth, characterHeight, startingCharacterInTheMap );* [block:code] { "codes": [ { "code": "LabelAtlas *label = LabelAtlas::create( \"String to display\", \"Filepath of the character map\", 5, 5, 3 );", "language": "cplusplus", "name": "Cocos2d-x C++" }, { "code": "var label = new cc.LabelAtlas( \"String to display\", \"Filepath of the character map\", 5, 5 );", "language": "javascript", "name": "Cocos2d-JS" } ] } [/block] Note: *Glypth Designer can be used to create atlas fonts **[https://71squared.com/en/glyphdesigner](https://71squared.com/en/glyphdesigner)** * ##**BMFont Label** - a label which uses an BMFont file for the characters *Example format:* *Label( bmFontFilePath, stringToDisplay );* [block:code] { "codes": [ { "code": "Label *label = Label::createWithBMFont( );", "language": "cplusplus", "name": "Cocos2d-x C++" }, { "code": "var label = new cc.LabelBMFont( \"String to display\", \"Filepath of the bmfont\" );", "language": "javascript", "name": "Cocos2d-JS" } ] } [/block] Note: *Glypth Designer can be used to create BMFonts **[https://71squared.com/en/glyphdesigner](https://71squared.com/en/glyphdesigner)** * ##**TTF Label** - a label which uses a regular font file *Example format:* *Label( stringToDisplay, fontFilepath, fontSize );* [block:code] { "codes": [ { "code": "Label *label = Label::createWithTTF( \"String to display\", \"Font filepath\", 5.5 );", "language": "cplusplus", "name": "Cocos2d-x C++" }, { "code": "var label = new cc.LabelTTF( \"String to display\", \"Font filepath\" );", "language": "javascript", "name": "Cocos2d-JS" } ] } [/block]