Text Alignment in labels not functioning correctly

Text Alignment in labels not functioning correctly
0.0 0


Im porting some code over from cocos2d to cocos2dx and have run into a couple of problems with the labels :

Moving CCLabel from CCLabelTTF and I’ve lost the alignment :

basically im calling :

m_labelName = CCLabelTTF::labelWithString(m_Name, CGSizeMake(243, 27), UITextAlignmentLeft, “Arial Rounded MT Bold”, 24);

Digging through the code it looks like the alignment is being ignored.

Its passed in through the constructor in CCXBitmapDC::CCXBitmapDC, however it doesn’t get passed through to initWithString. InitWithString forces the alignment to be center aligned. Ive been playing with the code and now have everything passed through correctly, however it appears as if the size being used to calculate the rect to render the string is being ignored, and not using the one passed through (im new to this code, so i could be mistaken)

Any ideas as to the correct approach to fixing this ?



I managed to fix this locally, bit of a hack but it works…




Thanks! It’s commited at https://github.com/cocos2d/cocos2d-x/commit/a9ab95ebe290a6f3f5cf6e842207dfb9dc7a4260
cocos2d::UITextAlignment seems crash with ::UITextAlignment. I would like to rename it to cocos2d::ccTextAlignment in the future.


Cool, glad its working :slight_smile: