Actionscript 3 Box2D调试器不使用Starling

Actionscript 3 Box2D调试器不使用Starling,actionscript-3,debugging,box2d,starling-framework,Actionscript 3,Debugging,Box2d,Starling Framework,我正在将Box2D与最新版本的Starling一起使用,我正在尝试使用Box2D调试器,但到目前为止没有任何效果,这就是我尝试的,我在stage3D层的顶部添加了一个Flash层,因此我可以使用Flash Sprite,我正在网络上运行我的应用程序 主要类别: public function BallFriction() { this.addEventListener(Event.ADDED_TO_STAGE, onReady, false, 0, true);

我正在将Box2D与最新版本的Starling一起使用,我正在尝试使用Box2D调试器,但到目前为止没有任何效果,这就是我尝试的,我在stage3D层的顶部添加了一个Flash层,因此我可以使用Flash Sprite,我正在网络上运行我的应用程序

主要类别:

    public function BallFriction()
    {
        this.addEventListener(Event.ADDED_TO_STAGE, onReady, false, 0, true);
    }

    private function onReady(event : Event) : void
    {
        this.removeEventListener(Event.ADDED_TO_STAGE, onReady);


        var stats:Stats = new Stats();
        stats.y = 500;
        stats.x = 50;
        this.addChild(stats);

        stage.color = 0x333333;
        stage.stage3Ds[0].addEventListener(Event.CONTEXT3D_CREATE, onContextCreated);

        oStarling = new Starling(Game, stage);
        //          akaStarling = new Starling(BoxWorld, stage);
        oStarling.antiAliasing = 1;
        oStarling.start();


    }

    private function onContextCreated(e:Event):void{
        //debug mode
        debugSprite=new Sprite();
        addChild(debugSprite);

        (BallFriction.oStarling.stage.getChildAt(0) as Game).debugDraw(BallFriction.debugSprite);
    }
游戏世界:

  public function Game() 
    {
        super();

        // Create a b2World with gravity 9.8 towards y axis. 
        world = new b2World(new b2Vec2(0, 9.8), true);

        floor(400,590,800,20);
        theBall = ball(100,400,ballWidth/2,Texture.fromBitmap(new Ball()));
        // I also set the velocity of the ball
        theBall.SetLinearVelocity(new b2Vec2(8, -8));

        // Listen enterframe event and update world for each enter frame
        this.addEventListener(EnterFrameEvent.ENTER_FRAME, updateWorld);
        this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
    }

    private function onAddedToStage():void
    {
        this.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);

        //(BallFriction.oStarling.stage.getChildAt(0) as Game).debugDraw(BallFriction.debugSprite);

    }

 private function updateWorld(e:EnterFrameEvent):void
    {
        world.Step(timestep, 10, 10);
        world.DrawDebugData()
        world.ClearForces();
    }

    public function debugDraw(debugSprite:flash.display.Sprite):void{
        var debugDraw:b2DebugDraw = new b2DebugDraw();
        debugDraw.SetSprite(Starling.current.nativeOverlay);
        debugDraw.SetDrawScale(30);
        debugDraw.SetLineThickness( 1.0);
        debugDraw.SetAlpha(1);
        debugDraw.SetFillAlpha(0.4);
        debugDraw.SetFlags(b2DebugDraw.e_shapeBit);
        world.SetDebugDraw(debugDraw);
    }

每次调用
step()
时都必须调用
world.DrawDebugData()
,每次调用
step()

时都必须调用
world.DrawDebugData()
看起来您并没有使用
b2DebugDraw.AppendFlag()
b2DebugDraw.SetFlags()向调试绘图逻辑添加任何标志
;这些标志告诉调试绘图需要在屏幕上绘制什么样的信息。您很可能希望使用
b2DebugDraw.e_shapeBit
标志

看起来您还没有使用
b2Debug.SetDrawScale()
定义绘图比例,尽管我现在无法确定这是否绝对必要


在我的游戏框架中签出类可能会帮助您解决这个问题-它可以处理这个确切的问题。

看起来您没有使用
b2DebugDraw.AppendFlag()
b2DebugDraw.SetFlags()
将任何标志添加到调试绘图逻辑中;这些标志告诉调试绘图需要在屏幕上绘制什么样的信息。您很可能希望使用
b2DebugDraw.e_shapeBit
标志

看起来您还没有使用
b2Debug.SetDrawScale()
定义绘图比例,尽管我现在无法确定这是否绝对必要


在我的游戏框架中查看类可能会帮助您解决这个问题-它可以处理这个确切的问题。

太复杂了,无法单独对站点进行故障排除可能太复杂了。。我编辑了我的问题并添加了更新方法,即使使用world.DrawDebugData()也不会显示任何内容。。。我编辑了我的问题并添加了更新方法,即使使用world.DrawDebugData()也不会显示任何内容。。。我编辑了调试功能(编辑了我的帖子),它成功了,奇怪的是我以前已经尝试过这个解决方案,但什么都没有发生,这就是为什么我必须使用一个更简单的解决方案,我不知道除了晚上关闭我的计算机之外发生了什么变化,谢谢你,如果你还有其他关于Starling&Box2D的例子,那就太好了,我在那里找不到太多:)。。。我编辑了调试功能(编辑了我的帖子),它成功了,奇怪的是我以前已经尝试过这个解决方案,但什么都没有发生,这就是为什么我必须使用一个更简单的解决方案,我不知道除了晚上关闭我的计算机之外发生了什么变化,谢谢你,如果你还有其他关于Starling&Box2D的例子,那就太好了,我在那里找不到太多:)。