Check for number of items?

0 favourites
  • 5 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • Hi, I have a game inwhich the player has to collect stars (original I know) but I can't figure a way to check if all the stars on the layout have been picked up before allowing them to continue.

    I have a block that's in the way of the exit, once all stars are gone the block moves. I've tried checking if the star sprite IS ON LAYER (and inverted) but it doesn't work.

    I have 2 layouts using the same event sheet, is it because the stars on the other layout are still there or should the event react on the layout that's currently playing?


  • Try sprite.count.

  • How are you starting your layout? Are you created the sprites at layout in the event sheet. Or have you created and placed your sprites manually in the layout editor?

    A basic fix is to have a global/instance variable. If you create sprites at the start of layout, then add one to that value per sprites. Alterntively if your sprites are already place before the start of layout. You could instead use "for each" and add 1 to the value of the variable.

    Then when your player collects the sprites, subtract 1 from the value per sprite.

    When the variable = 0 then all the sprites have been collected, the door move etc....

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have this in my project, but I added 1 each time something is collected, then told system to look for the specific number of items. Same thing, essentially.

  • Thanks all. I've tidied it up a lot and found out I can include one event sheet in another so now I've put all the major things in one sheet and each level has it's own variable / stats for the number of stars. I'm adding them manually in design time and want to keep it that way because I'm thinking of adding hidden stars etc, so it'll be easier for me to impliment. Still learning with Construct but getting there.


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