how to pause a game

0 favourites
  • 4 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • 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 !

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • but remember that Time Scale is best to use with timedelta as Ashley mention that on other post

    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.

  • Is there a way to pause when a game loses focus?

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