How do I Limit one Bullet at a time?

Get help using Construct 2

Post » Fri Mar 07, 2014 4:49 pm

I have two objects 1 player and 1 enemy i want that if space is pressed spawn bullet but i also want that only one can be spawn at a time (i have used Groups,Variables etc.) Could anyone give me a live example (The player and enemy can shoot at one time but player can not shoot if is last shot bullet was not destroyed and same was the case of enemy)
Banned User
B
32
S
6
G
5
Posts: 116
Reputation: 6,420

Post » Fri Mar 07, 2014 6:08 pm

You can add an instance variable to your player called "bulletCount". When you shot the bullet set it to 1, when you destroy the bullet set it to 0.
Then on you fire bullet event add a condition, if "player.bulletCount = 0".
B
39
S
15
G
5
Posts: 295
Reputation: 6,089

Post » Sat Mar 08, 2014 7:39 am

It will take long as i have many layouts and event sheet? any other ideas?
Banned User
B
32
S
6
G
5
Posts: 116
Reputation: 6,420

Post » Sat Mar 08, 2014 8:16 am

What Joskin said is the best way. It's always important to build the foundation of your project early on to avoid having to go back and tediously change things.
B
3
Posts: 4
Reputation: 187

Post » Sat Mar 08, 2014 8:53 am

Can i do that by Adding a group that is disabled and whenever player wants to shoot it will set the group active and the group will further check variables and decide whether player can shoot or not?
Banned User
B
32
S
6
G
5
Posts: 116
Reputation: 6,420

Post » Sat Mar 08, 2014 11:20 am

Do as you want, there are multiples ways to achieve this. Do the easiest one for your system ! :)
B
39
S
15
G
5
Posts: 295
Reputation: 6,089

Post » Sat Mar 08, 2014 3:48 pm

You can always add how far player bullets has travels and then destroy it. say for example player bullet travel distance > then 400 pixel then destroy player bullets this way soon as player bullet is destroyed player can spawn another
B
250
S
39
G
15
Posts: 1,953
Reputation: 40,623


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], Yahoo [Bot], yiuyiu6666 and 16 guests