cocos2d x 3.0 - Get the size of wrapped text in Label -


if create label in 500x500 area wordwrap, how can find out height of wrapped text ? i'm looking yellow height, not salmon height.

enter image description here

answer of @idrise doesn't work system font , here give more flexible answer.

assume want create text/label has fixed width, dynamic height according text's length. can use below code:

label *lbl = label::createwithsystemfont("aaa aaa aaa aaa aaa aaa", "arial", 50); lbl->setdimensions(fixed_width, 0); // "0" means don't care wrapping vertically, hence `getcontentsize().height` give dynamic height according text's length //// auto dynamicheight = title->getcontentsize().height; // according text's length :) 

and fixed height can similarly.

hope :]


Comments

Popular posts from this blog

java - Incorrect order of records in M-M relationship in hibernate -

command line - Use qwinsta in PowerShell ISE -

php - I want to create a website for polls/survey like this http://www.poll-maker.com/ -