osinski Posted October 30, 2014 Share Posted October 30, 2014 Hi!How can I customize tweens? For example in Bounce tween I need constant bounce, not depends on distance from point A to point B. Thx! Link to comment Share on other sites More sharing options...
lewster32 Posted October 30, 2014 Share Posted October 30, 2014 You can write your own easing equation if you need very specific tween easing, but I warn you it's maths heavy! See the code here: http://docs.phaser.io/Easing.js.html#sunlight-1-line-498 If you just want a constantly bouncing animation on the other hand, you'd be better off looping a tween:var ball = game.add.sprite(0, 0, 'ball');game.add.tween(ball) .to({y: 300}, 1000, Phaser.Easing.Quadratic.In) // drop down to y = 300 .to({y: 0}, 1000, Phaser.Easing.Quadratic.Out) // bounce back up to y = 0 .loop().start(); // repeat forever Link to comment Share on other sites More sharing options...
osinski Posted October 30, 2014 Author Share Posted October 30, 2014 You can write your own easing equation if you need very specific tween easing, but I warn you it's maths heavy! See the code here: http://docs.phaser.io/Easing.js.html#sunlight-1-line-498 If you just want a constantly bouncing animation on the other hand, you'd be better off looping a tween:var ball = game.add.sprite(0, 0, 'ball');game.add.tween(ball) .to({y: 300}, 1000, Phaser.Easing.Quadratic.In) // drop down to y = 300 .to({y: 0}, 1000, Phaser.Easing.Quadratic.Out) // bounce back up to y = 0 .loop().start(); // repeat foreverThx lewster32!! Link to comment Share on other sites More sharing options...
Recommended Posts