I have a game similar to bejeweled that I am working on. I originally had it in 3D, but have recently converted over to 2D. I have a bunch of cubes that make up the board and each cube has an idle state image (Single), infected state (animated sprite) and a dead state (single image again). When my cubes are destroyed I call the below code. When I was doing this in 3D before, I would just change the material on the renderer and it went very quickly. Now it seems since I have changed over to 2D, I am getting a huge performance hit when calling the function below.
When I comment out the "anim.Play" line, the performance hit disappears. What is the best way to change back to my idle image across all blocks destroyed. I am not allocating any memory. When I destroy an object, I simply scale the object down, call the method below and then scale it back up. I also keep track of the id's so I dont have to have 2DToolkit perform a lookup by the string, but that didnt seem to increase performance much. Guess my overall question is what is the proper way to do this without taking a hit. Whats happeneing is when I am destroying like 8 cubes at once, it just sits there for literally a couple noticable seconds before continuing. One last thing I have recently upgraded to 3.5 and not sure if there are any known issues right now with 2dtoolkit and the new version. I can't say if this was happening in the older version since I have recently changed over to 2D. Any ideas?
void SetRandomcolor()
{
ColorIndex = _boardMgr.GetWeightedRandomColor();
anim.Play(_boardMgr.MyBlockColors[ColorIndex].IdleAnimationIndex);
_boardMgr.MyBlockColors[ColorIndex].NumOnBoard++;
_boardMgr.PopulateProbabilities();
}