示例#1
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            pongConfig = PongConfig.Load(GetStorageDevice());
            if (pongConfig != null)
            {
                scalingFactor = pongConfig.ScalingFactor;
                if (scalingFactor == 0)
                {
                    scalingFactor            = scalingFactorOrigin;
                    pongConfig.ScalingFactor = scalingFactorOrigin;
                }

                screenOffset = pongConfig.ScreenOffset;
            }
            else
            {
                pongConfig   = new PongConfig();
                currentState = GameState.ScalingScreen;
            }
        }
示例#2
0
        public static PongConfig Load(StorageDevice storageDevice)
        {
            PongConfig _returnData = null;

            try
            {
                using (StorageContainer container = storageDevice.OpenContainer("MyPong"))
                {
                    string fileName = Path.Combine(container.Path, "PongConfig.xml");
                    if (File.Exists(fileName))
                    {
                        using (FileStream fileStream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
                        {
                            XmlSerializer serializer = new XmlSerializer(typeof(PongConfig));
                            _returnData = serializer.Deserialize(fileStream) as PongConfig;
                            fileStream.Close();
                        }
                    }
                }
            }
            catch { }
            return(_returnData);
        }
示例#3
0
 public static void Save(StorageDevice storageDevice, PongConfig config)
 {
     config.Save(storageDevice);
 }