tibberous Posted July 28, 2007 Share Posted July 28, 2007 Here is the header. function ease (startingX, startingY, endingX, endingY, frame, framesTotal, ease){ return Array(currentX, currentY); } Basically it takes 2 sets of points, the starting location of an object and the ending location. It returns the location the object would be at at frame, provided there are framesTotal total frames. Ease simulates easing in or out, causing the object to move slower at the beginning or the end of the function. Anyone know how to write this? I used to know but I forget. Quote Link to comment Share on other sites More sharing options...
tibberous Posted July 28, 2007 Author Share Posted July 28, 2007 Here, I'll help: function ease (startingX, startingY, endingX, endingY, frame, framesTotal, ease){ currentX = startingX - ( (startingX - endingX) * (frame/framesTotal) ); currentY = startingY - ( (startingY - endingY) * (frame/framesTotal) ); return Array(currentX, currentY); } That works so long as ease is 0. Can someone tell me how to add easing? Quote Link to comment Share on other sites More sharing options...
tibberous Posted July 28, 2007 Author Share Posted July 28, 2007 function easeTo (startingX, startingY, endingX, endingY, frame, framesTotal, ease){ if(ease > 0) ease = 1 + (ease / 100); else if(ease < 0) ease = 1 + (ease / 200); else ease = 1; currentX = startingX - ( (startingX - endingX) * Math.pow( (frame/framesTotal) , ease) ); currentY = startingY - ( (startingY - endingY) * Math.pow( (frame/framesTotal) , ease) ); return Array(currentX, currentY); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.