Jump to content

No VS autocomplete on game.physics.box2d


Recommended Posts

I have the Box2d plugin, but game.physics.box2d doesn't have autocomplete when I type "game.physics.box2d" in Visual Studio.

In phaser.d.ts I see:
        arcade: Phaser.Physics.Arcade;
        config: any;
        game: Phaser.Game;
        ninja: Phaser.Physics.Ninja;
        p2: Phaser.Physics.P2;
        box2d: any;

I think it Might be that it thinks game.physics.box2d is any instead of box2d class. How do I get autocomplete?

Link to comment
Share on other sites

yes, it is because box2d is any. Cast it like this:

let physics = <Phaser.Physics.Box2D>this.game.physics.box2d;

Do the same with bodies (code below is from class extending Phaser.Sprite):

let body = <Phaser.Physics.Box2D.Body>this.body;

Make sure you have TS defs (both files): https://github.com/SBCGames/Phaser-Box2D-Typescript-defs


Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...