How do I spawn a sprite at a specific word in text?

Get help using Construct 2

Post » Mon Jan 09, 2017 1:09 pm

Hi all,

I just wondering if there is any way to spawn a sprite at a specific word in a text. For example: "The quick black fox jumped over the lazy dog". When 'the' is in the text it spawns a sprite behind/above 'the' text word.

I hope that makes sense.

Thanks for the help!
B
16
S
4
Posts: 69
Reputation: 1,834

Post » Mon Jan 09, 2017 1:58 pm

I would use a hidden text object but only fill it with text up to and including the space before the word you're interested in. Use the text width property (not the text object width) and add it to the text object's bounding box left position. That will give you the starting/left x position. You could also measure the width of a single word using a similar technique. Just note that it takes one tick for these text width values to populate after signing the text content.
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,215
Reputation: 43,852

Post » Tue Jan 10, 2017 1:29 am

Or you can put invisible sprite/spawner and put in every word or text you have then spawn na sprite you want to spawn on the invisible sprite/spawner. Happy building! :D
B
79
S
31
G
7
Posts: 148
Reputation: 9,179


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], Yahoo [Bot], yiuyiu6666 and 14 guests