Time attack - Time triggered/stored per layout

0 favourites
  • 3 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • 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!

  • 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. :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks, i'll test this out!

    If anyone still have some input, feel free to shoot. Especially about the storing of highscores!

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