Shrink to Fit function

hi everyone,

I am trying to make a game involving texts, lots of text. And those words are put in boxes for it to be dragged and put in a place somewhere. My problem is that I dont want to make the box bigger whenever there is a longer word and a big space if there is a smaller words. Is there some way to make it fit in the box? It’s okay if it’s only the shrink to fit, longer words, fonts size are adjusted. Is there a function that does this? if not, how do I do this? [import]uid: 141531 topic_id: 25868 reply_id: 325868[/import]

You could just manually set the font size to be lower on longer words. (You could check the length using string:len and then make adjustments from there.)

Peach :slight_smile: [import]uid: 52491 topic_id: 25868 reply_id: 104620[/import]

Oh ok, so there is no built in function for this? too bad. Thanks.

Ronel [import]uid: 141531 topic_id: 25868 reply_id: 104778[/import]

You could also scale using xScale and yScale but no there is no “shrink to fit” API for text - manually doing it will only take you a couple of lines to resize regardless of the number of buttons though so really it shouldn’t be too bad :slight_smile: [import]uid: 52491 topic_id: 25868 reply_id: 104828[/import]

XScale and YScale? Okay let me search on that. I’m quite new to corona, so every input is much appreciated.

I was just asking because I dont want to waste time doing the hard way. :slight_smile:

Thanks Peach, saw your post all over the net and appreciate on replying on my posts.

Regards, Ronel [import]uid: 141531 topic_id: 25868 reply_id: 104858[/import]

Thanks Ronel - no worries about replying.

It may seem like a “hard” way at first but as you get into it you will find it can be simplified a lot.

Resizing using xScale and yScale is easy - take an image (or your displayed text) and try;

myImage.xScale, myImage.yScale = 0.5, 0.5

That should half the size.

Peach :slight_smile: [import]uid: 52491 topic_id: 25868 reply_id: 104883[/import]