4 using System.Collections.Generic;
6 using SiliconStudio.Core;
7 using SiliconStudio.Core.Mathematics;
8 using SiliconStudio.Core.Serialization;
9 using SiliconStudio.Core.Serialization.Converters;
10 using SiliconStudio.Core.Serialization.Serializers;
11 using SiliconStudio.Paradox.EntityModel;
12 using SiliconStudio.Paradox.Graphics;
14 namespace SiliconStudio.
Paradox.Engine
20 [DataContract(
"SpriteComponent")]
46 [DataMemberCustomSerializer]
49 internal double ElapsedTime;
51 private int currentFrame;
56 [DataMemberCustomSerializer]
59 get {
return SpriteGroupInternal; }
62 if(SpriteGroupInternal == value)
65 SpriteGroupInternal = value;
73 public int CurrentFrame
75 get {
return currentFrame; }
78 if (SpriteGroupInternal == null || SpriteGroupInternal.Images == null || SpriteGroupInternal.Images.Count == 0)
84 currentFrame = Math.Max(0, value % SpriteGroupInternal.Images.Count);
92 public Sprite CurrentSprite
96 if (SpriteGroupInternal == null || SpriteGroupInternal.Images == null)
99 return SpriteGroupInternal.Images[Math.Min(currentFrame, SpriteGroupInternal.Images.Count)];
103 private readonly
static Queue<List<int>> SpriteIndicesPool =
new Queue<List<int>>();
105 internal double AnimationTime;
107 internal int CurrentIndexIndex;
109 internal bool IsPaused;
111 internal struct AnimationInfo
113 public float FramePerSeconds;
115 public bool ShouldLoop;
117 public List<int> SpriteIndices;
120 internal Queue<AnimationInfo> Animations =
new Queue<AnimationInfo>();
122 internal static List<int> GetNewSpriteIndicesList()
124 lock (SpriteIndicesPool)
126 return SpriteIndicesPool.Count > 0 ? SpriteIndicesPool.Dequeue() :
new List<int>();
130 internal static void RecycleSpriteIndicesList(List<int> indicesList)
132 lock (SpriteIndicesPool)
135 SpriteIndicesPool.Enqueue(indicesList);
139 internal void ClearAnimations()
141 lock (SpriteIndicesPool)
143 while (Animations.Count>0)
144 RecycleSpriteIndicesList(Animations.Dequeue().SpriteIndices);
148 internal void RecycleFirstAnimation()
150 CurrentIndexIndex = 0;
151 if (Animations.Count > 0)
153 var info = Animations.Dequeue();
154 RecycleSpriteIndicesList(info.SpriteIndices);
Base class for converters to/from a data type.
SpriteEffects
Defines sprite mirroring options.
SpriteEffects SpriteEffect
The effect to apply on the sprite.
Add a Sprite to an Entity. It could be an animated sprite.
Represent of group of Sprite
Represents a 32-bit color (4 bytes) in the form of RGBA (in byte order: R, G, B, A).
Effect Effect
The effect to use to render the sprite.
A class that represents a tag propety.
A sprite represents a series frames in an atlas forming an animation.