我正在使用 Windows 8 Metro 应用程序 C# 创建一个 pacman 游戏。
我目前在“IntersectsWith”上有一些错误。
如下图所示,我实际上是想让吃豆人吃掉这些颗粒。谁能告诉我为什么代码有错误?:
代码:
var rectPacman = pacman.GetRect(cnvMain);
bool gotPellet = false;
foreach (var pellet in pellets)
{
if (pellet.Visibility == Visibility.Visible)
{
var rectPellet = pellet.GetRect(cnvMain);
var pelletCellPoint = pellet.GetCellPoint();
if (rectPacman.IntersectsWith(rectPellet))
{
gotPellet = true;
pellet.Visibility = Visibility.Collapsed;
AddPellet(pellet);
mazeValues[(int)pelletCellPoint.X, (int)pelletCellPoint.Y] = ' ';
break;
}
}
}
错误显示:
'Windows.Foundation.Rect' does not contain a definition for 'IntersectsWith' and no extension method 'IntersectsWith' accepting a first argument of type 'Windows.Foundation.Rect' could be found (are you missing a using directive or an assembly reference?)