Var T=0
..。
var TestClass =新类()
TestClass.extend({
init: function () {
this.TT = T;
T++
}
});
TestClass.include({
animate: function () {
A = this
window.requestAnimationFrame(function () {
A.animate();
console.log(A.TT)
});
}
});..。
var can1 = new TestClass();
var can2 = new TestClass();
var can3 = new TestClass();..。
var can1.animate()
var can2.animate()
var can3.animate()所以它只适用于can3。控制台:>>2
如果我要做的话:
TestClass.include({
animate: function ()
{
console.log(this.TT)
}
});
var can1 = new TestClass();
var can2 = new TestClass();
var can3 = new TestClass();
function G() {
window.requestAnimationFrame(function () {
can1.animate()
can2.animate()
can3.animate()
G()
});
}
G()它将正常工作,但是我如何在每个TestClass中做requestAnimationFrame?
发布于 2015-07-21 09:26:36
我也有同样的问题。那就去做吧。试试看?https://github.com/mixed/requestAnimationFrameInterval
TestClass.include({
animate: function () {
A = this
window.requestAnimationFrameInterval(function () {
A.animate();
console.log(A.TT);
});
}
});
var can1 = new TestClass();
var can2 = new TestClass();
var can3 = new TestClass();
var can1.animate()
var can2.animate()
var can3.animate()`
https://stackoverflow.com/questions/27332990
复制相似问题