Step 1 - Making the Textures accessible from Level.cs
The texture for each item is being stored inside the TextureItem class inside Level.cs. You should be able find something like this on your file:
public partial class TextureItem : Item
{
Texture2D texture;
public override void load(ContentManager cm)
{
// Your load implementation
}
}
Now, start by making it public:
public partial class TextureItem : Item
{
public Texture2D Texture;
public override void load(ContentManager cm)
{
// Your load implementation
}
}
And then it's simply a matter of acessing the texture directly. Example:
Level level = Level.FromFile("map.xml", Content);
foreach(Layer layer in level.Layers)
{
foreach(Item item in layer.Items)
{
ImageItem imageItem = item as ImageItem;
if(imageItem != null)
{
Texture2D texture = imageItem.Texture;
// Do something with texture, such as per pixel collision detection
}
}
}
Step 2 - Handling per-pixel collision detection in XNA
In case you're not familiar with this process, here's two good references on the topic:
- Collision Series 2: 2D Per-Pixel Collision to learn how to implement the basics in XNA. The core feature needed is pretty much the Texture.GetData() method which allows you to get back pixel color information from any texture.
- Sonic Physics Guide which describes physics in Sonic games. They also used per-pixel collision detection with the terrain so you might be able to get some tips out of it.