Example #1
0
  public static Timeline moveAlongPath(
      Path<GridPoint2> path, float stepDuration, Object target, int tweenType) {
    Timeline timeline = Timeline.createSequence();

    for (GridPoint2 point : path.getPoints()) {
      timeline = timeline.push(Tween.to(target, tweenType, stepDuration).target(point.x, point.y));
    }

    return timeline;
  }
Example #2
0
  @Override
  protected Timeline showAnimation() {
    this.levelStartAnimation = Timeline.createSequence();

    float y = (stage.getHeight() + this.levelImage.getHeight()) / 2f;
    Tween slideinTween =
        Tween.to(this.levelImage, ActorAccessor.POSITION_Y, 1f)
            .ease(TweenEquations.easeInOutQuint)
            .target(y);
    slideinTween.setCallbackTriggers(TweenCallback.COMPLETE);
    slideinTween.setCallback(
        new TweenCallback() {

          @Override
          public void onEvent(int arg0, BaseTween<?> arg1) {
            levelStartAnimation.pause();
            imageStartAnimationFinished = true;
            startScreenCloseAnimation();
          }
        });
    this.levelStartAnimation.push(slideinTween);

    this.levelStartAnimation.push(Tween.to(this.filter, ActorAccessor.ALPHA, 0.5f).target(0f));

    y = stage.getHeight() + levelImage.getHeight();
    Tween slideoutTween =
        Tween.to(this.levelImage, ActorAccessor.POSITION_Y, 0.5f)
            .ease(TweenEquations.easeInQuint)
            .target(y);
    slideoutTween.setCallbackTriggers(TweenCallback.COMPLETE);
    slideoutTween.setCallback(
        new TweenCallback() {

          @Override
          public void onEvent(int arg0, BaseTween<?> arg1) {
            levelImage.remove();
            filter.remove();
            MusicPlayer.getInstance().playNext();
            getGameEngine().startGamePlay();
          }
        });
    levelStartAnimation.push(slideoutTween);

    return this.levelStartAnimation;
  }
Example #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);
  }
Example #4
0
  @Override
  public void show() {
    super.show();

    backgroundStage.addActor(new Image(atlas.findRegion("background")));

    Image alien = new Image(atlas.findRegion("alien"));
    alien.setPosition(mainStage.getWidth() + mainStage.getPadLeft(), -365f);
    mainStage.addActor(alien);

    Image energy = new Image(atlas.findRegion("energy")); // 195, 313
    energy.setPosition(83f, 201f);
    energy.setScale(0f);
    energy.setOrigin(energy.getPrefWidth() / 2, energy.getPrefHeight() / 2);
    mainStage.addActor(energy);

    final Table certificateTable = new Table();
    certificateTable.padTop(314f).padBottom(101f).defaults().padBottom(100f);
    certificateTable.setBackground(new TextureRegionDrawable(atlas.findRegion("certificate")));
    certificateTable.setSize(mainStage.getWidth(), mainStage.getHeight());
    certificateTable.setOrigin(195f, 313f);
    certificateTable.setTransform(true);
    certificateTable.setTouchable(Touchable.disabled);
    certificateTable.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            Assets.fanfareFX.stop();
            game.loadNextScreen(EndingScreen.this, KonnectingGame.ScreenType.MAIN_MENU);
          }
        });
    certificateTable.setScale(0f);
    mainStage.addActor(certificateTable);

    StatsData tempData = SavedData.getStats();
    int score =
        tempData.kronosScore1
            + tempData.kronosScore2
            + tempData.kronosScore3
            + tempData.kronosScore4
            + tempData.kronosScore5
            + tempData.kronosScore6
            + tempData.kronosScore7
            + tempData.zappingScore1
            + tempData.zappingScore2
            + tempData.zappingScore3
            + tempData.zappingScore4
            + tempData.zappingScore5;

    final Label userLabel =
        new Label(
            SavedData.getUsername() + "\n\n" + score + "pt",
            new Label.LabelStyle(uiSkin.getFont("default-font"), Color.WHITE));
    userLabel.setWrap(true);
    userLabel.setAlignment(Align.center);
    userLabel.getColor().a = 0f;
    certificateTable.add(userLabel).width(407f).row();

    String correctComment = comments[0];
    for (int i = scoreLimits.length - 1; i >= 0; i--) {
      if (score > scoreLimits[i]) {
        correctComment = comments[i];
        break;
      }
    }
    final Label commentLabel =
        new Label(correctComment, new Label.LabelStyle(uiSkin.getFont("arial"), Color.WHITE));
    commentLabel.setWrap(true);
    commentLabel.setFontScale(0.9f);
    commentLabel.setAlignment(Align.center);
    commentLabel.getColor().a = 0f;
    certificateTable.add(commentLabel).width(407f);

    Timeline.createSequence()
        .push(Tween.to(alien, ActorAccessor.MOVE_X, 1f).target(20f))
        .pushPause(0.25f)
        .push(Tween.to(energy, ActorAccessor.SCALEXY, 1f).target(1f))
        .push(Tween.to(energy, ActorAccessor.SCALEXY, 0.5f).target(0.8f))
        .push(Tween.to(energy, ActorAccessor.SCALEXY, 0.5f).target(1f))
        .push(Tween.to(certificateTable, ActorAccessor.SCALEXY, 0.5f).target(1f))
        .beginParallel()
        .push(Tween.to(userLabel, ActorAccessor.ALPHA, 0.5f).target(1f))
        .push(Tween.to(commentLabel, ActorAccessor.ALPHA, 0.5f).target(1f))
        .end()
        .setCallback(
            new TweenCallback() {
              @Override
              public void onEvent(int type, BaseTween<?> source) {
                Assets.fanfareFX.setOnCompletionListener(
                    new Music.OnCompletionListener() {
                      @Override
                      public void onCompletion(Music music) {
                        Assets.fanfareFX.setOnCompletionListener(null);
                        certificateTable.setTouchable(Touchable.enabled);
                      }
                    });
                Assets.fanfareFX.play();
              }
            })
        .start(tweenManager);
  }
