Hey guys,
I've been trying to create my own object with vertices... So far unsuccessfully. Using the following code:
The squares I create do appear, but when a dynamic square hits another one, it falls through (it does slow down and for two seconds it gets stuck, but then it falls through with high speed)...
It was working when i just used
But obviously I want to create more complicated objects than a Box...
Any help is appreciated,
Cheers guys!
I've been trying to create my own object with vertices... So far unsuccessfully. Using the following code:
Code:
var vertices:Vector.<b2Vec2> = new Vector.<b2Vec2>();
with (vertices){
var size:int = 1;
push(new b2Vec2(0,0));
push(new b2Vec2(0,size));
push(new b2Vec2(size,size));
push(new b2Vec2(size,0));
}
type = b2Body.b2_dynamicBody;
shape = b2PolygonShape.AsVector(vertices,vertices.length);
with (vertices){
var size:int = 1;
push(new b2Vec2(0,0));
push(new b2Vec2(0,size));
push(new b2Vec2(size,size));
push(new b2Vec2(size,0));
}
type = b2Body.b2_dynamicBody;
shape = b2PolygonShape.AsVector(vertices,vertices.length);
The squares I create do appear, but when a dynamic square hits another one, it falls through (it does slow down and for two seconds it gets stuck, but then it falls through with high speed)...
It was working when i just used
Code:
shape = b2PolygonShape.AsBox(0.5,0.5);
But obviously I want to create more complicated objects than a Box...
Any help is appreciated,
Cheers guys!