public void PlayAnimation(string animName, GTSpriteFrameSet.PlayMode playMode)
 {
     if (mFrameSetNameDic.ContainsKey(animName))
     {
         PlayAnimation(mFrameSetNameDic[animName], playMode);
     }
 }
    /// <summary>
    /// Play an animation by its index
    /// </summary>
    /// <param name="animationIndex"></param>
    /// <param name="playMode"></param>
    public void PlayAnimation(uint animationIndex, GTSpriteFrameSet.PlayMode playMode)
    {
        if (animationIndex > mFrameSet.Length)
            return;

        // Pre-setup for playing the animation
        mFrameSetIndex = animationIndex;
        mCurrentFrameSet = mFrameSet[animationIndex];        
        mFrameIndex = 0;
        mPlayingMode = playMode;
        mPrevTime = Time.time;
        mPlayingAnimation = true;
        // Show first frame
        ShowFrame(animationIndex, mFrameIndex);
    }
    /// <summary>
    /// Create a sprite from the atlas
    /// </summary>
    /// <param name="spriteAtlas"></param>
    /// <returns></returns>
    public bool Create(GTSpriteAtlasCocos2D spriteAtlas, GTTreeNode tnSprite)
    {
        if (null == spriteAtlas || spriteAtlas.frameCount == 0)
            return false;

        GTTreeNode tnAnimation = tnSprite.GetChild(GTPropertyFile.TagAnimation);
        GTTreeNode tnAnchor = tnSprite.GetChild(GTPropertyFile.TagAnchor);
        Vector2 pivot = GTSpriteFrameSet.PivotCenter;
        if (tnAnchor != null)
            pivot = tnAnchor.AsVector2();

        if (tnAnimation != null && tnAnimation.childCount != 0)
        {
            mFrameSet = new GTSpriteFrameSet[tnAnimation.childCount];
            // Create each frameset
            for (int childIndex = 0; childIndex < tnAnimation.childCount; childIndex++)
            {
                GTTreeNode tnFramdset = tnAnimation.GetChild(childIndex);
                if (tnFramdset != null)
                {
                    GTTreeNode tnFPS = tnFramdset.GetChild(GTPropertyFile.TagFPS);
                    GTTreeNode tnStartFrame = tnFramdset.GetChild(GTPropertyFile.TagStartFrame);
                    GTTreeNode tnFrameCount = tnFramdset.GetChild(GTPropertyFile.TagFrameCount);
                    if (tnStartFrame == null)
                        Debug.LogError("Couldn't find StartFrame in GTTreeNode !");
                    if (tnFrameCount == null)
                        Debug.LogError("Couldn't find FrameCount in GTTreeNode !");
                    if (tnStartFrame != null && tnFrameCount != null)
                    {
                        mFrameSet[childIndex] = new GTSpriteFrameSet();
                        mFrameSet[childIndex].name = tnFramdset.AsString();
                        mFrameSet[childIndex].Create(
                            spriteAtlas,
                            tnStartFrame.AsInt(),
                            tnFrameCount.AsInt(),
                            pivot
                            );
                        if (tnFPS != null)
                        {
                            mFrameSet[childIndex].FPS = tnFPS.AsFloat();
                        }
                    }

                    if(!mFrameSetNameDic.ContainsKey(tnFramdset.AsString()))
                        mFrameSetNameDic.Add(tnFramdset.AsString(), (uint)childIndex);
                }
            }
        }

        return true;
    }