Farseer, Metro & MonoGame

Aug 21, 2012 at 10:12 PM

Hi all,

I trying to porting in Win8 a my game developed for Windows Phone with Farseer, XNA and I use MonoGame for XNA porting.

My issues are some errors during Farseer libs compiling about FileStream for System.IO missing (this is the message error from compiler).

Someone can help me?

Thanks in advance.

-Kafar

 

 

Oct 4, 2012 at 3:56 AM
Edited Oct 4, 2012 at 4:01 AM

The latest package seems to have the FileStream stuff commented out.  However, I had started a port of Farseer to Windows 8 before I noticed this project and had already fixed those references up.

My code is below:

    using Windows.Storage;
    using System.Threading.Tasks;

    public static class WorldSerializer
    {
        public static async void Serialize(World world, string filename)
        {
            StorageFolder folder = ApplicationData.Current.LocalFolder;
            StorageFile file = await folder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
            using (Stream s = await file.OpenStreamForWriteAsync())
            {
                new WorldXmlSerializer().Serialize(world, s);
            }
        }

        public static async void Deserialize(World world, string filename)
        {
            StorageFolder folder = ApplicationData.Current.LocalFolder;
            StorageFile file = await folder.CreateFileAsync(filename, CreationCollisionOption.OpenIfExists);
            using (Stream s = await file.OpenStreamForReadAsync())
            {
                new WorldXmlDeserializer().Deserialize(world, s);
            }
        }

        public static async Task<World> Deserialize(string filename)
        {
            StorageFolder folder = ApplicationData.Current.LocalFolder;
            StorageFile file = await folder.CreateFileAsync(filename, CreationCollisionOption.OpenIfExists);
            using (Stream s = await file.OpenStreamForReadAsync())
            {
                return new WorldXmlDeserializer().Deserialize(s);
            }
        }
    }