Ejemplo n.º 1
0
  @Override
  public synchronized void onSurfaceCreated(final GLState pGLState) {
    if (BuildConfig.DEBUG) {
      Debug.d(
          this.getClass().getSimpleName()
              + ".onSurfaceCreated"
              + " @(Thread: '"
              + Thread.currentThread().getName()
              + "')");
    }

    if (this.mGameCreated) {
      this.onReloadResources();

      if (this.mGamePaused && this.mGameCreated) {
        this.onResumeGame();
      }
    } else {
      if (this.mCreateGameCalled) {
        this.mOnReloadResourcesScheduled = true;
      } else {
        this.mCreateGameCalled = true;
        this.onCreateGame();
      }
    }
  }
Ejemplo n.º 2
0
  @Override
  public void onDestroy() {
    if (BuildConfig.DEBUG) {
      Debug.d(
          this.getClass().getSimpleName()
              + ".onDestroy"
              + " @(Thread: '"
              + Thread.currentThread().getName()
              + "')");
    }

    super.onDestroy();

    this.mEngine.onDestroy();

    try {
      this.onDestroyResources();
    } catch (final Throwable pThrowable) {
      Debug.e(
          this.getClass().getSimpleName()
              + ".onDestroyResources failed."
              + " @(Thread: '"
              + Thread.currentThread().getName()
              + "')",
          pThrowable);
    }

    this.onGameDestroyed();

    this.mEngine = null;
  }
  public EngineOptions onCreateEngineOptions() {

    android.os.Debug.waitForDebugger();

    // Debug.setDebugLevel(DebugLevel.NONE);
    // Toast.makeText(this, "You move my sprite right round, right round...",
    // Toast.LENGTH_LONG).show();
    Debug.d("toast", "onCreateEngineOptions");

    final Camera camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);

    EngineOptions options =
        new EngineOptions(
            true,
            ScreenOrientation.LANDSCAPE_FIXED,
            new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT),
            camera);
    // EngineOptions options = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new
    // FillResolutionPolicy(), camera);
    options.getAudioOptions().setNeedsSound(true);
    options.getAudioOptions().setNeedsMusic(true);

    // getApplication().getWallpaperDesiredMinimumHeight()
    // DisplayMetrics metrics = getWindowManager().getDefaultDisplay().getMetrics(new
    // DisplayMetrics());

    return options;
  }
  public void onTapFromGame(TouchEvent event) {
    Debug.d("tap on " + event.getX() + "x" + event.getY());

    //		SoundLibrary.playSample(Sample.LASER); //AG: lo he movido a TouchProcess

    //		SoundLibrary.playSample(Sample.CHEWAKA);
    //		SoundLibrary.stopSample(Sample.CHEWAKA, true, 2);
  }
  public void onCreateResources() {
    Debug.d("toast", "onCreateResources");
    this.game = new StarWarsGame(this.getEngine(), this);
    this.game.onCreateResources();

    soundLibrary = new SoundLibrary(mEngine.getSoundManager(), this);
    this.mEngine.registerUpdateHandler(soundLibrary);
  }
 @Override
 public void onTerminated(final ServerConnector<BluetoothSocketConnection> pServerConnector) {
   Debug.d(
       "Closed Server-Connection from: '"
           + pServerConnector
               .getConnection()
               .getBluetoothSocket()
               .getRemoteDevice()
               .getAddress());
 }
  public Scene onCreateScene() {
    Debug.d("toast", "onCreateScene");

    this.mEngine.registerUpdateHandler(new FPSLogger());
    Scene initialScene = this.game.onCreateScene();

    this.starWarsScene = this.game.starWarsScene;

    return initialScene;
  }
Ejemplo n.º 8
0
  @Override
  public synchronized void onGameDestroyed() {
    if (BuildConfig.DEBUG) {
      Debug.d(
          this.getClass().getSimpleName()
              + ".onGameDestroyed"
              + " @(Thread: '"
              + Thread.currentThread().getName()
              + "')");
    }

    this.mGameCreated = false;
  }
