How do I select the top object in a layer?

0 favourites
  • 5 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • My end goal is to make something like Alchemy (http://littlealchemy.com/)

    I've been working on my project for some time, but as it has come together, it has come apart.

    The issue is that as I stack objects on top of each other, I don't know how to have them be distinct. What I WANT to do is to make it so that ONLY the top item in the stack (whatever is at the top of the Z order) can be combined.

    Right now there is an exploitable problem in my version. Putting together a HUGE STACK of different objects, and then bringing a new object over will cause it to combine with ANY OBJECT in the stack it can combine with instead of only considering the top object.

    The built in abilities of Construct don't seem to have a solution to this issue. I can't figure any way to get control of what is active in a same layer stack on the z-level.

    Any ideas or help would be appreciated <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • Use:

    For each Sprite order by Sprite.ZIndex descending, with a "Stop loop" event

    That will operate on the top most object.

  • So apologies for being such a newbie, but I'm not sure how exactly I'd do that.

    For my sprite objects - a, b, c, d (etc - there are 25 of them) I'd need to put each of them in to a loop that is saying to only look at the top-most sprite in the pile (ie - look at whatever is on top and ignore everything below).

    That's the general idea?

    I really appreciate the help!

    Could you help me identify how to create that loop inside Construct?

    I can put in a "for each" and set a specific object (say 'A') to order by A.ZIndex (Descending), but that isn't the solution to the issue I know, it doesn't take into consideration that object B should be ordered above A if B is in fact above B, and I can't figure how to get the object to be considered for each specific Sprite that might be in a stack (I expect I'm not thinking about this like a programmer...and that is well b/c I'm not one!)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Put all relevant objects in a Family, then it does exactly what you want.

    Edit: also, needing 25 different objects usually points to unnecessary complexity. You could use just one sprite with 25 frames/animations. Just track by frame number/animation name.

  • cyruszuo Can you give a screenshot of the event sheet that pertains to this? This will help give a better answer

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