当我发现两个相似的图像时,如何禁用按钮单击内存匹配游戏? [英] How Can I Disable The Button Click In A Memory Match Up Game When I Found Two Images Similar?
本文介绍了当我发现两个相似的图像时,如何禁用按钮单击内存匹配游戏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void b_Click(object sender, RoutedEventArgs e)
{
Image img = new Image();
Button b = sender as Button;
string BTNname = b.Name;
int BTNnum = 99;
if (BTNname.Length == 2)
{
BTNnum = int.Parse(BTNname[1] + "");
}
else
{
BTNnum = int.Parse(BTNname[1] + "" + BTNname[2]);
}
else if (firstClickINT == secondClickINT)
{
//matching buttons were selected: show second image
firstClickINT = BTNnum;
firstClick = BTNname;
secondClickINT = BTNnum;
secondClick = BTNname;
img.Source = new BitmapImage(new Uri("Assest/Images/" + folderName + "/" + BTNnum + "." + fileEXT + "", UriKind.Relative));
b.Content = img;
Image img1 = new Image();
img1.Source = new BitmapImage(new Uri("Assets/Images/" + folderName + "/" + BTNnum + "." + fileEXT + "", UriKind.Relative));
b.Content = img1;
secondButton = b;
firstButton = b;
firstClick = "";
secondClick = "";
b.IsHitTestVisible = false;
correctMatchings++;
if (correctMatchings == iconCount)
{
//Game Over: Navigate back to welcome page
score = (correctMatchings * matchingScore) - (wrongClicks * wrongScore);
NavigationService.Navigate(new Uri("/MainPage.xaml?score=" + score, UriKind.Relative));
}
//这里的常用按钮单击我设置图像并将它们相互比较。当他们发现相同时,他们将进入其他条件,在显示我要禁用按钮的图像后。但只有一个图像按钮禁用..//
// here on a common button click i set the images nd comparing them with each other. when they found same they will enter in the else if condition where after displaying the images i want to disable the button. but only one image button disable..//
推荐答案
你没有定义什么是相似。除非你想要考虑非常微不足道的相似性,否则很难形式化。
想象一个图像是另一个图像的副本,但添加了轻微的模糊。可能会发生相同位置的100%像素不同,但图像非常相似,如果你看它们就很明显。试想一下。
-SA
You did not define what is "similar". It is surprisingly difficult to formalize, unless you want to consider very trivial similarity.
Imagine that one image is a copy of another one, but with added with slight blur. It may happen then 100% of pixels at the same locations are different, and yet the images are very similar, which is apparent if you look at them. Just think about it.
—SA
这篇关于当我发现两个相似的图像时,如何禁用按钮单击内存匹配游戏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文