Example #5
0
  @Override
  public void show() {
    state = State.INITIALIZING;
    setBackground(Assets.bg);
    getBackgroundBounds().x = -100;
    getBackgroundBounds().y = -100;
    getBackgroundBounds().width = EatFishAndAI.WIDTH + 200;
    getBackgroundBounds().height = EatFishAndAI.HEIGHT + 200;

    spawner = new DummySpawner();
    spawner.setGameContext(getGameContext());

    gameNameLayout = new GlyphLayout();
    gameNameLayout.setText(Assets.font30, conf.gamename);

    // Preset predator ai
    // int offset = 100;
    // getGameContext().spawn(
    // new PredatorFish(EatFishAndAI.WIDTH - offset,
    // EatFishAndAI.HEIGHT - offset));
    // getGameContext().spawn(
    // new PredatorFish(EatFishAndAI.WIDTH - offset, offset));
    // getGameContext().spawn(
    // new PredatorFish(offset, EatFishAndAI.HEIGHT - offset));
    // getGameContext().spawn(new PredatorFish(offset, offset));
    List<AIFactory<?>> factories = conf.aiconf.getAIs();
    int count = factories.size(), radius = 150;
    float angle = (float) (2 * Math.PI / count);
    float angleOffset = (float) (Math.PI / 4);
    float randomOffset = (float) ((int) (Math.random() * 4) * Math.PI / 2);
    System.out.println(randomOffset);
    boolean newGame = conf.players.isEmpty();
    for (int i = 0; i < conf.aiconf.getAIs().size(); i++) {
      PlayerFish player;
      if (newGame) {
        player =
            new PlayerFish(
                (float)
                    (centerX
                        - PlayerFish.WIDTH / 2
                        + Math.cos(i * angle + angleOffset + randomOffset) * radius),
                (float)
                    (centerY
                        - PlayerFish.HEIGHT / 2
                        + Math.sin(i * angle + angleOffset + randomOffset) * radius));
        conf.players.add(player);
      } else {
        player = conf.players.get(i);
        player.killAI();
        player.setX(
            (float)
                (centerX
                    - PlayerFish.WIDTH / 2
                    + Math.cos(i * angle + angleOffset + randomOffset) * radius));
        player.setY(
            (float)
                (centerY
                    - PlayerFish.HEIGHT / 2
                    + Math.sin(i * angle + angleOffset + randomOffset) * radius));
        player.setVelocityX(0);
        player.setVelocityY(0);
        player.setMaxSpeed(PlayerFish.MAX_SPEED);
        player.setScale(PlayerFish.STARTING_SCALE);
        player.setAlive(true);
      }

      getGameContext().spawn(player);
      player.setGameContext(getGameContext());
      player.attachAI(factories.get(i).newInstance());
      player.start();
    }

    conf.playersAlive = new ArrayList<>(conf.players);

    getGameContext().spawn(new RoundScore(conf, playerListX, playerListY));

    CustomTextButton stopButton =
        new CustomTextButton(EatFishAndAI.WIDTH - CustomTextButton.WIDTH, 0, "STOP");

    stopButton.setButtonListener(
        new ButtonListener() {

          @Override
          public void handle(ButtonAction ba) {
            if (ba.type == TYPE.RELEASE) {
              game.setScreen(new MenuScreen((EatFishAndAI) game));
            }
          }
        });

    CustomTextButton killButton =
        new CustomTextButton(EatFishAndAI.WIDTH - 2 * CustomTextButton.WIDTH, 0, "KILL");

    killButton.setButtonListener(
        new ButtonListener() {

          @Override
          public void handle(ButtonAction ba) {
            if (ba.type == TYPE.RELEASE) {

              PlayerFish biggest = conf.playersAlive.get(0);
              for (PlayerFish o : conf.playersAlive) {
                if (o.getScale() > biggest.getScale()) {
                  biggest = o;
                }
              }

              while (conf.playersAlive.size() > 1) {
                int randomIndex = (int) (Math.random() * conf.playersAlive.size());
                PlayerFish fish = conf.playersAlive.get(randomIndex);
                if (fish.equals(biggest)) {
                  continue;
                }
                conf.playersAlive.remove(fish);
                fish.destroy();
              }
            }
          }
        });

    getGameContext().spawn(killButton);
    getGameContext().spawn(stopButton);

    state = State.STARTING;

    Timeline all = Timeline.createSequence();
    for (PlayerFish player : conf.playersAlive) {
      all.push(CommonTweens.zoomAtGameObject(player, getCamera(), 3.0f, 1.0f));
    }
    all.push(CommonTweens.zoomAtPoint(centerX, centerY, getCamera(), 1.0f, 1.0f));
    all.setCallback(
        new TweenCallback() {

          @Override
          public void onEvent(int type, BaseTween<?> source) {
            if (type == TweenCallback.COMPLETE) {
              state = State.PLAYING;
              getGameContext().setPaused(false);
            }
          }
        });
    GlobalTween.add(all);

    getGameContext().spawn(new OverallScore(conf, EatFishAndAI.WIDTH - 300, EatFishAndAI.HEIGHT));

    getGameContext().update(1);
    getGameContext().setPaused(true);
  }
  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);
  }