コード例 #1
0
  /**
   * <b>DO NOT CALL THIS METHOD</b>
   *
   * <p>This method is part of the Android Activity lifecycle which is managed by GameEngine itself.
   */
  @Override
  protected final void onPause() {
    super.onPause();
    printDebugInfo("GameEngine", "OnPause...");

    pause();
    GameSound.pauseSounds();
    MusicPlayer.pauseAll();

    MotionSensor.handleOnPause(this);
  }
コード例 #2
0
  /**
   * <b>DO NOT CALL THIS METHOD</b>
   *
   * <p>This method is part of the Android Activity lifecycle which is managed by GameEngine itself.
   */
  @Override
  protected final void onResume() {
    super.onResume();
    printDebugInfo("GameEngine", "onResume()...");
    // Note: only restart thread after a real pause, not at startup
    if (gameThread != null) {
      if (gameThread.getState() == Thread.State.TERMINATED) {
        startThread();
      }
    }
    GameSound.resumeSounds();
    MusicPlayer.resumeAll();

    MotionSensor.handleOnResume(this);
  }
コード例 #3
0
  /**
   * * <b>Do NOT call this method.</b>
   *
   * <p>Called when activity is started. Initialise GameEngine objects and set options to be used by
   * the GameEngine.<br>
   * This method is part of the Android Activity lifecycle which is managed by GameEngine itself.
   *
   * @param savedInstanceState
   */
  @Override
  protected final void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    checkScreenOrientation();
    printDebugInfo("GameEngine", "oncreate....");
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED,
            WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED);

    vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    appContext = getApplicationContext();

    gameView = new GameView(this);
    mainView = new FrameLayout(this);
    mainView.addView(gameView);
    addDashboard();

    // create GameThread in one place: the startThread method

    touch = new TouchInput(gameView);
    screenButtons = new OnScreenButtons();

    GameSound.initSounds(getAppContext());

    SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    MotionSensor.initialize(sensorManager);

    screenWidth = getWindow().getWindowManager().getDefaultDisplay().getWidth();
    screenHeight = getWindow().getWindowManager().getDefaultDisplay().getHeight();
    // default Dimensions of the game world: size of screen
    setMapDimensions(getScreenWidth(), getScreenHeight());

    setContentView(mainView);
    gameView.setKeepScreenOn(true);
  }
コード例 #4
0
 /**
  * <b>DO NOT CALL THIS METHOD</b>
  *
  * <p>This method is part of the Android sensor mechanism. It is used by GameEngine itself.
  */
 @Override
 public void onSensorChanged(SensorEvent event) {
   MotionSensor.handleSensorChange(event);
 }