Beispiel #1
0
  private void restart() {

    float y = (HEIGHT_WORLD / 2) - 10;

    planetCoreModel.setTransform(0, y, 0);
    planetCoreModel.setLinearVelocity(0f, 0f);
    planetCoreModel.setAngularVelocity(1f);

    planetModel.setTransform(0, y, 0f);
    planetModel.setLinearVelocity(0f, 0f);
    planetModel.setAngularVelocity(1f);

    Vector2 vec = new Vector2();

    for (int i = 0; i < MAX_BALLS; i++) {
      float tx = rand.nextFloat() * 1.0f - 1f;
      float ty = HEIGHT_WORLD + BALL_RADIUS;
      float angle = rand.nextFloat() * MathUtils.PI * 2;

      ballModels[i].setActive(false);
      ballModels[i].setLinearVelocity(vec.set(0, -10));
      ballModels[i].setAngularVelocity(0f);
      ballModels[i].setTransform(vec.set(tx, ty), angle);
    }

    tweenManager.killAll();

    Tween.call(
            new TweenCallback() {
              private int idx = 0;

              @Override
              public void onEvent(int arg0, BaseTween<?> arg1) {
                if (idx < ballModels.length) {
                  ballModels[idx].setAwake(true);
                  ballModels[idx].setActive(true);
                  idx += 1;
                }
              }
            })
        .repeat(MAX_BALLS, 0.5f)
        .start(tweenManager);
  }
 public void dispose() {
   tweenManager.killAll();
   batch.dispose();
 }