我在 XNA 3.1 中创建了一个应用程序,其中一个模型以 Windows 形式加载到图片框中,效果很好:下面是 Game1 类的代码。
现在我尝试在其中加载多个模型,因为我引用了一个应用程序WinFormControlLoading
,在这里我想知道要编写而不是 modelviewcontrol 行,或者我在哪里调用调用我的模型的 LoadContent 函数
void LoadModel(string fileName)
{
Cursor = Cursors.WaitCursor;
string buildError = contentBuilder.Build();
if (string.IsNullOrEmpty(buildError))
{
// If the build succeeded, use the ContentManager to
// load the temporary .xnb file that we just created.
modelViewerControl.Model = contentManager.Load<Model>("Model");
}
else
{
// If the build failed, display an error message.
MessageBox.Show(buildError, "Error");
}
Cursor = Cursors.Arrow;
}
在这一行发生错误
modelViewerControl.Model = contentManager.Load<Model>("Model");
当我将 LoadContent 的 Game1 类函数更改为 public 时
Game1 game;
game.LoadContent = contentManager.Load<Model>("Model");
我得到错误
错误 1“WindowsGame1.Game1.LoadContent()”:覆盖“受保护”继承成员“Microsoft.Xna.Framework.Game.LoadContent()”时无法更改访问修饰符
我如何解决这个问题?
任何帮助,将不胜感激。