Game Development Reference
In-Depth Information
@Override
public void onPause() {
synchronized (stateChanged) {
if if(isFinishing())
state = GLGameState. Finished ;
else
state = GLGameState. Paused ;
while ( true ) {
try {
stateChanged.wait();
break ;
} catch (InterruptedException e) {
}
}
}
wakeLock.release();
glView.onPause();
super .onPause();
}
The onPause() method is our usual Activity notification method that's called on the UI thread
when the Activity is paused. Depending on whether the application is closed or paused, we set
state accordingly and wait for the rendering thread to process the new state. This is achieved
with the standard Java wait/notify mechanism.
Finally, we release the WakeLock and tell the GLSurfaceView and the Activity to pause
themselves, effectively shutting down the rendering thread and destroying the OpenGL ES
surface, which triggers the dreaded OpenGL ES context loss mentioned earlier.
public GLGraphics getGLGraphics() {
return glGraphics;
}
The getGLGraphics() method is a new method that is only accessible via the GLGame class. It
returns the instance of GLGraphics we store so that we can get access to the GL10 interface in
our Screen implementations later on.
public Input getInput() {
return input;
}
public FileIO getFileIO() {
return fileIO;
}
public Graphics getGraphics() {
throw new IllegalStateException("We are using OpenGL!");
}
public Audio getAudio() {
return audio;
}
 
Search WWH ::




Custom Search