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

0 favourites
  • 7 posts
From the Asset Store
A master sorting Puzzle fun and addictive puzzle game! A challenging yet relaxing game to exercise your brain!
  • 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!

  • 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

  • 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

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

    https://dl.dropboxusercontent.com/u/700 ... Timer.capx

  • 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)

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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!

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