0 Favourites

How do I store a text into an array each letter on it's own

  • Hi!

    I need to write text in which each character can be separately colored. I found out that the Tag Text plugin can do that.

    The way Tag Text works is that you give the letters you want to color a tag by giving them a class. For example if I wanted to color the letter "t" in the sentence "My example sentence" I would have to type it like this:

    My example sen<class="tagged">t</class>ence.[/code:1m7uwsbc]
    
    I need to choose which letters to color dynamically based on variables. How should I approach this problem? My initial thoughts are that I should maybe store each letter of the sentence separately in an array so that I can loop through them and add the class when needed.
    
    Is it possible to take a sentence and automatically store each letter in an array? I'm trying to avoid having to put each letter by hand to it's place in the array.
    
    Any thoughts are welcome!
  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Phew, I finally got it!

    I will attach a capx-file in which we first take a string and store each letter in an array. Then we loop through the array and manipulate the contents based on variables. Finally we output the array back to text and use Tag Text to color specific letters of the sentence!

    Very cool!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)