Sign in to follow this  
mortsini

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?

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.