Limit amount of bullets available

0 favourites
  • 7 posts
  • Hi everyone, a quick question which I cant find an answer for and fear i am being monumentally stupid.

    In the game I am building you have two main weapons, left mouse button fires bullets, right mouse button fires missiles.

    I want to limit it so that you only have 3 missiles and when they are used you cant fire anymore... Can anyone tell me how to do this or point me to where its explained.

    Thank you in advance for any help.

    P.s. Have played with a lot of game making tools in the past year+ and this one is truly the best one I have encountered. Hoping I can use it from now on.

  • This is the type of thing variables are extremely useful for! You can set up a variable, either a private one belonging to the player or a global one, to keep track of the missiles. The initial value can be set to 3, or however many you want to have at the start.

    Every time you click the right mouse button, check the value of the variable; if it's greater than zero, meaning you have ammo, fire a missile and subtract one from the variable, but if it's zero, you ran out, so don't do anything.

    If you have trouble implementing that idea, I could whip up a quick example to show you how it works. <img src="smileys/smiley1.gif" border="0" align="middle" />

  • hi, thanks, that's what I thought.

    I have already set a global variable in exactly the way you said, but I cant work out how to set it so that it checks if the variable is zero and if it is stops you from firing so a quick example of that would be very handy.


    Here you go! It's a VERY quick example, but it illustrates the principle pretty simply.

  • Ah I see now, you can combine two events into one, that makes sense.

    Thank you, I should be able to add that without difficulty now.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • No problem. <img src="smileys/smiley1.gif" border="0" align="middle" /> Don't hesitate to ask if you have any more questions!

  • I was having a major problem trying to figure this out, thanks so much for posting and answering guys.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)