Nokdu Posted March 17, 2014 Share Posted March 17, 2014 i've been looking through the examples.. and tried some coding for phaser 2.0. i came across this http://examples.phaser.io/_site/view_lite.html?d=arcade%20physics&f=body+scale.js&t=body%20scale but i was wondering if it was working as intended? what i thought was that the sprite body would scale automatically when i scale the sprite.. but to me in that demo that doesn't seem to work.. Zenryo 1 Link to comment Share on other sites More sharing options...
Alexeef Posted March 17, 2014 Share Posted March 17, 2014 It seems body.gravityScale is returning null, so all the examples with gravityScale are not working properly Link to comment Share on other sites More sharing options...
valueerror Posted March 17, 2014 Share Posted March 17, 2014 in this example it is about sprite scale.. not gravityscale.. gravity scale works but you have to use it that way mind the "data"player.body.data.gravityScale=0.5;sprite scaling after enabling the physics body does NOT reconfigure the physics body.. this body is created with sprite bounds and stays this way until you configure it to change with sprite.body.setCircle() for example.. but it would be great if the physics body gets rescaled when the sprite scales.. i would totally agree with that! Link to comment Share on other sites More sharing options...
rich Posted March 19, 2014 Share Posted March 19, 2014 I did talk to Stefan (the author of P2) about supporting body scaling, but the basic response was "no, it leads to physically impossible situations". So yeah, scale first, then create your body. Or if you don't want to scale in real time you could update the body size after the scale is completed. Link to comment Share on other sites More sharing options...
jyapayne Posted March 19, 2014 Share Posted March 19, 2014 You could put sprite.body.updateBounds(sprite.scale.x, sprite.scale.y); in the update() method in the example code. That makes the body scale with the sprite. Link to comment Share on other sites More sharing options...
Recommended Posts