How do I auto resize text box ?

Get help using Construct 2

Post » Wed Mar 26, 2014 11:47 am

Hi all!

It's possible to resize in some way a text box to adapt to its content ?

I need to know the size of the text to put the purple box behind selected option.
The text on image is in Portuguese, sorry.
Image

Thanks
B
11
S
3
Posts: 39
Reputation: 814

Post » Wed Mar 26, 2014 12:00 pm

Only way I can think of to do this is when using spritefont.
Normal fonts are handled by the browser and could differ.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Mar 26, 2014 12:14 pm

But i need to use this font :S

I can do an estimate of how much space each character have and set the width through that.

Its not a perfect :/
B
11
S
3
Posts: 39
Reputation: 814

Post » Wed Mar 26, 2014 12:18 pm

Why not transform this font into spritefont using SpriteFontGenerator ?

Resizing the window could have unexpected effects when doing it with estimations, so I'd not recommend that.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Mar 26, 2014 12:21 pm

Thanks, i will try this solutioin.
B
11
S
3
Posts: 39
Reputation: 814

Post » Wed Mar 26, 2014 4:02 pm

I still have trouble with this, but the best solution is to use textwidth. Problem is, if you create the objects, then immediately try to size them according to the size of the text, you won't get the correct answer. You need to do a Wait (about 0.01 seconds is fine) and then resize the boxes. Problem with that is, it creates flicker, so maybe do it offscreen and then put them onscreen when it's finished.
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Wed Mar 26, 2014 4:08 pm

I only gonna create the object behind text when the user click on the answer, so i think i will not have problems with this, because the text is already created.
B
11
S
3
Posts: 39
Reputation: 814


Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 60 guests