[英]XNA game studio LoadContent
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? 我在XNA游戏stuido中找到了加载多个对象的代码,但是无法调用load contect方法,我该怎么办? Do I need to call it another class besides
Game1
or calling in game1
is just fine? 我是否需要在
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
This load content not called in this line. 此行未调用此加载内容。 I write this generally to show I call this LoadContent.
我通常写这个来表明我称之为LoadContent。
To use Content
you need to be in a class that inherits from GameComponent
or DrawableGameComponent
, because only Game
class has it. 要使用
Content
您需要处于从GameComponent
或DrawableGameComponent
继承的类中,因为只有Game
类拥有它。
And then you can call it as: 然后可以将其称为:
Game.Content.Load<..>("path");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.