Is possible to get pos(x,y) of a word in a text object?

Get help using Construct 2

Post » Fri Nov 28, 2014 6:35 pm

As I said in the subject, Is possible to calculate que exact position of a word in a text object? I want to do a special trivia game and i need that some words of a text can be clickable, and the text is not known so i need to calculate the position of the words.
B
32
S
7
G
2
Posts: 164
Reputation: 3,774

Post » Fri Nov 28, 2014 9:04 pm

Well, there is text.textwidth and .textheight. But it only works in the next frame, after the text is drawn, but you can probably work around that.
For example you can create a dummy string on screen with the same dimensions as your textbox, set its opacity to 0, set the text to all the text that comes before your word of choice, then check for textwidth and textheight. Your words position then is originaltext.x+dummytext.textwidth etc..
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Sat Nov 29, 2014 8:18 am

Right now I calculate the height with that method, i'm going to try your idea.
B
32
S
7
G
2
Posts: 164
Reputation: 3,774


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest

cron