2013-04-05 89 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运行。自从我试图避免这样做以来,这是令人伤心的。

相关问题