I am currently messing with C# XNA 4.0, but I am having some problems assigning a Texture2D to an existing Texture2D. An example of the code shown below:
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
texDisc48 = Content.Load<Texture2D>("textures/disc_24");
texDisc48 = Content.Load<Texture2D>("textures/disc_48");
texDisc96 = Content.Load<Texture2D>("textures/disc_96");
}
// Random place in the code
texCurrentDisc = texDisc96;
But when I am trying to use the texCurrentDisc in etc Draw, I get the following error: This method does not accept null for this parameter. Parameter name: texture . The texCurrentDisc is just initalized as: Texture2D texCurrentDisc;
这只是代码中的一个错误,因为纹理在绘制之前就初始化得太晚了。
Can you load the texture using "textures/disc_96"? I thought it had to use something like "textures\\disc_96". Also you assign to texDisc48 twice. So maybe try:
texDisc24 = Content.Load<Texture2D>("textures\\disc_24");
texDisc48 = Content.Load<Texture2D>("textures\\disc_48");
texDisc96 = Content.Load<Texture2D>("textures\\disc_96");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.