Prevent Player from spamming button

Get help using Construct 2

Post » Mon Sep 03, 2012 4:49 pm

Hello everyone, I am creating an action game in which the player can shoot by left-clicking the mouse. Only, I ha spams the left mouse button the game becomes too easy.
Is there a way to prevent the player from shooting repeatedly ?
B
9
S
1
Posts: 20
Reputation: 1,335

Post » Mon Sep 03, 2012 4:54 pm

You'll want to set a timer variable.

Something like this:

on left click:
if timer > 0.5:
--> shoot bullet
--> set timer to 0

every tick:
--> add dt to timer

You can change the '0.5' to change the possible rate of fire. You can also change 'on left click' to 'left button down' to allow them to hold the mouse button down to keep firing.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Mon Sep 03, 2012 4:58 pm

Thanks Sqiddster for awnsering this fast !
Billygoat2012-09-03 17:05:01
B
9
S
1
Posts: 20
Reputation: 1,335


Return to How do I....?

Who is online

Users browsing this forum: Televangelist and 22 guests