If out of ammo AND no bullets on screen restart, not working

0 favourites
  • 10 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • I want the layout to restart if the player's ammo = 0 AND there are no bullets currently on the screen.

    For example the player has 3 shots to hit the target, If he wastes his first 2 shots, then shoots the third bullet at the target, I don't want the layout to restart until the bullet is off the screen, just in case it does hit the target.

    I am using this setup currently, it doesn't work but I can't see why not.

    Note in my game I have 2 different kinds of ammo, and of course I only want it to restart if the player is out of BOTH kinds. Also note I destroy bullets when they leave the layout, so any workaround must take that into account please

  • How are you testing for this to occur? Its hard to tell from the above screenshot. Every tick, Every Second.. something else ?

  • How are you testing for this to occur? Its hard to tell from the above screenshot. Every tick, Every Second.. something else ?

    Nothing...

    I assumed the conditions themselves would be checked by the engine every tick, isn't that how all conditions are checked by default?

    I'm pretty new to construct 2 so correct me if I'm wrong.

  • If the event is a top level event indeed it should be checked every tick.

    As SpongeHammer said, it is hard for us to only tell from this very close up screenshot.

    It would be better if you could provide your full capx. (Go into Full Editor, tab "Upload attachment" and upload your capx there)

    This will make it easier for us to investigate and tell you what is going wrong.

  • Alright, I have attached the capx file to this comment.

    It's obviously a WIP and a bit of a mess, but just run any of the numbered layouts and you'll see how it works. There is only 1 event sheet currently.

  • The oproblem is, that you say "when Bullet & Sprite are not on screen" but the problem is, they don't exist, so they are not not on the screen either <img src="{SMILIES_PATH}/icon_e_wink.gif" alt=";)" title="Wink">

    You need to test, if any object bullet and any object sprite exists, and if they both don't (and your Ammo is 0) then restart.

    https://www.scirra.com/manual/29/object-type

    SOL functions

    sol.hasObjects()

    Returns true if the object type has at least one instance and select_all is true, or if the SOL instances array is not empty and select_all is false, else false.

  • Hey, thanks for responding... I gotta admit I'm pretty clueless though.

    Searching for "sol.hasfunctions()" in Construct 2 brings me no results and googling it didn't really bring me anything I could understand.

    I understand what you mean, but I don't know how to actually use it in Construct 2!

    Could you be so kind to show or tell me practically how I can apply this to my specific problem?

  • @TomCarter : Sorry, my bad, that's not for the use inside construct 2.

    As an apology, I tuned your capx-file, as simple, as I would do it.. Maybe this helps you more than just with this specific problem

  • >@TomCarter : Sorry, my bad, that's not for the use inside construct 2.

    As an apology, I tuned your capx-file, as simple, as I would do it.. Maybe this helps you more than just with this specific problem

    Hey! Thank you!

    I'll admit I spent about 15 minutes staring at it screaming why isn't it working?! As of course what you're wrote is logically sound...

    The thing we both missed is that I start my levels with 1 bullet off screen that is instantly destroyed. This means that before the player fires anything, we get -1 projectile, which means we have 0 projectiles when we still 1 ammo left which causes the game to restart as soon as we fire that last projectile, rather than when it's destroyed like we want.

    Very simple fix of course, I simply made Projectiles start at 1 instead of 0. I also did some clean up stuff like having it be set to 1 when loading any layout so it works for the rest of the game, just mentioning this in case anyone else with the same problem reads this thread ion the future and is confused

    Thanks again for your help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • [quote:3kudvpvy]The thing we both missed is that I start my levels with 1 bullet off screen that is instantly destroyed. This means that before the player fires anything, we get -1 projectile, which means we have 0 projectiles when we still 1 ammo left which causes the game to restart as soon as we fire that last projectile, rather than when it's destroyed like we want.

    Yeah, I have overseen that

    Happy, it still helped!

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