box2d中开启debug模式问题

话不多说,上代码

var *
MyScenceLayer = *
cc
.
Layer.extend({

ctor:

function(){

this.
_super()

this.
size=*
cc*.
director.getWinSize();

this.
world=
new *
Box2D*.
Dynamics.b2World(
new *
Box2D*.
Common.
Math.b2Vec2(0,-10),
true);

console.log(
this.
world)

this.
world.SetContinuousPhysics(
true);

var box=*
cc*.
Sprite.create(*
res*.
blocks);
*// this.addChild(box)
** *box.
x=
this.
size.
width/2;
box.
y=
this.
size.
height/2

var line_sprite=*
cc*.
Sprite.create(*
res*.
HelloWorld_png);
*// this.addChild(line_sprite)
**


var line=
new *
Box2D*.
Dynamics.b2BodyDef();
line.
type=*
Box2D*.
Dynamics.b2Body.
b2_staticBody;
line.
position.Set(0,0);
*// line.userData=line_sprite


var lineFix=
new *
Box2D*.
Dynamics.b2FixtureDef();
lineFix.
friction=0.3;*//摩擦力
** lineFix.
density=1;
//密度
** lineFix.
restitution=13;
//恢复力
**


var lineshapes=
new *
Box2D*.
Collision.
Shapes.b2PolygonShape();
lineshapes.SetAsBox(
this.
size.
width,1);
lineFix.
shape=lineshapes

this.
world.CreateBody(line).CreateFixture(lineFix);

var sprite=
new *
Box2D*.
Dynamics.b2BodyDef()
sprite.
type=*
Box2D*.
Dynamics.b2Body.
b2_dynamicBody

sprite.
position.Set(
this.
size.
width/2,
this.
size.
height/2);
sprite.
userData=box;

var shape=
new *
Box2D*.
Collision.
Shapes.b2PolygonShape();
shape.SetAsBox(20,20);

var fixture=
new *
Box2D*.
Dynamics.b2FixtureDef();
fixture.
shape=shape;
fixture.
friction=0.3;
fixture.
density=11;
fixture.
restitution=0.3;

this.
world.CreateBody(sprite).CreateFixture(fixture)

this.scheduleUpdate();

this.debugDraw();

this.
world.DrawDebugData()

},
debugDraw: 

function(){

var myDebugDraw =
new *
Box2D*.
Dynamics.b2DebugDraw();

var canvas=
document.getElementById(
“gameCanvas”)

var context = canvas.getContext(
‘2d’);
myDebugDraw.SetSprite(context);
*//debug instead of gameCanvas
** myDebugDraw.SetDrawScale(1);
myDebugDraw.SetFillAlpha(1);
myDebugDraw.SetLineThickness(1.0); // no need to change this anymore
** myDebugDraw.SetFlags(
Box2D
.
Dynamics.b2DebugDraw.
e_shapeBit | *
Box2D
.
Dynamics.b2DebugDraw.
e_jointBit);

this.
world.SetDebugDraw(myDebugDraw);
},
update:
function (dt) {

var velocityIterations = 8;

var positionIterations = 1;

this.
world.Step(1/24, 10, 10);

this.
world.DrawDebugData()

for (
var b =
this.
world.GetBodyList(); b; b = b.GetNext()) {

if (b.GetUserData() !=
null) {

var myActor = b.GetUserData();
myActor.
x = b.GetPosition().
x ;
myActor.
y = b.GetPosition().
y ;
myActor.
rotation = -1 * *
cc*.radiansToDegrees(b.GetAngle());

this.
world.DrawDebugData()

        }
    }

}

});

var *
MyScence = *
cc
.
Scene.extend({
onEnter:
function () {

this.
_super();

var layer =
new *
MyScenceLayer*();

this.addChild(layer);
}
});

以上是我的代码。在远行游戏的第一瞬间,能看见debug模式下面的绿线和物 体的边界线,但是一闪而过,后面就看不见了,。有人知道是什么原因吗?