How do I Use Picked Count?

0 favourites
  • 5 posts
From the Asset Store
Be quick and count the cards and choose the right number!
  • I'm trying to figure out if all enemies are killed EXCEPT ones with a Boolean attached.

    So I'm doing a

    if Enemies(family).Boolean = True

    compare if Enemies.PickedCount = 0

    Action "level complete"

    However. It doesn't seem to work properly. I have a button that destroys all enemies for testing, and when I do that, the pickedcount stays as is from the start of the layout. When I play the level normally - it goes down as I kill enemies one by one except once it gets to 1 enemy, it won't go to 0. Am I missing something?

  • have a capx with the issue isolated?

  • https://dl.dropboxusercontent.com/u/28104568/PickedCountBug.capx

    oosyrag - I've made a new project. I believe it's either a limitation or a bug. Ashley - any idea about this?

  • It is not a limitation. I believe you are using it incorrectly.

    The reason the counter does not change on kill all is that the event only triggers if a sprite with "countme" set to true exists. Pickedcount for an Object will never return 0 if you do it in any kind of event that picks instances of that object meeting a condition, because events with conditions trigger only after at least one instance meeting the conditions is found (assuming there is no condition set by you to tell it "if picked count>X", then you would need x+1). Also the event changing the counter is before the event destroying the enemies. What happens is:

    Tick 1

    1) counter is changed to reflect current number (5)

    2) button was pressed, destroyed all (after counter last updated)

    Tick 2

    1) no enemies exist and thus the condition for updating the counter is not met. This is why you see the initial number as the set text action does not execute at all.

    The proper way to do this would be as in the attached capx, use a subevent in a event block with no conditions, check if any marked with "countme" enemies exist in one subevent, else in the other subevent set counter to 0 (as they don't exist).

    https://www.dropbox.com/s/pdj2npl3h0tu1 ... .capx?dl=1

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Pulstar - Ahh, I suppose that makes sense. Thank you!!

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