これに似た問題に対するさまざまな解決策を読みましたが、自分に合った解決策が見つかりません。
XNA の基本を学ぶために簡単なゲームの作成を始めたばかりですが、追加のクラスでテクスチャをロードすることができません。私はこれを試しました:
編集:これは、十分に明確にしなかった場合のメインクラスではありません
class Wizard
{
// Variables
Texture2D wizardTexture;
GraphicsDeviceManager graphics; // I added this line in later, but it didn't seem to do anything
public Wizard(ContentManager content, GraphicsDeviceManager graphics)
{
this.graphics = graphics;
Content.RootDirectory = "Content";
LoadContent();
}
protected override void LoadContent()
{
wizardTexture = Content.Load<Texture2D>("Wizard"); // Error is here
base.LoadContent();
}
私も次のような方法を作ってみました
public Texture2D Load(ContentManager Content)
{
return Content.Load<Texture2D>("Wizard");
}
そして、wizardTexture = Load(Content); を持っています。しかし、それもうまくいきませんでした。
助けと説明をいただければ幸いです、ありがとう