Flash words from a text file?

0 favourites
  • 4 posts
From the Asset Store
A collection of 10 amazing sprite sheet animations for your incredible games
  • Any suggestions or directions on how I can use an (external text file) to display words, one at a time on screen? For example, I have an external text file that says "Now is the time for all good men... yada yada".. And I want be able to display "Now" -- "is" --- "the" --- "time" --- "for " --- "all" --- "good".... (you get the idea I think)... It is actually a "reader" for a short story, so the text file may be somewhat lengthy...

  • If you make sure that there is always the same symbol separating words (space may be the obvious choice), then you can use tokenat and tokencount expressions.

    variable currentWord=0
    
    Keyboard on Enter pressed:
     Text set text to trim(tokenat(fileData, currentWord, " "))
     Add 1 to currentWord
    

    You can also use tokenat() with newline separator to break text into paragraphs, and then break paragraphs into words.

  • I will do a test to implement what you have suggested,,,, BUT what determines the "timing" of the words being presented. I see no reference to time? Will these flash too rapidly? If so how to slow them down? Possibly add a "delay"?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I thought your question was more about how to get words from the file.

    In my example one word is shown at a time when Space key is pressed. You can change this to "Every X seconds" or some other event. Or you can display all words in a loop, here is an example with 0.5 delay between words:

    Repeat tokencount(fileData, " ") times
     Wait 0.5*loopindex
     Text set text to trim(tokenat(fileData, currentWord, " "))
     Add 1 to currentWord
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)