0

When creating an isometric tilemap-based game using Cocos2d 2.x, automatic Z-ordering was not a problem.

We can just read the vertexZ/zOrder value of the tiles (treaded as CCSprites) of every layer and update our nodes accordingly.

Now I use v3.3 of Cocos2d.

CCTMXTiledMaps have been replaced with CCTiledMaps

CCTMXLayers are replaced with CCTiledMapLayers

In versions 3.0+ we cannot treat individual tiles as CCSprite's and hence the tiles themselves has no zOrder or vertexZ property. This makes it impossible to know what zOrder i should update my moving characters to in order for them to be rendered realistically.

Is it possible to do automatic zOrdering in some way using tiled maps and moving objects? How is it supposed to be done using cocos2d v3+?

Eyeball
  • 3,267
  • 2
  • 26
  • 50
  • It seems property is still available for set/get. Here is reference, find "getVertexZ" here : http://www.cocos2d-x.org/reference/native-cpp/V3.3rc0/d3/d82/classcocos2d_1_1_node.html#ae705b7d749a779ad526e9d59df8b34dd – Mrunal Dec 21 '14 at 08:34
  • That's not the problem though. Since my tiles are not treated as sprites, I cannot access their vertexZ property. So Even if I can set the vertexZ priperty of my character,I wouldn't know the appropriate value – Eyeball Dec 21 '14 at 09:16
  • vertexZ became a private property in v3.x with the new rendering engine. You could try importing CCNode_Private.h Also check out this link for more info http://forum.cocos2d-swift.org/t/cocos2d-v3-1-or-3-x-how-to-enable-vertex-z/15774?u=mu1ex – johnny peter Dec 22 '14 at 11:57
  • edit: sifting through the CCTiledMapLayer class it seems that tiles will be rendered using vertexz if a property by the name `cc_vertexz` is found with value automatic. Hence add a property named `cc_vertexz` with the property `automatic` in layer properties in tiled app. If this solution works out, ill upgrade this as an answer. – johnny peter Dec 22 '14 at 12:15
  • I've tried this aswell. V 3.3 does render the map properly with cc_vertexz set to automatic. After setting a breakpoint at the loc where cctiledmaplayer observes the tiled properties, the cc_vertexz is not even considered – Eyeball Dec 22 '14 at 19:20

0 Answers0