CCLabelBMFont類在使用之前,需要添加好字體文件,包括一個png圖片文件和一個fnt字體座標文件。
static CCLabelBMFont *create(const char *str,const char *fntFile);
創建的時候我們只需要傳入需要顯示的內容以及fnt文件的路徑。
例:
//需要testChinese.fnt和testChinese.png
CCLabelBMFont *bmfont=CCLabelBMFont ::create("中國", "testChinese.fnt");
bmfont->setPosition(ccp(150, 300));
addChild(bmfont);