我目前正在搞乱C#XNA 4.0,但我在将Texture2D分配给现有的Texture2D时遇到了一些问题。如下图所示 的代码示例:将Texture2D分配到现有的Texture2D
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;
但是,当我试图使用texCurrentDisc在等抽奖,我得到以下错误: 这种方法不适合此参数接受空。 参数名称:纹理。 texCurrentDisc只是初始化为:Texture2D texCurrentDisc;
你确定你在正确的时间正确地分配它吗?当您调用Draw时,是否在texCurrentDisc中引用了相同的纹理? – Euphoric 2010-10-12 09:02:14