Question

actually i'm trying to develop a small windows store game.so in order to create game,game libraries are required.so i want to use xna framework.so i downloaded monogame library which supports xna.it has two pages(GamePage.xaml.cs,Game1.cs) and one designer page(GamePage.xaml).when i set the color of the Game.cs to Blue it is not getting reflected in the xaml page.

  Game1.cs page:

  using Microsoft.Xna.Framework;
 using Microsoft.Xna.Framework.Graphics;

 namespace GameName1
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Game
{
    GraphicsDeviceManager _graphics;
    SpriteBatch _spriteBatch;


    public Game1()
    {
        _graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";
    }

    /// <summary>
    /// Allows the game to perform any initialization it needs to before starting to run.
    /// This is where it can query for any required services and load any non-graphic
    /// related content.  Calling base.Initialize will enumerate through any components
    /// and initialize them as well.
    /// </summary>
    protected override void Initialize()
    {
        // TODO: Add your initialization logic here

        base.Initialize();
    }

    /// <summary>
    /// LoadContent will be called once per game and is the place to load
    /// all of your content.
    /// </summary>
    protected override void LoadContent()
    {
        // Create a new SpriteBatch, which can be used to draw textures.
        _spriteBatch = new SpriteBatch(GraphicsDevice);

        // TODO: use this.Content to load your game content here
    }

    /// <summary>
    /// UnloadContent will be called once per game and is the place to unload
    /// all content.
    /// </summary>
    protected override void UnloadContent()
    {
        // TODO: Unload any non ContentManager content here
    }

    /// <summary>
    /// Allows the game to run logic such as updating the world,
    /// checking for collisions, gathering input, and playing audio.
    /// </summary>
    /// <param name="gameTime">Provides a snapshot of timing values.</param>
    protected override void Update(GameTime gameTime)
    {
        // TODO: Add your update logic here

        base.Update(gameTime);
    }

    /// <summary>
    /// This is called when the game should draw itself.
    /// </summary>
    /// <param name="gameTime">Provides a snapshot of timing values.</param>
    protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.Blue);

        // TODO: Add your drawing code here

        base.Draw(gameTime);
    }
}
}

  GamePage.xaml.cs:
 using Windows.UI.Xaml;
 using Windows.UI.Xaml.Controls;
 using MonoGame.Framework;
 using Microsoft.Xna.Framework.Graphics;
 using Microsoft.Xna.Framework;
 using MonoGame.Framework;
 using Windows.ApplicationModel.Activation;

namespace GameName1
{ 
  /// <summary>
  /// The root page used to display the game.
  /// </summary>
public sealed partial class GamePage : SwapChainBackgroundPanel
{
    readonly Game1 _game;


    public GamePage(string launchArguments)
    {
        this.InitializeComponent();

        // Create the game.
        _game = XamlGame<Game1>.Create(launchArguments, Window.Current.CoreWindow, this);
    }
}

}

Was it helpful?

Solution

actually it was some project creation error.try creating a new project it will work.sometimes clean and rebulid the solution might work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top