/// <summary> /// Draws the animation with the given SpriteBatch. /// </summary> public virtual void Draw(SpriteBatch spriteBatch) { for (int i = 0; i < DrawInfos.Count; ++i) { SpriteDrawInfo di = DrawInfos[i]; ISprite sprite = di.Drawable; sprite.Draw(spriteBatch, di.Pivot, di.Position, di.Scale, di.Rotation, di.Color, di.Depth); } }
protected override void ApplySpriteTransform(ISprite drawable, SpriterObject info) { float posX, posY, rotation; GetPositionAndRotation(info, out posX, out posY, out rotation); SpriteDrawInfo di = DrawInfoPool.Count > 0 ? DrawInfoPool.Pop() : new SpriteDrawInfo(); di.Drawable = drawable; di.Pivot = new Vector2(info.PivotX, (1 - info.PivotY)); di.Position = new Vector2(posX, posY); di.Scale = new Vector2(info.ScaleX, info.ScaleY) * Scale; di.Rotation = rotation; di.Color = Color * info.Alpha; di.Depth = Depth + DeltaDepth * DrawInfos.Count; DrawInfos.Add(di); }
protected override void ApplySpriteTransform(ISprite drawable, SpriterObject info) { float px = info.X; float py = -info.Y; float rotation = MathHelper.ToRadians(-info.Angle); if (Scale.X < 0) { px = -px; rotation = -rotation; } if (Scale.Y < 0) { py = -py; rotation = -rotation; } px *= scaleAbs.X; py *= scaleAbs.Y; float posX = px * rotationCos - py * rotationSin; float posY = px * rotationSin + py * rotationCos; SpriteDrawInfo di = DrawInfoPool.Count > 0 ? DrawInfoPool.Pop() : new SpriteDrawInfo(); di.Drawable = drawable; di.Pivot = new Vector2(info.PivotX, (1 - info.PivotY)); di.Position = new Vector2(posX, posY) + Position; di.Scale = new Vector2(info.ScaleX, info.ScaleY) * Scale; di.Rotation = rotation + Rotation; di.Color = Color * info.Alpha; di.Depth = Depth + DeltaDepth * DrawInfos.Count; DrawInfos.Add(di); }