Я получаю ContentLoadException «Файл не найден», когда отладчик использует мой метод LoadContent в моем DrawableGameComponent.Я создал тестовую строку, которая выводит корневой каталог содержимого, и он выглядит следующим образом: \ GameName \ bin \ x86 \ Debug \ Content, за исключением, конечно, предшествующих ему личных папок.
Вот код в дочернем элементе игрыclass:
GraphicsDeviceManager graphics;
global_vars variables;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content"; //Folder for the Content Manager to place pipelined files as they are loaded
}
/// <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()
{
variables = new global_vars(graphics);
Character c = new Character(null, null, variables, this);
this.Components.Add(c);
base.Initialize();
}
И реализация DrawableGameComponent:
public Character(Ability[] starting_abilities, Player owner, global_vars vars, Game game) : base(game)
{
this.variables = vars;
this.abilities = starting_abilities;
this.character_owner = owner;
this.experience = 0;
this.position = new Rectangle(variables.CHARACTER_START_POSITION_X, variables.CHARACTER_START_POSITION_Y, variables.CHARACTER_WIDTH + variables.CHARACTER_START_POSITION_X, variables.CHARACTER_HEIGHT + variables.CHARACTER_START_POSITION_Y);
}
public override void Initialize()
{
base.UpdateOrder = variables.CHARACTER_UPDATE_PRIORITY;
base.DrawOrder = variables.CHARACTER_UPDATE_PRIORITY;
base.Enabled = true; //Enables Game to call Update on this component
base.Visible = true; //Enables Game to call Draw on this component
this.move_speed = 3;
this.position.X = variables.CHARACTER_START_POSITION_X;
this.position.Y = variables.CHARACTER_START_POSITION_Y;
this.move_state = variables.CHARACTER_DEFAULT_MOVESTATE;
this.charsprite = new SpriteBatch(variables.manager.GraphicsDevice);
base.Initialize(); //Super class calls LoadContent
}
protected override void LoadContent()
{
String test = Game.Content.RootDirectory;
character_default = Game.Content.Load<Texture2D>("Character_Grey_Eyes_Center");
character_right = Game.Content.Load<Texture2D>("Character_Grey_Eyes_Right");
character_left = Game.Content.Load<Texture2D>("Character_Grey_Eyes_Left");
character_down = Game.Content.Load<Texture2D>("Character_Grey_Eyes_Down");
character_up = Game.Content.Load<Texture2D>("Character_Grey_Eyes_Up");
base.LoadContent();
}
Я проверил и дважды проверил папки, имена файлов и т. д., и все они выглядят нормально.Я абсолютно в тупике.