Using multiple families together

0 favourites
  • 8 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Hi, I'm having trouble understanding how to use multiple families together. Please help.

    Please refer to the following .capx https://we.tl/g4BVWiNxdo

    I have 2 blue sprites in the the 'BlueF' family.. and 2 green sprites in the 'GreenF' family.

    When I have BlueF 'set position to' GreenF, it does exactly what I want it to do, with each blue sprite going to his own green sprite.

    Next, i have an event that Destroys BlueF when I Click on GreenF.. The entire BlueF family gets destroyed.

    What I actually want to happen is that only the blue sprite that is sharing the same position as a green sprite get destroyed. the other blue sprite must remain until I click the green sprite on top of it.

    Please help, Would be amazing if the attached capx is altered for me to get a good understanding =)

    THANKS

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You need conditions to "pick" the instances your actions are applied to. By clicking greenf, you pick that greenf but bluef is not specified, so when you destroy bluef all instances of bluef are destroyed.

    You can add an additional condition bluef is overlapping greenf to pick the correct one to destroy.

    But in this case, it sounds like you should be using containers instead of families.

  • oosyrag That overlapping condition doesnt work because both blue sprites are overlapping green sprites.

    dewetberg

    You have no idea of the complexity of the question you are asking xD

    You want to make a connection between an instance of a green sprite and an instance of a blue sprite, so when you click on green, blue gets destroyed. Impossible.

    There are a couple of ways to go around that.

    1st way - as suggested by oosyrag, using containers. The problem - the green and blue sprites both get destroyed.

    2nd way - use multiple green and blue sprites, so - green1, green2... and blue1, blue2..., and when

    green1 clicked>>destroy blue1

    green2 clicked>>destroy blue2... and so on.

    There might be some clever way using instance and global variables, UID and IID, that solves your problem, but it will be hard to do.

  • 99Instances2Go

    Your example doesnt work. When I click the first green square 3 times, all blue sprites are destroyed. When green is clicked, only the blue sprite below it should be destroyed.

  • True, i am wrong.

    But they do pair by IID. Destroying 1 breaks the entanglement. (hope that statement holds up)

  • Thanks to everyone for the response and interest in this topic.

    Programmer25 Nothing is Impossible =D

    oosyrag and 99Instances2Go You guys are rock stars!

    So both of your suggestions didn't work out to have the required result.

    BUT

    I've taken 99Instances2Go's capx that has the IID event in and added the overlapping condition to it as suggested by oosyrag..

    BOOM! works perfectly. so it was basically a combination of the two suggestions. go team! thanks guys!!

    Here is the capx: https://www.dropbox.com/s/3eo64ag2shdu59d/theypairbyIID-Edit.capx?dl=0

  • dewetberg

    Nice work! I learned something - you can have multiple conditions on one event (Im new to Construct). Without them it would be impossible xD

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