CCMenuItemAtlasFont用法

时间:2012-02-11 16:17:06

标签: ios fonts cocos2d-iphone

任何人都可以告诉我CCMenuItemAtlasFont的用法吗?我无法在网络上的任何地方找到任何示例,也不知道如何传递.fnt文件。唯一有意义的公共职能是

[[self alloc] initFromString:<#(NSString *)#> charMapFile:<#(NSString *)#> itemWidth:<#(int)#> itemHeight:<#(int)#> startCharMap:<#(char)#> target:<#(id)#> selector:<#(SEL)#>

其中charMapFile似乎是png。但我不知道如何使用itemWidth或itemHeight为我的fontatlas(用bmpGlyph制作)没有固定的栅格。

谢谢你!

1 个答案:

答案 0 :(得分:2)

CCMenuItemAtlasFont使用CCLabelAtlas生成文本纹理。 (来自CCLabelAtlas.h评论:

// CCLabelAtlas versus CCLabel:
// - CCLabelAtlas is MUCH faster than CCLabel
// - CCLabelAtlas "characters" have a fixed height and width
// - CCLabelAtlas "characters" can be anything you want since they are taken from an image file

所以我猜你对变宽字体感到很冷。您需要宽度和高度来指定“固定”字符字体的点数。

查看here以获取带有字体文件的示例