[英]how to navigate from GamePage.xaml.cs to Game1.cs in vs2012(monogame library)
實際上我正在嘗試開發一個小的Windows商店game.so為了創建游戲,需要游戲庫。所以我想使用xna framework.so我下載了支持xna的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);
}
}
}
實際上這是一個項目創建錯誤。嘗試創建一個新項目,它將起作用。有時清理並重新定義解決方案可能會起作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.