For my thesis I’m making a platform game with cocos2d HTML 5 and box2d.
As the floor I would like to use polygon objects.
But I can’t seem to create a polygon.
I’ve tries several ways and none have worked.
This is what I have now:
var bodyDef = new b2BodyDef(); bodyDef.type = "static"; var fixDef = new b2FixtureDef(); var polyShape = new b2PolygonShape(); polyShape.vertexCount = 3; polyShape.m_vertices = new b2vec2(334.0000, 205.0000); polyShape.m_vertices = new b2vec2(310.0000, 203.0000); polyShape.m_vertices = new b2vec2(353.0000, 192.0000); cc.log(polyShape)
in the console log I see that the m_radius is 0.005 which is obviously wrong.
These are the different ways I’ve tried:
polyShape.vertices.Set(new b2vec2(0,1)); polyShape.vertices.Set(0,1); polyShape.m_vertices = [353.0000, 192.0000]; polyShape.m_vertices = new b2vec2(353.0000, 192.0000);
Any help or tips are greatly appreciated.