Delayed shooting with one key press

Get help using Construct 2

Post » Sun Feb 26, 2012 9:32 pm

I'm trying to make an object shoot other objects when the player presses a button, but the shoots should be delayed by 0.1 seconds.

I tried 'repeat' with 'every 0.1 seconds', but it just shoots once.
I tried 'repeat' with 'wait', but it just freezes the game after I press the key.
I tried substituting 'repeat' with a 'for', and it does the same in both scenarios.
I tried to assign a variable with an 'every 0.1 seconds', but it just shoots once.

I would post the capx but it's a mess, so if you really need me, I'll try to recreate the problem in a new one (I hope that's not necessary).

Thanks in advance!
B
22
S
3
G
6
Posts: 59
Reputation: 4,450

Post » Sun Feb 26, 2012 9:45 pm

So are you:
- Trying to shoot multiple shots with one press of the button, spaced 0.1 seconds apart,
- Trying to shoot multiple shots while the button is held down, spaced 0.1 seconds apart, or
- Trying to shoot one shot, delayed 0.1 seconds after the button is pressed (or released)?
B
13
S
6
G
2
Posts: 13
Reputation: 1,977

Post » Sun Feb 26, 2012 9:54 pm

Trying to shoot multiple shots with one press of the button, spaced.

I have another action that doesn't let me 'shot' more than once per second, so let's say I press the button two seconds in a row, I would want, at these times:

0.0 shot 1
0.1 shot 2
0.2 shot 3
1.0 shot 1
1.1 shot 2
1.2 shot 3
B
22
S
3
G
6
Posts: 59
Reputation: 4,450

Post » Sun Feb 26, 2012 10:17 pm

+ On key pressed
-> Spawn an object
-> Wait 0.1 seconds
-> Spawn an object
-> Wait 0.1 seconds
-> Spawn an object
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Sun Feb 26, 2012 10:37 pm

My bad, I should have said that the number of shoots could vary and I'm shooting them from different image points, so that's why I was trying to use a loop...

Anyway, checking for the points worked as Ashley said, so thank you very much!

Can you explain me why the wait inside the loop freezes the game?
B
22
S
3
G
6
Posts: 59
Reputation: 4,450


Return to How do I....?

Who is online

Users browsing this forum: Kagubro and 23 guests