【问题标题】:XNA game studio LoadContentXNA 游戏工作室 LoadContent
【发布时间】:2013-11-21 08:38:33
【问题描述】:

我在 XNA game stuido 中找到了加载多个对象的代码,但无法调用 load contect 方法,我需要做什么?除了Game1之外,我还需要调用另一个类吗?或者调用game1就可以了吗?

public override void LoadContent()
{
    // Create a new SpriteBatch, which can be used to draw textures.
    spriteBatch = new SpriteBatch(GraphicsDevice);

    //Dictionary<string, Model> models = new Dictionary<string, Model>;

    mymodel = Content.Load<Model>("Models\\tableBasse2");

    aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;

    backgroundTexture = Content.Load<Texture2D>("123");
    screenWidth = this.Window.ClientBounds.Width;
    screenHeight = this.Window.ClientBounds.Height;
}

//__http://stackoverflow.com/questions/4052532/xna-get-an-array-list-of-resources
public static Dictionary<string,Model> LoadContent

此行中未调用此加载内容。我写这个一般是为了表明我称之为 LoadContent。

【问题讨论】:

  • 您需要更具体地说明您需要做什么...您能详细说明您要做什么吗?
  • 如果出于某种原因,您需要将它放在单独的方法中,请将其命名为例如“CustomLoadContent()”并从“Game1.LoadContent()”方法中调用它。所有内容都应该在那里加载,除非您想要延迟加载并且真正知道自己在做什么。

标签: c# xna


【解决方案1】:

要使用Content,您需要位于从GameComponentDrawableGameComponent 继承的类中,因为只有Game 类拥有它。

然后你可以这样称呼它:

Game.Content.Load<..>("path");

【讨论】:

    猜你喜欢
    • 2011-05-20
    • 1970-01-01
    • 1970-01-01
    • 2018-08-29
    • 2012-06-08
    • 1970-01-01
    • 1970-01-01
    • 2011-06-09
    • 1970-01-01
    相关资源
    最近更新 更多