コード例 #1
0
  @Override
  public void show() {
    Texture.setEnforcePotImages(false);
    butBatch = new SpriteBatch();
    logoMenuBatch = new SpriteBatch();
    splashBatch = new SpriteBatch();

    logoTexture = new Texture("resources/logo.png");
    splashTexture = new Texture("resources/teamlogo.png");
    splashBGTexture = new Texture("resources/background2.png");
    menuBGTexture = new Texture("resources/menubg.png");

    splashSprite = new Sprite(splashTexture);
    splashBGSprite = new Sprite(splashBGTexture);
    logoSprite = new Sprite(logoTexture);
    menuBGSprite = new Sprite(menuBGTexture);

    logoSprite.setX(Gdx.graphics.getWidth() / 2 - logoSprite.getWidth() / 2);
    logoSprite.setY(Gdx.graphics.getHeight() / 2 - Gdx.graphics.getHeight() / 7);
    splashSprite.setX(Gdx.graphics.getWidth() / 2 - logoSprite.getWidth() / 2);
    splashSprite.setY(Gdx.graphics.getHeight() / 7);

    // buttons
    butAtlas = new TextureAtlas("resources/button.pack");
    butSkin = new Skin();
    butSkin.addRegions(butAtlas);
    font1 = new BitmapFont(Gdx.files.internal("resources/font_black.fnt"), false);
  }
コード例 #2
0
  @Override
  public void setValues(Sprite sprite, int i, float[] floats) {
    switch (Mode.values()[i]) {
      case SCALE:
        sprite.setScale(floats[0]);
        break;

      case ALPHA:
        Color color = sprite.getColor();
        sprite.setColor(color.r, color.g, color.b, floats[0]);
        break;

      case POSITION:
        sprite.setX(floats[0]);
        sprite.setY(floats[1]);
        break;

      case ROTATION:
        sprite.setRotation(floats[0]);
        break;

      default:
        assert false;
    }
  }
コード例 #3
0
  public void moveToPosition(Sprite sprite, float x, float y) {
    final float currentX = sprite.getX();
    final float currentY = sprite.getY();

    // go to x first
    if (x > currentX && x != 0) {
      sprite.setX(currentX + (movementSpeed * Gdx.graphics.getDeltaTime()));
    } else if (x < currentX && x != 0) {
      sprite.setX(currentX - (movementSpeed * Gdx.graphics.getDeltaTime()));
    }

    if (y > currentY && y != 0) {

      sprite.setY(currentY + movementSpeed * Gdx.graphics.getDeltaTime());

    } else if (y < currentY && y != 0) {

      sprite.setY(currentY - movementSpeed * Gdx.graphics.getDeltaTime());
    }
  }
コード例 #4
0
 @Override
 public void setValues(Sprite target, int tweenType, float[] newValues) {
   switch (tweenType) {
     case ALPHA:
       target.setColor(
           target.getColor().r, target.getColor().g, target.getColor().b, newValues[0]);
       break;
     case SCALE:
       target.setScale(newValues[0]);
       break;
     case VERTICAL:
       target.setY(newValues[0]);
       break;
   }
 }
 public boolean update(float deltaTime) {
   sprite.setY(sprite.getY() - speed * deltaTime);
   return sprite.getY() >= 0;
 }