Exemplo n.º 1
0
 public AnimationSheetCollection(CustomSpriteBatch spriteBatch, string strFilename)
 {
     Load(spriteBatch, strFilename);
 }
Exemplo n.º 2
0
        public void Load(CustomSpriteBatch spriteBatch, string strFilename)
        {
            XmlFile xmlFile = new XmlFile(strFilename.Replace(".png", ".xml"));

            Load(spriteBatch, xmlFile.Root.FindTagByName("sheet"), strFilename);
        }
Exemplo n.º 3
0
 public AnimationSheet()
 {
     ans_saAnimations = new List <Animation>();
     ans_pTexture     = null;
     ans_pSpriteBatch = null;
 }
Exemplo n.º 4
0
 public AnimationSheet(CustomSpriteBatch spriteBatch, string strFilename)
 {
     ans_saAnimations = new List <Animation>();
     Load(spriteBatch, strFilename);
 }
Exemplo n.º 5
0
        public Vector2 Render(GameTime gameTime, Vector2 vPos, Vector2 vSize, AnimationState state, float fRotation, float fOverX, float fOverY, Color color, float fDepth)
        {
            Animation pAnim = this;

            if (ani_pAliasOwner != null)
            {
                pAnim = ani_pAliasOwner;
            }

            CustomSpriteBatch rend = pAnim.ani_pSheet.ans_pSpriteBatch;
            Texture2D         tex  = pAnim.ani_pSheet.ans_pTexture;

            if (state.iCurrentFrame >= pAnim.ani_saFrames.Count)
            {
                state.Reset();
            }

            AnimationFrame frame = pAnim.ani_saFrames[state.iCurrentFrame];

            RotRect rectDest = new RotRect();

            rectDest.width  = vSize.X;
            rectDest.height = vSize.Y;

            float fOffsetX = pAnim.ani_rectOffset.X;
            float fOffsetY = pAnim.ani_rectOffset.Y;

            float fWidth = pAnim.ani_rectOffset.Width;

            if (fWidth == 0)
            {
                fWidth = vSize.X;
            }
            if (ani_bFlipH)
            {
                fOffsetX -= ((fOffsetX - rectDest.width / 2) * 2) + fWidth;
            }

            float fHeight = pAnim.ani_rectOffset.Height;

            if (fHeight == 0)
            {
                fHeight = vSize.Y;
            }
            if (ani_bFlipV)
            {
                fOffsetY -= ((fOffsetY - rectDest.height / 2) * 2) + fHeight;
            }

            rectDest.x = vPos.X - fOffsetX;
            rectDest.y = vPos.Y - fOffsetY;

            Rectangle rectSrc = new Rectangle();

            rectSrc.X      = (int)frame.anf_vOffset.X;
            rectSrc.Y      = (int)frame.anf_vOffset.Y;
            rectSrc.Width  = (int)pAnim.ani_vSize.X;
            rectSrc.Height = (int)pAnim.ani_vSize.Y;

            if (fOverX != 0)
            {
                rectDest.width = fOverX;
            }
            if (fOverY != 0)
            {
                rectDest.height = fOverY;
            }

            rend.CurrentDepth = fDepth;
            rend.Draw(tex, rectSrc, rectDest, color, ani_bFlipH, ani_bFlipV, false);

            if (!frame.anf_bPause)
            {
                state.fCurrentFrameCounter += gameTime.ElapsedGameTime.TotalMilliseconds;

                if (state.fCurrentFrameCounter++ >= frame.anf_fTime)
                {
                    AdvanceFrame(state);
                }
            }

            // hmm..
            if (fOverX != 0)
            {
                fWidth = fOverX;
            }
            if (fOverY != 0)
            {
                fHeight = fOverY;
            }

            return(new Vector2((int)fWidth, (int)fHeight));
        }