2d-gamesconstruct-2

Timer in Construct 2


I'm using Construct 2 for create a game. It's just for browser, not mobile. The thing is, I need to use a timer, this timer going to start from 10 seconds and countdown. When the timer it is in 0, I stop the game, show the score and put a button that's move the user to home screen and in this home screen I have a button to start the game again.

The problem is, I put a condition, when time is <= 0 stop the game, then, the timer doesn't stop and continue counting to negative values, so, when I tried to start again pressing the button, the timer indicates me negative numbers and I can´t start again.

How can I restart the timer and this doesn't show me negative values and let's me start the game again.


Solution

  • I have created a sample project for you.The project does exactly what you want.You press the home screen button and it takes you to the game screen. From there you press the button and the counter runs from 10 to 0.

    The result is accomplished basically by using global variables to know when timer starts and when the 10 seconds have passed.

    timer code

    You can find the whole code here https://onedrive.live.com/redir?resid=2CE98A8912F75BBB%2154720