aaronhampton Posted October 30, 2014 Share Posted October 30, 2014 I am using a tween to scale a sprite from small to large, then yoyo-ing back to small. When the sprite scales, the body does not. I used setCircle to set a circle shaped body, if that makes a difference. I am also using P2 physics. Will I have to keep calling setCircle throughout the tween to make sure the body is the right size? Is there a way to scale the body through tweening or when the sprite is scaled? Link to comment Share on other sites More sharing options...
valueerror Posted October 30, 2014 Share Posted October 30, 2014 you need to scale the shape of the body.. you can acces the shape for example by putting it on a var on the first place..myshape = player.body.seCircle(20);but there are other ways too.. i guess something like player.body.data.shapes[0]; should also work..but.. there are other obstacles coming with shape changes.. it's not that easy flowabuse and aaronhampton 2 Link to comment Share on other sites More sharing options...
schteppe Posted October 30, 2014 Share Posted October 30, 2014 Maybe this helps? http://www.html5gamedevs.com/topic/5692-p2-increase-body-radius-over-time/ aaronhampton 1 Link to comment Share on other sites More sharing options...
aaronhampton Posted October 31, 2014 Author Share Posted October 31, 2014 Thanks! Both of those responses really helped me figure it out. My tween looks like this:var speed = 1500;var multi = 3.5;var rad = sprite.body.data.shapes[0].radius;game.add.tween(sprite.scale).to( {y: multi, x: multi}, speed, Phaser.Easing.Linear.None, true).repeat(Number.MAX_VALUE).yoyo(true);game.add.tween(sprite.body.data.shapes[0]).to( {radius: rad * multi}, speed, Phaser.Easing.Linear.None, true).repeat(Number.MAX_VALUE).yoyo(true);Then, in update I run the following to see the body update during debug:sprite.body.debugBody.draw();Thanks again for all the help! Link to comment Share on other sites More sharing options...
Recommended Posts