Clickable individual words within a Text object

Get help using Construct 2

Post » Sat Jul 16, 2016 12:11 am

Hi there.

Is it possible to make individual words within a text object clickable? -And if so, how would I go about this?

I'm working on a project that'll have large amounts of text read from XML files and I need to be able to make specific words interactable.

I've yet to find a way to be able to do this.

Any ideas?

Thanks.
B
4
Posts: 12
Reputation: 224

Post » Sat Jul 16, 2016 12:36 am

Or, failing this, does anyone have any ideas as to the best way to achieve a similar effect?

I suppose one could, in theory, have every word within an XML doc load into a separate Text object.
But this seems rather inefficient when dealing with large amounts of text.

Is there a better way?
B
4
Posts: 12
Reputation: 224

Post » Sat Jul 16, 2016 10:17 pm

B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Jul 17, 2016 2:55 pm

Message: LoremDimSum can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
You might want to look at :
https://www.google.be/search?q=scirra+s ... spritefont


How does the use of a Sprite Font make it any easier to interact with specific parts of text content within an object?

Sorry, I'm not quite following.
B
4
Posts: 12
Reputation: 224

Post » Sun Jul 17, 2016 3:02 pm

You know the exact lenght of the words. If you know the lenght, you know where they are.
Some math and good logic will bring you there.

Unless you expected a capx dooing it all for you, ofcours. Then you are still nowhere. Sorry.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Jul 17, 2016 9:39 pm

You know the exact lenght of the words. If you know the lenght, you know where they are.
Some math and good logic will bring you there.


True.
But, firstly, I'd be somewhat concerned about relying upon absolute positioning, as apposed to addressing the text content itself, as it wouldn't allow for flexibilty in layout & font formatting.

Addressing via position would also means one would have to separately refer to every instance of a particular word, as apposed to once per unique word.


I'd be working with hundreds of thousands of words in XML docs.
So it only becomes feasible if I can automate the process of making words addressible, (ideally by text content rather that relying upon absolute positioning.)

Unless you expected a capx dooing it all for you, ofcours

I expected nothing of the sort.
What would give you that impression?

I'm merely asking if anyone has any ideas or advice on the subject.
Is that not what this section of the forum is for?

Thanks.
B
4
Posts: 12
Reputation: 224

Post » Sun Jul 17, 2016 10:19 pm

Regardless of if you use a text object or spritefont, I would imagine parsing out the words of interest, replacing them with blank space of the same length, and putting an object with the former contents in it's place.

Alternatively, you would create an "imagemap" of sorts, where you identify the words of interest and their x/y coordinates. Spritefont would be superior, as it would be much more reliable to calculate out pixel locations and sizes of characters with expressions.

The method would use either tokens (simpler, less powerful), or regex (powerful, more complicated)
Mistakes were made.
B
52
S
26
G
110
Posts: 1,620
Reputation: 62,161

Post » Mon Jul 18, 2016 1:32 am

Have you tried when the text object is clicked to determine where the touch/click point is? Then find a formula based on position to determine which word.

There are fonts where each character is the same size so should be possible.
ImageImageImage
B
40
S
23
G
11
Posts: 498
Reputation: 10,062

Post » Mon Jul 18, 2016 1:58 am

Or assign one spritefont object per word, and create an on trigger condition based on some instance variable of the spritefont object.
B
28
S
10
G
10
Posts: 97
Reputation: 6,584

Post » Mon Jul 18, 2016 7:34 am

What is the ultimate goal?

Dragging selected words arround as sprites, mayby rearrange ?

Do evalutions on the text content? Should the action return a string ?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Next

Return to How do I....?

Who is online

Users browsing this forum: neverk and 43 guests