How do I make a limit on how many bullets my char can shoot?

Get help using Construct 2

Post » Sat Apr 19, 2014 4:08 pm

Hello all, I have a question; how do I make a limit on how many bullets my character can shoot? Right now my main character can shoot an infinite amount of bullets. I want to limit this, can somebody point me in the direction of a good tutorial (please)?

Thanks,
guannstar (FNORD)
B
28
S
5
G
1
Posts: 594
Reputation: 3,286

Post » Sat Apr 19, 2014 4:20 pm

Hey! Do you mean so that there's an amount of time between shots or there is a limit on the quantity fired?

Basically do you mean a reload time or ammo?
B
23
S
4
G
1
Posts: 71
Reputation: 8,346

Post » Sat Apr 19, 2014 4:30 pm

No, not reload time, I'm talking about having to use/pick up ammo. (Thanks for the quick reply.)
B
28
S
5
G
1
Posts: 594
Reputation: 3,286

Post » Sat Apr 19, 2014 4:34 pm

No problem! Using an instance variable is probably best. Give your character a variable "ammo" and set it to 10 or something

On the shooting event add another condition - character, compare instance variable, ammo > 0

Then add an action - character, subtract from, subtract one from ammo

If you need to pick up ammo, just add to the ammo variable.


Hope this helps!
B
23
S
4
G
1
Posts: 71
Reputation: 8,346

Post » Sat Apr 19, 2014 4:36 pm

OK, thanks a lot, I'll try that and get back to you:)
B
28
S
5
G
1
Posts: 594
Reputation: 3,286

Post » Sun Apr 20, 2014 3:54 pm

Yeah, that did help a lot. Just one more thing thing though, how do I display text that says how many bullets I have left? Do you have to link a text variable with a number variable? If so, how?
B
28
S
5
G
1
Posts: 594
Reputation: 3,286

Post » Sun Apr 20, 2014 5:14 pm

Bump:( Sorry, but I really need some help.
B
28
S
5
G
1
Posts: 594
Reputation: 3,286

Post » Sun Apr 20, 2014 5:39 pm

You have the text box object option you can display it or spritefont. There have been a few issues that text box wasn't working on all browsers and stuff so it is recommended to use spritefont. But for testing a rextbox should be fine all you have to do is set the event that says text box set text and put the variable that you are using to be placed there.
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Sun Apr 20, 2014 5:53 pm

I believe the Text object is what you want and not the Textbox !
https://www.scirra.com/manual/116/text
What I know would fill a Book , what I don't know would fill a Library
B
37
S
12
G
29
Posts: 331
Reputation: 16,499

Post » Mon Apr 21, 2014 9:56 pm

OK, I did everything @LevelUpJordan said, there's still one problem though. In the image below, there is "Text" under the "S" button (which is the shooting button). When I preview the game everything works fine. My character has a limit now of 36 shots. When they are done (the bullets), he has to pick up an item to get 18 more bullets. That's exactly how I wanted it, so thanks for that:) The problem is that the "Text" below the shooting button below shows up when previewed as the number 36, but does not subtract anything from itself at all when I shoot. Can somebody help to explain why that might be?

Image

P.S. The Text below the shooting button was named "AmmoTxt".


Thanks,
guannstar
B
28
S
5
G
1
Posts: 594
Reputation: 3,286

Next

Return to How do I....?

Who is online

Users browsing this forum: vegapomme27 and 10 guests