0 Favourites

Typewriter effect and word wrap problem

  • 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" />

  • Construct 3

    Buy Construct 3

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

    Buy 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)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread sticky
276 261,903
gamecorpstudio's avatar
Unread hot topic
0 Favourites
3 word story
120 11,701
MPPlantOfficial's avatar
Unread hot topic
164 38,099
totoe's avatar