示例#1
0
 public void resetValues() {
   enemyCount = 0;
   ball.restart();
   clearChildScene();
   registerUpdateHandler(new GameLoopUpdateHandler());
   if (activity.isMusic()) {
     activity.awesomeness.pause();
     activity.awesomeness.seekTo(0);
     activity.battleTheme.play();
   }
   activity.score.reset();
 }
示例#2
0
  public void enemyCollide(Sprite _target, Iterator<Sprite> targets) {
    if (activity.isShield) {
      activity.isShield = false;
      detachChild(activity.shieldSprite);
      createExplosion(
          _target.getX() + _target.getWidth() / 2,
          _target.getY() + _target.getHeight() / 2,
          Color.RED,
          15,
          mCamera.getWidth() / 10);

      createExplosion(
          ball.sprite.getX() + ball.sprite.getWidth() / 2,
          ball.sprite.getY() + ball.sprite.getHeight() / 2,
          Color.BLUE,
          5,
          mCamera.getWidth() / 17);

      if (activity.isSfx()) activity.dropShieldSound.play();

      removeSprite(_target, targets);
      addTarget();
    } else {
      if (!isLoseNow) {
        if (activity.isMusic()) {
          activity.battleTheme.pause();
          activity.battleTheme.seekTo(0);
        }
        if (activity.isSfx()) {
          activity.explSound.play();
        }
        activity.score.onLose();
        activity.score.score -= 20;
        activity.editor.putInt("time", activity.prefs.getInt("time", 0) - 2);
        activity.editor.commit();

        activity.vibrator.vibrate(300);

        createExplosion(
            ball.sprite.getX() + ball.sprite.getWidth() / 2,
            ball.sprite.getY() + ball.sprite.getHeight() / 2,
            Color.RED,
            10,
            mCamera.getWidth() / 20);

        detachChild(ball.sprite);
        detachChild(scoreText);

        DelayModifier dMod =
            new DelayModifier(2) {
              @Override
              protected void onModifierFinished(IEntity pItem) {
                if (activity.isMusic()) activity.awesomeness.resume();
                restart();
              }
            };
        registerEntityModifier(dMod);
        isLoseNow = true;
      }
    }
  }