Ejemplo n.º 1
0
  private void onExit(
      final Screen screen, TextButton buttonPlay, TextButton buttonCredits, TextButton buttonExit) {

    Tween.set(buttonPlay, ActorAccessor.ALPHA)
        .target(buttonPlay.getColor().a)
        .start(getTweenManager());
    Tween.to(buttonPlay, ActorAccessor.ALPHA, 0.5f).target(0).delay(0.2f).start(getTweenManager());
    Tween.set(buttonCredits, ActorAccessor.ALPHA)
        .target(buttonCredits.getColor().a)
        .start(getTweenManager());
    Tween.to(buttonCredits, ActorAccessor.ALPHA, 0.5f)
        .target(0)
        .delay(0.1f)
        .start(getTweenManager());
    Tween.set(buttonExit, ActorAccessor.ALPHA)
        .target(buttonExit.getColor().a)
        .start(getTweenManager());
    Tween.to(buttonExit, ActorAccessor.ALPHA, 0.5f)
        .target(0)
        .setCallback(
            new TweenCallback() {

              @Override
              public void onEvent(int type, BaseTween<?> source) {
                getGame().setScreen(screen);
              }
            })
        .start(getTweenManager());
  }
Ejemplo n.º 2
0
  @Override
  public void show() {
    super.show();

    table = new Table();
    table.setFillParent(true);

    TextButtonStyle bStyle = new TextButtonStyle();
    bStyle.font = Cache.getFont(48);
    bStyle.fontColor = Color.LIGHT_GRAY;
    final TextButton buttonPlay = new TextButton("PLAY", bStyle);

    buttonPlay.pad(20);
    table.add(buttonPlay);

    table.row();
    final TextButton buttonCredits = new TextButton("CREDITS", bStyle);

    buttonCredits.pad(20);
    table.add(buttonCredits);
    table.row();
    final TextButton buttonExit = new TextButton("EXIT", bStyle);

    buttonExit.pad(20);
    table.add(buttonExit);
    table.pad(150, 0, 0, 0);
    getStage().addActor(table);

    buttonPlay.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            onExit(new LevelSelect(getGame()), buttonPlay, buttonCredits, buttonExit);
          }
        });
    buttonCredits.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            onExit(new Credits(getGame()), buttonPlay, buttonCredits, buttonExit);
          }
        });
    buttonExit.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            Gdx.app.exit();
          }
        });
    Tween.set(buttonPlay, ActorAccessor.ALPHA).target(0).start(getTweenManager());
    Tween.to(buttonPlay, ActorAccessor.ALPHA, 1).target(1).start(getTweenManager());
    Tween.set(buttonCredits, ActorAccessor.ALPHA).target(0).start(getTweenManager());
    Tween.to(buttonCredits, ActorAccessor.ALPHA, 1).target(1).delay(0.1f).start(getTweenManager());
    Tween.set(buttonExit, ActorAccessor.ALPHA).target(0).start(getTweenManager());
    Tween.to(buttonExit, ActorAccessor.ALPHA, 1).target(1).delay(0.2f).start(getTweenManager());

    Gdx.input.setInputProcessor(new InputMultiplexer(getStage(), new TouchDetector(this)));
  }
