Jump to content

Box2D + build in Tweening ??


Recommended Posts

Hello, I have been trying to use the build in tweening from phaser with a box2d Sprite but didn't have much luck with it.

I used this box2d example , turned off gravity and added the tween line. 

blockSprite = game.add.sprite(400, 200, 'block');
blockSprite.body.angle = 30;
game.add.tween(blockSprite).from( { y: -200 }, 2000, Phaser.Easing.Bounce.Out, true);

Can anyone tell me what I'm doing wrong here ?



Link to comment
Share on other sites

Hi, just change last line to:

game.add.tween(blockSprite.body).from( { y: -200 }, 2000, Phaser.Easing.Bounce.Out, true);

to tween body instead of sprite. But, be aware, that tween might fight with physics applied to your dynamic body. If you want to tween physical body, then better make it kinematic instead of dynamic:

blockSprite.body.kinematic = true;


Link to comment
Share on other sites


  • Recently Browsing   0 members

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