0

我正在扩展 XNA 游戏工作室 2D 教程并添加来自 microsoft XNA 游戏工作室网站的菜单。我以为它只是插入并运行,但比我想象的要复杂得多。这是一个错误,当我得到它们时,我会发布更多。这是调试窗口:

C:\Users\Ian\Desktop\GameStateManagementSample - Copy\GameStateManagement\Screens\GameplayScreen.cs(81,24): 错误 CS1502: 'Microsoft.Xna.Framework.GraphicsDeviceManager.GraphicsDeviceManager(Microsoft.Xna. Framework.Game)' 有一些无效参数 C:\Users\Ian\Desktop\GameStateManagementSample - Copy\GameStateManagement\Screens\GameplayScreen.cs(81,50): error CS1503: Argument '1': cannot convert from 'GameStateManagement.GameplayScreen ' 到 'Microsoft.Xna.Framework.Game'

编译完成 -- 2 个错误,0 个警告 ========== 构建:0 个成功或最新,1 个失败,0 个跳过 ==========

这是代码:

public GameplayScreen()

        {
            //new GraphicsDeviceManager(this) has the error line under it!!!
            graphics = new GraphicsDeviceManager(this);
            content.RootDirectory = "Content";
        }
4

2 回答 2

3

您需要GraphicsDeviceManager使用有效的Microsoft.Xna.Framework.Game对象而不是当前类传递构造函数this

此外,可能有助于创建您的第一个游戏的演练

于 2009-03-02T15:52:27.377 回答
1

I guess you're working on the GameStateManagmentSample. If so, since the graphics device is already available in ScreenManager so the only thing you need to do is call the graphics device instead of define a new graphic.

ScreenManager.GraphicsDevice.Viewport.AspectRatio;
于 2012-05-22T07:36:59.133 回答