我同时使用CCLabelTTF和NSLocalizedString,但是我不能设置锚点。(我希望我的所有按钮都左对齐,所以它应该是ccp(0,0.5f),但在任何本地化中,结果总是居中。下面的方法在Helper.m中,我调用CCLabelTTF* startLabel = Helper createItemLabelWithStringUpperCase:@“PLAY!”
+(CCLabelTTF*) createLocalizedLabelWithStringUpperCase: (NSString*) str color: (ccColor3B) c fontSize: (int) s {
NSString* font;
if ([Helper useCutomFontFile]) {
font = @"font.ttf";
}
else {
font = @"Arial";
}
CCLabelTTF* label = [CCLabelTTF labelWithString:NSLocalizedString(str, nil) fontName:font fontSize:s];
CCLOG(@"%@\n", str);
CCLOG(@"%@\n", NSLocalizedString(str, nil));
label.color = c;
return label;
}
+(CCLabelTTF*) createLocalizedLabelWithStringUpperCase: (NSString*) str color: (ccColor3B) c {
return [Helper createLocalizedLabelWithStringUpperCase:str color:c fontSize:32];
}
+(CCLabelTTF*) createUnlocalizedLabelWithString:(NSString *)str color:(ccColor3B)c fontSize: (int) s {
CCLabelTTF* label = [CCLabelTTF labelWithString: str fontName:@"font.ttf" fontSize:s];
label.color = c;
return label;
}
+(CCLabelTTF*) createUnlocalizedLabelWithString: (NSString*) str color: (ccColor3B) c {
return [Helper createUnlocalizedLabelWithString:str color:c fontSize:32];
}
+(CCLabelTTF*) createItemLabelWithStringUpperCase: (NSString*) str {
CCLabelTTF* label = [Helper createLocalizedLabelWithStringUpperCase:str color:ccBLACK];
label.anchorPoint = ccp(0, 0.5f);
return label;
}顺便说一句,我在哪里可以找到一些常见的本地化词汇,比如"play",“resume”,“pause”等等?我不认为谷歌翻译足够准确
发布于 2012-01-29 21:08:54
请看这里的CCLabelTTF类引用:
http://www.cocos2d-iphone.org/api-ref/0.99.5/interface_c_c_label_t_t_f.html并尝试此方法:
labelWithString:dimensions:alignment:fontName:fontSize:或者这样:
initWithString:dimensions:alignment:fontName:fontSize:若要创建具有对齐的CCStringTTF,请执行以下操作。
对齐方式可以是以下方式之一:
CCTextAlignmentLeft
CCTextAlignmentCenter
CCTextAlignmentRight https://stackoverflow.com/questions/9053109
复制相似问题