Question about pausing game

Get help using Construct 2

Post » Sun Jun 15, 2014 11:58 am

I want the game to remain paused for ONLY 3 seconds, then I want it to resume itself. But it is not working:

Try 1:

System: Set Time Scale = 0
System: Wait 3 seconds
System: Set Time Scale = 1

Doesn't work

Try 2:
Variable Count = 0;

System: Set Time Scale = 0
System: Every 1 second, add 1 to variable count.
Is count = 3? If yes then Set Time Scale = 1

Doesn't work.


It looks like when "time scale = 0" everything stops working, even the "in every X sec" action stops working. Is there a workaround for this?
B
10
S
2
Posts: 79
Reputation: 1,122

Post » Sun Jun 15, 2014 1:41 pm

Try this:



Create a Global variable called IsPaused
Create a Global variable called Timer

Create a family FamilyObjects

Put all objects you want paused into FamilyObjects

Timer=0

System > Timer (Is Greater than 0) > System > Set IsPaused to 0
System > Timer (is less than or = 0)>System > Set IsPaused to 1


System > IsPaused =0 > Set FamilyObject Time Scale = 1

System > IsPaused =1 > Set FamilyObject Time Scale = 0
-----(sub event---)------- > System > every 1 Second > System -1 > From Timer


On some Condition > System > Set Value Timer to 3



It actually may work without the Family and just trying it setting the System timescale to 0 and 1, if not, setting the time scale of the objects to 0 should do it.
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Mon Jun 16, 2014 2:11 pm

TheDom wrote:Try this:



Create a Global variable called IsPaused
Create a Global variable called Timer

Create a family FamilyObjects

Put all objects you want paused into FamilyObjects

Timer=0

System > Timer (Is Greater than 0) > System > Set IsPaused to 0
System > Timer (is less than or = 0)>System > Set IsPaused to 1


System > IsPaused =0 > Set FamilyObject Time Scale = 1

System > IsPaused =1 > Set FamilyObject Time Scale = 0
-----(sub event---)------- > System > every 1 Second > System -1 > From Timer


On some Condition > System > Set Value Timer to 3



It actually may work without the Family and just trying it setting the System timescale to 0 and 1, if not, setting the time scale of the objects to 0 should do it.


@TheDom thanks for helping. The problem is that this game is an endless runner and it contains a lot of "Every tick do this" functions for example: Every tick: Move platform, every tick increment DistanceRan. As far as I know, you cannot add an event to a family; you can only add objects. I want the "Every tick" function and other game events to stop for 3 secs. Is this possible?
B
10
S
2
Posts: 79
Reputation: 1,122

Post » Mon Jun 16, 2014 2:28 pm

Add "IsPaused to 0" as a 2nd condition to the "every tick" conditions. The events can only fire every tick if the game is not paused.
B
75
S
23
G
3
Posts: 673
Reputation: 9,283

Post » Mon Jun 16, 2014 3:07 pm

TheDom wrote:Add "IsPaused to 0" as a 2nd condition to the "every tick" conditions. The events can only fire every tick if the game is not paused.

@TheDom
Thanks,

When trying to move objects that I want to be paused to FamilyObjects, it says you can only add objects of the same plugin to familyobjects. What should I do?
B
10
S
2
Posts: 79
Reputation: 1,122

Post » Mon Jun 16, 2014 3:11 pm

Setting the timescale also affects the 'Wait' action.

Instead try making a measurement based on the wallclocktime expression, which is not affected by the time scale.
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,762

Post » Mon Jun 16, 2014 3:51 pm

thesecretweapon wrote:
TheDom wrote:Add "IsPaused to 0" as a 2nd condition to the "every tick" conditions. The events can only fire every tick if the game is not paused.

@TheDom
Thanks,

When trying to move objects that I want to be paused to FamilyObjects, it says you can only add objects of the same plugin to familyobjects. What should I do?


Just create more Families for the other plugin types and then add them in the same events as FamilyObjects
B
75
S
23
G
3
Posts: 673
Reputation: 9,283


Return to How do I....?

Who is online

Users browsing this forum: evillair and 7 guests