Ejemplo n.º 9
0
  @Override
  public void onReloadResources() {
    if (BuildConfig.DEBUG) {
      Debug.d(
          this.getClass().getSimpleName()
              + ".onReloadResources"
              + " @(Thread: '"
              + Thread.currentThread().getName()
              + "')");
    }

    this.mEngine.onReloadResources();
  }
  @Override
  public synchronized void onResumeGame() { // esto viene despues de reload resources
    // Toast.makeText(this, "onResumeGame", Toast.LENGTH_LONG).show();
    Debug.d("toast", "onResumeGame");

    game.onResumeGame();

    super.onResumeGame();
    //		TimerHelper.startTimer(mEngine.getScene(), 2f,  new ITimerCallback() {
    //			public void onTimePassed(final TimerHandler pTimerHandler){
    //				restartEngine();
    //			}
    //		});
  }
Ejemplo n.º 11
0
  @Override
  public synchronized void onPauseGame() {
    if (BuildConfig.DEBUG) {
      Debug.d(
          this.getClass().getSimpleName()
              + ".onPauseGame"
              + " @(Thread: '"
              + Thread.currentThread().getName()
              + "')");
    }

    this.mGamePaused = true;

    this.mEngine.stop();
  }
Ejemplo n.º 12
0
 @Override
 public synchronized void onSurfaceChanged(
     final GLState pGLState, final int pWidth, final int pHeight) {
   if (BuildConfig.DEBUG) {
     Debug.d(
         this.getClass().getSimpleName()
             + ".onSurfaceChanged(Width="
             + pWidth
             + ",  Height="
             + pHeight
             + ")"
             + " @(Thread: '"
             + Thread.currentThread().getName()
             + "')");
   }
 }
Ejemplo n.º 13
0
  @Override
  public synchronized void onResume() {
    if (BuildConfig.DEBUG) {
      Debug.d(
          this.getClass().getSimpleName()
              + ".onResume"
              + " @(Thread: '"
              + Thread.currentThread().getName()
              + "')");
    }

    super.onResume();

    this.acquireWakeLock();
    this.mRenderSurfaceView.onResume();
    if ((this.mGamePaused) && (this.mGameCreated)) {
      onResumeGame();
    }
  }
Ejemplo n.º 14
0
  @Override
  public void onDestroyResources() throws Exception {
    if (BuildConfig.DEBUG) {
      Debug.d(
          this.getClass().getSimpleName()
              + ".onDestroyResources"
              + " @(Thread: '"
              + Thread.currentThread().getName()
              + "')");
    }

    if (this.mEngine.getEngineOptions().getAudioOptions().needsMusic()) {
      this.getMusicManager().releaseAll();
    }

    if (this.mEngine.getEngineOptions().getAudioOptions().needsSound()) {
      this.getSoundManager().releaseAll();
    }
  }
Ejemplo n.º 15
0
  @Override
  public void onPause() {
    if (BuildConfig.DEBUG) {
      Debug.d(
          this.getClass().getSimpleName()
              + ".onPause"
              + " @(Thread: '"
              + Thread.currentThread().getName()
              + "')");
    }

    super.onPause();

    this.mRenderSurfaceView.onPause();
    this.releaseWakeLock();

    if (!this.mGamePaused) {
      this.onPauseGame();
    }
  }
Ejemplo n.º 16
0
  @Override
  public void onCreate(final Bundle pSavedInstanceState) {
    if (BuildConfig.DEBUG) {
      Debug.d(
          this.getClass().getSimpleName()
              + ".onCreate"
              + " @(Thread: '"
              + Thread.currentThread().getName()
              + "')");
    }

    clearAllDataGame();
    shareApplicationData = getActivity().getSharedPreferences("application_data", 1);
    songName = shareApplicationData.getString("song_name", "").toLowerCase();

    super.onCreate(pSavedInstanceState);

    this.mGamePaused = true;

    this.mEngine = this.onCreateEngine(this.onCreateEngineOptions());

    this.applyEngineOptions();
  }
 @Override
 protected synchronized void onResume() {
   Debug.d("toast", "onResume");
   super.onResume();
 }
