Beispiel #1
0
        /// <summary>
        /// Setup animation-related fields.
        /// </summary>
        /// <param name="animationFrames">The list of animation frames</param>
        /// <param name="startTick">The tick to start on (must be between 0 and the total number of ticks in animationFrames)</param>
        protected void SetAnimation(AnimationFrame[] animationFrames, int startTick)
        {
            if (animationFrames == null) throw new ArgumentNullException("animationFrames");
            if (animationFrames.Length < 1) throw new ArgumentException("No animation frames given");

            _animationFrames = animationFrames;
            _frame = 0;
            while (startTick >= _animationFrames[_frame].Ticks)
            {
                startTick -= _animationFrames[_frame].Ticks;
                _frame++;
                if(_frame >= _animationFrames.Length) throw new ArgumentException("startTick is higher than the total ticks in the animation");
            }

            _currentTick = startTick;
            Sprite = _animationFrames[_frame].Sprite;
        }
Beispiel #2
0
 protected void SetAnimation(AnimationFrame[] frames)
 {
     SetAnimation(frames, 0);
 }