Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Box2D + build in Tweening ??


Miezel
 Share

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');
game.physics.box2d.enable(blockSprite);
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 ?

Thanks.

 

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

 Share

  • Recently Browsing   0 members

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