Physics errors "Property does not exist" with phaser.js (2.0) and TypeScript in Visual Studio Express 2013

StackOverflow https://stackoverflow.com/questions/22452813

Вопрос

The title pretty much says it all.

Using the Phaser framework version 2.0, my IDE Visual Studio Express 2013 throws Property X does not exist errors with most physics related functions. For example when trying to initialize the physics system with this.game.physics.startSystem(Phaser.Physics.ARCADE);, I receive The property 'startSystem' does not exist on value of type 'Phaser.Physics.Arcade.World'.

I use TypeScript.

Might this be a problem of my phaser.d.ts (even though it's the newest one...)?

Это было полезно?

Решение

for that particular error just modify it as this : https://github.com/photonstorm/phaser/blob/master/build/phaser.d.ts#L2803

as :

   class World {

            constructor(game: Phaser.Game, config: Object);

            applyDamping: boolean
            applyGravity: boolean;
            applySpringForces: boolean;
            bounds: any;
            collisionGroups: any[];
            emitImpactEvent: boolean;
            enableBodySleeping: boolean;
            friction: number;
            game: Phaser.Game;
            gravity: Phaser.Physics.Arcade.InversePointProxy;
            materials: Phaser.Physics.Arcade.Material[];
            onBeginContact: Phaser.Signal;
            onBodyRemoved: Phaser.Signal;
            onConstraintAdded: Phaser.Signal;
            onConstraintRemoved: Phaser.Signal;
            onContactMaterialAdded: Phaser.Signal;
            onContactMaterialRemoved: Phaser.Signal;
            onEndContact: Phaser.Signal;
            onImpact: Phaser.Signal;
            onPostBroadphase: Phaser.Signal;
            onPostStep: Phaser.Signal;
            onSpringAdded: Phaser.Signal;
            onSpringRemoved: Phaser.Signal;
            restitution: number;
            solveConstraints: boolean
            startSystem: Function; // was missing 
            time: boolean;
            world: any;

            addBody(body: Phaser.Physics.Arcade.Body): boolean;
            addConstraint(constraint: any)


        }

Be sure to send them a pull request to help the next guy.

Другие советы

So the developer contacted me at their forums and told me that it really is due to the phaser.d.ts being outdated! It's being worked on. Also the github phaser dev branch already sports a newer version.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top