示例#1
0
        public void Update(GameTime gameTime)
        {
            float animationLengthMs = GetAnimationLengthMs();

            if (animationLengthMs != 0 && IsPlaying && IsEnabled)
            {
                _timeSinceStart += gameTime.ElapsedGameTime;
                if (_timeSinceStart.TotalMilliseconds >= animationLengthMs)
                {
                    if (LoopAnimation)
                    {
                        _timeSinceStart = TimeSpan.FromSeconds(0);
                    }
                    else
                    {
                        _timeSinceStart = TimeSpan.FromMilliseconds(animationLengthMs);
                        IsPlaying       = false;
                    }
                }

                if (ExternalAnimationRef != null)
                {
                    ExternalAnimationRef.UpdateNode(gameTime);
                }

                OnFrameChanged?.Invoke(CurrentFrame);
            }

            UpdateAnimationFrame();
        }
 public void CallOnFrameChanged(BitmapSource bmp)
 {
     OnFrameChanged?.Invoke(bmp);
 }