Back to layout after approx. 30 seconds

For questions about using Classic.

Post » Mon Feb 27, 2012 4:04 pm

Hiya,

For one of my end projects I persuaded my teacher so that I can now create an awesome game in Construct Classic (it will take me too long to learn Construct 2, that's why).

I'll be presenting my game in an art museum and I was having some difficulties on how to make sure every visitor gets the same playing experience. I know people are lazy, so I wanted to make sure that after approximately 30 seconds the game automatically jumps back to the title screen, another layout. Otherwise I can guess what will happen: people leave it in the middle of the short game and the next visitor has no idea what to do. Is this possible to do in Construct? :)

Thanks in advance,

M. vd Laar
B
4
Posts: 11
Reputation: 347

Post » Mon Feb 27, 2012 7:45 pm

Of course, it is possible :)
Combine the system condition 'compare time' with the system action 'go to layout'. The timer will be compared to a millisecond value (1000ms = 1s). You should also give your layout a name (in this example "titlescreen") and then use that name in the 'go to layout' action.

+ System: Timer is Greater or equal 30000
-> System: Go to layout "titlescreen" with transition "None" lasting 0 MS
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Mon Feb 27, 2012 7:58 pm

MvdLaar,

maybe this is obvious, but, you'll probably want the time to restart with each input, no? So, in addition to Tulamide's events:

+Every 1ms: Add 1ms to "timer"
->On Any Key Pressed: Set Timer to 0

This way, the player isn't interrupted and reset in the middle of the game, but once they stop playing, the counter won't be reset and will trigger the "go to "titlescreen" action.
B
17
S
3
G
4
Posts: 91
Reputation: 3,929

Post » Tue Feb 28, 2012 4:11 am

[QUOTE=the_chosen_byte] MvdLaar,

maybe this is obvious, but, you'll probably want the time to restart with each input, no? So, in addition to Tulamide's events:

+Every 1ms: Add 1ms to "timer"
->On Any Key Pressed: Set Timer to 0

This way, the player isn't interrupted and reset in the middle of the game, but once they stop playing, the counter won't be reset and will trigger the "go to "titlescreen" action.[/QUOTE]
I know what you're aiming for, and it is a good idea, but that code won't work. Timer is a system expression and you can't go faster than the current frame rate with "every x milliseconds" (and I doubt the game will run with solid 1000 fps all of the time) and key pressed is a trigger, not an action.

But you can do it by adding a global variable ("currenttime")

+ System: Always (every tick)
-> System: Add TimeDelta to global variable 'currenttime'

+ MouseKeyboard: On any key pressed
-> System: Set global variable 'currenttime' to 0

+ System: Is global variable 'currenttime' Greater or equal 30
-> System: Go to layout "titlescreen" with transition "None" lasting 0 MS

Note that you have to compare 'currenttime' to seconds, not milliseconds, if you want to use this method.

Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Tue Feb 28, 2012 2:40 pm

Thank you for your replies! Great explanations.

But, and I am truly sorry for this, I seem to have forgotten a major detail in my wishes in the first post: I actually meant that the game should automatically go to the layout after 30 seconds of complete silence;

In other words: I need to make something that makes sure that when there hasn't been touched a single button for 30 seconds, it goes to the layout 'titlescreen'.

I believe both your theories work and can be of practical use in this situation, only I need to add the fact that no button is touched whatsoever for 30 seconds.

I figured I could use a combination between tulamide's way and the_chosen_bite's way to do this, right? Like, every tick the system adds some milliseconds to the global variable timer (the amount depending on the fps) and when any button is touched, it sets the timer to 0. Only when for 20 seconds no button has been touched, it will automatically go to the titlescreen, right?
B
4
Posts: 11
Reputation: 347


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests