tonky Posted April 8, 2016 Share Posted April 8, 2016 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 More sharing options...
rich Posted April 8, 2016 Share Posted April 8, 2016 In the first bit of code, test is being turned into a Box2D Body. So setRectangle works. In the second bit of code, test is a Sprite. So to access its body you need to use 'test.body.setRectangle' instead. tonky 1 Link to comment Share on other sites More sharing options...
Recommended Posts