内存错误使用c#在Windows Phone 8中匹配游戏。 [英] error in memory match up game in windows phone 8 using c#.
问题描述
在下面的代码中,我无法比较待处理的图像值。
公共部分类MainPage:PhoneApplicationPage
{
Image PendingImage1;
Image PendingImage2;
public void img1_Tap(object sender,System.Windows.Input。 GestureEventArgs e)
{
this.img1.Source = new BitmapImage(new Uri(Assets / baby.jpg,UriKind.RelativeOrAbsolute));
if(PendingImage1 == null)
{
PendingImage1 = img1;
}
else if(PendingImage1!= null && PendingImage2 == null)
{
PendingImage2 = img1;
}
if(PendingImage1!= null && PendingImage2!= null)
{
if(PendingImage1.Tag == PendingImage2.Tag)
{
}
其他
{
DispatcherTimer计时器=新的DispatcherTimer();
timer.Start();
}
}
}
private void img2_Tap(object sender,System.Windows.Input.GestureEventArgs e)
{
this.img2.Source = new BitmapImage(new Uri(Assets / duckk.jpg,UriKind.RelativeOrAbsolute));
if(PendingImage1 == null)
{
PendingImage1 = img2;
}
else if(PendingImage1!= null && PendingImage2 == null)
{
PendingImage2 = img2;
}
if(PendingImage1!= null && PendingImage2 != null)
{
if(PendingImage1.Tag == PendingImage2.Tag)
{
< br $>
}
其他
{
DispatcherTimer计时器=新的DispatcherTimer();
timer.Start();
}
}
}
In the following Code i'm unable to compare the pending image values.
public partial class MainPage : PhoneApplicationPage
{
Image PendingImage1;
Image PendingImage2;
public void img1_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
this.img1.Source = new BitmapImage(new Uri("Assets/baby.jpg", UriKind.RelativeOrAbsolute));
if (PendingImage1 == null)
{
PendingImage1 = img1;
}
else if (PendingImage1 != null && PendingImage2 == null)
{
PendingImage2 = img1;
}
if (PendingImage1 != null && PendingImage2 != null)
{
if (PendingImage1.Tag == PendingImage2.Tag)
{
}
else
{
DispatcherTimer timer = new DispatcherTimer();
timer.Start();
}
}
}
private void img2_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
this.img2.Source = new BitmapImage(new Uri("Assets/duckk.jpg", UriKind.RelativeOrAbsolute));
if (PendingImage1 == null)
{
PendingImage1 = img2;
}
else if (PendingImage1 != null && PendingImage2 == null)
{
PendingImage2 = img2;
}
if (PendingImage1 != null && PendingImage2 != null)
{
if (PendingImage1.Tag == PendingImage2.Tag)
{
}
else
{
DispatcherTimer timer = new DispatcherTimer();
timer.Start();
}
}
}
推荐答案
为什么要对图像进行比较?
看来你的数据模型是不存在的,这就是搞砸你的东西现在。
每个图像应该是数据模型中数据点的直观表示。该数据点应该是一个数值。然后比较非常简单。
Why are you comparing images at all?
It seems you're data model is non-existent and that's what is screwing you over right now.
Each image should be the visual representation of a data point in your data model. That data point should be a numerical value. Then the comparison is very easy.
这篇关于内存错误使用c#在Windows Phone 8中匹配游戏。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!