Timer and countdown

3

Stats

7,950 visits, 10,820 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Timer and countdown

Hey there, i again decided to make tutorial today it will be timer because my good friend asked me about it so let's start.

Layers

For timer we will need just one layer and its HUD or absolutely top layer.

Sprites

Ok now we won't need any sprites because we won't work with it just add text box and go to event sheet.

Event Sheet

Open your event sheet and add new Global Variable called "time1" keep default number and let it be 0.

Next you have to add condition System > Every X Seconds(0.1 for me) and action for this System > Add to > time1 > 0.1 ( you can chose

your own time but if im using every 0.1 second i will keep it here of course so timer is down

let's add now your visual timer so in-game timer. Add new condition System > Every tick and action

TextBox ( that you have created ) > Set text > "time1" so every 10ns will check your time and change this number in text.

Countdown

I think this will be for you a lot useful so check it and below check SPECIAL for some advanced settings.

Timer

This is not same timer as was before this is countdown timer ehm i don't know how to name it but ok let's continue. Make this type of timer is very easy just set up another Global Variable named "Countdown" and keep number and value change to your time that you want for me it's 5 seconds so will put there 5. Now you have to go

to event sheet and add another condition System > Every X Seconds ( now for me each second ) so my number is 1 and action System > Substract from "Countdown" 1. Let's explain it. Every second will remove 1 from my 5 second countdown so every second it will be first 5 second 4 etc. You can again setup your text by condition Every Tick and action Set text > "Countdown" this will make your countdown timer almost done, but here's problem. How to fix problem with negative numbers like i don't want from my countdown timer to go to -1 second left etc. This is bit harder i will show you easiest way to solve it and it's timescale function. Just add another condition System > Compare variable ( this works only when you have done your global variable ) Variable is "Countdown" Comparison "Equel to" and Value will be 0 then action will be System > Set timescale > to 0 this will stop all your processes in your game ok simple it will pause game. You can change Set timescale to "Restart layout" and this will restart current level of your game. For more ideas check Specials. Ok that's all :) Thanks for reading i hope it was helpful for you if you don't understood leave me comment with question.

P.S. If you are making timer dont use every X seconds lower than 0.001 because it's unneeded of course you can but just

tip :)

Specials

Difficulty: Advanced

While i was writting this tutorial i got small idea how to make it better and it is timer with countdown ok let's think our level have 20 seconds for complete.

Timer will take seconds once timer reach 15 seconds countdown will start but here's question why you should have 2 timers on your screen? You won't, just set opacity of your countdown text to 0 or visibility to invisible at start of layout you will be able to see only normal timer for make it easier i will use visibility. So set visibility of your countdown timer to "invisible" and go to event sheet. At event sheet add condition

Compare variable > time1 > Equel to > 15 and now add two actions first one "TextCountdown" Set visible to "visible" and second "TextTime" set visible to "invisible" this will hide one and appear second. This is done. But we need to start countdown timer and how? Simple you can set your countdown timer to your full round time it will appear from 5 seconds so it will go 20, 19, 18....5, 4.... and again solve it with set time scale as i said before. If you completed this congratulations it was hard and my english isn't best too :) You can support me by clicking on link below at my work first link with ads.

My work

You can also check my profile with my work on:

http://c36c7c1d.linkbucks.com (with ads)

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!