2013-04-05 83 views
0

創建我的遊戲元素這樣在我的活動:爲什麼onSurfaceCreated不會在此代碼中運行?

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    mGame = new Game(this); 
    mGame.bootstrap(); 
    setContentView(CommonObject.sCommonParams.touch); 
    mGame.loadTextures(); 
} 

然後在我的引導創建我GLsurfaceView是這樣的:(callingActivity是,當我創建MGAME我通過了這一點)

CommonObject.sCommonParams.openGLView = new GLSurfaceView(callingActivity); 
CommonObject.sCommonParams.openGLView.setRenderer(new GameRenderer()); 
CommonObject.sCommonParams.openGLView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); 

是否因爲我將GLSurfaceView傳遞給它不工作的靜態對象?

回答

1

原來我不得不

setContentView(CommonObject.sCommonParams.openGLView); 

爲onSurfaceCreated運行。自從我試圖避免這樣做以來,這是令人傷心的。