動畫在加載時工作正常,但過了一段時間它就會滯後。首先,我在for循環中創建了新的drops
變量。讓它成爲全球並沒有幫助。 fps
是40與5 particles
。任何幫助?動畫在某段時間後滯後 - Easeljs緩存
function init(){
stage = new createjs.Stage("rain-canvas");
createjs.Ticker.setFPS(fps);
createjs.Ticker.addEventListener("tick", refresh);
}
function refresh(){
for(var i = 0; i < particles; i++){
drops = new createjs.Shape();
xxx = Math.random() * viewportWidth;
yyy = -10 + Math.random() * 10;
drops.graphics.beginFill('#fff').rect(xxx, yyy, 2, 18);
drops.alpha = 0.15 + Math.random() * 0.5;
stage.addChild(drops);
TweenLite.to(drops, 1.25, {y: viewportHeight + 150,
onComplete: function(){
stage.removeChild(drops);
}, ease: Power1.easeNone
});
};
stage.update();
}