How do I make ammunition and change it

Get help using Construct 2

Post » Sat Oct 22, 2016 2:12 am

Hi all! I came across an idea in Construct 2. I was wondering how I can make ammunition to my player and change it when he fires.
B
4
Posts: 4
Reputation: 208

Post » Sat Oct 22, 2016 2:27 am

Please be more specific... there are many ways to do what you are asking and many different possible expectations.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
65
S
17
G
8
Posts: 635
Reputation: 9,331

Post » Sat Oct 22, 2016 2:50 am

Like when I maybe declare a variable and check the condition of it everytime I fire. And when it reaches 0, it reloads itself.
B
4
Posts: 4
Reputation: 208

Post » Sat Oct 22, 2016 4:40 am

Here is a thread of a similar nature, close to the bottom is a link in my post to a .capx I put together for him. It does more than what you ask... maybe it will help you get your head around how to do what your after.

https://www.scirra.com/forum/viewtopic.php?f=147&t=182474

Otherwise, it's pretty simple. Just make a variable called ammo. Every time you fire subtract 1 from ammo. When ammo = 0 set its value back to start amount and play reload animation/sound/ or message.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
65
S
17
G
8
Posts: 635
Reputation: 9,331

Post » Sat Oct 22, 2016 4:50 am

Maybe also add an action: wait X seconds, so there is reloading time?
B
5
S
1
Posts: 13
Reputation: 351

Post » Sat Oct 22, 2016 2:31 pm

Okay, thank you all for the replies!
B
4
Posts: 4
Reputation: 208

Post » Sun Oct 23, 2016 11:46 am

If you want to display text of how much ammo is available do this

Ad global variable "Ammo"

Everytick set text to "Ammo:"&ammo

Rightmousebuttonclicked
System
Subtract 1 from ammo

Ammo is less than < 1 add 10 to ammo

That's how I do it maby someone knows easier way I'm I started programming 3 months ago
B
6
Posts: 23
Reputation: 304

Post » Sun Oct 23, 2016 1:32 pm

I update my text boxes when I change their value. It's just one extra line of code per and less updating.
You could also update something like this every x seconds using .01 or .5 and never notice visually but would cut down the number of updates a min drastically.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
65
S
17
G
8
Posts: 635
Reputation: 9,331


Return to How do I....?

Who is online

Users browsing this forum: wizdigitech, Zamargo and 14 guests