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. Link to comment https://forums.phpfreaks.com/topic/62127-solved-i-need-an-ease-function/ 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? Link to comment https://forums.phpfreaks.com/topic/62127-solved-i-need-an-ease-function/#findComment-309301 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); } Link to comment https://forums.phpfreaks.com/topic/62127-solved-i-need-an-ease-function/#findComment-309318 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.