Ejemplo n.º 3
0
  /** Launch splashScreen. */
  @Override
  public void show() {
    // Switch to normal stage.
    tappy.setStage(splashNormalStage);

    // Register tweenEngine timeline.
    Timeline.createSequence()
        // Set default values.
        .push(Tween.set(splashHeadphone, SpriteAccessor.ALPHA).target(0))
        .push(Tween.set(splashBackground, SpriteAccessor.ALPHA).target(0))
        .push(
            Tween.set(splashBackground, SpriteAccessor.POSITION)
                .target(0, -(splashBackground.getHeight() - Gdx.graphics.getHeight())))
        // FadeIn & Slide down.
        .push(Tween.to(splashHeadphone, SpriteAccessor.ALPHA, 1.2f).target(1))
        .pushPause(1.4f)
        .push(Tween.to(splashHeadphone, SpriteAccessor.ALPHA, 1.2f).target(0))
        .beginParallel()
        .push(Tween.to(splashBackground, SpriteAccessor.ALPHA, 5.2f).target(1))
        .push(Tween.to(splashBackground, SpriteAccessor.POSITION, 9.8f).target(0, 0).ease(Quad.OUT))
        .end()
        // Waiting.
        .pushPause(1.2f)
        // FadeOut.
        .push(Tween.to(splashBackground, SpriteAccessor.ALPHA, 0.7f).target(0))
        // Register callback.
        .setCallback(
            new TweenCallback() {
              @Override
              public void onEvent(int type, BaseTween<?> source) {
                if (tappy.getPreferences().getBoolean("firstTime", true)) {
                  tappy.setScreen(new TutorialScreen(tappy));
                } else {
                  tappy.setScreen(new HomeScreen(tappy));
                }
              }
            })
        // Launch!
        .start(tweenManager);
  }
  public SplashScreen(TweenCallback callback) {
    this.callback = callback;

    TextureAtlas atlas = Assets.inst().get("data/splash/pack", TextureAtlas.class);
    universal = atlas.createSprite("universal");
    tween = atlas.createSprite("tween");
    engine = atlas.createSprite("engine");
    logo = atlas.createSprite("logo");
    strip = atlas.createSprite("white");
    powered = atlas.createSprite("powered");
    gdx = atlas.createSprite("gdxblur");
    veil = atlas.createSprite("white");
    gdxTex = atlas.findRegion("gdx");

    float wpw = 1f;
    float wph = wpw * Gdx.graphics.getHeight() / Gdx.graphics.getWidth();

    camera.viewportWidth = wpw;
    camera.viewportHeight = wph;
    camera.update();

    Gdx.input.setInputProcessor(inputProcessor);

    Sprite[] sprites = new Sprite[] {universal, tween, engine, logo, powered, gdx};
    for (Sprite sp : sprites) {
      sp.setSize(sp.getWidth() / PX_PER_METER, sp.getHeight() / PX_PER_METER);
      sp.setOrigin(sp.getWidth() / 2, sp.getHeight() / 2);
    }

    universal.setPosition(-0.325f, 0.028f);
    tween.setPosition(-0.320f, -0.066f);
    engine.setPosition(0.020f, -0.087f);
    logo.setPosition(0.238f, 0.022f);

    strip.setSize(wpw, wph);
    strip.setOrigin(wpw / 2, wph / 2);
    strip.setPosition(-wpw / 2, -wph / 2);

    powered.setPosition(-0.278f, -0.025f);
    gdx.setPosition(0.068f, -0.077f);

    veil.setSize(wpw, wph);
    veil.setPosition(-wpw / 2, -wph / 2);
    veil.setColor(1, 1, 1, 0);

    Timeline.createSequence()
        .push(Tween.set(tween, SpriteAccessor.POS_XY).targetRelative(-1, 0))
        .push(Tween.set(engine, SpriteAccessor.POS_XY).targetRelative(1, 0))
        .push(Tween.set(universal, SpriteAccessor.POS_XY).targetRelative(0, 0.5f))
        .push(Tween.set(logo, SpriteAccessor.SCALE_XY).target(7, 7))
        .push(Tween.set(logo, SpriteAccessor.OPACITY).target(0))
        .push(Tween.set(strip, SpriteAccessor.SCALE_XY).target(1, 0))
        .push(Tween.set(powered, SpriteAccessor.OPACITY).target(0))
        .push(Tween.set(gdx, SpriteAccessor.OPACITY).target(0))
        .pushPause(0.5f)
        .push(Tween.to(strip, SpriteAccessor.SCALE_XY, 0.8f).target(1, 0.6f).ease(Back.OUT))
        .push(Tween.to(tween, SpriteAccessor.POS_XY, 0.5f).targetRelative(1, 0).ease(Quart.OUT))
        .push(Tween.to(engine, SpriteAccessor.POS_XY, 0.5f).targetRelative(-1, 0).ease(Quart.OUT))
        .push(
            Tween.to(universal, SpriteAccessor.POS_XY, 0.6f)
                .targetRelative(0, -0.5f)
                .ease(Quint.OUT))
        .pushPause(-0.3f)
        .beginParallel()
        .push(Tween.set(logo, SpriteAccessor.OPACITY).target(1))
        .push(Tween.to(logo, SpriteAccessor.SCALE_XY, 0.5f).target(1, 1).ease(Back.OUT))
        .end()
        .push(Tween.to(strip, SpriteAccessor.SCALE_XY, 0.5f).target(1, 1).ease(Back.IN))
        .pushPause(0.3f)
        .beginParallel()
        .push(Tween.to(tween, SpriteAccessor.POS_XY, 0.5f).targetRelative(1, 0).ease(Back.IN))
        .push(Tween.to(engine, SpriteAccessor.POS_XY, 0.5f).targetRelative(1, 0).ease(Back.IN))
        .push(Tween.to(universal, SpriteAccessor.POS_XY, 0.5f).targetRelative(1, 0).ease(Back.IN))
        .push(Tween.to(logo, SpriteAccessor.POS_XY, 0.5f).targetRelative(1, 0).ease(Back.IN))
        .end()
        .pushPause(-0.3f)
        .push(Tween.to(powered, SpriteAccessor.OPACITY, 0.3f).target(1))
        .beginParallel()
        .push(Tween.to(gdx, SpriteAccessor.OPACITY, 1.5f).target(1).ease(Cubic.IN))
        .push(Tween.to(gdx, SpriteAccessor.ROTATION, 2.0f).target(360 * 15).ease(Quad.OUT))
        .end()
        .pushPause(0.3f)
        .push(
            Tween.to(gdx, SpriteAccessor.SCALE_XY, 0.6f)
                .waypoint(1.6f, 0.4f)
                .target(1.2f, 1.2f)
                .ease(Cubic.OUT))
        .pushPause(0.3f)
        .beginParallel()
        .push(Tween.to(powered, SpriteAccessor.POS_XY, 0.5f).targetRelative(1, 0).ease(Back.IN))
        .push(Tween.to(gdx, SpriteAccessor.POS_XY, 0.5f).targetRelative(1, 0).ease(Back.IN))
        .end()
        .pushPause(0.3f)
        .setCallback(callback)
        .start(tweenManager);
  }