1 using Microsoft.Xna.Framework;
9 private Rectangle[] sourceRects;
10 private int emptyFrames;
14 get {
return sourceRects.Length - emptyFrames; }
24 : base(element, path, file)
30 Init(columnCount, rowCount);
33 public SpriteSheet(
string filePath,
int columnCount,
int rowCount, Vector2
origin, Rectangle? sourceRect =
null)
37 if (sourceRect.HasValue) {
SourceRect = sourceRect.Value; }
38 Init(columnCount, rowCount);
41 private void Init(
int columnCount,
int rowCount)
43 sourceRects =
new Rectangle[rowCount * columnCount];
45 float cellWidth =
SourceRect.Width / columnCount;
46 float cellHeight =
SourceRect.Height / rowCount;
47 FrameSize =
new Point((
int)cellWidth, (
int)cellHeight);
49 for (
int x = 0; x < columnCount; x++)
51 for (
int y = 0; y < rowCount; y++)
53 sourceRects[x + y * columnCount] =
new Rectangle((
int)(
SourceRect.X + x * cellWidth), (
int)(
SourceRect.Y + y * cellHeight), (
int)cellWidth, (
int)cellHeight);
Vector2 GetAttributeVector2(string key, in Vector2 def)
int GetAttributeInt(string key, int def)
SpriteSheet(ContentXElement element, string path="", string file="")
SpriteSheet(string filePath, int columnCount, int rowCount, Vector2 origin, Rectangle? sourceRect=null)