コード例 #1
0
        /// <summary>
        /// Queue the sprite animation defined by the provided sequence of indices at the end of the animation queue.
        /// </summary>
        /// <param name="spriteComponent">The sprite component containing the animation</param>
        /// <param name="indices">The sequence of indices defining the sprite animation</param>
        /// <param name="repeatMode">The value indicating how to loop the animation</param>
        /// <param name="framesPerSeconds">The animation speed in frames per second. 0 to use the sprite animation system default speed.</param>
        public void Queue(SpriteComponent spriteComponent, int[] indices, AnimationRepeatMode repeatMode, float framesPerSeconds = 0)
        {
            if (spriteComponent == null)
                return;

            var animationInfo = new SpriteComponent.AnimationInfo
            {
                ShouldLoop = repeatMode == AnimationRepeatMode.LoopInfinite,
                FramePerSeconds = framesPerSeconds > 0 ? framesPerSeconds : DefaultFramesPerSecond,
                SpriteIndices = SpriteComponent.GetNewSpriteIndicesList()
            };

            foreach(var i in indices)
                animationInfo.SpriteIndices.Add(i);

            spriteComponent.Animations.Enqueue(animationInfo);

            playingSprites.Add(spriteComponent);
        }
コード例 #2
0
ファイル: AnimationAsset.cs プロジェクト: releed/paradox
 /// <summary>
 /// Create an instance of <see cref="AnimationAsset"/> with default values.
 /// </summary>
 public AnimationAsset()
 {
     RepeatMode = AnimationRepeatMode.LoopInfinite;
     ScaleImport = 1.0f;
 }
コード例 #3
0
        /// <summary>
        /// Play the sprite animation defined by the provided sequence of indices.
        /// </summary>
        /// <param name="spriteComponent">The sprite component containing the animation</param>
        /// <param name="indices">The sequence of indices defining the sprite animation</param>
        /// <param name="repeatMode">The value indicating how to loop the animation</param>
        /// <param name="framesPerSeconds">The animation speed in frames per second. 0 to use the sprite animation system default speed.</param>
        /// <param name="clearQueuedAnimations">Indicate if queued animation should be cleared</param>
        public void Play(SpriteComponent spriteComponent, int[] indices, AnimationRepeatMode repeatMode, float framesPerSeconds = 0, bool clearQueuedAnimations = true)
        {
            if (spriteComponent == null)
                return;

            var animationInfo = new SpriteComponent.AnimationInfo
            {
                ShouldLoop = repeatMode == AnimationRepeatMode.LoopInfinite,
                SpriteIndices = SpriteComponent.GetNewSpriteIndicesList(),
                FramePerSeconds = framesPerSeconds > 0 ? framesPerSeconds : DefaultFramesPerSecond,
            };

            foreach (var i in indices)
                animationInfo.SpriteIndices.Add(i);

            spriteComponent.RecycleFirstAnimation();
            spriteComponent.Animations.Enqueue(animationInfo);
            var queuedAnimationsCount = spriteComponent.Animations.Count - 1;
            for (int i = 0; i < queuedAnimationsCount; i++)
            {
                var queuedAnimation = spriteComponent.Animations.Dequeue();
                if (!clearQueuedAnimations)
                    spriteComponent.Animations.Enqueue(queuedAnimation);
            }

            playingSprites.Add(spriteComponent);
            spriteComponent.ElapsedTime = 0;
            spriteComponent.CurrentIndexIndex = 0;
            spriteComponent.IsPaused = false;
        }
コード例 #4
0
        /// <summary>
        /// Queue the sprite animation starting at index <paramref name="startIndex"/> and ending at <paramref name="endIndex"/> at the end of the animation queue.
        /// </summary>
        /// <param name="spriteComponent">The sprite component containing the animation</param>
        /// <param name="startIndex">The first index of the animation</param>
        /// <param name="endIndex">The last index of the animation</param>
        /// <param name="repeatMode">The value indicating how to loop the animation</param>
        /// <param name="framesPerSeconds">The animation speed in frames per second. 0 to use the sprite animation system default speed.</param>
        public void Queue(SpriteComponent spriteComponent, int startIndex, int endIndex, AnimationRepeatMode repeatMode, float framesPerSeconds = 0)
        {
            if (spriteComponent == null)
            {
                return;
            }

            var animationInfo = new SpriteComponent.AnimationInfo
            {
                ShouldLoop      = repeatMode == AnimationRepeatMode.LoopInfinite,
                FramePerSeconds = framesPerSeconds > 0 ? framesPerSeconds : DefaultFramesPerSecond,
                SpriteIndices   = SpriteComponent.GetNewSpriteIndicesList()
            };

            for (int i = startIndex; i <= endIndex; i++)
            {
                animationInfo.SpriteIndices.Add(i);
            }

            spriteComponent.Animations.Enqueue(animationInfo);

            playingSprites.Add(spriteComponent);
        }
コード例 #5
0
        /// <summary>
        /// Play the sprite animation starting at index <paramref name="startIndex"/> and ending at <paramref name="endIndex"/>.
        /// </summary>
        /// <param name="spriteComponent">The sprite component containing the animation</param>
        /// <param name="startIndex">The first index of the animation</param>
        /// <param name="endIndex">The last index of the animation</param>
        /// <param name="repeatMode">The value indicating how to loop the animation</param>
        /// <param name="framesPerSeconds">The animation speed in frames per second. 0 to use the sprite animation system default speed.</param>
        /// <param name="clearQueuedAnimations">Indicate if queued animation should be cleared</param>
        public void Play(SpriteComponent spriteComponent, int startIndex, int endIndex, AnimationRepeatMode repeatMode, float framesPerSeconds = 0, bool clearQueuedAnimations = true)
        {
            if (spriteComponent == null)
            {
                return;
            }

            var animationInfo = new SpriteComponent.AnimationInfo
            {
                ShouldLoop      = repeatMode == AnimationRepeatMode.LoopInfinite,
                SpriteIndices   = SpriteComponent.GetNewSpriteIndicesList(),
                FramePerSeconds = framesPerSeconds > 0 ? framesPerSeconds : DefaultFramesPerSecond,
            };

            for (int i = startIndex; i <= endIndex; i++)
            {
                animationInfo.SpriteIndices.Add(i);
            }

            spriteComponent.RecycleFirstAnimation();
            spriteComponent.Animations.Enqueue(animationInfo);
            var queuedAnimationsCount = spriteComponent.Animations.Count - 1;

            for (int i = 0; i < queuedAnimationsCount; i++)
            {
                var queuedAnimation = spriteComponent.Animations.Dequeue();
                if (!clearQueuedAnimations)
                {
                    spriteComponent.Animations.Enqueue(queuedAnimation);
                }
            }

            playingSprites.Add(spriteComponent);
            spriteComponent.ElapsedTime       = 0;
            spriteComponent.CurrentIndexIndex = 0;
            spriteComponent.IsPaused          = false;
        }
コード例 #6
0
 /// <summary>
 /// Create an instance of <see cref="AnimationAsset"/> with default values.
 /// </summary>
 public AnimationAsset()
 {
     RepeatMode  = AnimationRepeatMode.LoopInfinite;
     ScaleImport = 1.0f;
 }
コード例 #7
0
 /// <summary>
 /// Create an instance of <see cref="AnimationAsset"/> with default values.
 /// </summary>
 public AnimationAsset()
 {
     RepeatMode = AnimationRepeatMode.LoopInfinite;
 }