YagerX wrote:
hm i'm having trouble using the chains... It keeps throwing "Shape type not found or cannot be added to Dynamic Bodies."
but uh i'm adding the chain to a new body so shouldn't it be static?
but uh i'm adding the chain to a new body so shouldn't it be static?
I don't think you can just add the chain to a normal body, if you use the code that shaktool posted on page 3, you can use normal bodies, but adding a chain to them requires a slightly different treatment. (not body.CreateShape) I will repost:
Code:
var bd:b2BodyDef = new b2BodyDef();
body = phys.CreateBody(bd);
var chain:b2StaticEdgeChainDef = new b2StaticEdgeChainDef();
chain.vertexCount = points.length;
chain.isALoop = false;
for each(var point:b2Vec2 in points){
chain.vertices.push(new b2Vec2(point.x, point.y));
}
edgeChain = new b2StaticEdgeChain(chain, phys, body);
body = phys.CreateBody(bd);
var chain:b2StaticEdgeChainDef = new b2StaticEdgeChainDef();
chain.vertexCount = points.length;
chain.isALoop = false;
for each(var point:b2Vec2 in points){
chain.vertices.push(new b2Vec2(point.x, point.y));
}
edgeChain = new b2StaticEdgeChain(chain, phys, body);
Pay special attention to the last line.