How do I make a delay between bullets (plataform game)

Just started using Construct 2? Post your questions here

Post » Sun May 18, 2014 5:53 pm

Hi guys,

i'm wondering how to make a delay between each bullet shot, i'm building a "megaman like" game and i want my "archer" to shot an arrow, then wait something like 0.5 seconds and then shot another. See what i mean?

(I attached an image for you people to see the arrows)

the player objetct is "Archer" and the arrow is called "SingleArrow"
You do not have the required permissions to view the files attached to this post.
B
7
S
2
Posts: 57
Reputation: 591

Post » Sun May 18, 2014 10:54 pm

You need to add instance variable to the player : boolean and make it true

keyboard on clicked or mouse
Boolean is true ------------- shoot
------------- set boolean to false
------------- wait 0.5 seconds
------------- set boolean to true

You can check the shooter rain demo inside C2, The player use delay with his gun.
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,155

Post » Mon May 19, 2014 12:28 am

A0Nasser wrote:You need to add instance variable to the player : boolean and make it true

keyboard on clicked or mouse
Boolean is true ------------- shoot
------------- set boolean to false
------------- wait 0.5 seconds
------------- set boolean to true

You can check the shooter rain demo inside C2, The player use delay with his gun.


Thanks A0Nasser :)
It works like a charm
You do not have the required permissions to view the files attached to this post.
B
7
S
2
Posts: 57
Reputation: 591

Post » Mon May 19, 2014 10:42 am

You can make the "Archer" in the same Keyboard event, you don't have to use subevent.
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,155

Post » Mon May 19, 2014 1:29 pm

You could also use the "Every X Seconds" event together with the On Space Bar Pressed event, it will work the same way.

You can also use the "On Key Pressed" event, if you want the archer to shoot an arrow every time you press the spacebar, but don't want him to keep shooting while the bar is pressed.
B
20
S
5
G
1
Posts: 37
Reputation: 1,139

Post » Tue May 20, 2014 12:01 pm

diogomuller wrote:You could also use the "Every X Seconds" event together with the On Space Bar Pressed event, it will work the same way.

You can also use the "On Key Pressed" event, if you want the archer to shoot an arrow every time you press the spacebar, but don't want him to keep shooting while the bar is pressed.


"Every X Seconds" doesn't work as well because the seconds are independent of any key press.
For instance, if it's every 5 seconds, and you press shoot at the 4th second, you can shoot once then, and after a second, you can shoot again.
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

Post » Tue May 20, 2014 12:58 pm

Sushin wrote:
diogomuller wrote:You could also use the "Every X Seconds" event together with the On Space Bar Pressed event, it will work the same way.

You can also use the "On Key Pressed" event, if you want the archer to shoot an arrow every time you press the spacebar, but don't want him to keep shooting while the bar is pressed.


"Every X Seconds" doesn't work as well because the seconds are independent of any key press.
For instance, if it's every 5 seconds, and you press shoot at the 4th second, you can shoot once then, and after a second, you can shoot again.


Even when it's a sub condition? I have been using this without problems, but my delay is a lot shorter than that. Didn't know, I'll fix that on my game, thanks! :D
B
20
S
5
G
1
Posts: 37
Reputation: 1,139

Post » Tue May 20, 2014 2:06 pm

The Timer behaviour is the most versatile mechanism to use.
ImageImageImage
B
71
S
21
G
230
Posts: 3,688
Reputation: 128,847


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests