ios_developer
ios_developer

Reputation: 21

CCLabelTTF incorrectly positioned

I am having some trouble with cocos2dx (windows-ver. cocos2d-1.0.1-x-0.12.0) CCLabelTTF. Whichever label having string-with-spaces, the label is moving upwards by few pixels.

Here is the basic code I used to display two labels (with and without spaces) at the same position. This picture shows how it is displayed.

CCLabelTTF *label0 = CCLabelTTF::labelWithString( "This is a", GAME_FONT, 20 );
addChild( label0 );
label0->setPosition( ccp( SCR_W / 2, SCR_H / 2 ) );

CCLabelTTF *label1 = CCLabelTTF::labelWithString( "string", GAME_FONT, 20 );
addChild( label1 );
label1->setPosition( ccp( SCR_W / 2, SCR_H / 2 ) );

The project is working fine on Mac for iOS. I noticed the bug while trying to port it for windows. It is too late for me to update to a new cocos2dx SDK, as it involves API changes.

Upvotes: 0

Views: 521

Answers (1)

Dinesh Patel
Dinesh Patel

Reputation: 142

you can create label such type. try it
 CCLabelTTF *lbl_Question=CCLabelTTF::create("23", "mvboli.ttf", 36, CCSize(400, 0),       kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);

Upvotes: 1

Related Questions