AS3 Flexible Partial Shifts Formula


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

**mostly used inside an onEnterFrame event handler


Copy this code and paste it in your HTML
  1. var dx:Number = sprite.x - fixedX;
  2. var dy:Number = sprite.y - fixedY;
  3.  
  4. var angle:Number = Math.atan2(dy, dx);
  5.  
  6. var targetX:Number = fixedX + Math.cos(angle) * springLength;
  7. var targetY:Number = fixedX + Math.sin(angle) * springLength;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.