Hello,
I have started to work with cocos2dx and I’m having issues generating the ground collision from a TMX map.
The tiled map renders fine but when I try to add a collision polygon to ground body it does not show anything (the physics debug shows no collider).
I’m sure I’m doing something wrong.
What’s the recommended way to load a tiled map and use the polygon information stored in one of the layers?
I found a couple of examples while searching but the code seems to have been written for an older version of cocos2dx.
The only success I have had has been creating big collision shape for the ground body (3000 by 3000) but that’s too big. When I do something like 30 by 30 the small box is not shown in the screen.
if I do the following:
std::vector<Vec2> pointsV;
pointsV.push_back(Vec2(0, 40));
pointsV.push_back(Vec2(40, 40));
pointsV.push_back(Vec2(40, 0));
pointsV.push_back(Vec2(0, 0));
groundBody = PhysicsBody::createPolygon(&pointsV[0], pointsV.size(), PhysicsMaterial(0.1f, 1.0f, 0.0f));
groundBody->setDynamic(false);
I see no collision box at all.
Is there a special coordinate system I got to use when defining a collision polygon for a body?
Another question, can cocos creator be used as a scene editor? So for example, can I create a scene with my tiled map, add then collision and then loading it under cocos2dx?
Any input would be appreciated it.