List of usage examples for com.badlogic.gdx.scenes.scene2d Stage Stage
public Stage()
From source file:ateamproject.kezuino.com.github.render.screens.BaseScreen.java
public BaseScreen(Game game) { skin = Assets.getSkin("uiskin.json"); // Bootstrap screen. renderers = new ArrayList<>(); inputs = new InputMultiplexer(); stage = new Stage(); clearOnRender = true;//from w w w. java2 s . c om clearOnRenderColor = Color.valueOf("ffffcc"); // Bootstrap game objects. this.game = game; // Bootstrap input. inputs.addProcessor(stage); inputs.addProcessor(new InputAdapter() { @Override public boolean keyDown(int keycode) { switch (keycode) { case Input.Keys.F2: Gdx.graphics.setDisplayMode(Gdx.graphics.getDesktopDisplayMode().width, Gdx.graphics.getDesktopDisplayMode().height, !Gdx.graphics.isFullscreen()); break; case Input.Keys.F12: // Reset the screen. try { Constructor<? extends BaseScreen> constructor = BaseScreen.this.getClass() .getConstructor(Game.class); final BaseScreen[] screen = { null }; // Reload content. Assets.reloadSkin(false, () -> { try { screen[0] = constructor.newInstance(game); game.setScreen(screen[0]); } catch (InstantiationException | IllegalAccessException | InvocationTargetException ignored) { } if (screen[0] != null) { // Show dialog. new Dialog("Reload", screen[0].skin) { { text("Skin was reloaded."); button("Oke"); } }.show(screen[0].stage); } }); } catch (NoSuchMethodException e) { // Show dialog. new Dialog("Error", skin) { { text("Couldn't reload the skin."); button("Oke"); } }.show(stage); } return true; } return super.keyDown(keycode); } }); Gdx.input.setInputProcessor(inputs); // Bootstrap view. camera = stage.getCamera(); viewport = new FitViewport(stage.getWidth(), stage.getHeight(), camera); stage.setViewport(viewport); }
From source file:awakening.view.menu.Audio.java
License:Apache License
/** * Constructor/*from w w w . j ava 2 s . c o m*/ * * @param game Tower Awakening's Game * @param sound Main menu's music * @param effect Button's effect */ public Audio(TAGame game, Music sound, Sound effect) { this.game = game; this.sound = sound; this.effect = effect; stage = new Stage(); try { if (game.getLanguage().equals("ENGLISH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_en_EN", locales[0]); } else if (game.getLanguage().equals("FRENCH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_fr_FR", locales[1]); } else if (game.getLanguage().equals("ITALIAN")) { language = ResourceBundle.getBundle("awakening.view.menu.res_it_IT", locales[2]); } else { language = ResourceBundle.getBundle("awakening.view.menu.res", locales[0]); } } catch (java.util.MissingResourceException e) { System.out.println("yolo"); } ///Viewport camera = new OrthographicCamera(); view = new StretchViewport(Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getWidth(), camera); ///Background background = new Texture(Gdx.files.internal("img/menu/Background-2.png")); batch = new SpriteBatch(); ///Skin skin = new Skin(Gdx.files.internal("uiskin.json")); ///Title title = new Label(language.getString("button_audio"), skin); ///Widgets Background widgetsBackground = new Image(new Texture(Gdx.files.internal("img/widget/bg widgets.png"))); ///Back Button btnBack = new TextButton(language.getString("button_back"), skin); ///Music Slider sliderMusic = new Slider(0, 10, 1, false, skin); ///Music Label musicLabel = new Label(language.getString("label_music_volume"), skin); ///Sound Slider sliderEffects = new Slider(0, 10, 1, false, skin); ///Sound Label soundLabel = new Label(language.getString("label_effect_volume"), skin); }
From source file:awakening.view.menu.Controls.java
License:Apache License
/** * Constructor/* ww w . j a v a 2 s . com*/ * * @param game Tower Awakening's Game * @param sound Main menu's music * @param effect Button's effect */ public Controls(TAGame game, Music sound, Sound effect) { this.game = game; this.sound = sound; this.effect = effect; stage = new Stage(); ///Language try { if (game.getLanguage().equals("ENGLISH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_en_EN", locales[0]); } else if (game.getLanguage().equals("FRENCH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_fr_FR", locales[1]); } else if (game.getLanguage().equals("ITALIAN")) { language = ResourceBundle.getBundle("awakening.view.menu.res_it_IT", locales[2]); } else { language = ResourceBundle.getBundle("awakening.view.menu.res", locales[0]); } } catch (java.util.MissingResourceException e) { System.out.println("yolo"); } ///Viewport camera = new OrthographicCamera(); view = new StretchViewport(Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getWidth(), camera); ///Background background = new Texture(Gdx.files.internal("img/menu/Background-4.png")); batch = new SpriteBatch(); ///Skin skin = new Skin(Gdx.files.internal("uiskin.json")); ///Title title = new Label(language.getString("label_controls_menu"), skin); ///Background Widget widgetsBackground = new Image(new Texture(Gdx.files.internal("img/widget/window_large.png"))); ///Langage Checkbox lblLangage = new Label(language.getString("label_language"), skin); String[] lang = { "English", "Francais", "Italiano" }; slbLangages = new SelectBox<String>(skin); slbLangages.setItems(lang); ///Back Button btnBack = new TextButton(language.getString("button_back"), skin); btnBack.setName(language.getString("button_back")); ///Right Button lblRight = new Label(language.getString("label_right"), skin); btnRight = new TextButton(game.getRightKey(), skin); btnRight.setName("right"); ///Left Button lblLeft = new Label(language.getString("label_left"), skin); btnLeft = new TextButton(game.getLeftKey(), skin); btnLeft.setName("left"); ///Down Button lblDown = new Label(language.getString("label_down"), skin); btnDown = new TextButton(game.getDownKey(), skin); btnDown.setName("down"); ///Up Button lblUp = new Label(language.getString("label_up"), skin); btnUp = new TextButton(game.getUpKey(), skin); btnUp.setName("up"); ///Zoom In Button lblZoomIn = new Label(language.getString("label_zoom_in"), skin); btnZoomIn = new TextButton(game.getZoomInKey(), skin); btnZoomIn.setName("zoom+"); ///Zoom Out Button lblZoomOut = new Label(language.getString("label_zoom_out"), skin); btnZoomOut = new TextButton(game.getZoomOutKey(), skin); btnZoomOut.setName("zoom-"); Gdx.input.setInputProcessor(stage); }
From source file:awakening.view.menu.Graphics.java
License:Apache License
/** * Constructor// ww w . ja va 2s . c o m * * @param game Tower Awakening's Game * @param sound Main menu's music * @param effect Button's effect */ public Graphics(TAGame game, Music sound, Sound effect) { this.game = game; this.sound = sound; this.effect = effect; stage = new Stage(); try { if (game.getLanguage().equals("ENGLISH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_en_EN", locales[0]); } else if (game.getLanguage().equals("FRENCH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_fr_FR", locales[1]); } else if (game.getLanguage().equals("ITALIAN")) { language = ResourceBundle.getBundle("awakening.view.menu.res_it_IT", locales[2]); } else { language = ResourceBundle.getBundle("awakening.menu.res", locales[0]); } } catch (java.util.MissingResourceException e) { System.out.println("yolo"); } ///Viewport camera = new OrthographicCamera(); view = new StretchViewport(Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getWidth(), camera); ///Background background = new Texture(Gdx.files.internal("img/menu/Background-3.png")); batch = new SpriteBatch(); ///Skin skin = new Skin(Gdx.files.internal("uiskin.json")); ///Title title = new Label(language.getString("label_graphics_menu"), skin); ///Widgets Background widgetsBackground = new Image(new Texture(Gdx.files.internal("img/widget/bg widgets.png"))); ///Back Button btnBack = new TextButton(language.getString("button_back"), skin); ///CheckBox Fullscreen cbxFullscreen = new CheckBox(language.getString("label_fullscreen"), skin); ///SelectBox Resolution slbResolutions = new SelectBox<TAScreenSize>(skin); ///Label Resolution lblResolution = new Label(language.getString("label_resolution"), skin); }
From source file:awakening.view.menu.MainMenu.java
License:Apache License
/** * Constructor/* w ww .j a v a 2 s. co m*/ * * @param game Tower Awakening's Game */ public MainMenu(TAGame game) { super(); this.game = game; this.music = Gdx.audio.newMusic(Gdx.files.internal("sound/menu/Dark Intro_0.ogg")); effect = Gdx.audio.newSound(Gdx.files.internal("sound/widget/Button Sound 53.wav")); stage = new Stage(); ///Language try { if (game.getLanguage().equals("ENGLISH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_en_EN", locales[0]); } else if (game.getLanguage().equals("FRENCH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_fr_FR", locales[1]); } else if (game.getLanguage().equals("ITALIAN")) { language = ResourceBundle.getBundle("awakening.view.menu.res_it_IT", locales[2]); } else { language = ResourceBundle.getBundle("awakening.view.menu.res", locales[0]); } } catch (java.util.MissingResourceException e) { System.out.println("yolo"); } ///Viewport camera = new OrthographicCamera(); view = new StretchViewport(Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getWidth(), camera); ///Background background = new Texture(Gdx.files.internal("img/menu/background-menu.png")); batch = new SpriteBatch(); ///Skin skin = new Skin(Gdx.files.internal("uiskin.json")); font = new BitmapFont(Gdx.files.internal("font/space.fnt")); style = new LabelStyle(font, Color.WHITE); ///Title title = new Label(language.getString("label_main_title"), skin); title.setStyle(style); ///Widgets Background widgetsBackground = new Image(new Texture(Gdx.files.internal("img/widget/bg widgets.png"))); ///Exit Button btnExit = new TextButton(language.getString("button_exit"), skin); ///Options Button btnOptions = new TextButton(language.getString("button_options"), skin); ///Multiplayer Button btnMultiplayer = new TextButton(language.getString("button_multiplayer"), skin); ///Solo Button btnSolo = new TextButton(language.getString("button_solo"), skin); }
From source file:awakening.view.menu.MainMenu.java
License:Apache License
/** * Constructor/*from w w w .j a v a 2 s. c o m*/ * * @param game Tower Awakening's Game * @param sound Main menu's music * @param effect Button's effect */ public MainMenu(TAGame game, Music sound, Sound effect) { this.game = game; this.music = sound; this.effect = effect; stage = new Stage(); ///Language try { if (game.getLanguage().equals("ENGLISH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_en_EN", locales[0]); } else if (game.getLanguage().equals("FRENCH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_fr_FR", locales[1]); } else if (game.getLanguage().equals("ITALIAN")) { language = ResourceBundle.getBundle("awakening.view.menu.res_it_IT", locales[2]); } else { language = ResourceBundle.getBundle("awakening.view.menu.res", locales[0]); } } catch (java.util.MissingResourceException e) { System.out.println("yolo"); } ///Viewport camera = new OrthographicCamera(); view = new StretchViewport(Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getWidth(), camera); ///Background background = new Texture(Gdx.files.internal("img/menu/background-menu.png")); batch = new SpriteBatch(); ///Skin skin = new Skin(Gdx.files.internal("uiskin.json")); font = new BitmapFont(Gdx.files.internal("font/space.fnt")); style = new LabelStyle(font, Color.WHITE); ///Title title = new Label(language.getString("label_main_title"), skin); title.setStyle(style); ///Widgets Background widgetsBackground = new Image(new Texture(Gdx.files.internal("img/widget/bg widgets.png"))); ///Exit Button btnExit = new TextButton(language.getString("button_exit"), skin); ///Options Button btnOptions = new TextButton(language.getString("button_options"), skin); ///Multiplayer Button btnMultiplayer = new TextButton(language.getString("button_multiplayer"), skin); ///Solo Button btnSolo = new TextButton(language.getString("button_solo"), skin); }
From source file:awakening.view.menu.MapSelection.java
License:Apache License
/** * Constructor/*from www . j av a2 s .c om*/ * * @param game Tower Awakening's Game * @param sound Main menu's music * @param effect Button's effect */ public MapSelection(final TAGame game, Music sound, final Sound effect) { this.game = game; this.sound = sound; this.effect = effect; stage = new Stage(); try { File monsterDirectory = Gdx.files.internal("Field").file(); for (File ft : monsterDirectory.listFiles()) { if (ft.isFile()) if (ft.getName().endsWith("mta")) { Field newMap = Field.loadTower(ft); if (newMap != null) mapListes.add(newMap); } } if (game.getLanguage().equals("ENGLISH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_en_EN", locales[0]); } else if (game.getLanguage().equals("FRENCH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_fr_FR", locales[1]); } else if (game.getLanguage().equals("ITALIAN")) { language = ResourceBundle.getBundle("awakening.view.menu.res_it_IT", locales[2]); } else { language = ResourceBundle.getBundle("awakening.view.menu.res", locales[0]); } } catch (java.util.MissingResourceException e) { System.out.println("yolo"); } ///Viewport camera = new OrthographicCamera(); view = new StretchViewport(Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getWidth(), camera); ///Background background = new Texture(Gdx.files.internal("img/menu/Background-2.png")); batch = new SpriteBatch(); ///Skin skin = new Skin(Gdx.files.internal("uiskin.json")); ///Title title = new Label(language.getString("label_map_selection"), skin); ///Widgets Background widgetsBackground = new Image(new Texture(Gdx.files.internal("img/widget/window_selection.png"))); widgetsBackground.setSize(Gdx.app.getGraphics().getWidth() - Gdx.app.getGraphics().getWidth() / 8, Gdx.app.getGraphics().getHeight() - Gdx.app.getGraphics().getHeight() / 8); ///Back Button btnBack = new TextButton(language.getString("button_back"), skin); btnJeu = new TextButton(language.getString("button_game"), skin); ///Next Button Texture t1 = new Texture(Gdx.files.internal("img/widget/arrow_hover_right.png")); Texture t2 = new Texture(Gdx.files.internal("img/widget/arrow_right.png")); ImageButtonStyle style1 = new ImageButtonStyle( new TextureRegionDrawable(new TextureRegion(t1, 0, 0, t1.getWidth(), t1.getHeight())), new TextureRegionDrawable(new TextureRegion(t2, 0, 0, t2.getWidth(), t2.getHeight())), new TextureRegionDrawable(new TextureRegion(t1, 0, 0, t1.getWidth(), t1.getHeight())), new TextureRegionDrawable(new TextureRegion(t2, 0, 0, t2.getWidth(), t2.getHeight())), new TextureRegionDrawable(new TextureRegion(t1, 0, 0, t1.getWidth(), t1.getHeight())), new TextureRegionDrawable(new TextureRegion(t2, 0, 0, t2.getWidth(), t2.getHeight()))); btnNext = new ImageButton(style1); ///Previous Button Texture t3 = new Texture(Gdx.files.internal("img/widget/arrow_hover_left.png")); Texture t4 = new Texture(Gdx.files.internal("img/widget/arrow_left.png")); ImageButtonStyle style2 = new ImageButtonStyle( new TextureRegionDrawable(new TextureRegion(t3, 0, 0, t3.getWidth(), t3.getHeight())), new TextureRegionDrawable(new TextureRegion(t4, 0, 0, t4.getWidth(), t4.getHeight())), new TextureRegionDrawable(new TextureRegion(t3, 0, 0, t3.getWidth(), t3.getHeight())), new TextureRegionDrawable(new TextureRegion(t4, 0, 0, t4.getWidth(), t4.getHeight())), new TextureRegionDrawable(new TextureRegion(t3, 0, 0, t3.getWidth(), t3.getHeight())), new TextureRegionDrawable(new TextureRegion(t4, 0, 0, t4.getWidth(), t4.getHeight()))); btnPrevious = new ImageButton(style2); maps = new ArrayList<BoutonShop>(); }
From source file:awakening.view.menu.Multiplayer.java
License:Apache License
/** * Constructor/* ww w.j a v a2s.com*/ * * @param game Tower Awakening's Game * @param sound Main menu's music * @param effect Button's effect */ public Multiplayer(TAGame game, Music sound, Sound effect) { this.game = game; this.sound = sound; this.effect = effect; stage = new Stage(); try { if (game.getLanguage().equals("ENGLISH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_en_EN", locales[0]); } else if (game.getLanguage().equals("FRENCH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_fr_FR", locales[1]); } else if (game.getLanguage().equals("ITALIAN")) { language = ResourceBundle.getBundle("awakening.view.menu.res_it_IT", locales[2]); } else { language = ResourceBundle.getBundle("awakening.view.menu.res", locales[0]); } } catch (java.util.MissingResourceException e) { System.out.println("yolo"); } ///Viewport camera = new OrthographicCamera(); view = new StretchViewport(Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getWidth(), camera); ///Background background = new Texture(Gdx.files.internal("img/menu/Background-2.png")); batch = new SpriteBatch(); ///Skin skin = new Skin(Gdx.files.internal("uiskin.json")); ///Title title = new Label(language.getString("button_multiplayer"), skin); ///Widgets Background widgetsBackground = new Image(new Texture(Gdx.files.internal("img/widget/window_large.png"))); ///Back Button btnBack = new TextButton(language.getString("button_back"), skin); ///Server List btnJoin = new TextButton(language.getString("button_join"), skin); btnCreate = new TextButton(language.getString("button_create"), skin); ///Port TextField tfdPort = new TextField("", skin); ///Port TextField tfdIp = new TextField("", skin); }
From source file:awakening.view.menu.Options.java
License:Apache License
/** * Constructor// w w w . j a v a2 s .c o m * * @param game Tower Awakening's Game * @param sound Main menu's music * @param effect Button's effect */ public Options(TAGame game, Music sound, Sound effect) { this.game = game; this.sound = sound; this.effect = effect; stage = new Stage(); //Language try { if (game.getLanguage().equals("ENGLISH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_en_EN", locales[0]); } else if (game.getLanguage().equals("FRENCH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_fr_FR", locales[1]); } else if (game.getLanguage().equals("ITALIAN")) { language = ResourceBundle.getBundle("awakening.view.menu.res_it_IT", locales[2]); } else { language = ResourceBundle.getBundle("awakening.view.menu.res", locales[0]); } } catch (java.util.MissingResourceException e) { System.out.println("yolo"); } ///Viewport camera = new OrthographicCamera(); view = new StretchViewport(Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getWidth(), camera); ///Background background = new Texture(Gdx.files.internal("img/menu/Background-1.png")); batch = new SpriteBatch(); ///Skin skin = new Skin(Gdx.files.internal("uiskin.json")); ///Title title = new Label(language.getString("label_options_menu"), skin); ///Background Widget widgetsBackground = new Image(new Texture(Gdx.files.internal("img/widget/bg widgets.png"))); ///Back Button btnBack = new TextButton(language.getString("button_back"), skin); ///Graphics Button btnGraphics = new TextButton(language.getString("button_graphics"), skin); ///Controls Button btnControls = new TextButton(language.getString("button_controls"), skin); ///Audio Button btnAudio = new TextButton(language.getString("button_audio"), skin); }
From source file:awakening.view.menu.WaitingRoomClient.java
License:Apache License
/** * Constructor/*from www.ja v a 2s. c o m*/ * * @param game Tower Awakening's Game * @param sound Main menu's music * @param effect Button's effect */ public WaitingRoomClient(TAGame game, Music sound, Sound effect) { this.game = game; this.sound = sound; this.effect = effect; try { socket = new Socket(InetAddress.getByName(null), 1134); input = new BufferedReader(new InputStreamReader(socket.getInputStream())); output = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())), true); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } th1 = new Thread(new Runnable() { @Override public void run() { try { while (true) { String messagePlayer = input.readLine(); if (messagePlayer != null) { TextArea t = new TextArea(messagePlayer, skin); t.setTouchable(Touchable.disabled); chatBox.row(); chatBox.add(t).height(75).width(500); } } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); th1.start(); stage = new Stage(); try { if (game.getLanguage().equals("ENGLISH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_en_EN", locales[0]); } else if (game.getLanguage().equals("FRENCH")) { language = ResourceBundle.getBundle("awakening.view.menu.res_fr_FR", locales[1]); } else if (game.getLanguage().equals("ITALIAN")) { language = ResourceBundle.getBundle("awakening.view.menu.res_it_IT", locales[2]); } else { language = ResourceBundle.getBundle("awakening.view.menu.res", locales[0]); } } catch (java.util.MissingResourceException e) { System.out.println("yolo"); } ///Viewport camera = new OrthographicCamera(); view = new StretchViewport(Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getWidth(), camera); ///Background background = new Texture(Gdx.files.internal("img/menu/Background-2.png")); batch = new SpriteBatch(); ///Skin skin = new Skin(Gdx.files.internal("uiskin.json")); ///Title title = new Label(language.getString("label_waiting_room"), skin); ///Widgets Background widgetsBackground = new Image(new Texture(Gdx.files.internal("img/widget/window_selection.png"))); widgetsBackground.setSize(Gdx.app.getGraphics().getWidth() - Gdx.app.getGraphics().getWidth() / 8, Gdx.app.getGraphics().getHeight() - Gdx.app.getGraphics().getHeight() / 8); ///Back Button btnBack = new TextButton(language.getString("button_back"), skin); ///ChatBox chatBox = new Table(); scroll = new ScrollPane(chatBox); scroll.setForceScroll(false, true); scroll.setFlickScroll(true); scroll.setOverscroll(false, false); ///Message message = new TextField("", skin); btnSend = new TextButton(language.getString("button_send"), skin); }