@Override
  public void render(SpriteBatch sb) {
    delta = (TimeUtils.millis() - startTime + 700) / 1000;
    tweenManager.update(delta);
    bgManager.render(sb);

    sb.setProjectionMatrix(camera.combined);
    sb.begin();
    backButton.render(sb);
    randomCardButton.draw(sb);
    rareCardButton.draw(sb);

    Fonts.MFont.draw(
        sb, "Cost: " + randomCardCost, randomCardButton.getX(), randomCardButton.getY() - 40);
    Fonts.MFont.draw(
        sb, "Cost: " + rareCardCost, rareCardButton.getX(), rareCardButton.getY() - 40);

    Fonts.MFont.draw(
        sb,
        currGold,
        MainGame.WIDTH - Fonts.MFont.getBounds(currGold).width - 40,
        MainGame.HEIGHT - 50);

    if (showingCard) {
      sb.draw(alpha, 0, 0, MainGame.WIDTH, MainGame.HEIGHT);
      purchasedCard.render(
          new Vector2(
              MainGame.WIDTH / 2 - (Card.WIDTH / 2 * cardAnimSprite.getScaleX()),
              MainGame.HEIGHT / 2 - (Card.HEIGHT / 2 * cardAnimSprite.getScaleX())),
          cardAnimSprite.getScaleX(),
          sb);
      unlockedText.draw(sb);
    }
    sb.end();
  }
Example #2
0
  @Override
  public int getValues(Sprite sprite, int i, float[] floats) {
    switch (Mode.values()[i]) {
      case SCALE:
        floats[0] = sprite.getScaleX();
        return 1;

      case ALPHA:
        floats[0] = sprite.getColor().a;
        return 1;

      case POSITION:
        floats[0] = sprite.getX();
        floats[1] = sprite.getY();
        return 2;

      case ROTATION:
        floats[0] = sprite.getRotation();
        return 1;

      default:
        assert false;
        return -1;
    }
  }
  @Override
  public void render() {
    camera.update();
    // Step the physics simulation forward at a rate of 60hz
    world.step(1f / 60f, 6, 2);

    sprite.setPosition(
        (body.getPosition().x * PIXELS_TO_METERS) - sprite.getWidth() / 2,
        (body.getPosition().y * PIXELS_TO_METERS) - sprite.getHeight() / 2);

    sprite.setRotation((float) Math.toDegrees(body2.getAngle()));
    sprite2.setPosition(
        (body2.getPosition().x * PIXELS_TO_METERS) - sprite2.getWidth() / 2,
        (body2.getPosition().y * PIXELS_TO_METERS) - sprite2.getHeight() / 2);
    sprite2.setRotation((float) Math.toDegrees(body.getAngle()));

    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    batch.setProjectionMatrix(camera.combined);
    batch.begin();

    batch.draw(
        sprite,
        sprite.getX(),
        sprite.getY(),
        sprite.getOriginX(),
        sprite.getOriginY(),
        sprite.getWidth(),
        sprite.getHeight(),
        sprite.getScaleX(),
        sprite.getScaleY(),
        sprite.getRotation());
    batch.draw(
        sprite2,
        sprite2.getX(),
        sprite2.getY(),
        sprite2.getOriginX(),
        sprite2.getOriginY(),
        sprite2.getWidth(),
        sprite2.getHeight(),
        sprite2.getScaleX(),
        sprite2.getScaleY(),
        sprite2.getRotation());
    batch.end();
  }
 @Override
 public int getValues(Sprite target, int tweenType, float[] returnValues) {
   switch (tweenType) {
     case ALPHA:
       returnValues[0] = target.getColor().a;
       return 1;
     case SCALE:
       returnValues[0] = target.getScaleX();
       returnValues[1] = target.getScaleY();
       return 2;
     default:
       assert false;
       return -1;
   }
 }
 @Override
 public int getValues(Sprite target, int tweenType, float[] returnValues) {
   switch (tweenType) {
     case ALPHA:
       returnValues[0] = target.getColor().a;
       return 1;
     case SCALE:
       returnValues[0] = target.getScaleX();
       return 2;
     case VERTICAL:
       returnValues[0] = target.getY();
       return 3;
     default:
       return 0;
   }
 }
 float getScaledWidth() {
   return sprite.getWidth() * sprite.getScaleX();
 }