Typewriter and Time Scale

0 favourites
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • When I set my time scale to 0 my typewriter animation keeps going. Is there a way to make the typewriter animation respect the time scale when I set it to 0? I would like to pause the typewriter when I set my time scale to 0. It appears typewriter has its own time scale that won't listen to a global timescale?

  • Its n action and its execute at any way.

    If you check in debug mode you will see that if you typewrite "hello world" in 5 seconds , at next click the text is "hello world" and not "h".

    If you want to stop the typewritting on timescale = 0 just set the text to spritefont.text but then when you set the timescale to 1 you have to re-typewritting from start.

    I didnt found any way to continue the typewritting.

  • savvito123 Thanks for the reply. So, there is no way to actually pause the typewriter. It either plays all the way or it starts over from your experience?

  • Hi, can you link a capx or a screenshot of your code so we can help you to find a solution? It all depends of how you managed your typewritting effect; Thanks ~

  • Tomycase

    Hey, thanks for your interest in trying to help with this issue. Apologies for taking a bit to reply.

    To give you a rundown - I have a globally shared event sheet called "D_Pause". It talks to all of my other event sheets. When you suspend the game or touch the settings button it brings up the pause menu and sets the time scale to 0. EXCEPT for typewriter. It appears to keep going whether I pause or not. As a result, when I pause, the narrator or sounds will actually pause, but upon resuming, the text from the typewriter is finished and it makes the narrator or sfx appear to lag. Screenshots attached. I can make you a capx if interested, figured I'd start with images first. Let me know. Thanks.

  • It's definitely because the built-in Type Writer plugin uses the worldclock time measurement system and division (as oppose to wait for seconds). Changing time scale will hence still make it finish in real-time.

    But you can make your own Type Writer 'function'. And same way, pass on the Text and Duration, with 'wait for some seconds' in between it will do the same.

    I made a quick one here just now: https://drive.google.com/file/d/1X_5eRV-9f7zwMD_JQ4aIIuozICPi-E-R/view?usp=sharing

    Note: It uses recursion, which is slow by itself, so it wastes some extra time. Meaning, the 'duration' you enter won't be exact. It may take a few extra seconds to complete. But it stops with time scale 0, so it does the job!

  • Right I forgot C3 text has typewritter built in now, I know tho that the same happens with the particles in C2, they won't be affected by timescale unless you set their timescale individually, maybe try to set your text object timescale to 0 the same way?

  • Tomycase

    I thought your idea was a good one - setting the object time scale. Sadly it didn't work though. It makes sense as to why it doesn't work based on El Constructorr's explanation. Thanks for the suggestion though!

  • El Constructorr

    Thanks for the explanation. Your method is above my understanding and skillset, but it totally works! I looked at your code and wanted to tweak it with bbcode colors. However, when the sentences are written out it flashes my bbcode before it processes it and then the colors are applied. Is there a way to avoid showing bbcode as it typewrites the sentence? See the attached example I tweaked.

    my.pcloud.com/publink/show

  • Oh yeah, it simply inputs every character at a time so it only recognizes the bb code until it's finish reading the square bracket close.

    I've added another function that appends everything after "[" until it reaches "]" together.

    Here: https://drive.google.com/file/d/1Vld_KKaslJQrRHWb-R89m0lFf27w3Iif/view?usp=sharing

  • El Constructorr

    Your solution was awesome and it totally works! I actually put it into my working file and got it to work. However, it broke my masks I was using over my text boxes - That has nothing to do with your solution. That is a totally separate issue that I did not include in this forum topic.

    The new issue - in my working file I have masks atop my text box that are activated on touch. the masks are set to "Blend Mode": Source Atop". When I tap on them now, they don't recognize your solution as something they want to blend atop of. I have no idea why. They were working fine when I had my lamer text box there... but with your solution, they got grumpy and stopped working.

    *edit : found out why: I have an action "When Typewriter is finished" set my masks to active. I need to find a way to replace "When Typewriter is finished" with your "When Function is finished" instead.

    That's the joy of developing a game, fix one thing, break 2 more things. Are you interested in consulting at all? I could use a guru to talk about issues like this. Let me know if there is a good way to contact you.

  • Thanks, I'm glad it worked!

    As for 'On TypeWriter Finished', the simplest solution would be to raise a signal (I prefer using another function) when the loop reaches the end of 'length'. This is where you would add that function:

    So it would work the same way as the original plugin. EXCEPT, if you later add more Type Write texts, you'll need a way to specify which textbox finished. Currently, the function is specifically for one Text box. But if you want to use multiple text boxes, I've modified the function, which lets you add 'tag' so you can refer to which 'On typeWriter Finished', and also TextUID to refer to which textBox you want to write to.

    Here: https://drive.google.com/file/d/1XlAVb_h002XTk3I7ir5l_MnUvT_sjMwU/view?usp=sharing

    Sorry, I am currently not looking for consultancy, as I see myself getting busier and more occupied soon with my own pending projects. Thank you for asking though! I'll be around on and off, you can use this forum to get help from myself and many others, who ever is available.

    Hope this helps.

  • El Constructorr

    Understood about being swamped with your current projects. I figured it was worth a shot to see about your availabilty.

    Welp, I managed to break your code. Ugh! I tried to bring your code into my existing project (as your other versions) and I could not tweak it to talk to my project this time around. I suspect it is all about the UID. This UID thing went over my head.

    To give you an idea -

    My project has 32 pages - each page has a body of text that changes to tell the story. When I brought your code in I could not figure out how to tweak the individual page text box's UID to sync up with your code per page. So, I deleted the instance variables talking to UID in your project, and I got it to work again. I really want to understand the thinking behind UID and tried to read up on it, but it doesn't seem easy to tweak. Then again, I'm not a programmer.

    Overall, Your code works awesome as it has since the first iteration, but I did come across another issue. I tweaked your C3 file (attached) to "somewhat" resemble my project in a barebones sense. You'll see that I have two pages now to simulate going to a new page, etc. If you go to page two, then decide to go back to page 1, you'll see that the textbox actually truncates and ignores the first part of what needs to be written for page 1, and starts typing mid sentence instead of starting at the beginning of the paragraph.

    To replicate: Go to page 2, then hurry back to page 1 (don't waste any time, just click), and you'll see what I mean (hopefully). Also, as a test on page 1 - I set up "on Function Typewriter Finished/Create/Purple Sprite. When I go to page two, it still creates the sprite. Not sure why since I am on page 2. I don't have the function "on Function Typewriter finished" on Page 2's event sheet but still creates it?

    Thanks again for your suggestion. I enjoy learning different perspectives on how to tackle this issue.

    Project example here:

    my.pcloud.com/publink/show

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Alright, so since we've made a custom function and your project is expanding, you can expect to fall upon such problems. BUT, they are easy to fix. The solution is really simple.

    But, to make you understand 'why' tags and UID were so important (and in fact, they're required to solve your issue there) let's intentionally bump into more problems (along with the two problems you mentioned), and then fix them one by one as I explain what we're doing. I want you to make the changes as you read this post (at least half way through) so you can follow along.

    Problem 1

    First, to fix the initial problem of moving layouts before the writing finishes, it is because it uses a global variable 'i' to track the position (index) of typeWrite, and it's when you change layout at (let's say) i = 10, then it resumes from 10th character. All you need to do is add this in the _global eventsheet, so every time on the start of every layout it types from the beginning:

    Before continuing, do that above, try it out, make sure that works.

    Problem 2

    Alright, here's a new problem that you're most likely to face later. So let's face it now. I want you to place TWO (or more) Text boxes on Layout 2 for example. Ideally, you would want the first text box to finish writing, and then the next one starts. ALSO, in both, you have written different texts. But from the Function typeWriter there is no way you can tell which text box writes what. Try it out and see how the two textboxes behave.

    This is where "tags" and "UID" are so important. The UID is an ID number unique for every object in C3. So you can 'pick' or refer to it from event-sheets. With the help of UIDs, you can tell which textbox you mean, rather than just saying Type ! Question is: type where?

    So if you click on a text box, you can see it's UID on the left panel:

    The function that I made had a place to include that UID, so that it writes exactly to that, and doesn't get confused.

    Problem 3

    How do I include 'On Finished' in different layouts?

    Unfortunately, "On Function" events can only be used once. Yes they do get activated no where in which layout this is placed. So I highly suggest, place that 'On Finished' event in the _global layout.

    The only way you can correspond to 'On Finished' on for each layout, is by knowing which textBox 'on finished' you're referring to. So you can add sub-events with UID's in one place like this:

    Problem 4

    What are tags then?

    Optional, but very useful. As you can see above, when you have a large project and you need to change what happens after Layout 12 text finishes, it would be become so convenient that (in addition to UID's) you also label each typeWrite with your own "tag", so that you can identify them textually like this:

    And lastly, you can even place the other functions of TypeWriting/SkipBB (that I had made, which are not to be changed) in the _global layout too. Will become more organised.

    You can find a complete page-wise C3P here: https://drive.google.com/file/d/18nAVXIN5XEiyr2yVN4pgZESzt3dGJDPG/view?usp=sharing

    Hope this clears everything.

  • El Constructorr

    Thank you for the detailed reply! I started to add changes and so far so good. However, I ended up on an intense freelance project and my time has been occupied. When I get a moment to breathe I'll update you on how it goes on this typewriter project.

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