我用 Box2D 做了一些测试并坚持了下来。这是我的身体构造代码:
var bodyDef:b2BodyDef = new b2BodyDef(); bodyDef.type = b2Body.b2_dynamicBody; bodyDef.fixedRotation = true; var center:Number = Consts.stageToB2(Consts.worldSize / 2); bodyDef.position.Set(center, center);
var body:b2Body = physicWorld.CreateBody(bodyDef);
var shape:b2CircleShape = new b2CircleShape(Consts.stageToB2(w) * 0.5); // our monster is in circle shape.
var fixtureDef:b2FixtureDef = new b2FixtureDef();
fixtureDef.shape = shape;
body.CreateFixture(fixtureDef);
我创造了这样的两个物体,但它们不会碰撞!debugDraw 也不会点亮身体。但是当我为其中一个添加角速度时:
body.SetAngularVelocity(Math.PI / 89);
他们会开始碰撞。你能解释一下这里发生了什么吗?