How do I pick top instance for scoring

From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • "The Image"

    Disks are created with stars for each disk. Since the disks are created at different times on that layer, they overlap each other - each new instance is created above the last instance.

    If the ball is 'overlapping' or 'on collision' with a star it's destroyed and scored (I've tried both ways). The problem is if there are other stars directly below the one the ball is currently on, all stars underneath are destroyed and scored.

    How can i destroy and score only the star that is on the disk that the ball is currently on? I've thought about trying it as scoring a 'combo', when 2 or more stars are directly underneath, but that's way beyond my brain.

    I've tried different ways that 99Instances2Go solved for me in the capx of this thread: https://www.scirra.com/forum/viewtopic.php?t=183022 which include a 'pick top instance' sub-event, but still can't figure this one out.

    Thanks for any help or input.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Cant use containers, because killing the star would kill the disk.

    Give the star an instance variable 'parent'.

    When you create the disk and the star ... set star.parent to disk.UID

    Give the star an instance boolean 'selected'

    Now

    In the event where you pick the disk that is overlapping the ball and refine that to the top most disk ...

    Add a 'every tick'

    with the action ... star > set boolean 'selected' to false

    add the following condition ..

    star > pick by UID .. UID = disk.UID

    and the action ... star > set booelan 'selected' to true

    Now you can pick the right ball anywhere in your events with ...

    star is overlapping ball

    star has boolean 'selected' set

    Question ... why is this not working ?

    star is overlapping ball

    star is top most

  • 99Instances2Go

    Holy crack, braniac! Uhhhhh.....thanks for the reply.

    Gonna have to go over that a few times for it to sink in.

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