Object Count

Get help using Construct 2

Post » Tue Feb 18, 2014 6:14 pm

Your example is perfect, but I want to touch the three destroyed sprites and sprite is created, but in doing so, I create three sprites
B
11
S
4
G
1
Posts: 410
Reputation: 2,752

Post » Tue Feb 18, 2014 6:16 pm

Sorry still confused, you want to first destroy 3 sprites, then create a single other sprite in their place?
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Post » Tue Feb 18, 2014 6:18 pm

exact
B
11
S
4
G
1
Posts: 410
Reputation: 2,752

Post » Tue Feb 18, 2014 6:28 pm

This means you will need to identify the different groups of overlapping objects within the "Check Overlap" function. A given group can be defined whenever you reach these two conditions:

1. For a given Sprite, there are no more overlapping Reds, (or Sprite2 and Greens) and recursion has reached the deepest level

AND

2. The number of overlapping sprites found is greater than 2

So whenever these conditions are true you can store an X and a Y value of where you want the new sprite to be created, then loop through all those values after they have all been created and create a sprite for each.

Why don't you give it a shot, it should be obvious where the two conditions I mentioned are met if you look at my capx. If you can't figure it out I'll edit the example, but it will be a long while before I have time to do that.
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Post » Tue Feb 18, 2014 6:33 pm

You can make me your Capx example?
B
11
S
4
G
1
Posts: 410
Reputation: 2,752

Post » Tue Feb 18, 2014 6:37 pm

cant this be done with families ?

Stuff all balls in 3 identical families.

Families instance variable color

3 way collision, same color balls

event
fam1 overlapping fam2
fam1.color = fam2.color
fam2 overlapping fam3
fam2.color = fam3.color
fam3 overlapping fam1
fam3.color = fam1.color
action
fam1 destroy
fam2 destroy
fam3 destroy


In theory this should be able to destroy the 3 balls with the same colors overlapping.

lennaert2014-02-18 18:37:38
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Tue Feb 18, 2014 6:37 pm

You should try it because that's how you learn. Why don't you make an attempt, upload it, and when I get home in 10 hours I will look at it and fix it if it's not working.
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Post » Wed Feb 19, 2014 12:59 pm

God knows that I will have tried hundreds of times to no avail
B
11
S
4
G
1
Posts: 410
Reputation: 2,752

Post » Wed Feb 19, 2014 9:19 pm

If you upload your best attempt (using my original example) to figure out how split up the groups of overlapping objects so that each group only spawns one other sprite, I can take a look at it and help in getting it to work :)
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Post » Wed Feb 19, 2014 10:23 pm

Instance Variables
Boolean: Red1 touching Red2 (R1R2) = false
Boolean: Red1 touching Red3 (R1R3) = false
Boolean: Red2 touching Red3 (R2R3) = false
-----------------------------------------------------------------
IsColliding(Red2) with (Red3) - Set R2R3 (true)
Else R2R3 (false)
IsColliding(Red1) with (Red2) - Set R1R2 (true)
Else R1R2 (false)
IsColliding(Red1) with (Red3) - Set R1R3 (true)
Else R1R3 (false)

Then you will want to do something like this:

R1R2(true) - Red1.destroy, Red2.destroy, Red3.destroy
(condition) R2R3 (true)
(condition) R1R3 (true)
B
6
S
2
Posts: 19
Reputation: 547

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests