// Get layers from the map
background = tiledMap~~>layerNamed;
background~~>setScale(mapScale);
this~~>addChild;
// Create an invisible meta-layer for collision detection
meta = tiledMap~~>layerNamed(“meta_layer”);
meta->setVisible(false);
And when my app run it show Error Dialog (mine ’s an Android apk). Follow the note I go to CCNode.cpp, line 507 and see this:
CCAssert( child->m_pParent == NULL, "child already added. It can't be added again");
I have no clue what ’s happening because it’s the first time I add a layer in my code. If I change to adding the whole CCTMXTiledMap, I run well (but how am I going to work with the meta-layer for collision detection later?).
Umm, as I understand it, all the layers of a CCTMXTiledMap are added to be children of the tiled map by default. So this is what is making your program fail to assertion error:
I guess I’m not sure what you problem would be to using your meta layer for collision detection even when it’s a child of tiledMap, the same as background, and you’ve added tiledMap to the scene. Wouldn’t it be handy that your background and meta have basically the same coordinates and scale (if you just scale and move the tiledMap when you need to do that)?
Umm, as I understand it, all the layers of a CCTMXTiledMap are added to be children of the tiled map by default. So this is what is making your program fail to assertion error:
[…]
>
I guess I’m not sure what you problem would be to using your meta layer for collision detection even when it’s a child of tiledMap, the same as background, and you’ve added tiledMap to the scene. Wouldn’t it be handy that your background and meta have basically the same coordinates and scale (if you just scale and move the tiledMap when you need to do that)?
Yeah maybe I’ve got it somehow. It’s all about API usage pattern…
I’m on the way now. Just need to add the whole map and using each layer of it later _