Пример #1
0
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        public void InfoRequested(DeltaTime deltaTime)
        {
            //This clean out any old data.
            SpriteAnimationData animData = new SpriteAnimationData();

            m_spriteInfo.m_animationData = default(SpriteAnimationData);

            if (m_spriteAnimation != null)
            {
                animData = m_spriteAnimation.UpdateCurrentAnimation(deltaTime);
            }
            else
            {
                animData.m_currentFrame = Frame.Zero;

                if (m_spriteInfo.m_texture2D != null)
                {
                    animData.m_frameSize.X = m_spriteInfo.m_texture2D.Bounds.Width;
                    animData.m_frameSize.Y = m_spriteInfo.m_texture2D.Bounds.Height;
                }
                else
                {
                    animData.m_frameSize.X = 0;
                    animData.m_frameSize.Y = 0;
                }
            }

            m_spriteInfo.m_animationData = animData;

            if (SendInfo != null)
            {
                SendInfo(m_spriteInfo);
            }
        }
Пример #2
0
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        public SpriteAnimationData UpdateCurrentAnimation(DeltaTime deltaTime)
        {
            SpriteAnimationData data = new SpriteAnimationData();

            if (m_currentAnimation != null && !Paused)
            {
                m_fTimeElapsedScinceLastFrame += deltaTime.ElapsedGameTime.TotalMilliseconds;

                if (m_fTimeElapsedScinceLastFrame >= m_fDesiredElapsedTime)
                {
                    data.m_currentFrame.X         = Direction == AnimationDirection.Forward ? m_currentFrame.X++ : m_currentFrame.X--;
                    m_fTimeElapsedScinceLastFrame = 0;
                }
                else
                {
                    data.m_currentFrame.X = m_currentFrame.X;
                }

                data.m_currentFrame.Y = m_currentFrame.Y;
                data.m_frameSize      = m_currentAnimation.m_frameSize;

                if ((m_currentFrame.X * m_currentAnimation.m_frameSize.X) >= m_currentAnimation.m_sheetSize.X)
                {
                    if (m_currentAnimation.m_bLooping)
                    {
                        m_currentFrame = Frame.Zero;
                    }
                    else
                    {
                        m_currentAnimation = null;
                    }
                }
            }
            //We need to do this if it is paused with an animation.
            else if (m_currentAnimation != null && Paused)
            {
                data.m_currentFrame = m_currentFrame;
                data.m_frameSize    = m_currentAnimation.m_frameSize;
            }

            return(data);
        }