List of usage examples for com.badlogic.gdx.utils.viewport StretchViewport StretchViewport
public StretchViewport(float worldWidth, float worldHeight, Camera camera)
From source file:com.worms.screen.AbstractScreen.java
private void init() { createCamera();/*from w ww. ja v a2s. c o m*/ stage = new Stage(new StretchViewport(Constants.SCREEN_WIDTH * Constants.SCALE, Constants.SCREEN_HEIGHT * Constants.SCALE, camera)); shapeRenderer = new ShapeRenderer(); Gdx.input.setInputProcessor(stage); }
From source file:com.ethereal.rm.game.WorldRenderer.java
private void init() { batch = new SpriteBatch(); //camera = new OrthographicCamera(Constants.WIDTH, Constants.HEIGHT); //viewport = new ScreenViewport(camera); //viewport.apply(); camera = new OrthographicCamera(); viewport = new StretchViewport(Constants.VIEWPORT_WIDTH, Constants.VIEWPORT_HEIGHT, camera); viewport.apply();//from w w w .j a va 2s. c om //camera = new OrthographicCamera(Constants.VIEWPORT_WIDTH, Constants.VIEWPORT_HEIGHT); //camera = new PerspectiveCamera(); //viewport = new ExtendViewport(camera); camera.position.set(camera.viewportWidth / 2, camera.viewportHeight / 2, 0); camera.update(); }
From source file:genuini.screens.AbstractScreen.java
protected AbstractScreen() { super(new StretchViewport(MainGame.V_WIDTH, MainGame.V_HEIGHT, new OrthographicCamera())); prefs = new PreferencesManager(); stage = new Stage(); //batch = new SpriteBatch(); skinManager = new SkinManager(); connectArduino = new Texture("img/arduinoconnected.png"); if (!connected) { //connection with ArduinoLink class arduinoInstance = new ArduinoLink(); try {/*w w w . j a v a2 s.c o m*/ connected = true; arduinoPort = arduinoInstance.initialize(); } catch (UnobtainableComPortException e) { connected = false; System.out.println(e.getMessage()); connectArduino = new Texture("img/errorarduino.png"); } } }
From source file:net.kleinhenz.meteors.GameScreen.java
License:Open Source License
public GameScreen() { super();// w w w .j av a 2 s . c o m OrthographicCamera cam = new OrthographicCamera(WIDTH, HEIGHT); stage = new Stage(new StretchViewport(WIDTH, HEIGHT, cam)); }
From source file:gui.screen.GameScreen.java
/** * Constructor// www . j a v a 2s . co m * @param game */ public GameScreen(Game game, Client client, Server server) { super(game, client, server); this.sendCommand = client.getSendCommand(); this.camera = new OrthographicCamera(); this.stage = new Stage(new StretchViewport(Constants.SCREENWIDTH, Constants.SCREENHEIGHT, camera)); this.mapManager = new MapLoader(camera, sendCommand); this.entityManager = new EntityManager(camera, mapManager, sendCommand, inputHandler); this.processData = new ClientProcessData(entityManager, mapManager); this.mainPlayerHud = new MainPlayerHud(entityManager, game, server, client, mapManager, camera); this.camera.zoom = Constants.DEFAULTZOOM; // Controls if (Constants.ISRUNNINGONSMARTPHONE) { Gdx.input.setInputProcessor(mainPlayerHud.stage); camera.zoom = Constants.SMARTPHONEZOOM; } else { inputHandler.setInputSource(mainPlayerHud.stage); Gdx.input.setCursorCatched(true); } }
From source file:com.badlogic.gdx.tests.ViewportTest1.java
License:Apache License
static public Array<Viewport> getViewports(Camera camera) { int minWorldWidth = 640; int minWorldHeight = 480; int maxWorldWidth = 800; int maxWorldHeight = 480; Array<Viewport> viewports = new Array(); viewports.add(new StretchViewport(minWorldWidth, minWorldHeight, camera)); viewports.add(new FillViewport(minWorldWidth, minWorldHeight, camera)); viewports.add(new FitViewport(minWorldWidth, minWorldHeight, camera)); viewports.add(new ExtendViewport(minWorldWidth, minWorldHeight, camera)); viewports.add(new ExtendViewport(minWorldWidth, minWorldHeight, maxWorldWidth, maxWorldHeight, camera)); viewports.add(new ScreenViewport(camera)); ScreenViewport screenViewport = new ScreenViewport(camera); screenViewport.setUnitsPerPixel(0.75f); viewports.add(screenViewport);/*from w w w . j a v a 2 s .c o m*/ viewports.add(new ScalingViewport(Scaling.none, minWorldWidth, minWorldHeight, camera)); return viewports; }
From source file:awakening.view.menu.Options.java
License:Apache License
/** * Constructor//from w ww. j a va2 s. c om * * @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.Audio.java
License:Apache License
/** * Constructor//from w w w .j av a 2s .co 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.Multiplayer.java
License:Apache License
/** * Constructor//from w w w . ja v a 2 s .co m * * @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.Graphics.java
License:Apache License
/** * Constructor/*from w ww . 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 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); }