Hey there forums! recently jumped into using TweenLite and really like its simplicity. All though when I try to tween between 40-60 CreateJS shapes at once my fps drop by 1 thrid.
Here is what I have got. The tweenInStar gets called 3 times simultaneously. and draws a whole bunch of particles and shapes (The particles are handled by raw canvas code and dont affect the fps). The moment it gets to the " TweenLite.to(largeSparkle,.8, {easel:{rotation: 270 }});" My fps takes the hit.
function tweenInStar(star, starX, starY , particleCount){
var shape = starsShapes[star];
if(!sparkleArrayFilled[star]){
buildSparkles(star, starX - 58,shape.y - 20, random(20,40));
sparkleArrayFilled[star] = true;
}
TweenLite.to(shape,.2, {easel:{scaleX: 0.9,
scaleY: 0.9,
alpha: 1.0},onComplete:function(){
fireworks.push( new Firework( starX, starY , starIndex, particleCount) );
createParticles(starX,starY);
var largeSparkle = createSparkle(starX , shape.y - 10, 80, 40);
TweenLite.to(largeSparkle,.8, {easel:{rotation: 270 }});
TweenLite.to(largeSparkle,.4, {easel:{scaleX: 1, scaleY: 1 ,alpha: 0.8 }});
TweenLite.to(largeSparkle,.4, {easel:{scaleX: 0, scaleY: 0 ,alpha: 0 }, delay:.4});
TweenLite.to(shape,.15, { easel:{exposure:1.25}, onComplete: complete});
}});
function complete(){
TweenLite.to(shape,.15, { easel:{exposure:1}});
drawSparkles(sparklesArray[star]);
}
}
var sparkleArrayFilled = [false, false, false];
var sparklesArray = [[],[],[]];
function buildSparkles(star, x, y, scale){
var i = Math.floor(random(5,15));
while(i--){
sparklesArray[star].push(createSparkle((x + random(15, 100)), (y + random(-20, 60)), Math.floor(random(10,30))), 20);
}
}
function drawSparkles(sparkles){
for(var j = 0; j < sparkles.length; j++){
var shape = sparkles[j];
TweenLite.to(shape,.8, {easel:{rotation: 270 }, onComplete:resetRotate()});
TweenLite.to(shape,.4, {easel:{scaleX: 1, scaleY: 1 ,alpha: 0.8 }});
TweenLite.to(shape,.4, {easel:{scaleX: 0, scaleY: 0 ,alpha: 0 }, delay:.4});
function resetRotate(){
shape.rotation = 0;
}
}
}
function createSparkle(x, y, scale, shadowBlur){
var sparkle = new createjs.Shape();
//sparkle.shadow = new createjs.Shadow("#fff", 0, 0, shadowBlur);
sparkle.graphics.beginFill("#fff").drawPolyStar(x , y, scale, 4, 0.87, -90);
sparkle.x = x;
sparkle.y = y;
sparkle.regX = x ;
sparkle.regY = y ;
sparkle.scaleX = 0;
sparkle.scaleY = 0;
sparkle.alpha = 0;
// sparkle.cache(-x, -y, 200, 200);
stage.addChild(sparkle);
return sparkle;
}
Would be eternally greatful for any help