English 中文(简体)
D. 通过可移植文本的问题 执行
原标题:Problem Loading Textures via DrawableGameComponent Implementation

我拿到一个“没有发现碎片”的内容,当时,浮标击中了我的洛德森特方法。 我制作了一个试验,显示内容目录的输出情况如下: HorNameinx86DebugContent减去我的个人文件。

这里是《狩猎儿童法典》:

 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();
    }  

And the DrawableGameComponent implementation :

   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();
    }

I ve checked and double checked the Folders, Filenames, etc and they all look normal. I m absolutely stumped.

问题回答

处理。 我的特征在运动会启动后,被列入运动会的构成部分清单。 初始。 这使我的游戏开始称作“特征”和“Init”功能。 由于没有打上猎枪,Microsoft超级。 Xna.Framework。 动物体质变量要么是一个无效点,要么没有适当设置。

The solution was to add the Character to the Component list in the game s LoadContent()





相关问题
How can I load a folders files into a ListView?

I d like to have a user select a folder with the FolderBrowserDialog and have the files loaded into the ListView. My intention is to make a little playlist of sorts so I have to modify a couple of ...

File Handling Issue

I am developing a tool in c#, at one instance I start writing into a xml file continuously using my tool,when i suddenly restart my machine the particular xml file gets corrupted, what is the reason ...

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Saving output of a for-loop to file

I have opened a file with blast results and printed out the hits in fasta format to the screen. The code looks like this: result_handle = open("/Users/jonbra/Desktop/my_blast.xml") from Bio.Blast ...

热门标签