XNA游戏工作室LoadContent

时间:2013-11-20 05:47:23

标签: c# xna

我发现一个代码在XNA游戏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。

1 个答案:

答案 0 :(得分:1)

要使用Content,您需要加入一个继承自GameComponentDrawableGameComponent的班级,因为只有Game班级才有。

然后你可以称之为:

Game.Content.Load<..>("path");
相关问题