I am making a 2d rpg game in xna and I need to be able to use xna's xml framework to load a map. I have a so called "map egine" which has a map class that has a layer array/list and a layer class that has a gameobject array/list.
If some could help me find away I can use xml to define the map, its layer, than the layers object, and lastly the object components(lua, player). I attached my source code here: https://mega.co.nz/#!OQ5BiSoC!UlOPiiSkk ... 3l1UgRynSI.
XNA XML Map Loading
Moderator: Coders of Rage
-
- Chaos Rift Newbie
- Posts: 3
- Joined: Tue Apr 22, 2014 5:47 pm
- Current Project: 2d xna rpg
- Favorite Gaming Platforms: XBpx
- Programming Language of Choice: C#
- Location: Tallahasse, FL
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: XNA XML Map Loading
Assuming you're using the full .NET framework, you should have access to the XmlSerializer class. Check out the example on the MSDN page.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
-
- Chaos Rift Newbie
- Posts: 3
- Joined: Tue Apr 22, 2014 5:47 pm
- Current Project: 2d xna rpg
- Favorite Gaming Platforms: XBpx
- Programming Language of Choice: C#
- Location: Tallahasse, FL
Re: XNA XML Map Loading
I need to read an xml not write it. I know xna has an xml framework itself but I need to read a xml file like this:
<Map name="shity map">
<Layer number="0">
<Gameobject renderable="true" name="player" x="0: y="0">
<Component type="player" parent="player"></Component>
<Component type="lua" script="player.lua" parent="player"></Component>
</GameObject>
</Layer>
</Map>
<Map name="shity map">
<Layer number="0">
<Gameobject renderable="true" name="player" x="0: y="0">
<Component type="player" parent="player"></Component>
<Component type="lua" script="player.lua" parent="player"></Component>
</GameObject>
</Layer>
</Map>
- flsfr
- ES Beta Backer
- Posts: 3
- Joined: Wed Jul 10, 2013 6:40 pm
- Favorite Gaming Platforms: GBA, PC, NES
- Programming Language of Choice: C++
- Location: Victoria BC, Canada
- Contact:
Re: XNA XML Map Loading
Though I've never used XNA and I am not up to speed with the .NET framework I'll be glad to help. You can use one of the Deserialize methods from the "XmlSerializer" class to "read an xml."
http://msdn.microsoft.com/en-us/library ... alize.aspx
Instead of using the given example class, "OrderedItem", you could use your "Map" class. However, I have no real idea what your "Map" class and it's members look like as the link you posted shawk08033 doesn't work – make sure it's surrounded using the url tag.
http://msdn.microsoft.com/en-us/library ... alize.aspx
Instead of using the given example class, "OrderedItem", you could use your "Map" class. However, I have no real idea what your "Map" class and it's members look like as the link you posted shawk08033 doesn't work – make sure it's surrounded using the url tag.
-
- Chaos Rift Newbie
- Posts: 3
- Joined: Tue Apr 22, 2014 5:47 pm
- Current Project: 2d xna rpg
- Favorite Gaming Platforms: XBpx
- Programming Language of Choice: C#
- Location: Tallahasse, FL
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: XNA XML Map Loading
Aye, assuming you have access to or are able to recreate the C# class(es). Otherwise you'd have to use an XmlReader to consume the data into your own object(s).flsfr wrote:Though I've never used XNA and I am not up to speed with the .NET framework I'll be glad to help. You can use one of the Deserialize methods from the "XmlSerializer" class to "read an xml."
http://msdn.microsoft.com/en-us/library ... alize.aspx
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!