arturoc / ofxTween

tween addon for openFrameworks
Other
80 stars 51 forks source link

Framerate independent #9

Open RogerGMartins opened 10 years ago

RogerGMartins commented 10 years ago

Hello, how would one turn the tweens framerate independent?

arturoc commented 10 years ago

use time instead of frames to do the calculations, with the map functions:

ofxTween::map(ofGetElapsedTimef(),initTme,endTime,initValue,endValue,clamp,ofxTweenEaseLinear());

where initTime, endTime are the times at which your animation started and should end and initValue, endValue the values you'll use for animation, so for example if you want to do an animation of something moving from the left to right in the screen that takes 1 second:

endTime = initTime + 1;
initValue = 0;
endValue = ofGetWidth()
ofxTween::map(ofGetElapsedTimef()-initTime,initTme,endTime,initValue,endValue,clamp,ofxTweenEaseLinear());

where you fix initTime at some point to the current ofGetElapsedTimef()

RogerGMartins commented 10 years ago

very cool, thanks alot mate