Beispiel #1
0
 private void resetAxises() {
   frontCards.getTopCard().setAxis(Card.AXIS_TOP);
   frontCards.getBottomCard().setAxis(Card.AXIS_TOP);
   backCards.getBottomCard().setAxis(Card.AXIS_TOP);
   backCards.getTopCard().setAxis(Card.AXIS_BOTTOM);
 }
Beispiel #2
0
  public synchronized void draw(FlipRenderer renderer, GL10 gl) {
    applyTexture(renderer, gl);

    if (!TextureUtils.isValidTexture(frontCards.getTexture())
        && !TextureUtils.isValidTexture(backCards.getTexture())) return;

    if (!visible) return;

    switch (state) {
      case STATE_INIT:
        {
          /*if (false) { //XXX: debug only
          	if (angle >= 180)
          		forward = false;
          	else if (angle <= 0)
          		forward = true;

          	rotateBy((forward ? TIP_SPEED : -TIP_SPEED));
          	if (angle > 90 && angle <= 180 - MAX_TIP_ANGLE) {
          		forward = true;
          	} else if (angle < 90 && angle >= MAX_TIP_ANGLE) {
          		forward = false;
          	}
          }*/
        }
        break;
      case STATE_TOUCH:
        break;
      case STATE_AUTO_ROTATE:
        {
          animatedFrame++;
          rotateBy((forward ? ACCELERATION : -ACCELERATION) * animatedFrame);

          if (angle >= 180 || angle <= 0) {
            setState(STATE_INIT);
            if (angle >= 180) { // flip to next page
              if (backCards.getIndex() != -1) {
                activeIndex = backCards.getIndex();
                controller.postFlippedToView(activeIndex);
              } else angle = 180;
            }
            controller.postHideFlipAnimation();
          } else controller.getSurfaceView().requestRender();
        }
        break;
      default:
        AphidLog.e("Invalid state: " + state);
        break;
    }

    if (angle < 90) { // render front view over back view
      frontCards.getTopCard().setAngle(0);
      frontCards.getTopCard().draw(gl);

      backCards.getBottomCard().setAngle(0);
      backCards.getBottomCard().draw(gl);

      frontCards.getBottomCard().setAngle(angle);
      frontCards.getBottomCard().draw(gl);
    } else { // render back view first
      frontCards.getTopCard().setAngle(0);
      frontCards.getTopCard().draw(gl);

      backCards.getTopCard().setAngle(180 - angle);
      backCards.getTopCard().draw(gl);

      backCards.getBottomCard().setAngle(0);
      backCards.getBottomCard().draw(gl);
    }
  }