Xamarin Studio を使用して MonoGame にテクスチャを読み込もうとしています。私のコードは以下のように設定されています:
#region Using Statements
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Input;
#endregion
namespace TestGame
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
//Game World
Texture2D texture;
Vector2 position = new Vector2(0,0);
public Game1 ()
{
graphics = new GraphicsDeviceManager (this);
Content.RootDirectory = "Content";
graphics.IsFullScreen = false;
}
/// <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);
//Content
texture = Content.Load<Texture2D>("player");
}
/// <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)
{
// For Mobile devices, this logic will close the Game when the Back button is pressed
if (GamePad.GetState (PlayerIndex.One).Buttons.Back == ButtonState.Pressed) {
Exit ();
}
// 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)
{
graphics.GraphicsDevice.Clear (Color.CornflowerBlue);
//Draw
spriteBatch.Begin ();
spriteBatch.Draw (texture, position, Color.White);
spriteBatch.End ();
base.Draw (gameTime);
}
}
}
デバッグすると、エラーが表示されます:
Microsoft.Xna.Framework.Content.ContentLoadException: プレーヤー アセットを非コンテンツ ファイルとして読み込めませんでした! ---> Microsoft.Xna.Framework.Content.ContentLoadException: ディレクトリが見つかりませんでした。---> System.IO.DirectoryNotFoundException: パス 'C:\Users\Flame\Documents\Projects\TestGame\TestGame\bin\Debug\Content\player.xnb' の一部が見つかりませんでした。---> System.Exception:
--- 内部例外スタック トレースの終了 ---
at System.IO.__Error.WinIOError(Int32 errorCode, String MaybeFullPath)
System.IO.FileStream.Init で (文字列パス、FileMode モード、FileAccess アクセス、Int32 権限、Boolean useRights、FileShare 共有、Int32 bufferSize、FileOptions オプション、SECURITY_ATTRIBUTES secAttrs、String msgPath、Boolean bFromProxy、Boolean useLongPath)
System.IO.FileStream..ctor で (文字列パス、FileMode モード、FileAccess アクセス、FileShare 共有、Int32 bufferSize、FileOptions オプション、文字列 msgPath、ブール値 bFromProxy)
at at System.IO.FileStream..ctor(文字列パス、FileMode モード、FileAccess アクセス、FileShare 共有)
at at System.IO.File.OpenRead(文字列パス)
at at Microsoft.Xna.Framework.TitleContainer.OpenStream(文字列名)
at at Microsoft.Xna.Framework.Content.ContentManager.OpenStream(String assetName)
--- 内部例外スタック トレースの終了 ---
at at Microsoft.Xna.Framework.Content.ContentManager.OpenStream(String assetName)
at at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject)
--- 内部例外スタック トレースの終了 ---
at at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject)
at at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)
c:\Users\Flame\Documents\Projects\TestGame\TestGame\Game1.cs:0 の TestGame.Game1.LoadContent() で
Microsoft.Xna.Framework.Game.Initialize() で
c:\Users\Flame\Documents\Projects\TestGame\TestGame\Game1.cs:0 の TestGame.Game1.Initialize() で
Microsoft.Xna.Framework.Game.DoInitialize() で
Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior) で
Microsoft.Xna.Framework.Game.Run() で
c:\Users\Flame\Documents\Projects\TestGame\TestGame\Program.cs:0 の TestGame.Program.Main() で
それで、私は何を間違っていますか?