我正在尝试让 box2d debugdaw 在 cocos2djs 中工作。以下代码对我来说只是正常运行游戏,没有任何错误或调试形状。我哪里错了?
var b2Vec2 = Box2D.Common.Math.b2Vec2
, b2World = Box2D.Dynamics.b2World
, b2BodyDef = Box2D.Dynamics.b2BodyDef
, b2Body = Box2D.Dynamics.b2Body
, b2FixtureDef = Box2D.Dynamics.b2FixtureDef
, b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape
, b2DebugDraw = Box2D.Dynamics.b2DebugDraw;
// Construct a world object, which will hold and simulate the rigid bodies.
this.world = new b2World(new b2Vec2(0, -10), true);
this.world.SetContinuousPhysics(true);
var debugDraw = new b2DebugDraw();
debugDraw.SetSprite(cc.renderContext);
debugDraw.SetDrawScale(PTM_RATIO);
debugDraw.SetFillAlpha(0.8);
debugDraw.SetFlags(b2DebugDraw.e_shapeBit);
this.world.SetDebugDraw(debugDraw);
然后我添加了世界边界和物理实体。
提前致谢。赞恩