Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - xtr33me

Pages: [1]
1
Support / Fastest way to swap animations?
« on: February 22, 2012, 04:42:25 am »
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?

Code: [Select]
    void SetRandomcolor()
    {
        ColorIndex = _boardMgr.GetWeightedRandomColor();
       
         anim.Play(_boardMgr.MyBlockColors[ColorIndex].IdleAnimationIndex);

        _boardMgr.MyBlockColors[ColorIndex].NumOnBoard++;
        _boardMgr.PopulateProbabilities();

    }

Pages: [1]