Ejemplo n.º 18
0
  protected synchronized void onCreateGame() {
    if (BuildConfig.DEBUG) {
      Debug.d(
          this.getClass().getSimpleName()
              + ".onCreateGame"
              + " @(Thread: '"
              + Thread.currentThread().getName()
              + "')");
    }

    final OnPopulateSceneCallback onPopulateSceneCallback =
        new OnPopulateSceneCallback() {
          @Override
          public void onPopulateSceneFinished() {
            try {
              if (BuildConfig.DEBUG) {
                Debug.d(
                    BaseGameFragment.this.getClass().getSimpleName()
                        + ".onGameCreated"
                        + " @(Thread: '"
                        + Thread.currentThread().getName()
                        + "')");
              }

              BaseGameFragment.this.onGameCreated();
            } catch (final Throwable pThrowable) {
              Debug.e(
                  BaseGameFragment.this.getClass().getSimpleName()
                      + ".onGameCreated failed."
                      + " @(Thread: '"
                      + Thread.currentThread().getName()
                      + "')",
                  pThrowable);
            }

            BaseGameFragment.this.callGameResumedOnUIThread();
          }
        };

    final OnCreateSceneCallback onCreateSceneCallback =
        new OnCreateSceneCallback() {
          @Override
          public void onCreateSceneFinished(final Scene pScene) {
            BaseGameFragment.this.mEngine.setScene(pScene);

            try {
              if (BuildConfig.DEBUG) {
                Debug.d(
                    BaseGameFragment.this.getClass().getSimpleName()
                        + ".onPopulateScene"
                        + " @(Thread: '"
                        + Thread.currentThread().getName()
                        + "')");
              }

              BaseGameFragment.this.onPopulateScene(pScene, onPopulateSceneCallback);
            } catch (final Throwable pThrowable) {
              Debug.e(
                  BaseGameFragment.this.getClass().getSimpleName()
                      + ".onPopulateScene failed."
                      + " @(Thread: '"
                      + Thread.currentThread().getName()
                      + "')",
                  pThrowable);
            }
          }
        };

    final OnCreateResourcesCallback onCreateResourcesCallback =
        new OnCreateResourcesCallback() {
          @Override
          public void onCreateResourcesFinished() {
            try {
              if (BuildConfig.DEBUG) {
                Debug.d(
                    BaseGameFragment.this.getClass().getSimpleName()
                        + ".onCreateScene"
                        + " @(Thread: '"
                        + Thread.currentThread().getName()
                        + "')");
              }

              BaseGameFragment.this.onCreateScene(onCreateSceneCallback);
            } catch (final Throwable pThrowable) {
              Debug.e(
                  BaseGameFragment.this.getClass().getSimpleName()
                      + ".onCreateScene failed."
                      + " @(Thread: '"
                      + Thread.currentThread().getName()
                      + "')",
                  pThrowable);
            }
          }
        };

    try {
      if (BuildConfig.DEBUG) {
        Debug.d(
            this.getClass().getSimpleName()
                + ".onCreateResources"
                + " @(Thread: '"
                + Thread.currentThread().getName()
                + "')");
      }

      this.onCreateResources(onCreateResourcesCallback);
    } catch (final Throwable pThrowable) {
      Debug.e(
          this.getClass().getSimpleName()
              + ".onCreateGame failed."
              + " @(Thread: '"
              + Thread.currentThread().getName()
              + "')",
          pThrowable);
    }
  }
 @Override
 public void onReloadResources() {
   // Toast.makeText(this, "loading resources...", Toast.LENGTH_LONG).show(); //no que peta!
   Debug.d("toast", "onReloadResources");
   super.onReloadResources();
 }
 @Override
 public void onPauseGame() {
   Debug.d("toast", "onPauseGame");
   game.onPauseGame();
   super.onPauseGame();
 }
 public void onGameCreated() {
   Debug.d("toast", "onGameCreated");
   super.onGameCreated();
   Debug.d("GameCreated: start StarWarsGame");
   this.game.onGameCreated();
 }
 protected void onPopulatedScene() throws Exception {
   Debug.d("toast", "onPopulatedScene");
   this.game.initialize();
 }