[英]Unable to set Left Alignment for button title in Cocos2d
左对齐CCLabelTTF非常容易,但是CCButton似乎存在对齐问题。
设置button.horizontalpadding = CCTextAlignmentLeft;
对按钮对齐没有影响。 我试图修改属性preferredSize
和contentSize
,以便创建未成功对齐的框。
您需要设置“锚点”而不是“ Aliment属性”,这里是可以帮助您的示例:
CCLabel _label= new CCLabel("sample text here!", "Fonts/font.otf", 60, CCTextAlignment.Left);
_label.AnchorPoint = new CCPoint(0.0f, 0.5f);
尚无法测试,但我会尝试
[button.label setHorizontalAlignment:CCTextAlignmentLeft];
我不知道在cocos2d中没有CCButton类。 我假设您正在谈论CCMenuItelLabel。 尝试这种方式:
CGPoint rightAlligned = ccp(1.0f, 0.5f);
CGPoint leftAlligned = ccp(0.0f, 0.5f);
button.label.anchorPoint = leftAligned; //For left text align
button.label.anchorPoint = rightAligned; //For right text align
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.