Using multiple families together

Just started using Construct 2? Post your questions here

Post » Tue Jul 26, 2016 9:56 am

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
B
5
Posts: 8
Reputation: 241

Post » Tue Jul 26, 2016 4:05 pm

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.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Tue Jul 26, 2016 7:09 pm

@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.
B
10
S
3
G
1
Posts: 46
Reputation: 1,261

Post » Tue Jul 26, 2016 7:33 pm

B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Jul 26, 2016 7:48 pm

@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.
B
10
S
3
G
1
Posts: 46
Reputation: 1,261

Post » Tue Jul 26, 2016 7:55 pm

True, i am wrong.

But they do pair by IID. Destroying 1 breaks the entanglement. (hope that statement holds up)
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Jul 27, 2016 8:38 am

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
B
5
Posts: 8
Reputation: 241

Post » Wed Jul 27, 2016 8:56 am

@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
B
10
S
3
G
1
Posts: 46
Reputation: 1,261


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests