public static Table setupScrollpane( float x, float y, float paneWidth, float paneHeight, ScrollPane target, Texture scrollButton) { ScrollPane.ScrollPaneStyle scrollPaneStyle = new ScrollPane.ScrollPaneStyle(); scrollPaneStyle.vScrollKnob = new TextureRegionDrawable(new TextureRegion(scrollButton)); target.setStyle(scrollPaneStyle); target.setFadeScrollBars(false); target.setOverscroll(false, false); target.setFlickScroll(false); target.addListener(new GetScrollFocusWhenEntered(target)); Table scenarioPaneContainer = new Table(); scenarioPaneContainer.setX(x); scenarioPaneContainer.setY(y); scenarioPaneContainer.setWidth(paneWidth); scenarioPaneContainer.setHeight(paneHeight); scenarioPaneContainer.add(target).fill().expand(); return scenarioPaneContainer; }
@Override public void show() { super.show(); // retrieve the custom skin for our 2D widgets Skin skin = super.getSkin(); // create the table actor and add it to the stage table = super.getTable(); table.setWidth(stage.getWidth()); table.setHeight(stage.getHeight()); table.pad(10).defaults().spaceBottom(10).space(5); table.row().fill().expandX(); AtlasRegion splashRegion = getAtlas().findRegion("splash-screen/menulogo"); Image logo = new Image(splashRegion); table.add(logo).fill(false); table.row(); table.pad(10).defaults().spaceBottom(10); TextButton continueButton = new TextButton("Continue", skin); continueButton.setVisible(false); continueButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { // game.setScreen( new StartGameScreen( game ) ); } }); table.add(continueButton).size(300, 60).uniform().spaceBottom(10); table.row(); table.pad(10).defaults().spaceBottom(10); TextButton newGameButton = new TextButton("New game", skin); newGameButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { // TODO: Move it back to char select screen // game.setScreen( new CharSelectScreen( game ) ); if (Unsealed.DEBUG) game.setScreen(new BattleScreen(game)); else game.setScreen(new SplashScreen(game)); } }); table.add(newGameButton).size(300, 60).uniform().spaceBottom(10); table.row(); table.pad(10).defaults().spaceBottom(10); // TextButton optionsButton = new TextButton( "Options", skin ); // optionsButton.setDisabled(true); // optionsButton.addListener( new ClickListener() { // @Override // public void clicked(InputEvent event, float x, float y ) { // game.setScreen( new OptionsScreen( game ) ); // } // } ); // table.add(optionsButton).size( 300, 60 ).uniform().spaceBottom(10); }
private void loadScreen() { // Grafo de escena que contendrá todo el menú stage = new Stage(); // Crea una tabla, donde añadiremos los elementos de menú Table table = new Table(); table.setPosition(Constants.SCREEN_WIDTH / 2.5f, Constants.SCREEN_HEIGHT / 1.5f); // La tabla ocupa toda la pantalla table.setFillParent(true); table.setHeight(500); stage.addActor(table); // Etiqueta de texto Label label = new Label("Bienvenido a JFighter2DX", game.getSkin()); table.addActor(label); // Botón TextButton buttonPlay = new TextButton("Partida Rapida", game.getSkin()); buttonPlay.setPosition(label.getOriginX(), label.getOriginY() - 120); buttonPlay.setWidth(200); buttonPlay.setHeight(40); buttonPlay.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { dispose(); game.setScreen(new GameScreen(game, GameType.QUICK)); } }); table.addActor(buttonPlay); // Botón TextButton buttonHistory = new TextButton("Modo Historia", game.getSkin()); buttonHistory.setPosition(label.getOriginX(), label.getOriginY() - 170); buttonHistory.setWidth(200); buttonHistory.setHeight(40); buttonHistory.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { dispose(); game.setScreen(new GameScreen(game, GameType.HISTORY)); } }); table.addActor(buttonHistory); // Botón TextButton buttonConfig = new TextButton("Configurar", game.getSkin()); buttonConfig.setPosition(label.getOriginX(), label.getOriginY() - 220); buttonConfig.setWidth(200); buttonConfig.setHeight(40); buttonConfig.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { dispose(); game.setScreen(new ConfigurationScreen(game)); } }); table.addActor(buttonConfig); // Botón TextButton buttonQuit = new TextButton("Salir", game.getSkin()); buttonQuit.setPosition(label.getOriginX(), label.getOriginY() - 270); buttonQuit.setWidth(200); buttonQuit.setHeight(40); buttonQuit.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { game.dispose(); System.exit(0); } }); table.addActor(buttonQuit); Gdx.input.setInputProcessor(stage); }
@Override public void show() { super.show(); // retrieve the custom skin for our 2D widgets Skin skin = super.getSkin(); game.getMusicManager().play(UnsealedMusic.MENU); // create the table actor and add it to the stage table = super.getTable(); table.setWidth(stage.getWidth()); table.setHeight(stage.getHeight()); table.pad(10).defaults().spaceBottom(10).space(5); table.row().fill().expandX(); AtlasRegion splashRegion = getAtlas().findRegion("splash-screen/menulogo"); Image logo = new Image(splashRegion); table.add(logo).colspan(3).fill(false); table.row(); table.pad(10).defaults().spaceBottom(10); TextButton currentButton = new TextButton("Story Mode", skin); currentButton.setVisible(true); currentButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { game.setScreen(new ChapterSelectScreen(game)); } }); table.add(currentButton).colspan(3).size(300, 60).uniform().spaceBottom(10); table.row(); table.pad(10).defaults().spaceBottom(10); currentButton = new TextButton("Battle Arena", skin); currentButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (Unsealed.DEBUG) game.setScreen(new BattleScreen(game, false, "TownOne")); else if (Gdx.app.getType() != ApplicationType.Android) game.setScreen(new QuickTutorialScreen(game)); else game.setScreen(new BattleScreen(game, false, "TownOne")); } }); table.add(currentButton).colspan(3).size(300, 60).uniform().spaceBottom(10); table.row(); table.pad(10).defaults().spaceBottom(10); currentButton = new TextButton("Options", skin); currentButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { game.setScreen(new OptionsScreen(game)); } }); table.add(currentButton).uniform().spaceBottom(10); currentButton = new TextButton("Tutorial", skin); currentButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (Gdx.app.getType() == ApplicationType.Android) game.setScreen(new TutorialAndroidScreen(game)); else game.setScreen(new TutorialDesktopScreen(game)); } }); table.add(currentButton).uniform().spaceBottom(10); currentButton = new TextButton("Credits", skin); currentButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { game.setScreen(new CreditsScreen(game)); } }); table.add(currentButton).uniform().spaceBottom(10); table.pad(10).defaults().spaceBottom(10); }