Solved my own problem

Get help using Construct 2

Post » Thu Jul 18, 2013 3:34 am

Edit: I was trying to figure out how to make my game pause and unpause. I couldn't find any tutorial regarding unpausing. I found toggle_switch, and made it work using that.



Rezialn2013-07-18 04:08:17
B
3
Posts: 1
Reputation: 177

Post » Thu Jul 18, 2013 4:01 am

If you're doing this the way I think you're doing it then I believe I've encountered a similar problem before.

The solution for me was to have the pause/unpause key toggle the boolean global variable instead of setting it to 1 and 0 because what happens is Construct will run through the events and the last even to be executed will have the final input on what the global variable will be.

Here's the solution:

On "p" pressed: toggle boolean global variable
subevent: boolean global variable = 1: pause
subevent: boolean global variable = 0: unpause
B
4
S
1
G
2
Posts: 27
Reputation: 1,004

Post » Thu Jul 18, 2013 4:06 am

Add an else condition between the two statements.

Problem:
If pause 0, pause = 1
If pause 1, unpause = 0

You are effectively pausing the game and unpausing the game in the same action, because the events are read from top down.

Adding an else condition to the second event will cause only one of those to be read per tick.

Solution:
If pause 0, pause = 1
Else, if pause 1, unpause = 0Sushin2013-07-18 04:07:03
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

Post » Thu Jul 18, 2013 4:14 am

If you are using the free edition, sushin's solution will save precious events, just be sure to add the key press as a condition in addition to the "if" checks.vinnie2013-07-18 04:15:27
B
4
S
1
G
2
Posts: 27
Reputation: 1,004


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests