Save map ingame?

Mar 25, 2012 at 4:35 PM

Is it possible to save the map ingame? I haven't looked at the API so much but what I have seen it aint build in.

Mar 25, 2012 at 5:12 PM


FormatManager.DefaultFormat.Store(map, stream);

where map is your map object and stream is a stream object that you can set to a file stream.

Mar 30, 2012 at 12:16 AM
Edited Mar 30, 2012 at 12:19 AM

This is just really good so I can make a ingame map editor :)

using (FileStream stream = new FileStream(@"F:\TE\Test\File.xml", FileMode.Create, FileAccess.Write, FileShare.None))
      FormatManager.Instance.DefaultFormat.Store(map, stream);

using (FileStream stream = new FileStream(@"F:\TE\Test\File.xml", FileMode.Open, FileAccess.Read, FileShare.None))
     map = FormatManager.Instance.DefaultFormat.Load(stream);


Mar 30, 2012 at 7:09 AM
Edited Mar 30, 2012 at 7:10 AM

You got the gist of it :)

Obviously this way you will be bypassing the content manager if working through XNA.

Mar 30, 2012 at 4:28 PM

I noticed that you have that feature. But there was one thing I got a bit confused on and I don't want to mess around with the Source due to it will just make all more frustrating. But how do you load all the tilesheets? From what I know 'Initialize()' is called before 'LoadContent()' Or is it reinitialize it? 

Becosue if I use

map = FormatManager.Instance.DefaultFormat.Load(stream);

Will it reinitialize it? Or yeah... I just want to know how it load all the tilesheets.


Mar 30, 2012 at 8:27 PM

You have to call map.LoadTileSheets(displayDevice) after you load your map (or at least before you attempt to render it).

Mar 31, 2012 at 11:08 PM

Okey, I did test it out and see what did load first with Debugging and found out that LoadContent is Called before Initialize. So I understand it now.