0 Favourites

How to count items on screen?

  • Hello everyone, I've got a problem with a kind of puzzle game I'm trying to make. On each screen there are some balls that the player has to destroy (think of something a bit like puzzle bobble). I'm trying to make a counter to see how many balls are on the screen at each time, but I can't find the right funciont to do it. Until now, I was using something like this:

    System / Every tick

    System / Pick all "ObjectA"

    System / Pick all "ObjectB" -> Variable Set var to objectA.Count + objectB.Count

    I then dump that var into a text object on screen each tick.

    The problem is that when there are no instances of ObjectA, for example, the counter just stops working. Is there any other way to count how many instances of more than one object type are there?

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Just " Every Tick -> Set var to A.Count+B.Count " should do the trick. The reason it's not working is the "Pick all" conditions. The event doesn't run when there are no instances of either of the objects.

  • Thanks a lot, that did it. I thought I needed some "Pick all" conditions in order to be able to use those .Count funcions.

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