0
votes

I am trying to great a lunar lander like Game using MonoGame with Xna, integrated with Visual Studios 2013 and my end goal is to run this a app on a Windows 8.1 phone. I am encountering some errors. Below is the code that is causing the most problems.

One of the errors I am having is in the Game1.cs file:

public class GameStart : Game
{
    ...
}

The error I am getting is

Error 1 Missing partial modifier on declaration of type 'GameName1.GameStart'; another partial declaration of this type exists C:\Users\Matthew\Documents\Visual Studio 2013\Projects\GameName1\GameName1\GamePage.xaml.cs

UPDATE

    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;

    }

Type 'GameName1.GameStart' already defines a member called 'GameStart' with the same parameter types C:\Users\Matthew\Documents\Visual Studio 2013\Projects\GameName1\GameName1\Game1.cs

Here are both of the classes that this error message is referring to.

public GameStart()
{
    InitializeComponent();

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

     // Sample code to localize the ApplicationBar
     //BuildLocalizedApplicationBar();
}

Update

I tired changing XamlGame.Create method to take string instead of "", and it gave me a different error, as a side note this code was auto generated.

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();
    }

} I was getting this error with " ":

Error 3 The best overloaded method match for 'MonoGame.Framework.WindowsPhone.XamlGame.Create(string, Microsoft.Phone.Controls.PhoneApplicationPage)' has some invalid arguments C:\Users\Matthew\Documents\Visual Studio 2013\Projects\GameName1\GameName1\GamePage.xaml.cs

But

now I am getting this error: Invalid expression term 'string'

.

1
Part of this update is incorrect - passing string makes no sense, it is an alias for the type - the point is the variable or value you pass there has to be a string. - kaveman

1 Answers

0
votes

For your class GameStart, the error is saying that you need the partial modifier on the class. This is how you tell the compiler that the class definition is split into multiple files (in this case, Game1.cs and GamePage.xaml.cs). See Partial classes and Methods

Everywhere you have

public class GameStart : Game 
{
    ...
}

Change it to

public partial class GameStart : Game 
{
    ...
}

Update for updated question

The second error is saying you are passing the incorrect parameters to the Create method. The signature

MonoGame.Framework.WindowsPhone.XamlGame.Create(string, Microsoft.Phone.Controls.PhoneApplicationPage)

indicates that the first argument must be of type string and the second of type Microsoft.Phone.Controls.PhoneApplicationPage

You are calling the method like _game = XamlGame<Game>.Create("", this);

The first parameter ("") is a string, so this is fine.

The second parameter (this) refers to the instance of the class being constructed, in this case an instance of the GameStart class. The error is telling you that this does not have the correct type, namely Microsoft.Phone.Controls.PhoneApplicationPage.