How do I change the color of a text.

0 favourites
From the Asset Store
OpenAI TTS
$10 USD
Text-to-Speech plugin.Allows your Construct 3 project to convert written text into spoken words
  • Try this:

    Add a special character to each letter in the string that you want to be yellow:

    myText="Hello, ^J^o^h^n! How are you?"

    Then parse this string character-by-character and when you find "^", read next letter and wrap it into {color} tag:

    H
    e 
    l
    l
    o
    ,
    
    J[/color]
    o[/color]
    h[/color]
    n[/color]
    etc.[/code:cpf80vsm]
    
    [quote:cpf80vsm]is there any way to change the plugin of my texts
    
    If you need to replace lots of text objects, you can edit XML files of the project, as described [url=https://www.scirra.com/forum/viewtopic.php?f=147&t=196534]here[/url], but it's not recommended.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Try this:

    Add a special character to each letter in the string that you want to be yellow:

    myText="Hello, ^J^o^h^n! How are you?"

    Then parse this string character-by-character and when you find "^", read next letter and wrap it into {color} tag:

    H
    e 
    l
    l
    o
    ,
    
    J[/color]
    o[/color]
    h[/color]
    n[/color]
    etc.[/code:52zgqv8e]
    
    [quote:52zgqv8e]is there any way to change the plugin of my texts
    

    If you need to replace lots of text objects, you can edit XML files of the project, as described here, but it's not recommended.

    I do not need to try to know that I will have the same problem but worse seen all the tags that there is. The problem with this plugin is that the color is displayed when the text is displayed. However, the dialogs display the text letters by letters, without forgetting the tags. Once the opening tag is written, the following becomes yellow. The closing tag will also be displayed before it is fully written.

  • I'm not sure I understand you.

    When you need to display next letter of the dialog and that letter should be yellow, add this:

    ""&letter&"[/color]"[/code:2dcx5z5p]
    
    Your code could be something like this:
    
    [code:2dcx5z5p]
    myText="Hello, %John%! How are you?"     <-   Put symbol % before and after the text you want to display in yellow
    textYellow=0  
    letter=""
    
    For i=0 to len(myText)-1
      Wait 0.5*loopindex seconds
      letter=mid(myText, loopindex, 1)
      If letter="%" set textYellow=(textYellow=0)    <- this will invert textYellow variable, 0 becomes 1, 1 becomes 0
      Else 
         If textYellow=0  dialogText append letter
         If textYellow=1  dialogText append ""&letter&"[/color]"
    [/code:2dcx5z5p]
  • To display my dialogues, I proceed more or less this way

    Every 0.05 seconds || bbt_dialogue_texte | Set text to left(bbt_dialogue_texte.instancevariable&FLOWEY&newline&...., len(bbt_dialogue_texte.Text) + 1)

    This means that the tags will still be displayed.

  • See my updated comment above.

  • I'm not sure I understand you.

    When you need to display next letter of the dialog and that letter should be yellow, add this:

    ""&letter&"[/color]"[/code:2uor5bmf]
    
    Your code could be something like this:
    
    [code:2uor5bmf]
    myText="Hello, %John%! How are you?"     <-   Put symbol % before and after the text you want to display in yellow
    textYellow=0  
    letter=""
    
    For i=0 to len(myText)-1
      Wait 0.5*loopindex seconds
      letter=mid(myText, loopindex, 1)
      If letter="%" set textYellow=(textYellow=0)    <- this will invert textYellow variable, 0 becomes 1, 1 becomes 0
      Else 
         If textYellow=0  dialogText append letter
         If textYellow=1  dialogText append ""&letter&"[/color]"
    [/code:2uor5bmf]
    

    I ... I did not understand?

    Could you use more simple "comments"? I have a hard time with English.

  • At worst, it does not matter. The universe of my game is already bugged in history. So having an effect of this style may not be so bad.

  • This may be easier to understand:

    myText="Hello, %John%! How are you?"     <-  use % to mark start and end of yellow text.
    
    letter=""
    
    textYellow=0    <-  textYellow=0 means black text, textYellow=1 means yellow text
    
    For i=0 to len(myText)-1
      Wait 0.5*loopindex seconds
      letter=mid(myText, loopindex, 1)
      If letter="%"     
                If textYellow=0  Set textYellow=1    <- next letters will be yellow
                Else Set textYellow=0                   <- next letters will be black
      Else
           If textYellow=0  bbt_dialogue_texte Append letter
           If textYellow=1  bbt_dialogue_texte Append ""&letter&"[/color]"[/code:16o5kby7]
  • This may be easier to understand:

    myText="Hello, %John%! How are you?"     <-  use % to mark start and end of yellow text.
    
    letter=""
    
    textYellow=0    <-  textYellow=0 means black text, textYellow=1 means yellow text
    
    For i=0 to len(myText)-1
      Wait 0.5*loopindex seconds
      letter=mid(myText, loopindex, 1)
      If letter="%"     
                If textYellow=0  Set textYellow=1    <- next letters will be yellow
                Else Set textYellow=0                   <- next letters will be black
      Else
           If textYellow=0  bbt_dialogue_texte Append letter
           If textYellow=1  bbt_dialogue_texte Append ""&letter&"[/color]"[/code:3l3t2kxn]
    

    Even that seems to me too complicated ...

    I think I'll keep it that way eventually.

    As I said before, it fits well with the story of my game.

    Sorry to have bothered you and thank you for your help.

    The plugin will still be useful for texts in menus and others.

  • It's not complicated, here:

    https://www.dropbox.com/s/52pnctfjocwbq ... .capx?dl=0

  • It's not complicated, here:

    https://www.dropbox.com/s/52pnctfjocwbq ... .capx?dl=0

    Thank you but...

    You did not save it in one file.

    I only have the .capx

  • You only need the .capx

    Just open it in C2.

  • You only need the .capx

    Just open it in C2.

    Oh, I have to update construct 2

    Tank you

  • If you have old version of Construct 2, you can do this:

    Unzip CAPX file into a folder.

    Then open .caproj file in Notepad and edit this line:

        <saved-with-version>24600</saved-with-version>
    
    change to your version, for example :
        <saved-with-version>24400</saved-with-version>
    [/code:y97j1txw]
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)