English 中文(简体)
最优化的排雷性能(清雷式的游戏彩色灯色)
原标题:optimise performance for minesweeper-style game silverlight

我正在设计银灯游戏的扫雷布局类型。 目前,我在 square 控制上使用了 quare 用户控制。 有指定属性。 我还想在稍后阶段添加一个功能。 是要使用贝色曲线弯曲, 用 x, 以坐标而不是绕行的方式绘制曲线上的方形。 然后我要在 XML 文件中发送正方形 s x,y 位置 。

< p > 我的疑问是, 我应使用哪种方式是最优化的组合, 即最小的内存消耗、 快速高效的性能和易于执行。 如果专家有任何其他想法, 请让我知道。 感谢!

最佳回答

几天来,我自己解决了答案。我继续通过我的 < code> Square 用户控制,并将其用于布局。

关于X/y 位置的绘图,我用了这个:

Point point = myElement.TransformToVisual(App.Current.RootVisual as FrameworkElement)).Transform(new Point(0, 0));

保存 XML 文件时出现故障, 因为银光 4 没有给予在浏览器中应用的高级权限 。 但我在保存按钮点击事件上使用了此选项 :

        SaveFileDialog dlgSave = new SaveFileDialog();
        dlgSave.DefaultExt = "xml";
        dlgSave.Filter = "XML Files (XML)|*.xml;";
        dlgSave.FilterIndex = 1;
        strXML = "<?xml version="1.0" encoding="UTF-8"?>
" + myXML.ToString();//myXML is the XDocument I created globally and saved data in it
        try
        {
            bool check = (bool)dlgSave.ShowDialog();
            if (check)
            {
                using (Stream stream = dlgSave.OpenFile())
                {
                    StreamWriter sw = new StreamWriter(stream, System.Text.Encoding.UTF8);
                    sw.Write(strXML);
                    sw.Close();
                    stream.Close();
                }
                MessageBox.Show("XML Saved successfully");
            }
            catch (SecurityException)
            {
                MessageBox.Show("There seems to be an issue with saving XML file on the disk, please try again...", "Something s not right", MessageBoxButton.OK);
            }
            catch (UnauthorizedAccessException)
            {
                MessageBox.Show("Saving here requires authorised permissions", "Access Denied", MessageBoxButton.OK);
            }
问题回答

如果您能够以形状和图像(即矢量图形)的形式绘制一切, 并且您能够利用图形元素的硬件加速度。 另外, 如果您不将方形定义为用户控件, 您将会得到更好的性能。 您应该以包含其他形状的形状来动态地创建代码, 并随后根据形状的位置( 如词典方形; 词典方形元素) 与形状连接到一个对象模型 。

就内存消耗和文件存取而言,您应该只在需要时(即当玩家离开游戏时)将正方形 s x,y 位置保留在作为点构造的记忆中,并按序列排序到文件(XML是罚款的)。



上一篇:
下一篇:


相关问题
Silverlight Rich text box control

Our team decided that we need our own custom Rich text box control for Silverlight app we are developing. We looked at existing controls mentioned at A good rich text control for Silverlight but ...

Silverlight ImageBrush not rendering (with Bing Map Control)

I m trying to add an image to a Pushpin instance from the Silverlight Bing Map Control, but I can t seem to get it to render (the pushpin renders fine). This is probably a general WPF question rather ...

Silverlight OpenFileDialog DoEvents equivalent

I m processing large files after they are selected by the user. My code looks like the following: if (FileDialog.ShowDialog() == true) { // process really big file } This freezes up the UI so ...

list of controls with templates in silverlight

Does anyone know where to find a list of controls that you can set the template on in Silverlight? I ve wasted several hours now trying to create control templates only to find that the control doesn ...

Silverlight, Updating the UI during processing

I have a simple silverlight multifile upload application, and i want to provide the user with some feedback, right now its only in a test phase and i dont have the webservice. Somehow i cant get the ...

Silverlight 3 - FindName returns null

This looks a bug to me.. Using Silverlight 3 and i have a user control defined in XAML and trying to access the object during runtime returns a null. <Grid> <common:CommonGridEditPanel x:...

silverlight 3 collection binding

Someone please help me understand why this binding does not work... I have a class called SelectionManager with a property called dates which is populated by a WCF service. The property is an ...

WPF/Silverlight: data binding a datacontext to a property programmatically

I ve got some code which sets up a datacontext. Often enough, the datacontext should be set to some underlying data collection, such as an ObservableCollection - but occasionally I d like to set it ...

热门标签