Time attack - Time triggered/stored per layout

Get help using Construct 2

Post » Thu Dec 15, 2011 1:45 am

Hello!

So i followed this neat tutorial on making a time counter. But now a problem has appeared.

The timer will start when the game starts, meaning it will count from 0 and up, starting at the menus. For example, when i start the first level from the menu, 15 seconds have already passed by.

So i need a way to trigger the timer only when a specific layout has been initiated.

The game will have several levels, as well as seperate high score tables, so in the end i'll need a way to have seperate timers, connected to each level, and a way to stop the timer when the end of a level has been reached, as well as the ability to store it to a value.

*Edit: I'll also need a feature that halts/pauses the timer for x seconds when the player collides with an object (when picking up an item).

Anyone done anything similar? Or have any tips on how i can achieve this?

Any help is appreciated!Era2011-12-15 01:48:08
B
34
S
11
G
9
Posts: 189
Reputation: 8,595

Post » Thu Dec 15, 2011 2:31 am

You can use global variables for that. I used two variables: counter, paused.
Set "counter" initial values to your maximum time.
Layer1:
on start of layout -> set paused = 0
every 1 seconds, paused = 0 -> subtract 1 from counter

player on collision with object -> set paused = 1, wait x seconds, set paused = 0

whenever you want to stop the counter, just set the "paused" variables to 1, and 0 to resume it. :)01lifeleft2011-12-15 02:33:34
B
34
S
8
G
5
Posts: 174
Reputation: 5,791

Post » Thu Dec 15, 2011 2:39 am

Thanks, i'll test this out!

If anyone still have some input, feel free to shoot. Especially about the storing of highscores!
B
34
S
11
G
9
Posts: 189
Reputation: 8,595


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 22 guests