AS3 Elastic Tween Formula


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. vx += (targetX - sprite.x) * spring; //'spring': elastic coefficient
  2. vy += (targetY - sprite.y) * spring;
  3.  
  4. sprite.x += (vx *= friction); //'friction': friction force
  5. sprite.y += (vy *= friction);
  6.  
  7.  
  8. //use it inside an OnEnterFrame event handler

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.