how to pause a game

Discussion and feedback on Construct 2

Post » Thu Sep 22, 2011 4:50 pm

hey there, can`t find out how to pause a game by pressing a key (e.g. "p")..
Guess it's easy, but dont know how to do it ;)

Thnx for answers !
Have a nice day !
B
17
S
3
G
5
Posts: 71
Reputation: 4,401

Post » Thu Sep 22, 2011 5:01 pm

Easiest way is to create a PauseToggle variable, then

when 'P' is pressed, set PauseToggle = 1-PauseToggle

If PauseToggle = 1 then set Time Scale = 0 Else set Time Scale = 1.0.

If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,843
Reputation: 48,287

Post » Thu Sep 22, 2011 5:22 pm

but remember that Time Scale is best to use with timedelta as Ashley mention that on other post

[QUOTE=Ashley] You should always include delta-time (the time since the last tick) in movements. For example, use

Rotate 90 * dt degrees clockwise

If you rotate 1 degree per tick like you had, at 10fps it rotates 10 degrees a second, and at 60fps it rotates 60 degrees a second (6 times faster). So to make games move at the same rate you always need to use dt. In the above example, it rotates 90 degrees per second regardless of the framerate.

When you set the timescale to 0, dt becomes 0 as well, so movements using dt also stop.[/QUOTE]
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Thu Sep 22, 2011 10:38 pm

Is there a way to pause when a game loses focus?
B
21
S
7
G
2
Posts: 185
Reputation: 3,280


Return to Construct 2 General

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests