C# 单局电话测试错误

C# 单局电话测试错误,c#,windows-phone-8,visual-studio-2013,monogame,C#,Windows Phone 8,Visual Studio 2013,Monogame,我正在尝试使用Xna的MonoGame制作一款类似月球着陆器的游戏,该游戏与Visual Studio 2013集成,我的最终目标是在Windows 8.1手机上运行这款应用程序。我遇到了一些错误。下面是导致问题最多的代码 我遇到的错误之一在Game1.cs文件中: public class GameStart : Game { ... } 我得到的错误是 错误1在类型的声明中缺少部分修饰符 '游戏名称1.游戏开始';另一部分声明 此类型存在于C:\Users\Matthew\Docu

我正在尝试使用Xna的MonoGame制作一款类似月球着陆器的游戏,该游戏与Visual Studio 2013集成,我的最终目标是在Windows 8.1手机上运行这款应用程序。我遇到了一些错误。下面是导致问题最多的代码

我遇到的错误之一在Game1.cs文件中:

public class GameStart : Game
{
    ...
}
我得到的错误是

错误1在类型的声明中缺少部分修饰符 '游戏名称1.游戏开始';另一部分声明 此类型存在于C:\Users\Matthew\Documents\Visual Studio 2013\Projects\GameName1\GameName1\GamePage.xaml.cs

更新

    public GameStart()
    {
        _graphics = new GraphicsDeviceManager(this);
        _graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft|DisplayOrientation.LandscapeRight;
        _graphics.IsFullScreen = true;

        Content.RootDirectory = "Content";

        //if (_motion.IsDataValid) //gonna get an error
        //{
        _motion = new Motion();
        //}
        // Frame rate is 30 fps by default for Windows Phone.
        TargetElapsedTime = TimeSpan.FromTicks(333333);

        // Extend battery life under lock.
        InactiveSleepTime = TimeSpan.FromSeconds(1);

        _CurrentState = GameState.Active;

    }
类型“GameName1.GameStart”已使用相同的参数类型C:\Users\Matthew\Documents\Visual Studio 2013\Projects\GameName1\GameName1\Game1.cs定义了名为“GameStart”的成员

下面是此错误消息引用的两个类

public GameStart()
{
    InitializeComponent();

    _game = XamlGame<Game>.Create("", this);

     // Sample code to localize the ApplicationBar
     //BuildLocalizedApplicationBar();
}
公共游戏开始()
{
初始化组件();
_game=XamlGame.Create(“,this”);
//本地化ApplicationBar的示例代码
//BuildLocalizedApplicationBar();
}
更新

我厌倦了更改XamlGame。创建方法以获取字符串而不是“”,它给了我一个不同的错误, 作为旁注,此代码是自动生成的。

public partial class GameStart : Game
{

    private GameStart _game;

    // Constructor
    public GameStart()
    {
        InitializeComponent();

        _game = XamlGame<Game>.Create(string , this);

        // Sample code to localize the ApplicationBar
        //BuildLocalizedApplicationBar();
    }
公共部分类游戏开始:游戏
{
私人游戏开始游戏;
//建造师
公共游戏开始()
{
初始化组件();
_game=XamlGame.Create(字符串,this);
//本地化ApplicationBar的示例代码
//BuildLocalizedApplicationBar();
}
} 我在“”中遇到此错误:

错误3与的最佳重载方法匹配 'MonoGame.Framework.WindowsPhone.XamlGame.Create(字符串, Microsoft.Phone.Controls.PhoneApplicationPage)“”具有一些无效的 参数C:\Users\Matthew\Documents\Visual Studio 2013\Projects\GameName1\GameName1\GamePage.xaml.cs

但是

现在我得到了这个错误:无效的表达式术语“string”


.

对于你的类
GameStart
,错误是说你需要类上的
partial
修饰符。 这就是告诉编译器类定义被拆分为多个文件(在本例中为Game1.cs和GamePage.xaml.cs)的方式。看

无论你身在何处

public class GameStart : Game 
{
    ...
}
换成

public partial class GameStart : Game 
{
    ...
}
更新问题的更新

第二个错误是将不正确的参数传递给
Create
方法。签名

MonoGame.Framework.WindowsPhone.XamlGame.Create(string, Microsoft.Phone.Controls.PhoneApplicationPage)
指示第一个参数的类型必须为
string
,第二个参数的类型必须为
Microsoft.Phone.Controls.PhoneApplicationPage

您调用的方法类似于
\u game=XamlGame.Create(“,this”)

第一个参数(
“”
)是一个字符串,因此这很好


第二个参数(
this
)是指正在构造的类的实例,在本例中是
GameStart
类的实例。错误是告诉您
的类型不正确,即
Microsoft.Phone.Controls.PhoneApplicationPage

此更新的一部分不正确-传递
字符串
没有意义,它是类型的别名-点是变量或传递的值必须是字符串。