什么会导致 Cocos2d iPhone 字体只显示 2/3 的字母/数字?
我正在尝试在 cocos2d iPhone 游戏中使用 此字体。字体仅显示字母/数字的 2/3。如果我打开 OS X 中安装的文本编辑器并使用该字体,则字母显示正常。对可能出什么问题有什么想法吗?
这是显示如何使用字体显示字符串的代码片段:
CCLabel* number = [CCLabel labelWithString:@"1" fontName:@"digital-7" fontSize:64];
// position the label on the center of the screen
number.position = ccp( 20 , size.height/2);
number.color = ccc3(0,0,0);
// add the label as a child to this Layer
[self addChild: number];
I am trying to use this font in a cocos2d iPhone game. The font only shows 2/3rds of the letter/number. If I open the text editor installed with OS X and use the font, the letters appear fine. Any ideas to what may be wrong?
Here's the code snippet showing how I display a string using the font:
CCLabel* number = [CCLabel labelWithString:@"1" fontName:@"digital-7" fontSize:64];
// position the label on the center of the screen
number.position = ccp( 20 , size.height/2);
number.color = ccc3(0,0,0);
// add the label as a child to this Layer
[self addChild: number];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,需要为 CCLabel 指定尺寸。默认区域一定太小,导致文本被剪切。当我添加尺寸参数时,文本显示正确。
[CCLabel labelWithString:@"1000" 尺寸:CGSizeMake(100, 50) 对齐方式:UITextAlignmentLeft fontName:@"digital-7 (mono)" fontSize:48];
It turns out that dimensions needed to be specified for the CCLabel. The default area must have been too small which caused the text to be clipped. When I added the dimensions parameter, the text appeared correctly.
[CCLabel labelWithString:@"1000" dimensions:CGSizeMake(100, 50) alignment:UITextAlignmentLeft fontName:@"digital-7 (mono)" fontSize:48];