在Windows8中创建游戏时出现交集错误

本文关键字:错误 Windows8 创建 游戏 | 更新日期: 2023-09-27 18:19:20

我正在使用windows 8 metro应用程序c#创建一个吃豆人游戏。

我目前在"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?)

在Windows8中创建游戏时出现交集错误

编译错误提示,类型Windows.Foundation.Rect (http://msdn.microsoft.com/en-us/library/windows/apps/windows.foundation.rect)没有InteresectsWith方法。

System.Drawing.Rectangle (http://msdn.microsoft.com/en-us/library/system.drawing.rectangle.aspx)做,但似乎你正在编写一个WinRT应用程序,常规的。net系统库不适用。