Reputation: 1
I am adding 37 shapes and is this the right way to add its mousedown and mouseover event handlers. With this 37 shapes the performance are not slower, but it increases with additional 100 shapes.
for(var i = 1;i<37;i++)
{
Independent_Bet_Shape = new createjs.Shape()
Independent_Bet_Shape.graphics.beginFill("#FFFFFF").drawRect(0,0,Independent_Bet_Width,Independent_Bet_Height);
Independent_Bet_Shape.alpha=0.8
Independent_Bet_Shape.cache(0,0,Independent_Bet_Width,Independent_Bet_Height)
Independent_Bet_Container.name = "Bet_Container"+i
Independent_Bet_Container.addChild(Independent_Bet_Shape)
s_oStage.addChild(Independent_Bet_Container)
if(i%3 == 0) //Splitting them in column for every 3 bets from bottom to top.
{
Current_Bet_X = Current_Bet_X+Independent_Bet_Width+0.1
Current_Bet_Y = Start_Bet_Y
for(var j = 0;j<3;j++)
{
Independent_Column_Bets_Array[columnCount][j] = j + (last_J + 1)
}
columnCount +=1
last_J = j * columnCount
}
}
for(var i = 1;i<37;i++)
{
Selection_Bet_Container = new createjs.Container();
Selection_Bet_Container.x = 5//-700
Selection_Bet_Container.y = 5//-210
Selection_Bets_Array.push(Selection_Bet_Container)
Independent_Bets_Array[i].addChild(Selection_Bet_Container)
Selection_Bet_Container.cache(0,0,Independent_Bet_Width,Independent_Bet_Height)
Independent_Chips_Array.push(Selection_Bet_Container)
}
for(var i = 1;i<37;i++)
{
Independent_Bets_Array[i].on("mousedown", Independent_TableBetFun);
Independent_Bets_Array[i].cursor='pointer'
}
Upvotes: 0
Views: 554
Reputation: 11294
Here is a quick overview:
There are lots of things you can do to get better performance:
Check out these examples:
stage.autoClear=false
Typically particle systems and other high-performance content will use bitmaps, or even SpriteSheets, which let you show a bunch of different elements with one image, which will give you huge advantages in performance.
If you are able to move to Bitmap or cached content, check out StageGL, which supports most things (some stuff like masks won't work - because they use vectors).
Cheers,
Upvotes: 1