0 Favourites

How do I Change text Format inline?

  • 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

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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:

    [quote:ry7dsweu]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][quote:ry7dsweu]Enclosed Alphanumeric from https://en.m.wikipedia.org/wiki/Enclosed_Alphanumerics

  • I don't think it can be done inline.

  • 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...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic Locked topic
195 16,205
Ashley's avatar
Ashley Construct Team Founder
Unread hot topic
0 Favourites
[Plugin] tag text
188 25,457
RBuster's avatar
RBuster
Unread hot topic
99 10,155
karshinkoff's avatar
karshinkoff