毕业设计之软件开发(2)-月鸟之光手游

发布时间 2023-10-27 18:00:29作者: 奔跑的小蚂蚁9538

  趁着这段时间有空,把之前整理开发的一款手机游戏记录一下。之前是用微软的winphone系统开发,开发工具vs2010。和以往一样,先发一下效果图。整理总结不易,如需全部代码,请联系我15098950589(微信同号)。

 

 

 

 

 

 

 

 

 

 

 

 

核心代码如下:

if (gesture.GestureType == GestureType.Tap)

                {

                    if (setting.collitionRectangle.Contains(new Point((int)gesture.Position.X, (int)gesture.Position.Y)))

                    {

                        if (GameMain.IsBGSoundOpen)

                        {

                            setting.ButtonTexture = Content.Load<Texture2D>(@"GameImages\SettingScreen\close");

                            GameMain.IsBGSoundOpen = false;

                            

                            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())

                            {

                                using (IsolatedStorageFileStream location = new IsolatedStorageFileStream("Setting.xml", System.IO.FileMode.Create, storage))

                                {

                                    StreamWriter file = new StreamWriter(location);

                                    //Stream strm = App.GetResourceStream(new Uri("/WeatherKnow;component/Data/Config.txt", UriKind.Relative)).Stream;

                                    //MemoryStream ms = new MemoryStream();

                                    //strm.CopyTo(ms, Convert.ToInt32(strm.Length));

 

                                    string xml = @"<?xml version='1.0' encoding='utf-8' ?>

                                                    <Setting>

                                                            <sound>" + 1 + "</sound>"

                                                                + "</Setting>";

                                    XDocument doc = XDocument.Parse(xml);

                                    doc.Save(file);

                                    file.Flush();

                                    file.Close();

 

                                }

                            }

 

                            

                        }

                        else

                        {

                            setting.ButtonTexture = Content.Load<Texture2D>(@"GameImages\SettingScreen\open");

                            GameMain.IsBGSoundOpen = true;

                            openSound.Play();

                          

                            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())

                            {

                                using (IsolatedStorageFileStream location = new IsolatedStorageFileStream("Setting.xml", System.IO.FileMode.Create, storage))

                                {

                                    StreamWriter file = new StreamWriter(location);

                                    //Stream strm = App.GetResourceStream(new Uri("/WeatherKnow;component/Data/Config.txt", UriKind.Relative)).Stream;

                                    //MemoryStream ms = new MemoryStream();

                                    //strm.CopyTo(ms, Convert.ToInt32(strm.Length));

 

                                    string xml = @"<?xml version='1.0' encoding='utf-8' ?>

                                                    <Setting>

                                                            <sound>" + 0 + "</sound>"

                                                                + "</Setting>";

                                    XDocument doc = XDocument.Parse(xml);

                                    doc.Save(file);

                                    file.Flush();

                                    file.Close();

 

                                }

                            }

                        }

                        

                    }