Beispiel #1
0
 @Override
 public void onPause() {
   synchronized (stateChanged) {
     if (isFinishing()) state = GLGameState.Finished;
     else state = GLGameState.Paused;
     while (true) {
       try {
         stateChanged.wait();
         break;
       } catch (InterruptedException e) {
       }
     }
   }
   wakeLock.release();
   glView.onPause();
   super.onPause();
 }
Beispiel #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    //        glView = new GLSurfaceView(this);
    //        glView.setRenderer(this);
    //        setContentView(glView);

    setContentView(R.layout.surface_overlay);
    glView = (GLSurfaceView) findViewById(R.id.glsurfaceview);
    glView.setRenderer(this);

    textPlayer1 = (TextView) findViewById(R.id.textPlayer1);
    textPlayer2 = (TextView) findViewById(R.id.textPlayer2);
    if (application.twoPlayers == false) textPlayer2.setText("");
    textTurn = (TextView) findViewById(R.id.textPlayerTurn);

    // as it is invoked from a GLSurfaceView thread,
    // a runOnUiThread is required
    listener =
        new ScreenListener() {
          public void updateTurn(final String turn) {
            runOnUiThread(
                new Runnable() {
                  public void run() {
                    textTurn.setText(turn);
                  }
                });
          }

          public void updateScorePlayer2(final int score) {
            runOnUiThread(
                new Runnable() {
                  public void run() {
                    textPlayer2.setText(
                        MainApplication.getAppContext().getString(R.string.player2_score) + score);
                  }
                });
          }

          public void updateScorePlayer1(final int score) {
            runOnUiThread(
                new Runnable() {
                  public void run() {
                    textPlayer1.setText(
                        MainApplication.getAppContext().getString(R.string.player1_score) + score);
                  }
                });
          }
        };

    glGraphics = new GLGraphics(glView);
    audio = new AndroidAudio(this);
    input = new AndroidInput(this, glView, 1, 1);
    PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "GLGame");

    Toast.makeText(application, R.string.how_to_play, 2).show();
  }
Beispiel #3
0
 public void onResume() {
   super.onResume();
   glView.onResume();
   wakeLock.acquire();
 }