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.
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.
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
-> spr_tree move behind Spr_player
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: dl.dropboxusercontent.com/u/172450407/ForumTest/index.html
I can probably do it much like I did the opacity problem, using blackhornet's method in combination with yours.
Here's an simple one event version that sorts objects based on their Y location. Uses a family, so you'll need paid license.
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.
Oh, r133 is a beta release. I guess it isn't because of Steam. heh
Here you go:
<img src="https://dl.dropboxusercontent.com/u/19921470/zordering.PNG" border="0" />
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.
Develop games in your browser. Powerful, performant & highly capable.
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.
Put both your trees and players in the same family.
Vee41: You sir, are a scholar and a saint. And a small, disheveled, furry brown thing, apparently. Regardless, I like you.
And here I thought making families would require weddings or some sort of weird sprite mating ritual that I wasn't entirely sure I wanted to be involved in. Your solution worked brilliantly. I actually didn't know about the families function or how it worked until now. You have saved me a TON of time in this project, and not just with this. Thanks. :D
It's construct 2 doing all the magic :)
Just remember that the family sorting method won't play nice with a combination of sprites and tiled backgrounds. But if you keep it to one object type, you should be good to go.