How do I count sprite that have a specific variable

0 favourites
  • 4 posts
From the Asset Store
An educational game for counting pictures. An easy to use template for developers to build larger games
  • Eg:

    I want to set a global variable to the number of sprite that have eg_variable=1

    Thanks

  • Make a family that is all sprites with eq_variable. Then loop through that family with a counter. If eq_variable=1 add one to the counter. When you are done the value in the counter is the answer.

    Or

    write a function that given a sprite in the family it returns one iff eq_variable=1. Then pick all members of the family for which this functions is 1. Then pickedCount gives you the number of the sprites with eq_variable=1.

    yours

    winkr7

  • Is there a way to use sprite.count and simply add an other expression that would make it so it only count the sprites that have the desired variable?

    It would be so much simplier if it's possible since I haven't used loops often.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Not that I know of. There are probably scripting ways to do this that loop through all the variable names associated with sprites but it is more complicated than I understand. There are much better construct 3 people here who perhaps can answer your question.

    yours

    winkr7

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