List of usage examples for com.badlogic.gdx.scenes.scene2d.ui ScrollPane setOverscroll
public void setOverscroll(boolean overscrollX, boolean overscrollY)
From source file:com.roterballon.balloonburster.scenes.AboutHUD.java
License:Common Public License
public AboutHUD(com.roterballon.balloonburster.BalloonBursterGame game) { this.game = game; this.assetmanager = game.getAssetManager(); this.skin = new Skin(Gdx.files.internal("skin/uiskin.json")); this.viewport = new FitViewport(com.roterballon.balloonburster.BalloonBursterGame.V_WIDTH, com.roterballon.balloonburster.BalloonBursterGame.V_HEIGHT, new OrthographicCamera()); this.stage = new Stage(this.viewport, game.getSpriteBatch()); // create wrapper table Table wrapper = new Table(); wrapper.top();// w w w . j ava 2s.co m wrapper.setWidth(com.roterballon.balloonburster.BalloonBursterGame.V_WIDTH * 0.8f); wrapper.setHeight(com.roterballon.balloonburster.BalloonBursterGame.V_HEIGHT * 0.65f); Label aboutLabel = new Label("About", skin, "logo"); wrapper.add(aboutLabel).expandX().align(Align.left); wrapper.row(); // create scroll wrapper table Table scrollWrapper = new Table(); //scrollWrapper.debug(); scrollWrapper.top(); // create content for scrollWrapper Label graphicsLabel = new Label("Graphics", skin, "bold"); scrollWrapper.add(graphicsLabel).width(wrapper.getWidth() * 0.9f); scrollWrapper.row(); //cloud 1 attribution Label cloud1LinkLabel = new Label("Clouds", skin, "link"); cloud1LinkLabel.setAlignment(Align.center); cloud1LinkLabel.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.net.openURI("https://www.flickr.com/photos/craightonmiller/5944377614/"); } }); scrollWrapper.add(cloud1LinkLabel).width(wrapper.getWidth() * 0.9f); scrollWrapper.row(); String cloud1Text = "by Craighton Miller is licensed under CC BY 2.0"; Label cloud1TextLabel = new Label(cloud1Text, skin); cloud1TextLabel.setWrap(true); scrollWrapper.add(cloud1TextLabel).width(wrapper.getWidth() * 0.9f); scrollWrapper.row(); //cloud 2 attribution Label cloud2LinkLabel = new Label("Single white cloud on a clear blue sky", skin, "link"); cloud2LinkLabel.setWrap(true); cloud2LinkLabel.setAlignment(Align.center); cloud2LinkLabel.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.net.openURI("https://www.flickr.com/photos/horiavarlan/4777129318"); } }); scrollWrapper.add(cloud2LinkLabel).width(wrapper.getWidth() * 0.9f).padTop(30); scrollWrapper.row(); String cloud2Text = "by Horia Varlan is licensed under CC BY 2.0"; Label cloud2TextLabel = new Label(cloud2Text, skin); cloud2TextLabel.setWrap(true); scrollWrapper.add(cloud2TextLabel).width(wrapper.getWidth() * 0.9f); scrollWrapper.row(); //balloons attribution Label balloonsTextLabel = new Label("Balloons created by", skin); balloonsTextLabel.setWrap(true); balloonsTextLabel.setAlignment(Align.center); scrollWrapper.add(balloonsTextLabel).width(wrapper.getWidth() * 0.9f).padTop(30); scrollWrapper.row(); Label balloonsLinkLabel = new Label("Marius Nolden", skin, "link"); balloonsLinkLabel.setAlignment(Align.center); balloonsLinkLabel.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.net.openURI("https://www.youtube.com/user/HydriasLP"); } }); scrollWrapper.add(balloonsLinkLabel).width(wrapper.getWidth() * 0.9f); scrollWrapper.row(); //sound attribution Label soundLabel = new Label("Sound", skin, "bold"); scrollWrapper.add(soundLabel).width(wrapper.getWidth() * 0.9f).padTop(30); scrollWrapper.row(); //music attribution Label musicLinkLabel = new Label("Flight", skin, "link"); musicLinkLabel.setAlignment(Align.center); musicLinkLabel.addListener(new ClickListener() { public void clicked(InputEvent e, float x, float y) { Gdx.net.openURI("https://soundcloud.com/iamhydra/flight"); } }); scrollWrapper.add(musicLinkLabel).width(wrapper.getWidth() * 0.9f); scrollWrapper.row(); String musicText = "by Hydra and LucienMusique is used as background music."; Label musicTextLabel = new Label(musicText, skin); musicTextLabel.setWrap(true); scrollWrapper.add(musicTextLabel).width(wrapper.getWidth() * 0.9f); scrollWrapper.row(); //balloon pop attribution Label balloonPopLinkLabel = new Label("Balloon Pop", skin, "link"); balloonPopLinkLabel.setAlignment(Align.center); balloonPopLinkLabel.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.net.openURI("http://www.freesound.org/people/qubodup/sounds/222373/"); } }); scrollWrapper.add(balloonPopLinkLabel).width(wrapper.getWidth() * 0.9f).padTop(30); scrollWrapper.row(); String balloonPopText = "by qubodup is licensed under CC BY 3.0"; Label balloonPopTextLabel = new Label(balloonPopText, skin); balloonPopTextLabel.setWrap(true); scrollWrapper.add(balloonPopTextLabel).width(wrapper.getWidth() * 0.9f); scrollWrapper.row(); String dev = "A game developed by roterballon.com"; Label devLabel = new Label(dev, skin, "bold-outline"); devLabel.setWrap(true); devLabel.setAlignment(Align.center); scrollWrapper.add(devLabel).width(wrapper.getWidth() * 0.9f).padTop(30); scrollWrapper.pack(); // create scroll pane ScrollPane scrollContainer = new ScrollPane(scrollWrapper); scrollContainer.setOverscroll(false, true); wrapper.add(scrollContainer).expandX().align(Align.left); // set Background wrapper.setBackground(new NinePatchDrawable( new NinePatch(assetmanager.get("img/bg_ninepatch.png", Texture.class), 10, 10, 10, 10))); wrapper.pack(); wrapper.setWidth(com.roterballon.balloonburster.BalloonBursterGame.V_WIDTH * 0.8f); wrapper.setHeight(com.roterballon.balloonburster.BalloonBursterGame.V_HEIGHT * 0.65f); wrapper.setPosition(com.roterballon.balloonburster.BalloonBursterGame.V_WIDTH / 2, com.roterballon.balloonburster.BalloonBursterGame.V_HEIGHT - wrapper.getHeight() / 2 - 220, Align.center); // padTop of 220 ImageButton menu = new ImageButton( new TextureRegionDrawable( assetmanager.get("img/buttons/buttons.atlas", TextureAtlas.class).findRegion("btn_menu")), new TextureRegionDrawable(assetmanager.get("img/buttons/buttons.atlas", TextureAtlas.class) .findRegion("btn_menu_pressed"))); menu.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { AboutHUD.this.game.transition(new MenuScreen(AboutHUD.this.game)); } }); menu.setSize(400, 70); menu.setPosition(com.roterballon.balloonburster.BalloonBursterGame.V_WIDTH / 2, wrapper.getY() - 50, Align.top | Align.center); stage.addActor(wrapper); stage.addActor(menu); Gdx.input.setInputProcessor(stage); }
From source file:com.vlaaad.dice.ui.windows.DiceWindow.java
License:Open Source License
@Override protected void doShow(final UserData userData) { final Table items = new Table(); final ScrollPane pane = new ScrollPane(items, new ScrollPane.ScrollPaneStyle()) { @Override/*from w w w . j a v a2 s . c o m*/ public void layout() { float w = items.getPrefWidth(); float h = Math.min(getParent().getHeight(), items.getPrefHeight()); if (w != getWidth() || h != getHeight()) { setSize(w, h); invalidateHierarchy(); } super.layout(); } }; pane.setTouchable(Touchable.childrenOnly); pane.setOverscroll(false, false); pane.setCancelTouchFocus(false); pane.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { pane.layout(); pane.layout(); items.layout(); if (actor instanceof Layout) ((Layout) actor).layout(); pane.layout(); pane.layout(); pane.scrollTo(actor.getX(), actor.getY(), actor.getWidth(), actor.getHeight() + 100); } }); Iterable<Die> dice = userData.dice(); int i = 1; int count = userData.diceCount(); for (Die die : dice) { DiePane diePane = new DiePane(die, userData, diceWindowGroup); table.add(diePane); diePane.setWidth(0); diePane.pack(); diePane.setWidth(ViewController.CELL_SIZE * 6.6f); Cell cell = items.add(diePane).fillX().maxWidth(ViewController.CELL_SIZE * 6.6f); if (i != count) { cell.padBottom(-1); } cell.row(); map.put(die, diePane); diePane.info.addListener(createMinimizeListener(die, dice)); i++; } items.pack(); table.add(pane).width(items.getPrefWidth());//.size(items.getPrefWidth(), 200); }
From source file:it.alcacoop.backgammon.ui.UIDialog.java
License:Open Source License
public static void getHelpDialog(Boolean cb) { Stage stage = GnuBackgammon.Instance.currentScreen.getStage(); instance.visible = true;/*from w w w . j a v a 2 s . c o m*/ instance.evt = Events.NOOP; instance.quitWindow = false; instance.leaveWindow = false; instance.optionsWindow = false; instance.dicesWindow = false; instance.remove(); Label l = new Label( "GAME TYPE\n" + "You can choose two game type, and several options:\n" + "Backgammon - usual starting position\n" + "Nackgammon - Nack's starting position, attenuates lucky starting roll\n" + "Doubling Cube: use or not the doubling cube, with or without Crawford rule\n\n" + "START TURN\n" + "If cube isn't available, dices are rolled automatically,\n" + "else you must click on 'Double' or 'Roll' button\n\n" + "MOVING MECHANIC\n" + "You can choose two moves mechanic (Options->Move Logic):\n" + "TAP - once you rolled dices, select the piece you would move.\n" + "If legal moves for that piece are available, they will be shown.\n" + "Click an available point and the piece will move there.\n" + "AUTO - click on a piece and it moves automatically to destination point.\n" + "Bigger dice is played first. You can change dice order clicking on dices\n\n" + "You can cancel your moves in current hand just clicking the UNDO button\n" + "in the game options menu popup.\n\n" + "END TURN\n" + "When you finish your turn, click again the dices to take back them and change turn.\n", GnuBackgammon.skin); l.setWrap(true); ScrollPane sc = new ScrollPane(l, GnuBackgammon.skin); sc.setFadeScrollBars(false); sc.setOverscroll(false, false); float height = stage.getHeight() * 0.85f; float width = stage.getWidth() * 0.9f; instance.clear(); instance.row().padTop(width / 25); instance.add(sc).colspan(3).expand().fill().align(Align.center).padTop(width / 25).padLeft(width / 35) .padRight(width / 35); instance.row().pad(width / 25); instance.add(); instance.add(instance.bContinue).fill().expand().height(height * 0.15f).width(width / 4); instance.add(); instance.setWidth(width); instance.setHeight(height); instance.setX((stage.getWidth() - width) / 2); instance.setY((stage.getHeight() - height) / 2); stage.addActor(instance); instance.setY(stage.getHeight()); instance.addAction( Actions.sequence( MyActions .sequence(Actions.parallel(Actions.color(new Color(1, 1, 1, alpha), 0.2f), Actions.moveTo((stage.getWidth() - width) / 2, (stage.getHeight() - height) / 2, 0.2f))), Actions.run(new Runnable() { @Override public void run() { Gdx.graphics.setContinuousRendering(true); } }))); }
From source file:it.alcacoop.backgammon.ui.UIDialog.java
License:Open Source License
public static void getAboutDialog(Boolean cb) { Stage stage = GnuBackgammon.Instance.currentScreen.getStage(); instance.visible = true;/*from w ww. j av a 2s . c o m*/ instance.evt = Events.NOOP; instance.quitWindow = false; instance.leaveWindow = false; instance.optionsWindow = false; instance.dicesWindow = false; instance.remove(); final String gnuBgLink = "http://www.gnubg.org"; final String gplLink = "http://www.gnu.org/licenses/gpl.html"; final String githubLink1 = "https://github.com/alcacoop/it.alcacoop.backgammon"; final String githubLink2 = "https://github.com/alcacoop/libgnubg-android"; final String wikipediaLink = "http://en.wikipedia.org/wiki/Backgammon#Rules"; Table t = new Table(); t.add(new Label("ABOUT BACKGAMMON MOBILE", GnuBackgammon.skin)).expand(); t.row(); t.add(new Label(" ", GnuBackgammon.skin)).fill().expand(); t.row(); t.add(new Label("Backgammon Mobile is based on GNUBackgammon (gnubg)", GnuBackgammon.skin)); Label link1 = new Label(gnuBgLink, GnuBackgammon.skin); link1.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { GnuBackgammon.Instance.snd.playMoveStart(); GnuBackgammon.Instance.nativeFunctions.openURL(gnuBgLink); }; }); t.row(); t.add(link1); t.row(); t.add(new Label(" ", GnuBackgammon.skin)).fill().expand(); t.row(); t.add(new Label("Its source code is released under a GPLv3 License", GnuBackgammon.skin)); Label link2 = new Label(gplLink, GnuBackgammon.skin); link2.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { GnuBackgammon.Instance.snd.playMoveStart(); GnuBackgammon.Instance.nativeFunctions.openURL(gplLink); }; }); t.row(); t.add(link2); t.row(); t.add(new Label(" ", GnuBackgammon.skin)).fill().expand(); t.row(); t.add(new Label("and is available on GitHub at:", GnuBackgammon.skin)); Label link3 = new Label(githubLink1, GnuBackgammon.skin); link3.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { GnuBackgammon.Instance.snd.playMoveStart(); GnuBackgammon.Instance.nativeFunctions.openURL(githubLink1); }; }); Label link4 = new Label(githubLink2, GnuBackgammon.skin); link4.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { GnuBackgammon.Instance.snd.playMoveStart(); GnuBackgammon.Instance.nativeFunctions.openURL(githubLink2); }; }); t.row(); t.add(link3); t.row(); t.add(link4); t.row(); t.add(new Label(" ", GnuBackgammon.skin)).fill().expand(); t.row(); t.add(new Label("You can find a detailed description of game rules on Wikipedia:", GnuBackgammon.skin)); Label link5 = new Label(wikipediaLink, GnuBackgammon.skin); link5.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { GnuBackgammon.Instance.snd.playMoveStart(); GnuBackgammon.Instance.nativeFunctions.openURL(wikipediaLink); }; }); t.row(); t.add(link5); t.row(); t.add(new Label(" ", GnuBackgammon.skin)).fill().expand(); t.row(); t.add(new Label("If you enjoy our game support us rating on the Play Store", GnuBackgammon.skin)); t.row(); t.add(new Label(" ", GnuBackgammon.skin)).fill().expand(); t.row(); t.add(new Label("Copyright 2012 - Alca Soc. Coop.", GnuBackgammon.skin)); ScrollPane sc = new ScrollPane(t, GnuBackgammon.skin); sc.setFadeScrollBars(false); sc.setOverscroll(false, false); float height = stage.getHeight() * 0.85f; float width = stage.getWidth() * 0.95f; instance.clear(); instance.row().padTop(width / 25); instance.add(sc).colspan(3).expand().fill().align(Align.center).padTop(width / 25).padLeft(width / 35) .padRight(width / 35); instance.row().pad(width / 25); instance.add(); instance.add(instance.bContinue).fill().expand().height(height * 0.15f).width(width / 4); instance.add(); instance.setWidth(width); instance.setHeight(height); instance.setX((stage.getWidth() - width) / 2); stage.addActor(instance); instance.setY(stage.getHeight()); instance.addAction( Actions.sequence( MyActions .sequence(Actions.parallel(Actions.color(new Color(1, 1, 1, alpha), 0.2f), Actions.moveTo((stage.getWidth() - width) / 2, (stage.getHeight() - height) / 2, 0.2f))), Actions.run(new Runnable() { @Override public void run() { Gdx.graphics.setContinuousRendering(true); } }))); }
From source file:it.alcacoop.fourinaline.actors.UIDialog.java
License:Open Source License
public static void getAboutDialog() { Stage stage = FourInALine.Instance.currentScreen.getStage(); instance.visible = true;/*from w w w .java2 s .co m*/ instance.evt = Events.NOOP; instance.quitWindow = false; instance.leaveWindow = false; instance.remove(); final String gnuBgLink = "http://code.google.com/p/fourinaline"; final String gplLink = "http://www.gnu.org/licenses/gpl.html"; final String githubLink1 = "https://github.com/alcacoop/it.alcacoop.fourinaline"; final String wikipediaLink = "http://en.wikipedia.org/wiki/Connect_Four"; Table t = new Table(); t.add(new Label("ABOUT FOUR IN A LINE MOBILE", FourInALine.Instance.skin)).expand(); t.row(); t.add(new Label(" ", FourInALine.Instance.skin)).fill().expand(); t.row(); t.add(new Label("\"Four in a Line Mobile!\" is based on FourInALine", FourInALine.Instance.skin)); Label link1 = new Label(gnuBgLink, FourInALine.Instance.skin); link1.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { FourInALine.Instance.snd.playMove(); FourInALine.Instance.nativeFunctions.openURL(gnuBgLink); }; }); t.row(); t.add(link1); t.row(); t.add(new Label(" ", FourInALine.Instance.skin)).fill().expand(); t.row(); t.add(new Label("Its source code is released under a GPLv3 License", FourInALine.Instance.skin)); Label link2 = new Label(gplLink, FourInALine.Instance.skin); link2.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { FourInALine.Instance.snd.playMove(); FourInALine.Instance.nativeFunctions.openURL(gplLink); }; }); t.row(); t.add(link2); t.row(); t.add(new Label(" ", FourInALine.Instance.skin)).fill().expand(); t.row(); t.add(new Label("and is available on GitHub at:", FourInALine.Instance.skin)); Label link3 = new Label(githubLink1, FourInALine.Instance.skin); link3.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { FourInALine.Instance.snd.playMove(); FourInALine.Instance.nativeFunctions.openURL(githubLink1); }; }); t.row(); t.add(link3); t.row(); t.add(new Label(" ", FourInALine.Instance.skin)).fill().expand(); t.row(); t.add(new Label("You can find a detailed description of game rules on Wikipedia:", FourInALine.Instance.skin)); Label link5 = new Label(wikipediaLink, FourInALine.Instance.skin); link5.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { FourInALine.Instance.snd.playMove(); FourInALine.Instance.nativeFunctions.openURL(wikipediaLink); }; }); t.row(); t.add(link5); t.row(); t.add(new Label(" ", FourInALine.Instance.skin)).fill().expand(); t.row(); t.add(new Label("If you enjoy our game, support us rating on the Play Store", FourInALine.Instance.skin)); t.row(); t.add(new Label(" ", FourInALine.Instance.skin)).fill().expand(); t.row(); t.add(new Label("Copyright 2013 - Alca Soc. Coop.", FourInALine.Instance.skin)); ScrollPane sc = new ScrollPane(t, FourInALine.Instance.skin); sc.setFadeScrollBars(false); sc.setOverscroll(false, false); float height = stage.getHeight() * 0.85f; float width = stage.getWidth() * 0.95f; instance.clear(); instance.row().padTop(width / 25); instance.add(sc).colspan(3).expand().fill().align(Align.center).padTop(width / 25).padLeft(width / 35) .padRight(width / 35); instance.row().pad(width / 25); instance.add(); instance.add(instance.bContinue).fill().expand().height(height * 0.15f).width(width / 4); instance.add(); instance.setWidth(width); instance.setHeight(height); instance.setX((stage.getWidth() - width) / 2); stage.addActor(instance); instance.setY(stage.getHeight()); instance.addAction(Actions.sequence(Actions.parallel(Actions.color(new Color(1, 1, 1, alpha), 0.2f), Actions.moveTo((stage.getWidth() - width) / 2, (stage.getHeight() - height) / 2, 0.2f)))); }
From source file:ui.PracticeScrollPanel.java
License:Apache License
public PracticeScrollPanel(final PracticeScreen screen, Rectangle bounds) { this.screen = screen; Table table = new Table(); int i = 0;// w ww . j a v a 2 s . c o m while (i < NUM_GAMETYPES) { table.row().expandX().pad(40); for (int j = 0; j < NUM_COLUMNS; j++) { final GameType type = GameType.values()[i % GameType.values().length]; final String name = GameNames[type.ordinal()]; final Image img = new Image(HyperTask.res.getTexture(name)); img.setSize(78, 78); img.setColor(GameColors[type.ordinal()]); img.setOrigin(Align.center); //img.setScale(1.2f); img.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { AudioManager.instance().play(HyperTask.res.getSound(SOUND_CLICK), CLICK_VOLUME); img.addAction( Actions.sequence(Actions.scaleTo(1.8f, 1.8f, 0.1f), Actions.scaleTo(1, 1, 0.1f))); screen.setGame(type); } }); table.add(img); i++; if (i >= NUM_GAMETYPES) break; } } final ScrollPane scroll = new ScrollPane(table); scroll.setOverscroll(false, true); scroll.setScrollingDisabled(true, false); setBounds(bounds.x, bounds.y, bounds.width, bounds.height); add(scroll).expand().fill(); }