carljalal carljalal -4 years ago 135
iOS Question

Unable to set Left Alignment for button title in Cocos2d

It's very easy to Left-Align CCLabelTTF, but CCButton seems to have a problem with alignments.


button.horizontalpadding = CCTextAlignmentLeft;
has no affect on button alignment.
I have attempted to modify properties
in order to create boxes for alignment without success.

Answer Source

I dont this there is a CCButton class in cocos2d. I assume you are talking about CCMenuItelLabel. Try this way:

        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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download