Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8944657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:04:40+00:00 2026-06-15T12:04:40+00:00

Hey i’ve been looking around for a while now and i still cant find

  • 0

Hey i’ve been looking around for a while now and i still cant find a straight answer to this problem. I have an XNA game in which part of the UI shows an icon which will change every so often(how often is irrelevant). I have decided to use a simple spritesheet maker which outputs the spritesheet as well as a simple XML file with the locations of each of the seperate icons in it.

What i would like to be able to do is read the spritesheet location and icon size of the appropriate icon from the XML file into a Rectangle. Then i can just use this as the source rectangle for the drawing bit.

However i have yet to come across a simple explanation of how to load in XML files into an XNA 4.0 project without writing my own content pipeline (something i would like to avoid if possible) and once loaded how to effectively (in general) extract the data into the Rectangle variable.

The XML file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with TexturePacker http://texturepacker.com-->
<!-- $TexturePacker:SmartUpdate:748fc56befb00c22540f953093f731a7$ -->
<!--Format:
n  => name of the sprite
x  => sprite x pos in texture
y  => sprite y pos in texture
w  => sprite width (may be trimmed)
h  => sprite height (may be trimmed)
oX => sprite's x-corner offset (only available if trimmed)
oY => sprite's y-corner offset (only available if trimmed)
oW => sprite's original width (only available if trimmed)
oH => sprite's original height (only available if trimmed)
r => 'y' only set if sprite is rotated
-->
<TextureAtlas imagePath="Loadout_Icons.png" width="185" height="86">
    <sprite n="Charge_Down.png" x="0" y="0" w="37" h="43"/>
    <sprite n="Charge_Up.png" x="37" y="0" w="37" h="43"/>
    <sprite n="Damage_Down.png" x="74" y="0" w="37" h="43"/>
    <sprite n="Damage_Up.png" x="111" y="0" w="37" h="43"/>
    <sprite n="FireRate_Down.png" x="148" y="0" w="37" h="43"/>
    <sprite n="FireRate_Up.png" x="0" y="43" w="37" h="43"/>
    <sprite n="Health_Down.png" x="37" y="43" w="37" h="43"/>
    <sprite n="Health_Up.png" x="74" y="43" w="37" h="43"/>
    <sprite n="Speed_Down.png" x="111" y="43" w="37" h="43"/>
    <sprite n="Speed_Up.png" x="148" y="43" w="37" h="43"/>
</TextureAtlas>

Also im not sure if im shooting myself in the foot by not making my own XML files, would that be easier?

I have read most of what msdn had to offer with no avail but any links to relevant pages or questions would be much appreciated.
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:04:40+00:00Added an answer on June 15, 2026 at 12:04 pm

    As it was only mentioned in a comment I decided to say that I ended up using Niko Drašković’s suggestion of the purpose built pipeline extension made specifically for texture packer which can be found at http://thirdpartyninjas.com/blog/2012/08/02/texturepacker-xna-content-pipeline-extension/. That make it very easy to work with XML files produced by texture packer.

    However as a bit of a side note and another reason why I revisited this question was to say that I have been doing a fair bit of work with XML’s lately (trying to get a better understanding for them) and the best way that I have found to deal with reading custom XML files without writing a new pipeline extension for each one (as elegant as that now seems)is as follows. I add the XML file to the content directory like you would any other texture etc. In the properties of the XML I set Build Action to “Content” and then Copy to Output Directory to “Copy Always”. From here I have a separate class in which I pass in the name of the file and inside which I process everything I need from the XML. These classes start with:

    Stream stream = TitleContainer.OpenStream("Content\\" + fileName + ".xml");
    XDocument doc = XDocument.Load(stream);
    

    and then go on (using the rest of the System.Xml.Linq library) to read and store the appropriate data, with methods to access data easily. This may not be the best approach to tackling the problem but it has since worked for me and is simple enough to understand and implement quickly. Hope this can help anyone else with a similar issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey i have been looking around and i cant find a way to get
hey guys having this really simple problem but cant seem to figure out have
Hey all. I've been been trying to figure this out for a while now.
Hey I have been looking all over the internet and this site for hours
Hey I've been struggling with this whole day, and I can't find the answer
Hey guys! I have this little problem: I have one ViewController which adds 2
Hey all i have a JSFiddle that i have been working on with trying
Hey I have following code like this public object RetrieveItemRun(int item) { if (dictionary.ContainsKey(item))
Hey there, Now im working this base on dmitko tutorial on extending django-registration post
Hey all- I have looked this up on here and Google but none of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.