Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added autostart #18

Merged
merged 1 commit into from Oct 15, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions build/Tween.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 31 additions & 3 deletions src/Tween.js
Expand Up @@ -8,13 +8,21 @@

var TWEEN = TWEEN || ( function () {

var i, tl, interval, time, tweens = [];
var i, tl, interval, time, fps = 60, auto = false, tweens = [];

return {

start: function ( fps ) {
setFPS: function ( f ) {

interval = setInterval( this.update, 1000 / ( fps || 60 ) );
fps = f || 60;

},

start: function ( f ) {

this.setFPS(f);

interval = setInterval( this.update, 1000 / fps );

},

Expand All @@ -24,10 +32,24 @@ var TWEEN = TWEEN || ( function () {

},

autostart: function (fps) {

auto = true;

this.start(fps);

},

add: function ( tween ) {

tweens.push( tween );

if (auto && !interval) {

this.start();

}

},

getAll: function() {
Expand Down Expand Up @@ -74,6 +96,12 @@ var TWEEN = TWEEN || ( function () {

}

if (tl == 0 && auto == true) {

this.stop();

}

}

};
Expand Down