示例#1
0
  @Override
  public Tint tween(Tint a, Tint b, float value) {

    final Interpolation linear = Interpolation.linear;

    final Color colorA = a.color;
    final Color colorB = b.color;

    color.r = linear.apply(colorA.r, colorB.r, value);
    color.g = linear.apply(colorA.g, colorB.g, value);
    color.b = linear.apply(colorA.b, colorB.b, value);
    color.a = linear.apply(colorA.a, colorB.a, value);

    return this;
  }
  @Override
  public void control(Actor actor, float deltaSeconds) {
    long deltaMillis = (long) (deltaSeconds * 1000);
    timePeriodManager.update(deltaMillis);
    float angle;
    float normalizedValue;
    int subPeriod = timePeriodManager.getCurrentSubPeriod();

    // Rotate up
    if (subPeriod == rotateUpSubPeriod) {
      normalizedValue = timePeriodManager.getNormalizedCurrentSubPeriodTime();
      Interpolation interpolation = Interpolation.linear;
      if (this.interpolation != null) {
        interpolation = this.interpolation;
      }
      angle = interpolation.apply(minAngle, maxAngle, normalizedValue);
    }

    // Stall up
    else if (subPeriod == stallUpSubPeriod) {
      angle = maxAngle;
    }

    // Rotate down
    else if (subPeriod == rotateDownSubPeriod) {
      normalizedValue = timePeriodManager.getNormalizedCurrentSubPeriodTime();
      Interpolation interpolation = Interpolation.linear;
      if (this.interpolation != null) {
        interpolation = this.interpolation;
      }
      angle = interpolation.apply(maxAngle, minAngle, normalizedValue);
    }

    // Stall up
    else {
      angle = minAngle;
    }

    actor.setRotation(angle);
  }
  @Override
  public void render(
      Batch batch, Texture currentScreenTexture, Texture nextScreenTexture, float percent) {
    float width = currentScreenTexture.getWidth();
    float height = currentScreenTexture.getHeight();
    float x = 0;
    float y = 0;
    if (interpolation != null) percent = interpolation.apply(percent);

    switch (direction) {
      case LEFT:
        x = -width * percent;
        if (!slideOut) x += width;
        break;
      case RIGHT:
        x = width * percent;
        if (!slideOut) x -= width;
        break;
      case UP:
        y = height * percent;
        if (!slideOut) y -= height;
        break;
      case DOWN:
        y = -height * percent;
        if (!slideOut) y += height;
        break;
    }
    Texture texBottom = slideOut ? nextScreenTexture : currentScreenTexture;
    Texture texTop = slideOut ? currentScreenTexture : nextScreenTexture;

    Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    batch.begin();
    batch.draw(
        texBottom,
        0,
        0,
        0,
        0,
        width,
        height,
        1,
        1,
        0,
        0,
        0,
        (int) width,
        (int) height,
        false,
        true);
    batch.draw(
        texTop,
        x,
        y,
        0,
        0,
        nextScreenTexture.getWidth(),
        nextScreenTexture.getHeight(),
        1,
        1,
        0,
        0,
        0,
        nextScreenTexture.getWidth(),
        nextScreenTexture.getHeight(),
        false,
        true);
    batch.end();
  }
 @Override
 public void render(SpriteBatch batch, Texture currScreen, Texture nextScreen, float alpha) {
   float w = currScreen.getWidth();
   float h = currScreen.getHeight();
   float x = 0;
   float y = 0;
   int sliceWidth = (int) (w / sliceIndex.size);
   Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
   Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
   batch.begin();
   batch.draw(
       currScreen,
       0,
       0,
       0,
       0,
       w,
       h,
       1,
       1,
       0,
       0,
       0,
       currScreen.getWidth(),
       currScreen.getHeight(),
       false,
       true);
   if (easing != null) alpha = easing.apply(alpha);
   for (int i : sliceIndex) {
     // current slice/column
     x = i * sliceWidth;
     // vertical displacement using randomized
     // list of slice indices
     float offsetY = h * (1 + sliceIndex.get(i) / (float) sliceIndex.size);
     switch (direction) {
       case UP:
         y = -offsetY + offsetY * alpha;
         break;
       case DOWN:
         y = offsetY - offsetY * alpha;
         break;
       case UP_DOWN:
         if (i % 2 == 0) {
           y = -offsetY + offsetY * alpha;
         } else {
           y = offsetY - offsetY * alpha;
         }
         break;
     }
     batch.draw(
         nextScreen,
         x,
         y,
         0,
         0,
         sliceWidth,
         h,
         1,
         1,
         0,
         i * sliceWidth,
         0,
         sliceWidth,
         nextScreen.getHeight(),
         false,
         true);
   }
   batch.end();
 }