0

How should I go about (it's an isometric game) to make the depth logical?

Example, if a farmer is above another farmer (a.k.a the y value is lower, but he is HIGHER up), how would I make it so that he looks as if he is behind the farmer below him?

Same goes with walls.

I want the characters to look like they are BEHIND the walls if they go... behind it.

But be in front of the wall if they are in front of it.

The isometric perspective makes this so much more confusing to code

A good comparison of what I want is like the older beatemup games (like TMNT) where you could walk to the left and right and up and down to some extent (for example on a road). In the middle of those roads, there were sometimes objects like barrels. You could either go above and behind it, or below and in front of it.

Or something like this http://www.maxdamage.org/wp-content/uploads/2012/10/tmnt02.jpeg

You see 4 characters. The characters can be in front of each other (if they stand behind).

1 Answers1

0

I'm not sure of the different ways in ActionScript to influence the order in which elements are drawn. One typical idea is the Z-index, which tells the graphics engine what to paint first. It can somehow be simulated in AS3 by the ChildIndex of a MovieClip, see Arrange (z) order of objects in Flash with ActionScript 3?.

But see also this http://oreilly.com/catalog/actscript/chapter/ch13.html#36994 about the stacking order and depth parameter of movieclips in a stack and the swapDepths() method in AS2 and http://www.matthijskamstra.nl/blog/index.php/2008/08/27/from-as2-to-as3-where-did-it-go-swapdepths/ of how these methods are related.


One very crude idea (if this is even possible) is to have an array of MovieClips or stacks that acts as layers of the image, each layer about one tile deep. Then assign objects and characters in the layer corresponding to their y variable and have the layer movieclips as children of a parent movieclip, with childindex arranged so that the layer most in the back comes first and is painted first, and the front layer is last in line to be drawn.

When moving a character, reassign to one layer above or below if the y coordinate changes out of the range of the current layer.

Sort objects in the same layer according to y coordinate.


Perhaps it is sufficient to just have the objects sorted according to the y coordinate. Multiple layers may speed things up by having smaller lists to sort, but this could also be wrong for the particular circumstances of AS.

Community
  • 1
  • 1
Lutz Lehmann
  • 25,219
  • 2
  • 22
  • 51