i am using CCLabelTTF together with NSLocalizedString, but i am not able to set the anchor point. (I want all my buttons to be aligned left, so it should be ccp(0, 0.5f), but the result is always center, in any localization.
the following methods are in a Helper.m, and i call 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;
}
btw, where can i find some common localized vocabulary like “play”, ‘resume’ ‘pause” etc? i don’t think google translate is accurate enough
Take a look at CCLabelTTF Class Reference here:
And try this method:
or this:
To create a CCStringTTF with alignment.
Alignment could be one of the followings: