예제 #1
0
        public void StartAnimation(IAnimation animation)
        {
            var scale = _scale;

            if (scale?.Width == 0f && animation.Frames.Count > 0)
            {
                scale.BaseSize = new SizeF(animation.Frames[0].Sprite.Width, animation.Frames[0].Sprite.Height);
            }

            stopAnimation();

            Animation = animation;
            animation.State.PropertyChanged += onAnimationStatePropertyChanged;
            OnAnimationStarted.Invoke();
            if (_image != null)
            {
                _image.SpriteProvider = this;
            }
        }
예제 #2
0
        public void StartAnimation(IAnimation animation)
        {
            if (animation == null)
            {
                throw new NullReferenceException("Animation is null");
            }
            var scale = _scale;

            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (scale?.Width == 0f && animation.Frames.Count > 0)
            {
                scale.BaseSize = new SizeF(animation.Frames[0].Sprite.Width, animation.Frames[0].Sprite.Height);
            }

            stopAnimation();

            Animation = animation;
            animation.State.PropertyChanged += onAnimationStatePropertyChanged;
            OnAnimationStarted.Invoke();
            if (_image != null)
            {
                _image.SpriteProvider = this;
            }
        }