Hello everybody,
I am currently working on a little project alike to traditional RPGs, so think orthogonal tiles like in Final Fantasy / Chrono Trigger / Zelda aLttP for example. Main part of this tile engine is the example code coming with Gideros (sewers) and I have been able to include character movement (pixel perfect), simple collision detection (rectangles in an object layer) and applying the outer borders, so the map won't pan out of the screen so far. The characters are drawn in a specified layer between normal objects and those which should appear above the hero / character.
As my character sprite is taller than one tile, I've stumbled upon the problem that tiles drawn in the "upper layer" always are on top of this sprite, even if the character is in front of a tree for example.
My first idea was to add each row of the map individually to the scene so that - depending on the y-position of the character - he is always drawn above the tiles which are "behind" him. This turned out to be not that trivial because of my lack of understanding the principles of sprite groupings and the behaviour of the tilemap class. Simply putting the "allLayers:addChild(row)" inside the vertical "for loop" didn't do the trick, as sprites seem to be grouped or something.
Another option would have been to assign z-order values to each tile and sort the layer group (but then I would have to add each object as a separate layer)
Does anyone has a simple solution to this issue? I've got the feeling that it should be easier to be done
Comments
http://giderosmobile.com/forum/discussion/2220/layer-or-z-index-programming-practice/p1
http://giderosmobile.com/forum/discussion/1521/z-axis-or-stage-drawing-order#Item_2
The first link is using box2d which I am not and draws every object seperatly, which would be quite the nuisance with tiled (at least if I am not overlooking something)
I don't know if I understood well your question, but I would do the following if I use Tilemap
I added the following functions that I used in
[-] Liasoft