com.badlogic.gdx.Screen Java Examples

The following examples show how to use com.badlogic.gdx.Screen. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShareScoreScreen.java    From Klooni1010 with GNU General Public License v3.0 6 votes vote down vote up
ShareScoreScreen(final Klooni game, final Screen lastScreen,
                 final int score, final boolean timeMode) {
    this.game = game;
    this.lastScreen = lastScreen;

    this.score = score;
    this.timeMode = timeMode;

    final Label.LabelStyle labelStyle = new Label.LabelStyle();
    labelStyle.font = game.skin.getFont("font_small");

    infoLabel = new Label("Generating image...", labelStyle);
    infoLabel.setColor(Klooni.theme.textColor);
    infoLabel.setAlignment(Align.center);
    infoLabel.layout();
    infoLabel.setPosition(
            (Gdx.graphics.getWidth() - infoLabel.getWidth()) * 0.5f,
            (Gdx.graphics.getHeight() - infoLabel.getHeight()) * 0.5f);

    spriteBatch = new SpriteBatch();
}
 
Example #2
Source File: SelectScreen.java    From Unlucky with MIT License 6 votes vote down vote up
/**
 * Handles the position and events of the exit button
 */
protected void handleExitButton(final Screen screen) {
    // init exit button
    ImageButton.ImageButtonStyle style = new ImageButton.ImageButtonStyle();
    style.imageUp = new TextureRegionDrawable(rm.menuExitButton[0][0]);
    style.imageDown = new TextureRegionDrawable(rm.menuExitButton[1][0]);
    exitButton = new ImageButton(style);
    exitButton.setSize(18, 18);
    exitButton.setPosition(177, 99);
    stage.addActor(exitButton);

    // fade back to previous screen
    exitButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (!game.player.settings.muteSfx) rm.buttonclick0.play(game.player.settings.sfxVolume);
            game.menuScreen.transitionIn = 0;
            setFadeScreen(screen);
        }
    });
}
 
Example #3
Source File: AbstractScreen.java    From Unlucky with MIT License 6 votes vote down vote up
/**
 * Switches to a new screen while handling fading buffer
 * Fade transition
 *
 * @param screen
 */
public void setFadeScreen(final Screen screen) {
    if (clickable) {
        clickable = false;
        batchFade = false;
        // fade out animation
        stage.addAction(Actions.sequence(Actions.fadeOut(0.3f),
            Actions.run(new Runnable() {
                @Override
                public void run() {
                    clickable = true;
                    game.setScreen(screen);
                }
            })));
    }
}
 
Example #4
Source File: AbstractScreen.java    From Unlucky with MIT License 6 votes vote down vote up
/**
 * Switches to a new screen while handling fading buffer
 * Slide transition either to the left or right
 *
 * @param screen
 * @param right
 */
public void setSlideScreen(final Screen screen, boolean right) {
    if (clickable) {
        clickable = false;
        batchFade = true;
        // slide animation
        stage.addAction(Actions.sequence(
            Actions.moveBy(right ? -Unlucky.V_WIDTH : Unlucky.V_WIDTH, 0, 0.15f),
            Actions.run(new Runnable() {
                @Override
                public void run() {
                    clickable = true;
                    game.setScreen(screen);
                }
            })));
    }
}
 
Example #5
Source File: FadingGame.java    From libgdx-transitions with Apache License 2.0 6 votes vote down vote up
/** Sets the current screen. {@link Screen#hide()} is called on any old screen, and {@link Screen#show()} is called on the new
 * screen, if any.
 * @param screen may be {@code null} */
@Override
public void setScreen(Screen screen) {
    screen.show();
    if (transitionRunning)
        Gdx.app.log(FadingGame.class.getSimpleName(), "Changed Screen while transition in progress");
    if (this.screen == null) {
        this.screen = screen;
    } else {
        if (screenTransition == null) {
            this.screen.hide();
            this.screen = screen;
        } else {
            this.nextScreen = screen;
            this.screen.pause();
            this.nextScreen.pause();
            currentTransitionTime = 0;
            transitionRunning = true;
            notifyStarted();
        }

    }

    this.screen.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

}
 
Example #6
Source File: Client.java    From riiablo with Apache License 2.0 6 votes vote down vote up
@Override
public void setScreen(Screen screen) {
  Screen previousScreen = this.screen;
  Gdx.app.debug(TAG, "Scene change: " + screenToString(previousScreen) + " -> " + screenToString(screen));
  if (previousScreen instanceof com.badlogic.gdx.InputProcessor) {
    input.removeProcessor((com.badlogic.gdx.InputProcessor) previousScreen);
  }

  super.setScreen(screen);
  if (previousScreen != null && screens.isEmpty()) {
    Gdx.app.debug(TAG, "Disposing " + screenToString(previousScreen));
    previousScreen.dispose(); // FIXME: memory leak -- need to fix assets loading/unloading scheme
  }
  if (screen instanceof com.badlogic.gdx.InputProcessor) {
    input.addProcessor((com.badlogic.gdx.InputProcessor) screen);
  }
}
 
