Overview
My game is currently based on a single activity (rather than multiple activities) and I would like to keep it that way.
At the moment, it goes straight into the game at level 1. I will shortly be adding an options menu and another 20 or so levels. (As well as a high-score screen, help screen etc).
The thing I'm not sure about is, how do I tell the app/renderer what screen/part of the game to render?
It's an openGL ES 2.0 app so at the moment, the method I have in my mind is something like this:
Code Snippets
int level = 0; //0 means menu, 1 means level 1 etc
in onDrawFrame(); have something like this:
@Override
public void onDrawFrame(GL10 gl) {
switch (level){
case 0:renderMenu();break;
case 1:renderLevel1();break
case 2............
And so on.
I would also do the same with the logic updating.
Is this the way to go? I'm just not sure it's very efficient but I can't really see what the alternatives are - another way I was looking into was having a separate GLRenderer for each 'screen / level' but this seems much more over-kill.
Would appreciate some guidance as to how to display the correct screen / level at the right time.
Edit This is the current structure of my code:
Activity class
public class MainActivity extends Activity {
//Various pieces of code here
class MyGLSurfaceView extends GLSurfaceView {
//Various pieces of code here
@Override
public boolean onTouchEvent(MotionEvent event) {
//Touch events handles here
}
GL Renderer class
onDrawFrame(){
render();
update();
}