2012-01-29 41 views
0

我正在使用CCLabelTTF与NSLocalizedString,但我无法设置锚点。 (我希望我的所有按钮都左对齐,所以它应该是ccp(0,0.5f),但结果始终居中,在任何本地化中。 以下方法位于Helper.m中,并且我调用CCLabelTTF * STARTLABEL = [助手createItemLabelWithStringUpperCase:@“PLAY!”]无法设置CCLabelTTF anchorPoint

+(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; 
} 

顺便说一句,我在哪里可以找到像“玩”,“恢复”“暂停”等一些常用的局部的词汇,我不认为谷歌翻译是不够准确

回答

1

看看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 
+0

没有它们实际上是不同的标签,我想5个标签靠左对齐,所以需要设置锚点CCP(0,0.5F )。顺便说一句,你知道我在哪里可以找到像“玩”,“简历”,“暂停”等一些常见的本地化词汇吗?我不认为谷歌翻译是否足够准确 – OMGPOP 2012-01-29 13:17:23

+0

你的意思是你有5个不同的标签,你使用像按钮? – Beppe 2012-01-29 13:20:32

+0

关于你的其他问题...我不知道任何常见的本地化声音,但也许这将是有用的: http://www.wordreference.com/ 请考虑问一个关于这个问题的新问题:它可以 – Beppe 2012-01-29 13:23:35