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

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -