cocos2d-x的自定义字体之CCLabelAtlas

需要图片:



 

		CCLabelAtlas* labelAtlas = CCLabelAtlas::create("1946", "fps_images.png", 12, 32, '.');
		labelAtlas->setPosition(ccp(size.width/2, size.height/2));
		addChild(labelAtlas, 100, 100);

 

CCLabelAtlas* labelAtlas = CCLabelAtlas::create("1946", "fps_images.png", 12, 32, '.');
第一个参数:显示的内容

第二个参数:图片的名字

第三个参数:每一个数字的宽

第四个参数:每一个数字的高

每五个数字:开始字符

 

说明:程序内部是议连续的ASCLL码识别的,如果上图中9后面是一个‘X’字符(

 ),那么就可以用‘:’字符来表示X,因为在ASCLL码中,9后面的字符是':'

 

附:ASCLL码部分

 

32 40 20 100000 Space
33 41 21 100001 ! Exclamation mark
34 42 22 100010 " Double quotes (or speech marks)
35 43 23 100011 # Number
36 44 24 100100 $ Dollar
37 45 25 100101 % Procenttecken
38 46 26 100110 & Ampersand
39 47 27 100111 ' Single quote
40 50 28 101000 ( Open parenthesis (or open bracket)
41 51 29 101001 ) Close parenthesis (or close bracket)
42 52 2A 101010 * Asterisk
43 53 2B 101011 + Plus
44 54 2C 101100 , Comma
45 55 2D 101101 - Hyphen
46 56 2E 101110 . Period, dot or full stop
47 57 2F 101111 / Slash or divide
48 60 30 110000 0 Zero
49 61 31 110001 1 One
50 62 32 110010 2 Two
51 63 33 110011 3 Three
52 64 34 110100 4 Four
53 65 35 110101 5 Five
54 66 36 110110 6 Six
55 67 37 110111 7 Seven
56 70 38 111000 8 Eight
57 71 39 111001 9 Nine
58 72 3A 111010 : Colon
59 73 3B 111011 ; Semicolon
60 74 3C 111100 < Less than (or open angled bracket)
61 75 3D 111101 = Equals
62 76 3E 111110 > Greater than (or close angled bracket)
63 77 3F 111111 ? Question mark
64 100 40 1000000 @ At symbol

你可能感兴趣的:(cocos2d-x)