0

我正在尝试在我的八哥游戏中使用物理注射器,并且在“。”上出现此错误。我的

static var PhysInjector.STARLING = true;

陈述。'。' 这里不允许。在 Physics Injector 博客上说“只需将静态变量 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}));
    }
4

2 回答 2

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}));
}
于 2013-04-08T08:23:03.010 回答
0

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

static var PhysInjector.STARLING = true;

应该

PhysInjector.STARLING = true;
于 2013-04-08T15:58:28.240 回答