XNA 游戏工作室 LoadContent [英] XNA game studio LoadContent

查看:28
本文介绍了XNA 游戏工作室 LoadContent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I found a code to load multiple objects in XNA game stuido but can't call load contect method, what do I need to do? Do I need to call it another class besides Game1 or calling in game1 is just fine?

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.

This load content not called in this line. I write this generally to show I call this LoadContent.

推荐答案

要使用 Content 你需要在一个继承自 GameComponentDrawableGameComponent 的类中,因为只有 Game 类有.

To use Content you need to be in a class that inherits from GameComponent or DrawableGameComponent, because only Game class has it.

然后您可以将其称为:

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

这篇关于XNA 游戏工作室 LoadContent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