Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17093

Label overflow not clamping text

$
0
0

@rob_type25 wrote:

Hi there

Using Cocos2dx-3.10

Hopefully a trivial one but can't work it out...

How do i constrain a labels text to it's contentSize?

Example:

auto usernameLabel = Label::createWithTTF(item->username, "fonts/WhitneyMedium.ttf", 8.0);
    usernameLabel->setPosition(Vec2(0, cell->getContentSize().height/2));
    usernameLabel->setContentSize(Size(20, usernameLabel->getContentSize().height));
    usernameLabel->setOverflow(cocos2d::Label::Overflow::CLAMP);

This doesn't "clamp" the text. Ideally i'd like ellipsis but i'll settle for it just clipping the text at the moment.

Thanks!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 17093

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>