var AnimationManager = function (time, completionMethod) {
"use strict";
this.animationObjects = [];
this.time = time;
this.add = function (animationObject) {
this.animationObjects.push(animationObject);
};
this.completionMethod = completionMethod;
this.currentStage = 0;
this.maximumStage = this.time * FPS;
this.tick = function () {
this.currentStage += 1;
if (this.currentStage < this.maximumStage) {
setTimeout(this.tick.bind(this), 1000.0 / FPS);
} else {
//Set manager to nil in the completion method
this.completionMethod();
}
var i;
for (i = 0; i < this.animationObjects.length; i += 1) {
this.animationObjects[i].applyAnimation(this.currentStage);
}
};
//Call this to start
this.startAnimation = function () {
this.timer = setTimeout(this.tick.bind(this), 1000.0 / FPS);
};
};
JSLint in brackets is giving me some annoying errors; two like: 'setTimeout' was used before it was defined. setTimeout(this.tick.bind(this), 1000.0 / FPS);
'setTimeout' was used before it was defined. setTimeout(this.tick.bind(this), 1000.0 / FPS);
What in the world is it talking about!
It also does this with console.log console is undefined.
You must tell JSLint that your code runs in a browser and that it also needs to assume console
is defined.
Put this on top of your code:
/*jslint browser: true, devel: true */
Honestly I prefer JSHint which is less opiniated.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.