0

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

-1

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

abinop
  • 3,153
  • 5
  • 32
  • 46
  • You can also accomplish this using the Sprite behavior "Timer". I usually have an invisible GameController Sprite for things like score, time, etc. On start of layout, you can set a timer to run for 10 seconds and then use the OnTimer condition to respond to the time running out. It's the same end result, but with only 2 events and no global variables. – Jeff Neet Jul 01 '16 at 20:15