Apr
24
2009
Simple ease function example
Sometimes there is no need to use heavy tweening libraries if you want to create just a simple easing motion from point A to point B.
obj.x += (targetPosX - obj.x) * .1; if (Math.abs(targetPosX - obj.x) < 1) { //reached a destination so remove listener or tweening function }
And another ease example with acceleration:
velX += (targetPosX - obj.x) * .01; velX *= .9; obj.x += velX; if(Math.abs(targetPosX - obj.x) < 1) { //reached a destination so remove listener or tweening function }


Comments