BMFont 사용하기



Resources 폴더에 BMFont 파일추가 (.fnt 파일, .png 파일)


c++)

createWithBMFont() 함수 사용

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "test81.hpp"
 
USING_NS_CC;
 
Scene* Test81::createScene()
{
    auto scene = Scene::create();
    
    auto layer = Test81::create();
    scene->addChild(layer);
    
    return scene;
}
 
 
bool Test81::init()
{
    if ( !Layer::init())
    {
        return false;
    }
    
    //ps. .fnt파일명과 .png파일명이 같아야 한다
    //ps. 폰트크기 지정 못함
    //createWithBMFont(BMFont명, 텍스트, 가로정렬, 너비)
    auto label = Label::createWithBMFont("bitmapFontChinese.fnt""Hello World, Fonts : BMFont", TextHAlignment::CENTER, 100);
    
 
    label->setPosition(Point(150150));
    this->addChild(label);
    
    return true;
}
cs



결과




+ Recent posts