Gun reloading and clip size

Get help using Construct 2

Post » Fri Mar 22, 2013 7:48 am

So anyways, I just got my free copy of Construct 2. And I plan to use it on a top down shooter game.


Here's the problem:

I can't figure out how to create a limit on the bullets and limit the number of bullets that come out of the gun.

Another extra Problem:

I can't figure out why my health bar doesn't show up, even when the code is right. maybe I'll just replace it with a CoD like health meter (Edges on the screen start going red).

Please help !

Thanks
B
3
Posts: 4
Reputation: 358

Post » Fri Mar 22, 2013 8:01 am

Limiting ammunition is done with variables. For example, you could create a local variable attached to the player called Ammo. Every time the player presses the button to fire their gun, first you check if Ammo > 0, then if it is, create an instance of the bullet along with the firing animations (or whatever else is needed) and subtract 1 from Ammo.

If your code is right with your health bar, then it's probably something silly like a layer or object set to invisible. If you can't come right on your own then you should post a link to your capx so we can take a look for you.
B
56
S
15
G
10
Posts: 910
Reputation: 11,972

Post » Fri Mar 22, 2013 8:10 am

Thanks! I'll try it out now

For the health bar, it was a layer problem. Guess i need to be careful next time :)
B
3
Posts: 4
Reputation: 358

Post » Fri Mar 22, 2013 9:06 am

I really keep on hitting roadbumps.

Anyways, i put a text which shows the variable AMMOPISTOL. It shows ammo properly while firing, but when I try to reload, what happens is after reloading, if you keep on shooting the bullets come out but the ammo doesn't change.

Maybe because my pc is slow? anyways please help!

Anyways, here is the link!
Exported version : https://www.dropbox.com/sh/rpltwhugxh582mk/d-XN22NDSw
Project Files :https://www.dropbox.com/sh/cvk5i458jg8bfl7/zJfpskkZKZ
B
3
Posts: 4
Reputation: 358

Post » Fri Mar 22, 2013 9:32 am

That "every 2.5 seconds" at event 15 is weird, and seems to be causing the issue. Disable that and replace it with system->trigger once while true. Also set event 14 to trigger once.
B
56
S
15
G
10
Posts: 910
Reputation: 11,972

Post » Fri Mar 22, 2013 9:44 am

@Blushot You are going to keep running into issues that seem like roadblocks until you get used to the tools. I highly advise going over the manual (judging by the number of badges under your name I would say you haven't) and also going through many of the tutorials. Also Construct ships with many sample projects. Open them up and check the event sheets for a lot of good info on how things work.

Glad to have you in the community, it has a bit of a learning curve, but is a great set of tools.
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,428

Post » Fri Mar 22, 2013 12:02 pm

Thanks for the replies. Looks like i need a lot of learning and editing to do :)

B
3
Posts: 4
Reputation: 358


Return to How do I....?

Who is online

Users browsing this forum: DemantDigitalArt, Lancifer, Yahoo [Bot] and 25 guests