List of usage examples for com.badlogic.gdx.scenes.scene2d.utils ClickListener ClickListener
public ClickListener()
From source file:Credits.java
License:Apache License
public Credits() { Sink.setBackground("title"); Table grid = new Table(); grid.setSize(Sink.targetWidth, Sink.targetHeight); grid.setFillParent(true);// www .ja v a 2s . c om grid.setPosition(0, 0); grid.top().left(); grid.center(); grid.setPosition(0, -250); grid.addAction(Actions.moveTo(0, 110, 2.0f)); grid.center(); /* ________________________ * |_______Credits__________| * | | | * | | | * | | | * |__________|_____________| * |_________Back___________| */ TextButton title = new TextButton("Credits", Asset.skin); TextButton back = new TextButton("Back", Asset.skin); back.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); Sink.setScene("Menu"); } }); grid.add(title).size(200, 75); grid.row(); grid.add(back).size(200, 75).center(); Sink.addActor(grid); }
From source file:Levels.java
License:Apache License
public Levels() { Table grid = new Table(); grid.setSize(Sink.targetWidth, Sink.targetHeight); grid.setFillParent(true);/* w w w. jav a2 s. co m*/ grid.setPosition(0, 0); grid.top().left(); grid.center(); grid.setPosition(-999, 0); grid.addAction(Actions.moveTo(0, 0, 0.3f)); grid.top().left().pad(10, 10, 10, 10); /* _____________________ * | [1] [2] [3] [4] [5] | * | | * | | * | | * |_____________________| */ for (int i = 0; i < maxLevel; i++) { final int index = i; TextButton btn = new TextButton("" + (i + 1), Asset.skin); if (i > Config.levels() - 0) btn.setVisible(false); if (i % 5 == 0) grid.row(); grid.add(btn).size(100, 100).pad(5, 0, 0, 0).expandX(); btn.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); Game.currentLevel = index; Sink.setScene("Game"); } }); } Sink.addActor(grid); }
From source file:Options.java
License:Apache License
public Options() { Sink.setBackground("title"); Sink.transitionDownToUp();//from w ww . j av a 2 s . c om grid = new Table(); grid.setSize(Sink.targetWidth, Sink.targetHeight); grid.setFillParent(true); grid.setPosition(0, 0); grid.top().left(); grid.center(); float yoffset = Sink.targetHeight - 80; float xcenter = Sink.targetWidth / 2; /* ________________________ * |_______Options__________| * | | | * | | | * | | | * |__________|_____________| * |_________Back___________| */ TextButton title = new TextButton("Options", Asset.skin); title.setSize(200, 75); TextButton back = new TextButton("Back", Asset.skin); back.setSize(200, 75); back.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); Sink.setScene("Menu"); } }); CheckBox soundbtn = new CheckBox(" Sound ", Asset.skin); soundbtn.setChecked(Config.isSound); CheckBox musicbtn = new CheckBox(" Music ", Asset.skin); musicbtn.setChecked(Config.isMusic); CheckBox battbtn = new CheckBox(" Battle ", Asset.skin); battbtn.setChecked(Config.isBattleEnabled()); CheckBox semibtn = new CheckBox(" Semi-Auto ", Asset.skin); semibtn.setChecked(Config.isSemiAutomatic()); CheckBox panbtn = new CheckBox(" PanScroll ", Asset.skin); panbtn.setChecked(Config.usePan); CheckBox dragbtn = new CheckBox(" DragScroll ", Asset.skin); dragbtn.setChecked(Config.useDrag); CheckBox keybtn = new CheckBox(" UseKeyboard ", Asset.skin); keybtn.setChecked(Config.useKeyboard); Slider musicSlider = new Slider(0f, 1f, 0.1f, false, Asset.skin); Slider soundSlider = new Slider(0f, 1f, 0.1f, false, Asset.skin); Sink.addActor(title, xcenter - title.getWidth() + 30, yoffset); Sink.addActor(musicbtn, xcenter - musicbtn.getWidth(), yoffset - 60); Sink.addActor(musicSlider, xcenter + 30, yoffset - 60); Sink.addActor(soundbtn, xcenter - soundbtn.getWidth(), yoffset - 90); Sink.addActor(soundSlider, xcenter + 30, yoffset - 90); Sink.addActor(battbtn, xcenter - battbtn.getWidth(), yoffset - 120); Sink.addActor(panbtn, xcenter + 30, yoffset - 120); Sink.addActor(semibtn, xcenter - semibtn.getWidth(), yoffset - 150); Sink.addActor(dragbtn, xcenter + 30, yoffset - 150); Sink.addActor(dragbtn, xcenter + 30, yoffset - 180); Sink.addActor(back, xcenter - back.getWidth() + 30, 20); }
From source file:ac.uk.dmu.ash.game.screen.CreditsScreen.java
License:Open Source License
/** * Creates a new {@link CreditsScreen}./*from w w w. j a v a2 s . co m*/ * @param game The game instance. * @param assets The game assets */ public CreditsScreen(final Game game, final AssetManager assets) { this.assets = assets; Gdx.input.setInputProcessor(stage); Table fpsTable = createTableWithLabel(assets, "ui_skin", Align.left, (Align.top | Align.left), "fps:"); fpsLabel = (Label) fpsTable.getCells().get(0).getWidget(); stage.addActor(fpsTable); Table creditsTable = createTableWithLabel(assets, "ui_skin", CREDITS); stage.addActor(creditsTable); TextButton backButton = createTextButton(assets, "ui_skin", "Back", new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { dispose(); game.setScreen(new MainMenuScreen(game, assets)); } }); Table buttonsTable = createTable(Align.left | Align.bottom); buttonsTable.add(backButton); stage.addActor(buttonsTable); }
From source file:actors.BasicSkel.java
public BasicSkel(float hlth, float dmg, float x, float y, int lvl, int pth, Stage stg, PlayScreen scrn) { this.setName("skeleton"); level = lvl;// w w w . j av a 2s. c om path = pth; stage = stg; screen = scrn; health = hlth; damage = dmg; slowTimer = -1; slowed = false; reset = false; poisoned = false; notmoving = false; if (damage < 220) texture = new Texture("skelsword1.png"); if (damage < 240 && damage >= 220) texture = new Texture("skelsword2.png"); if (damage >= 240) texture = new Texture("skelsword3.png"); sprite = new Sprite(texture); sprite.setScale(0.65f); setBounds(sprite.getX(), sprite.getY(), sprite.getWidth(), sprite.getHeight()); fireEffect = new ParticleEffect(); fireEffect.load(Gdx.files.internal("fire"), Gdx.files.internal("")); fireEffect.getEmitters().first().setPosition(getX(), getY()); fireballSound = Gdx.audio.newSound(Gdx.files.internal("fireball.wav")); iceEffect = new ParticleEffect(); iceEffect.load(Gdx.files.internal("ice"), Gdx.files.internal("")); iceEffect.getEmitters().first().setPosition(getX(), getY()); poisonEffect = new ParticleEffect(); poisonEffect.load(Gdx.files.internal("poison"), Gdx.files.internal("")); poisonEffect.getEmitters().first().setPosition(getX(), getY()); emptyHealthBar = new Sprite(new Texture("emptyBar.png")); fullHealthBar = new Sprite(new Texture("fullBar.png")); ColorAction red = new ColorAction(); red.setEndColor(Color.RED); red.setDuration(1f); MoveToAction moveOff = new MoveToAction(); moveOff.setPosition(-100, -100); kill = new SequenceAction(red, moveOff); this.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (health != 100000 && abs(screen.player.getX() - getX()) < screen.playerRange && abs(screen.player.getY() - getY()) < screen.playerRange) { if (screen.playerSpell == 1) { health -= screen.playerDamage; stage.addActor( new Fireball(screen.player.getX(), screen.player.getY(), getX() + 16, getY() + 16)); fireballSound.play(0.8f); fireEffect.start(); } if (screen.playerSpell == 2) { health -= screen.playerDamage * 0.75; stage.addActor( new IceBolt(screen.player.getX(), screen.player.getY(), getX() + 16, getY() + 16)); fireballSound.play(0.8f); iceEffect.start(); slowTimer = 3; if (health >= 0) slowed = true; } if (screen.playerSpell == 3) { poisoned = true; stage.addActor( new IceBolt(screen.player.getX(), screen.player.getY(), getX() + 16, getY() + 16)); fireballSound.play(0.8f); poisonEffect.start(); } } if (health <= 0) { poisoned = false; setName("dead"); health = 100000; clearActions(); addAction(kill); screen.skeletonDeath.play(1.0f); screen.addGold(5); } } }); velocity = 70; //Rectangle body = new Rectangle(getX(), getY(), getWidth(), getHeight()); //ScaleByAction sba = new ScaleByAction(); //sba.setAmount(0.25f); assignMovement(x, y); }
From source file:at.hid.tabletopsimulator.screens.About.java
License:Apache License
@Override public void show() { TableTopSimulator.debug(this.getClass().toString(), "creating About screen"); stage = new Stage(new ExtendViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); Gdx.input.setInputProcessor(stage);//from w ww .j a v a 2s . com // creating skin TableTopSimulator.debug(this.getClass().toString(), "creating skin"); skin = TableTopSimulator.assets.get("ui/gui.json", Skin.class); table = new Table(skin); // table.setFillParent(true); // table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // creating heading TableTopSimulator.debug(this.getClass().toString(), "creating heading"); Label lblHeading = new Label(TableTopSimulator.getLangBundle().format("About.lblHeading.text"), skin); final Label lblContent = new Label("http://libgdx.badlogicgames.com/\r\n" + "\r\n" + "libGDX is licensed under the Apache 2 License,\r\n" + "meaning you can use it free of charge, without strings attached in commercial and non-commercial projects.\r\n" + "We love to get (non-mandatory) credit in case you release a game or app using libgdx!", skin, "content"); // creating list final List<String> listAbout = new List<String>(skin, "content"); ArrayList<String> newItems = new ArrayList<String>(); newItems.add("libgdx"); newItems.add("libgdx-utils"); newItems.add("flare gameart"); String[] data = new String[newItems.size()]; listAbout.setItems(newItems.toArray(data)); listAbout.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (listAbout.getSelected().equals("libgdx")) { lblContent.clear(); lblContent.setText("http://libgdx.badlogicgames.com/\r\n" + "\r\n" + "libGDX is licensed under the Apache 2 License,\r\n" + "meaning you can use it free of charge, without strings attached in commercial and non-commercial projects.\r\n" + "We love to get (non-mandatory) credit in case you release a game or app using libgdx!"); } else if (listAbout.getSelected().equals("libgdx-utils")) { lblContent.clear(); lblContent.setText("https://bitbucket.org/dermetfan/libgdx-utils/wiki/Home\r\n" + "\r\n" + "/* Copyright (c) 2014 PixelScientists\r\n" + "*\r\n" + "* The MIT License (MIT)\r\n" + "*\r\n" + "* Permission is hereby granted, free of charge, to any person obtaining a copy of\r\n" + "* this software and associated documentation files (the \"Software\"), to deal in\r\n" + "* the Software without restriction, including without limitation the rights to\r\n" + "* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r\n" + "* the Software, and to permit persons to whom the Software is furnished to do so,\r\n" + "* subject to the following conditions:\r\n" + "*\r\n" + "* The above copyright notice and this permission notice shall be included in all\r\n" + "* copies or substantial portions of the Software.\r\n" + "*\r\n" + "* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n" + "* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r\n" + "* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r\n" + "* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r\n" + "* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r\n" + "* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n" + "*/"); } else if (listAbout.getSelected().equals("flare gameart")) { lblContent.clear(); lblContent.setText("https://github.com/clintbellanger/flare-game\r\n" + "\r\n" + "Flare (the game) is Copyright 2010-2013 Clint Bellanger. Contributors retain copyrights to their original contributions.\r\n" + "\r\n" + "The Flare Engine is released under GPL version 3 or later.\r\n" + "\r\n" + "All of Flare's art and data files are released under CC-BY-SA 3.0. Later versions are permitted.\r\n" + "\r\n" + "The Liberation Sans fonts version 2 are released under the SIL Open Font License, Version 1.1.\r\n" + "\r\n" + "The GNU Unifont font is released under GPL v2, with the exception that embedding the font in a document does not in itself bind that document to the terms of the GPL."); } } }); // creating buttons TableTopSimulator.debug(this.getClass().toString(), "creating buttons"); TextButton btnBack = new TextButton(TableTopSimulator.getLangBundle().format("About.btnBack.text"), skin); btnBack.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { TableTopSimulator.debug(this.getClass().toString(), "switching to Options screen"); ((Game) Gdx.app.getApplicationListener()).setScreen(new Options()); dispose(); } }); btnBack.pad(10); ScrollPane spAboutList = new ScrollPane(null, skin); ScrollPane spAboutContent = new ScrollPane(null, skin); SplitPane splitAbout = new SplitPane(spAboutList, spAboutContent, false, skin); splitAbout.setSplitAmount(0.2f); spAboutList.setWidget(listAbout); spAboutContent.setWidget(lblContent); // building ui TableTopSimulator.debug(this.getClass().toString(), "building ui"); table.add(lblHeading).spaceBottom(100).row(); table.add(splitAbout).spaceBottom(15).width(1200).row(); table.add(btnBack).spaceBottom(15).row(); if (TableTopSimulator.DEBUG) { table.debug(); // draw debug lines splitAbout.debug(); // draw debug lines } stage.addActor(table); }
From source file:ateamproject.kezuino.com.github.render.screens.ClanGamesScreen.java
public ClanGamesScreen(Game game) { super(game);/* w w w. ja v a2s. c o m*/ Table table = new Table(); for (int i = 0; i < 5; i++) { Label clan = new Label("OurClan", skin); Label clanjoin = new Label("8/10", skin); table.add(clan); table.add(clanjoin); table.row(); } TextButton btnBack = new TextButton("< Back", skin); btnBack.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { game.setScreen(new MainScreen(game)); } }); btnBack.setSize(300, 400); table.add(btnBack).colspan(2); table.setPosition(stage.getWidth() / 2, stage.getHeight() / 2); //stage.addActor(btnLogin); stage.addActor(table); backgroundMusic = Assets.getMusicStream("menu.mp3"); }
From source file:ateamproject.kezuino.com.github.render.screens.CreditsScreen.java
public CreditsScreen(Game game) { super(game);//from ww w. j ava 2 s. c o m this.maxNumberOfModifieingThreadsRandom = 40; this.maxNumberOfModifieingThreadsRow = 1; this.numberOfModifieingThreadsRow = new AtomicInteger(0); this.numberOfModifieingThreadsRandom = new AtomicInteger(0); content = new ArrayList<>(); titelLabels = new ArrayList<>(); contentLabels = new ArrayList<>(); titelLabelsModified = new CopyOnWriteArrayList<>(); contentLabelsModified = new CopyOnWriteArrayList<>(); this.titel = "The A - Team"; content.add("* Lead developer: Fatih Taskent*,"); content.add("* Logic/Netcode: Anton van Dijk*,"); content.add("* Logic/Clansystem: Jip van de Vijfeijke*,"); content.add("* Logic/Syncing: Ken van de Linde*,"); content.add("* Graphics/Testing: David Vlijmincx*,"); content.add("* Documentation/Support: Sven Keunen*"); backgroundMusic = Assets.getMusicStream("credits.mp3"); backgroundMusic.setPosition(0); clearOnRenderColor = Color.BLACK; titelFont = new Label.LabelStyle(new BitmapFont(Gdx.files.internal("fonts/credits.fnt"), Gdx.files.internal("fonts/credits_0.png"), false), Color.BLUE); contentFont = new Label.LabelStyle(new BitmapFont(Gdx.files.internal("fonts/credits.fnt"), Gdx.files.internal("fonts/credits_0.png"), false), Color.WHITE); rand = new Random(); Image i = new Image(new Texture("gui/credits.png")); i.setFillParent(true); stage.addActor(i); final Thread head = Thread.currentThread(); TextButton exit = new TextButton("", skin); exit.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { head.interrupt(); game.setScreen(new MainScreen(game)); } }); exit.setColor(Color.DARK_GRAY); exit.setPosition(stage.getWidth() - 35, stage.getHeight() - 30); stage.addActor(exit); createLabels(); placeLabels(); modifyLabels(); }
From source file:ateamproject.kezuino.com.github.render.screens.GameOverScreen.java
public GameOverScreen(Game game, Score score) { super(game);//from w w w.j a va2 s. co m TextButton btnBack = new TextButton("Stoppen", skin); TextButton btnRetry = new TextButton("Opnieuw proberen", skin); Label lblEndGameText = new Label("Game Over\nJe score was:", skin); Label lblScore = new Label(Integer.toString(score.valueOf()), skin); btnBack.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Client.getInstance().send(new PacketKick(PacketKick.KickReasonType.GAME, "Left game.", null)); game.setScreen(new MainScreen(game)); } }); btnRetry.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Client.getInstance().send(new PacketLaunchGame(false, null)); game.setScreen(new GameScreen(game)); } }); lblEndGameText.setPosition(stage.getWidth() / 2 - lblEndGameText.getWidth() / 2, stage.getHeight() - 50); lblScore.setPosition(stage.getWidth() / 2 - lblScore.getWidth() / 2, stage.getHeight() - 80); btnRetry.setSize(200, 40); btnBack.setSize(200, 40); btnRetry.setPosition((stage.getWidth() / 2) - (btnRetry.getWidth() / 2) + (btnBack.getWidth() / 2) + 5, stage.getHeight() / 4 - btnRetry.getHeight() / 2); btnBack.setPosition((stage.getWidth() / 2) - (btnBack.getWidth() / 2) - (btnRetry.getWidth() / 2) - 5, stage.getHeight() / 4 - btnBack.getHeight() / 2); if (Client.getInstance().isHost()) { stage.addActor(btnRetry); } stage.addActor(btnBack); stage.addActor(lblEndGameText); stage.addActor(lblScore); backgroundMusic = Assets.getMusicStream("menu.mp3"); }
From source file:ateamproject.kezuino.com.github.render.screens.GameScreen.java
private void createGui() { // Create pause menu. pauseMenu = new Dialog("Menu", skin); pauseMenu.setKeepWithinStage(false); TextButton bContinue = new TextButton("Doorgaan", skin); bContinue.addListener(new ClickListener() { @Override/* w w w .ja v a 2 s . c o m*/ public void clicked(InputEvent event, float x, float y) { MoveToAction action = Actions.action(MoveToAction.class); action.setPosition(stage.getWidth() / 2 - pauseMenu.getWidth() / 2, stage.getHeight() + pauseMenu.getHeight()); action.setDuration(0.1f); getSession().setPauseMenuShowing(false); pauseMenu.hide(action); } }); pauseMenu.add(bContinue); TextButton bExit = new TextButton("Verlaten", skin); bExit.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { PacketKick packet = new PacketKick(PacketKick.KickReasonType.GAME, "Client afgesloten.", null); Client.getInstance().send(packet); game.setScreen(new MainScreen(game)); } }); pauseMenu.add(bExit); //Create player menu. this.playerMenu = new Dialog("Menu", skin) { }; }