This commit is contained in:
parent
34863a9984
commit
09c32c605e
2 changed files with 39 additions and 123 deletions
37
Sledgemapper/SpriteSheet.cs
Normal file
37
Sledgemapper/SpriteSheet.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue