public Vector2 Render(GameTime gameTime, string strName, Vector2 vPos, Vector2 vSize, AnimationState state, float fRotation, float fOverX, float fOverY, float fDepth = 0) { Animation pAnim = GetAnimation(strName); Debug.Assert(pAnim != null); if (pAnim == null) { return(new Vector2(0, 0)); } if (ans_strLatestAnimation != strName) { ans_strLatestAnimation = strName; pAnim.SetActive(state); } return(pAnim.Render(gameTime, vPos, vSize, state, fRotation, fOverX, fOverY, Color.White, fDepth)); }
public Vector2 Render(GameTime gameTime, string strSheetName, string strAnimationName, Vector2 vPos, Vector2 vSize, AnimationState state, float fRotation, float fOverX, float fOverY) { AnimationSheet pSheet = GetSheet(strSheetName); Debug.Assert(pSheet != null); if (pSheet == null) { return(new Vector2(0, 0)); } return(pSheet.Render(gameTime, strAnimationName, vPos, vSize, state, fRotation, fOverX, fOverY)); }
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)); }