How do I Change text Format inline?

Get help using Construct 2

Post » Tue Aug 30, 2016 5:21 am

I'm wanting to use a single textbox that has colors on certain words.

I want to do something like this in a single textbox.

Any help is appreciated :)
Check out my work!

DeviantArt Twitter Tumblr

ART COMMISSIONS!

If you're interested in me doing commissions for you check my rules here and/or email me at: [email protected]
B
14
S
6
Posts: 12
Reputation: 1,124

Post » Tue Aug 30, 2016 6:05 am

Possible but not so straight forward.

first, see https://www.scirra.com/tutorials/624/te ... box/page-1

I don't know whether you can truly do all the HTML charade like in regular website on the textbox of C2 alone. If it's possible, that would simplify your problem quite greatly.

Nevertheless, with respect to the tutorial above, what I would do is creating a Sprite Font that has two colors in it.

For example, you have the default black letters and red letters. And refer to the red letters in the "character set" [1] by using unicode characters such as ⒶⒷⒸⒹⒺⒻⒼⒽ [2] .

Also, continuing from the tutorial above in this case, in the event sheet, you would want to check for the text input and see if the input has any matches with certain strings that you want. You will then replace all the characters in such string with their alphanumeric counterparts. Now, you will have certain red words or phrases in your text. It's quite hectic and lots of works.

Perhaps somebody could suggest a more elegant way?

[1] - from Sprite Font, C2 manual:
Character set
A string of characters that describes the sequence of letters in the sprite font image. This is used to map text to images. While the default starts with the English alphabet, it could be changed to another language or sequence and the image updated accordingly. Note however the Sprite Font can only display characters that are in the character set; any characters not in the character set with a corresponding image will appear as an empty space.


[2]
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Tue Aug 30, 2016 6:07 am

I don't think it can be done inline.
B
56
S
15
G
13
Posts: 826
Reputation: 17,675

Post » Tue Aug 30, 2016 7:21 am

It can be done with a little creativity, but not in a single textbox. Build your text one letter at a time with seperate objects.

https://www.dropbox.com/s/211xd1ir76hq8 ... .capx?dl=0

In the example I used a text object, but you should definitely use spritefont. Also, you can use a loop instead of every x seconds to get rid of the typewriter effect.

To simplify things, you can have two spritefont objects - one red version one black, and just create the suitable one with conditions. You can trigger the color change and end with an escape character in your string that doesn't actually get displayed.

Edit: Alternatively, you may want to look into positioning a tint layer effect over the words you want colored...
Mistakes were made.
B
53
S
27
G
114
Posts: 1,695
Reputation: 64,438


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests