2013-11-27 33 views
1

我已經在XNA 3.1中做了一個應用程序,其中一個模型正在Windows窗體中的圖片框中加載,這是工作得很好:下面是Game1類的代碼。
現在我試圖在加載多個模型,我refered到WinFormControlLoading的應用程序,在這裏我想知道寫的,而不是modelviewcontrol線或我在哪裏打電話這就要求我的模型的LoadContent功能加載3D模型與Windows窗體中的背景

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類功能的公共像

Game1 game; 
game.LoadContent = contentManager.Load<Model>("Model"); 

我得到

錯誤1 'WindowsGame1.Game1.LoadContent()' 的錯誤:無法更改訪問修飾符覆蓋,當 '保護' 繼承成員 'Microsoft.Xna.Framework.Game.LoadContent()'

我該如何解決?
任何幫助,將不勝感激。

回答

1

我不知道在哪個類你這樣做,但是這個類必須從GameComponentDrawableGameComponent繼承,這樣你可以使用ContentManager這樣的:

Game.Content.Load<Model>("Model"); 
+0

哦,謝謝,我會努力:) – user3041031

+0

和我正在做我的表格後,我想顯示我的渲染模型與紋理。 – user3041031

+0

要麼我沒有得到確切的地方,要麼我可能沒有正確解釋問題。我鏈接了兩個應用程序,一個是我在xna上製作的,它在Windows窗體圖片框控件中顯示可渲染的3D模型以及背景以及其他僅使用窗口形成已準備好的應用程序的窗口,該應用程序以windows窗體形式導入所有模型和材質並顯示但在'模型視圖控制器'工具,我不想使用 – user3041031