Jump to content

Customize tween


osinski
 Share

Recommended Posts

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

 

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

Thx lewster32!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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