使用Starling中的物理注射器不起作用

时间:2013-04-08 05:34:53

标签: actionscript-3 box2d physics

我正在尝试在我的starling游戏中使用Physics Injector并且在“。”上出现此错误。我的

static var PhysInjector.STARLING = true;

语句。 ''这里不允许。在物理注入器博客上说“简单地将静态变量PhysInjector.STARLING设置为true,就是这样!”

我把它放在错误的地方还是什么东西?我做错了什么?

        private function injectPhysics():void
    {
        static var PhysInjector.STARLING = true;
        physics = new PhysInjector (stage, new b2Vec2(0, 60), true)
        var floorObject:PhysicsObject = physics.injectPhysics(floor, PhysInjector.SQUARE, new PhysicsProperties({isDynamic:false, friction:0.5, restitution:0.5}));
        var presentP:PhysicsObject = physics.injectPhysics(present, PhysInjector.SQUARE, new PhysicsProperties({isDynamic:true, friction:0.2, restitution:0.5}));
    }

2 个答案:

答案 0 :(得分:0)

不了解PhysInjector如何初始化的更多信息试试这个:

private function injectPhysics():void {
    PhysInjector.STARLING = true;
    physics = new PhysInjector (stage, new b2Vec2(0, 60), true);
    var floorObject:PhysicsObject = physics.injectPhysics(floor, PhysInjector.SQUARE, new PhysicsProperties({isDynamic:false, friction:0.5, restitution:0.5}));
    var presentP:PhysicsObject = physics.injectPhysics(present, PhysInjector.SQUARE, new PhysicsProperties({isDynamic:true, friction:0.2, restitution:0.5}));
}

如果这不起作用,请尝试:

private function injectPhysics():void {
    physics = new PhysInjector (stage, new b2Vec2(0, 60), true);
    physics.STARLING = true;
    var floorObject:PhysicsObject = physics.injectPhysics(floor, PhysInjector.SQUARE, new PhysicsProperties({isDynamic:false, friction:0.5, restitution:0.5}));
    var presentP:PhysicsObject = physics.injectPhysics(present, PhysInjector.SQUARE, new PhysicsProperties({isDynamic:true, friction:0.2, restitution:0.5}));
}

答案 1 :(得分:0)

只需从代码中删除“static”和“var”命名空间即可。

static var PhysInjector.STARLING = true;

应该是

PhysInjector.STARLING = true;