Exemplo n.º 1
0
  @Override
  protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    WIDTH = w;
    HEIGHT = h;

    scaleAnimation = new ScaleAnimation(1.0f, zoomScale, 1.0f, zoomScale, w / 2, h / 2);
    scaleAnimation.setDuration(zoomDuration);
    scaleAnimation.setRepeatMode(Animation.REVERSE);
    scaleAnimation.setRepeatCount(1);
  }
Exemplo n.º 2
0
  private void init() {
    r = new Random();

    // settings
    // setStartOffset(getRandom(3000));
    setInterpolator(new LinearInterpolator());

    // rotate
    RotateAnimation rotateAnimation;
    if (getRandomBoolean()) {
      rotateAnimation =
          new RotateAnimation(
              0f, 359f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    } else {
      rotateAnimation =
          new RotateAnimation(
              0f, -359f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    }
    rotateAnimation.setRepeatMode(Animation.RESTART);
    rotateAnimation.setRepeatCount(Animation.INFINITE);
    rotateAnimation.setDuration(getRandom(10000, 13000));
    rotateAnimation.setFillAfter(true);
    this.addAnimation(rotateAnimation);

    // scale
    if (getRandomBoolean()) {
      ScaleAnimation scaleAnimation = new ScaleAnimation(0.4f, 1.2f, 0.4f, 1.2f, 0.5f, 0.5f);
      scaleAnimation.setDuration(getRandom(7500, 10000));
      scaleAnimation.setRepeatMode(Animation.REVERSE);
      scaleAnimation.setRepeatCount(Animation.INFINITE);
      scaleAnimation.setFillAfter(true);
      this.addAnimation(scaleAnimation);
    }

    // x movement
    TranslateAnimation translateAnimationX =
        new TranslateAnimation(
            Animation.ABSOLUTE,
            -100,
            Animation.ABSOLUTE,
            100,
            Animation.ABSOLUTE,
            0,
            Animation.ABSOLUTE,
            0);
    translateAnimationX.setRepeatMode(Animation.REVERSE);
    translateAnimationX.setRepeatCount(Animation.INFINITE);
    translateAnimationX.setDuration(getRandom(8000, 10000));
    translateAnimationX.setFillAfter(true);
    this.addAnimation(translateAnimationX);

    // y movement
    TranslateAnimation translateAnimationY =
        new TranslateAnimation(
            Animation.ABSOLUTE,
            0,
            Animation.ABSOLUTE,
            0,
            Animation.ABSOLUTE,
            0,
            Animation.ABSOLUTE,
            2500);
    translateAnimationY.setRepeatMode(Animation.RESTART);
    translateAnimationY.setRepeatCount(Animation.INFINITE);
    translateAnimationY.setDuration(getRandom(26000, 38000));
    translateAnimationY.setFillAfter(true);
    this.addAnimation(translateAnimationY);
  }