How do I go to a new layout, but start with NEW time from 0

Get help using Construct 2

Post » Tue Mar 11, 2014 2:00 am

I first created a little game. I set up the game so that after certain amounts of time, specific things would happen. I called this layout page "game". For example, in the game:

1. After 5 seconds, it will play sound1
2. After 10 seconds, it will play sound2

AFTER I set up the 'game' page, I then created the intro/title page... I set it up so that once they are on the title page, they hit a button and it brings them to 'game' page... but once they get there, all of the time is screwed up -- since the game already thinks certain time has already passed (while it was sitting on the title screen). Therefore...

HOW CAN I SET UP THE GAME SO THAT WHEN THE ACTUAL GAME PAGE BEGIN, IT STARTS FROM 0 SECONDS.. AS IF IT WAS THE VERY FIRST PAGE IN THE GAME?
B
9
S
2
Posts: 111
Reputation: 1,010

Post » Tue Mar 11, 2014 7:01 am

You could create a global variable to store time in. In your event sheet count it up every second, and reset the global variable when you switch to a new layout.
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Tue Mar 11, 2014 7:06 am

Make sure you use wallclocktime. It gives you the time in seconds since the game began and is not affected by anything (like pausing the game etc)
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Post » Tue Mar 11, 2014 1:48 pm

Sorry to be a bother.. but could you possibly give me an example and tell me EXACTLY how to do it? Basically, I want every level to start from a time of 0 and then just count normal. I do know how to create a global variable but I'm not sure how to have it deal with the time issue for each level. Sorry.

Thanks. :)
B
9
S
2
Posts: 111
Reputation: 1,010

Post » Tue Mar 11, 2014 2:20 pm

Here is what I would do:
  • Make global variable "timecount" and set it to Number, value=0
  • Create an event: System->Every 1 second; create an action: System->Add to timecount, value 1
  • Create another event: System->Compare instance variable->timecount = 5; create an action: System->Audio->Play sound = sound1
  • Create another event: System->Compare instance variable->timecount = 10; create an action: System->Audio->Play sound = sound2
Then, when you go to another layout: System->At start of layout; System->Set value->timecount = 0. This essentially resets your global timer each time you navigate to another layout.

Of course, you could probably also wrap most of this into a handy Function so you just call the Function each time you go to another layout; saves time having to copy/paste this for each layout!

Hope this makes some sense. I'm not actually at my home computer to view the exact inputs/outputs but maybe this gives you enough to work with for now.
B
7
S
1
G
1
Posts: 56
Reputation: 732


Return to How do I....?

Who is online

Users browsing this forum: jaytrott86, Lancifer and 8 guests