Example #7
Source File: TransitionScreen.java    From Klooni1010 with GNU General Public License v3.0 5 votes vote down vote up
public TransitionScreen(Klooni game, Screen from, Screen to, boolean disposeAfter) {
    this.disposeAfter = disposeAfter;
    this.game = game;
    fromScreen = from;
    toScreen = to;

    spriteBatch = new SpriteBatch();
}
 
Example #8
Source File: GdxDemo3D.java    From GdxDemo3D with Apache License 2.0 5 votes vote down vote up
@Override
public void create() {
	Gdx.app.setLogLevel(Application.LOG_DEBUG);

	getAssetManager().getLogger().setLevel(Logger.DEBUG);

	Screen currentScreen = new LoadingGameScreen(this, new GameScreen(this));
	setScreen(currentScreen);
}
 
Example #9
Source File: ScreenManager.java    From Norii with Apache License 2.0 5 votes vote down vote up
public void showScreen(ScreenEnum screenEnum, Object... params) {
	final Screen currentScreen = game.getScreen();

	final Screen newScreen = screenEnum.getScreen(params);
	game.setScreen(newScreen);

	if (currentScreen != null) {
		currentScreen.dispose();
	}
}
 
Example #10
Source File: Client.java    From riiablo with Apache License 2.0 5 votes vote down vote up
public void pushScreen(Screen screen) {
  if (this.screen != null) {
    screens.add(this.screen);
  }

  setScreen(screen);
}
 
Example #11
Source File: LoadingScreen.java    From riiablo with Apache License 2.0 5 votes vote down vote up
public LoadingScreen(Array<AssetDescriptor> assets, Screen screen) {
  this.screen = screen;

  stage = new Stage(Riiablo.defaultViewport, Riiablo.batch);

  Riiablo.assets.load(loadingscreenDescriptor);
  Riiablo.assets.finishLoadingAsset(loadingscreenDescriptor);
  final Animation loadingscreen = Animation.newAnimation(Riiablo.assets.get(loadingscreenDescriptor));
  loadingscreen.setFrameDuration(Float.MAX_VALUE);
  loadingscreenWrapper = new AnimationWrapper(loadingscreen) {
    @Override
    public void act(float delta) {
      super.act(delta);
      for (Animation animation : animations) {
        animation.setFrame((int) (Riiablo.assets.getProgress() * (animation.getNumFramesPerDir() - 1)));
      }
    }
  };
  loadingscreenWrapper.setPosition(
      (stage.getWidth()  / 2) - (loadingscreen.getMinWidth()  / 2),
      (stage.getHeight() / 2) - (loadingscreen.getMinHeight() / 2));
  stage.addActor(loadingscreenWrapper);

  this.assets = assets;
  if (assets != null) {
    for (AssetDescriptor asset : assets) {
      Riiablo.assets.load(asset);
    }
  }
}
 
Example #12
Source File: FadingGame.java    From libgdx-transitions with Apache License 2.0 4 votes vote down vote up
/** @return the next {@link Screen}. */
public Screen getNextScreen() {
    return nextScreen;
}
 
Example #13
Source File: LevelStartScreen.java    From ninja-rabbit with GNU General Public License v2.0 4 votes vote down vote up
public LevelStartScreen(final NinjaRabbitGame game, final Screen levelScreen) {
	this(game);
	this.levelScreen = levelScreen;
}
 
Example #14
Source File: KillingSpree.java    From killingspree with MIT License 4 votes vote down vote up
public void setScreen(Screen screen){
    nextScreen = screen;
    currentScreen.dispose();
    currentScreen = nextScreen;
    currentScreen.resize(width, height);
}
 
Example #15
Source File: ScreenSwitcher.java    From ud405 with MIT License 4 votes vote down vote up
public ScreenSwitcher(Game game, Screen screen1, Screen screen2) {
    this.game = game;
    this.screen1 = screen1;
    this.screen2 = screen2;
    currentScreen = 1;
}
 
Example #16
Source File: LoadingScreen.java    From riiablo with Apache License 2.0 4 votes vote down vote up
public <T extends Screen & Loadable> LoadingScreen(T screen) {
  this(screen.getDependencies(), screen);
}
 
Example #17
Source File: Client.java    From riiablo with Apache License 2.0 4 votes vote down vote up
public void clearAndSet(Screen screen) {
  for (Screen s : screens) s.dispose();
  screens.clear();
  setScreen(screen);
}
 
Example #18
Source File: Client.java    From riiablo with Apache License 2.0 4 votes vote down vote up
private String screenToString(Screen screen) {
  return screen != null ? screen.getClass().getSimpleName() : null;
}
 
Example #19
Source File: FadingGame.java    From libgdx-transitions with Apache License 2.0 4 votes vote down vote up
/** @return the currently active {@link Screen}. */
@Override
public Screen getScreen() {
    return screen;
}
 
Example #20
Source File: Klooni.java    From Klooni1010 with GNU General Public License v3.0 4 votes vote down vote up
public void transitionTo(Screen screen, boolean disposeAfter) {
    setScreen(new TransitionScreen(this, getScreen(), screen, disposeAfter));
}
 
Example #21
Source File: Klooni.java    From Klooni1010 with GNU General Public License v3.0 4 votes vote down vote up
public void transitionTo(Screen screen) {
    transitionTo(screen, true);
}