How do I Count Instances With A Variable of A Certain Value

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
  • I have a game that has a lot of the same sprites on screen with different abilities depending on a variable that defines their class. So class one blocks act differently from class 2 blocks, but they are the same object. This is necessary because the objects need to be able to switch between these modes quickly. I need to also be able to count how many of the object with a certain class there are in the game (i.e. how many blocks with their class set to 2 are in the layout). Is there a simple way to do this? I can provide screenshots of event sheets if needed.

  • Just use "Pick by comparison" to find your value and then Sprite.PickedCount contains the count.

  • Hi,

    Add an instance variable (example: "Class number") to your object.

    To check how many there are you can write:

    System: Every tick >

    (sub-event) Object: compare instance variable (value=x) > System: set Global variable to Object.PickedCount

    Hope this helps!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ...I am dumb.

    Thank you for the quick response!

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