Typewriter effect and word wrap problem

0 favourites
  • 11 posts
From the Asset Store
Keyboard, Mouse & Typewriter SFX / 27 Unique Sound Clips
  • Heya, I'm using Rex's text typing plugin - c2rexplugins.weebly.com/rex_text_typing.html - to apply a typewriter effect to my dialogue boxes. Very nice, I love it! Only problem is that the word wrap on my spritefont object kicks in mid-word sometimes, meaning you see the word start to spell out on the end of one line, only for the whole word to jump to the next line when it overflows. Is there anything that can be done about this?! The effect is so close to being perfect <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry for bump, but I really need help with this

    Because my spritefont has a fixed character width and always shows the same max characters per line, I was thinking of running some sort of process on the source text to automatically insert 'newline's before sending it to the text type effect. All I basically need to do is find and replace the LAST " " space instance every x characters, Maybe regex or something. But I'm just not smart enough to work it out.

  • Its maybe easyer to format the source of the text ?

  • That's what I want to do. But I don't want to do it manually - my game has a looooot of text that I edit and re-edit frequently. I don't want to be constantly previewing and adding newlines by hand because honestly, doesn't that sound like something a computer should do for you? :p

    The current character limit for my spritefont is 39 characters per line. All I really need to do is find the last instance of a " " space in every chunk of 39 characters and replace it with a newline. I've been trying to work out the logic and so far my best solution is a hideous dog's dinner of events that involves breaking the text into individual variables for lines and running a bunch of mid() and right() and find() and replace() expressions and then reassembling the lines into one string that is then sent to the text typer. I haven't tried this yet so I don't even know if it'll work - it just seems way too disgusting and unwieldly and I was hoping somebody who's good at coding (which I'm not) would be smarter than me and would know what a real programmer-type person would do and would save me from having to make such a monstrosity :p

  • I think you should format the whole text to a Dictionary. With 3 str variables. WholeText, TempText, NextText.

    once > Set NextText to WholeText

    While NextText is not ""

    Set TempText to NextText

    Variable 'place' = 0

    For "index" from 39 to 0

    if mid(TempText , loopindex("index"), 1) = " " > break loop

    > set place to loopindex("index")

    add key to dictonary .. key = str(some counter) .. value = left(TempText,place - 1)

    Set NextText to right(TempText, len(TempText) - place)

    (you might have to place -1 or + 1, not sure)

    Store the .jason, could be handy.

    Something like that.

    Then you have it all handy. Reading from from the dictonary goes like:

    the expression : Dictionary.Get(str(some counter))

  • Iiiinteresting! OK, thanks for your help, I'll put your idea in the melting pot

  • Hey, so I ended up doing this a completely different way - I realised I could use tokenat to just split the string up into words and count the characters in each. I gave my spritefont an instance variable called CharsPerLine to keep track of how many max characters to account for per line and then did this (source text is in a variable called textToProcess):

    Then you just call the processNewlines() function whenever you want it to do it!

    Works a treat, thought I'd share my solution for any future Construct users who have this problem

    (You don't need to use the areYouTyping boolean on the spritefont, I just have that because it's useful to know when the typing effect is in process)

  • mikehive

    Sorry to bring this topic back from the dead but I've run into the same problem, is this file still available as the link is now dead.

    Thanks.

  • mOOnpunk

    If your text is static, the easiest solution would be manually inserting line breaks into it. I usually use some symbol (like "^") to mark line breaks, and then replace it with newline before displaying on the screen.

    For example:

    myText = "You have unlocked^a new quest!"

    SpriteFont set text to replace(myText, "^", newline)

  • I'll give it try thanks.

  • Sorry to bump this old thread one last time, but I promise I'm doing it for a good reason...

    I'm aware that people land on this thread from Google searches a lot and I get asked questions about this problem all the time. As such, I thought it would be helpful to write up a full blog post with a detailed solution for anybody else who is having this issue - looks like the explanation I posted above has been removed.

    Construct 2 Text typing and word wrap tutorial: http://mikelaraman.com/construct-2-text-typing-and-word-wrap-tutorial/

    Hope it helps! This topic can now officially die ;)

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