Jump to content

box2d plugin - How is setting up a physics body using box2d.enable() different from Phaser.Physics.Box2D.Body()?


tonky
 Share

Recommended Posts

Only asking because I read the docs and they both are of the same type "Phaser.Physics.Box2D.Body" BUT I can't use some functions when i use one of the two initiating methods stated in title. For example:

Quote

               var test =  new Phaser.Physics.Box2D.Body(game, null, game.rnd.between(100, 700), game.rnd.between(100, 400), 0);
               test.setRectangle(game.rnd.between(50, 100), game.rnd.between(50, 100), 0, 0);

Quote

              var test = game.add.sprite(game.rnd.between(100, 700), game.rnd.between(100, 400), 'testSprite');
              game.physics.box2d.enable(test);
              test.setRectangle(game.rnd.between(50, 100), game.rnd.between(50, 100), 0, 0);  

In the second method, setRectangle method is not available. 

Error is test.setRectangle is not a function

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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