Page 1 of 2

Dynamic Z Order?

PostPosted: Thu Jun 06, 2013 3:19 pm
by Wigriff
The other issue I am having with making my player interact correctly with trees is a z order problem, I believe. I have browsed the forums looking for a solution, but so far I haven't found any.

Basically, I want the player sprite to look like he is standing in front of a tree if he logically SHOULD be standing "in front" of a tree, and I want him standing behind a tree if he should be standing "behind" a tree. So far I have him permanently z-ordered behind the trees.

This is a test level with some placeholder graphics for the UI and no animation, so please excuse the awful presentation. I just want to show an example of how it is currently working.

https://dl.dropboxusercontent.com/u/172450407/ForumTest/index.html

We are making a tower defense game along the lines of Pixel Junk Monsters if anyone here has played it on PS3. If you watch some PJM gameplay footage you will see how their player interacts with trees. We aren't cloning the game, but we pretty much cloned their 1st level because we figured if we can make a PJM level first with all the core functionality, we can just adjust things from there.

Re: Dynamic Z Order?

PostPosted: Thu Jun 06, 2013 3:31 pm
by EncryptedCow
I'm doing the same sort of thing. I put the origin of the trees and the player in a position where if you were looking at a 3d model, thats where the the center of the feet would be. For you it would be right in the middle of the shadow. Then, in the events I do:

For Each spr_tree
|- If spr_tree.Y >= spr_player.Y
   -> spr_tree move above spr_player
|- Else
   -> spr_tree move behind Spr_player

Re: Dynamic Z Order?

PostPosted: Thu Jun 06, 2013 3:47 pm
by Wigriff
I think that will work Cow, but I will have to work out a way to do it using the UIDs I think. When I apply it to all trees with a "For Each" it creates an... interesting phenomenon. lol

Check it out: https://dl.dropboxusercontent.com/u/172450407/ForumTest/index.html

Re: Dynamic Z Order?

PostPosted: Thu Jun 06, 2013 3:48 pm
by Wigriff
I can probably do it much like I did the opacity problem, using blackhornet's method in combination with yours. Wigriff2013-06-06 15:49:08

Re: Dynamic Z Order?

PostPosted: Thu Jun 06, 2013 4:39 pm
by vee41
Here's an simple one event version that sorts objects based on their Y location. Uses a family, so you'll need paid license.

Tree example

Re: Dynamic Z Order?

PostPosted: Thu Jun 06, 2013 5:00 pm
by Wigriff
Ugh. I DO have a paid license (personal), but it is through Steam. It says that I have version 132, and I need version 133 to open your capx. I should have never bought Construct through Steam. Ever. EVER. It has been a constant headache.

Re: Dynamic Z Order?

PostPosted: Thu Jun 06, 2013 5:03 pm
by Wigriff
Oh, r133 is a beta release. I guess it isn't because of Steam. heh

Re: Dynamic Z Order?

PostPosted: Thu Jun 06, 2013 5:06 pm
by vee41
Here you go:



You basically order objects by their Y, and then move them to top of the layer. The origin points need to be properly placed, usually at the bottom of the object. There is also a plugin that does the same thing.

Re: Dynamic Z Order?

PostPosted: Thu Jun 06, 2013 6:32 pm
by Wigriff
So I would make an identical command for the trees as well? I tried this, and with one for the trees as well, and either the player is always on top, or the trees are. I am sure I am doing something wrong. lol.

Re: Dynamic Z Order?

PostPosted: Thu Jun 06, 2013 6:39 pm
by vee41
Put both your trees and players in the same family.