实际上我正在尝试开发一个小型的Windows商店游戏。所以为了创建游戏,需要游戏库。所以我想使用xna framework.so我下载了支持xna.it的monogame库有两个页面(GamePage.xaml.cs,Game1.cs)和一个设计器页面(GamePage.xaml)。当我将Game.cs的颜色设置为蓝色时,它不会反映在xaml页面中。
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);
}
}
}
答案 0 :(得分:0)
实际上是一些项目创建错误。创建一个新项目它将工作。有时清理和rebulid解决方案可能会工作。