How do I select the top object in a layer?

Get help using Construct 2

Post » Sat Oct 04, 2014 8:58 pm

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 :)
B
4
Posts: 3
Reputation: 206

Post » Sat Oct 04, 2014 9:06 pm

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

That will operate on the top most object.
ImageImageImage
B
71
S
21
G
220
Posts: 3,646
Reputation: 123,721

Post » Tue Oct 14, 2014 3:04 pm

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

:)
B
4
Posts: 3
Reputation: 206

Post » Tue Oct 14, 2014 3:16 pm

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.
ImageImageImage
B
71
S
21
G
220
Posts: 3,646
Reputation: 123,721

Post » Tue Oct 14, 2014 11:07 pm

@cyruszuo Can you give a screenshot of the event sheet that pertains to this? This will help give a better answer
B
13
S
5
G
1
Posts: 119
Reputation: 2,292


Return to How do I....?

Who is online

Users browsing this forum: chrisyamao, Meqara, Twili and 1 guest