sledgemapper/Sledgemapper/SpriteSheet.cs
Michele Scandura 09c32c605e
All checks were successful
continuous-integration/drone/push Build is passing
more refactoring
2021-09-09 10:58:05 +01:00

38 lines
929 B
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
namespace Sledgemapper
{
internal class SpriteSheet
{
internal Texture2D Texture;
internal Dictionary<String, Rectangle> index;
public void LoadContent(ContentManager content, string spriteIndex, string texture)
{
index = content.Load<Dictionary<String, Rectangle>>(spriteIndex);
Texture = content.Load<Texture2D>(texture);
}
internal Rectangle? SourceRectangle(string spriteName)
{
Rectangle r;
bool hasValue = index.TryGetValue(spriteName, out r);
if (hasValue)
{
return r;
}
else
{
throw new Exception("value doesn't exist");
}
}
}
}