Пример #1
0
 public void pause() {
   if (moveAnimation.isActive()) {
     moveAnimation.stop();
   }
   if (selectionAnimation.isActive()) {
     selectionAnimation.stop();
   }
 }
Пример #2
0
 private void startExplosion() {
   if (selectionAnimation.isActive()) {
     selectionAnimation.stop();
   }
   explosionAnimation.setSpeed(dataHolder.getConfiguration().isFastAnimation());
   explosionAnimation.init(SystemClock.elapsedRealtime());
   invalidate();
 }
Пример #3
0
 public void startMove() {
   if (selectionAnimation.isActive()) {
     selectionAnimation.stop();
   }
   moveAnimation.setSpeed(dataHolder.getConfiguration().isFastAnimation());
   moveAnimation.setStartValues(
       dataHolder.getGameEngine().getGameField().getMaxMoveX(),
       dataHolder.getGameEngine().getGameField().getMaxMoveY());
   moveAnimation.init(SystemClock.elapsedRealtime());
   invalidate();
 }
Пример #4
0
 public void startSelection() {
   if (moveAnimation.isActive()) {
     return;
   }
   selectionAnimation.init(SystemClock.elapsedRealtime());
   invalidate();
 }
Пример #5
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    if (moveAnimation.isActive() || explosionAnimation.isActive()) {
      return true;
    }
    if (event.getAction() != MotionEvent.ACTION_UP) {
      return true; // super.onTouchEvent(event);
    }
    int x = Math.round((event.getX() - dataHolder.getCellSize() / 2) / dataHolder.getCellSize());
    int y = Math.round((event.getY() - dataHolder.getCellSize() / 2) / dataHolder.getCellSize());
    if (x < 0
        || x >= dataHolder.getGameEngine().getGameField().getSizeX()
        || y < 0
        || y >= dataHolder.getGameEngine().getGameField().getSizeY()) {
      return super.onTouchEvent(event);
    } else {
      TouchResult results = dataHolder.getGameEngine().touchAction(x, y);
      switch (results) {
        case explode:
          startExplosion();
          break;

        case selected:
          startSelection();
          break;

        case no_action:
          if (selectionAnimation.isActive()) {
            selectionAnimation.stop();
            invalidate();
          }
          if (moveAnimation.isActive()) {
            moveAnimation.stop();
            invalidate();
          }
          break;
        default:
          break;
      }
    }
    return true;
  }
Пример #6
0
  @Override
  protected void onDraw(Canvas canvas) {
    // drawField(canvas);
    drawBackGroud(canvas);

    if (moveAnimation.isActive()) {
      moveAnimation.draw(canvas);
    } else if (explosionAnimation.isActive()) {
      explosionAnimation.draw(canvas);
    } else {
      selectionAnimation.draw(canvas);
    }

    if (selectionAnimation.isActive()
        || moveAnimation.isActive()
        || explosionAnimation.isActive()) {
      invalidate();
    }
    updateAnimationObjects();
    if (false) {
      drawStatistic(canvas);
    }
  }
Пример #7
0
 private void updateAnimationObjects() {
   selectionAnimation.update(SystemClock.elapsedRealtime());
   moveAnimation.update(SystemClock.elapsedRealtime());
   explosionAnimation.update(SystemClock.elapsedRealtime());
 }