Auto Runner - Block

Get help using Construct 2

Post » Wed Sep 21, 2016 8:05 am

Hi guys,

I'm currently trying to create my own game using the Auto Runner template. If you had a look at the template, you know that the block will move to the left (bullet behavior) and leave some space, then create another block with random width. Two blocks won't stick together, there will always be some gap between two blocks.

My question is, I stopped the block from moving by using "Set Bullet Disabled" for 5 second, then it will resume moving to the left, then I notice, that the next block coming sticks with the previous block, so how could i stop all the blocks from moving when i use "Set Bullet Disabled"? Below is my capx file.

https://www.dropbox.com/s/2cbp6kcac0ue9 ... .capx?dl=0

Please help me, thanks!
B
48
S
20
G
6
Posts: 73
Reputation: 6,474

Post » Wed Sep 21, 2016 8:44 am

Hi johnkx,

Looking at the .capx file I can see that the following line is your problem:

"Distance
Every tick -> Add Block.Bullet.Speed * dt to CurrentDistance"

When you are "pausing" the game by using "Set Bullet Disabled" for 5 seconds you are not stopping this counter from running. In fact, Block.Bullet.Speed is still constant as you are not changing that value, you are merely 'Disabling' the object's behaviour. This means that even though your blocks are disabled they are continuing to spawn.

I resolved it by adding a global variable called "Pause" and used Boolean logic:

"On "BGStop" -> Set Pause to 1"

"On "BGStart" -> Set Pause to 0"

"Distance
Every tick
Pause = 0 -> Add Block.Bullet.Speed * dt to CurrentDistance"

By adding the condition "Pause = 0" your Distance logic will only run while the game isn't paused.
B
8
S
2
Posts: 59
Reputation: 686

Post » Fri Sep 23, 2016 3:42 am

@Lncredible Good job! You made my day, haha! Thanks alot!
B
48
S
20
G
6
Posts: 73
Reputation: 6,474


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 37 guests