How do I pick, sort, and destroy in order of Y every 0.5 sec

Get help using Construct 2

Post » Mon Jul 06, 2015 6:30 pm

Hi all,

I want to write a loop which will:

- Find all instances of object "1" which overlap object "2" and make them "flash"
- Sort them by value of their Y axis
- Loop through them in order of Y from low -> high
- Destroy them one by one, every 0.5 seconds.

I have scoured the forums for more information about For Each (ordered) but it seems to be performing the actions as many times as the objects are found, so it isn't helping me! There must be a simple way.

Hope you can help, Thanks!
B
8
S
2
Posts: 59
Reputation: 686

Post » Mon Jul 06, 2015 7:17 pm

I had a go at it. You indeed need a For Each (ordered) but only for picking the Object2 with the minimal Y coordinate.

Objects stop flashing if the overlap cease to be, dunno if it's what you wanted but it made more sense to me that way !

https://dl.dropboxusercontent.com/u/700 ... Timer.capx
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Post » Mon Jul 06, 2015 9:26 pm

Magistross wrote:I had a go at it. You indeed need a For Each (ordered) but only for picking the Object2 with the minimal Y coordinate.

Objects stop flashing if the overlap cease to be, dunno if it's what you wanted but it made more sense to me that way !



Hi,

Thanks very much for the help! I don't think I quite explained what I had in mind though - in your game object1 slides over object 2 at different times whereas mine all happens at once (i.e. you place a block that covers multiple objects but it resolves destroying them 1 by 1 based on their Y axis coordintes, regardless of when the overlap began).

Do you know what I mean? If not I could mockup a diagram to help explain it

Thanks
B
8
S
2
Posts: 59
Reputation: 686

Post » Mon Jul 06, 2015 10:35 pm

I changed the logic a bit, is it more like how you want this to be ?

https://dl.dropboxusercontent.com/u/700 ... Timer.capx
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Post » Mon Jul 06, 2015 10:47 pm

OK so imagine this.

1) The red object 2 already overlaps objects 1 but it is not checking for overlap yet!
2) The red object now checks overlap.
3) It detects 3 instances of object 1.
4) It removes them one by one over 1 second intervals in order of Y axis (forget Flash for now)

Image
B
8
S
2
Posts: 59
Reputation: 686

Post » Mon Jul 06, 2015 11:01 pm

An event like this should do it:

start of layout
red overlaps circle
for each circle ordered by circle.y ascending
--- wait loopindex+1
--- destroy circle
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756

Post » Tue Jul 07, 2015 6:09 am

I swear I tried that! But your version works!

I suspect I made an error like using "loopindex * 1" instead of loopindex +1 which gave me the impression it was all happening at once...


Thanks for your help all!
B
8
S
2
Posts: 59
Reputation: 686


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Casimir, tarek2, Yahoo [Bot] and 11 guests