How do I apply an action to all family members

0 favourites
  • 6 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Hi guys!

    I'm starting to use families since my license upgrade :) and just realize that families are made for attach behaviors to all the members but not to apply the action to all of them at the same time but just for the member that triggered the event.

    I understand that families were made that way. I've read scirra.com/manual/142/families and of course "Laser", on collision, has to destroy only the enemy family member that triggered the collision...

    ... but if I want to destroy all the members on the family "enemies" when any collision between laser and enemy happens?

    Is there a way to do this without doing it one by one?

    Similar to what I need is:

    Family: "myFamily".

    Content of "myFamily": 20 different sprites.

    The 20 sprites behavior: Physics.

    The sprites are moving randomly on the screen and when one hits another, I want to destroy all the "myFamily" members.

    I tried:

    "myFamily" -> on collision with "myFamily" -> "myFamily" destroy.

    But this only destroy the collisioners.

    Thanks for your time guys ;)

  • Well, the simplest way I can think of is to make a new global variable (let's call it "Destroy") and set it to 1 on the collision. Then in a separate event, say "If Destroy = 1 -> myFamily destroy".

    There might be another way, but this'll do the trick.

  • + Laser: on collision with myFamily

       + System: Pick all myFamily -> myFamily: destroy.

  • Haha, yup... I figured there was something like that, but I've never had to use it before. <img src="smileys/smiley17.gif" border="0" align="middle" />

  • shinkan thank you! I knew that something like that had to exist.

    Thank you very much :)

    I will try it as soon as I get home.

    SullyTheStrange thank you for your time and suggestion too :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I forgot to thank you shinkan, it works for what I need to do :)

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