LabelTTF with defined width but automatic height

I’m using cocos2d-x3.0-beta.

What settings do I use to make my LabelTTF have a defined width but have its height be automatically determined?

For example:

Sprite * textBox = Sprite::create( "textBox.png" );
this -> addChild( textBox );

LabelTTF * textLabel = LabelTTF::create( "Lorem Ipsum dolor sit amet.", "Arial", 24, Size( textBox -> getContentSize().width, 0 ), TextHAlignment::LEFT );
textBox -> addChild( textLabel );

It used to work on previous versions but it seems that passing Size( 100, 0 ) as the label’s dimension causes a crash. Before, passing a Size with a height of 0, causes the LabelTTF to automatically calculate it’s size.

TL;DR: I need to have the LabelTTF have defined width, but have its height automatically adjusting.

Hi, lance_gray!
This feature works in cocos2d-html5 v.2.2.2.
I found using a html-version convenient for fast prototyping (before going to cocos2d-x with the same code). :slight_smile: