List of usage examples for com.badlogic.gdx.utils.viewport Viewport Viewport
Viewport
From source file:com.mk.apps.superm.mtx.AbstractScreen.java
License:Apache License
/** * Construct the screen//from ww w .j a va 2 s . co m * <p> * -Gives reference to game<br> * -Creates stage<br> * -Centers camera of stage<br> * -Sets Input processor for stage (Gdx.input.setInputProcessor(stage))<br> * -Calls setUpScreenElements (Good place the set views and iniatial * elements) * * @param game * the main game class * @param screenName * the name of the screen * */ public AbstractScreen(Game game, String screenName) { super(); this.game = game; if (screenName.equals("")) { this.screenName = "Untitled Screen"; } else { this.screenName = screenName; } // Viewport viewPort = new Viewport() { }; viewPort.setWorldSize(AppSettings.SCREEN_W, AppSettings.SCREEN_H); stage = new Stage(viewPort); // stage = new Stage(AppSettings.SCREEN_W, AppSettings.SCREEN_H, false); stage.getCamera().position.set(AppSettings.SCREEN_W / 2, AppSettings.SCREEN_H / 2, 0); // Receive inputs from stage Gdx.input.setInputProcessor(stage); // INFO LOG MtxLogger.log(logActive, true, logTag, "SCREEN CONSTRUCTED: " + getScreenName()); }
From source file:com.mk.apps.superm.mtx.screen.AbstractScreen.java
License:Apache License
/** * Construct the screen/*from w ww . j ava 2s. c o m*/ * <p> * -Gives reference to game<br> * -Creates stage<br> * -Centers camera of stage<br> * -Sets Input processor for stage (Gdx.input.setInputProcessor(stage))<br> * -Calls setUpScreenElements (Good place the set views and iniatial * elements) * * @param game * the main game class * @param screenName * the name of the screen * */ public AbstractScreen(AbstractGame game, String screenName) { super(); // this.game = game; this.screenName = screenName; // if (!AppSettings.isAppSettingSet) { MtxLogger.log(logActive, true, logTag, "WARNING!: " + "AppSettings.setUp() not called anywhere, Stage size will be 0,0"); } // Viewport viewPort = new Viewport() { }; viewPort.setWorldSize(AppSettings.SCREEN_W, AppSettings.SCREEN_H); stage = new Stage(); // stage = new Stage(AppSettings.SCREEN_W, AppSettings.SCREEN_H, false); stage.getCamera().position.set(AppSettings.SCREEN_W / 2, AppSettings.SCREEN_H / 2, 0); // Receive inputs from stage Gdx.input.setInputProcessor(stage); // INFO LOG MtxLogger.log(logActive, true, logTag, "Scene2D Stage Constructed: " + AppSettings.SCREEN_W + " - " + AppSettings.SCREEN_H); MtxLogger.log(logActive, true, logTag, "SCREEN CONSTRUCTED: " + getScreenName()); // setOpenGLClearColor(0, 0, 0, 1); setBackBackButton(); }
From source file:com.bladecoder.engine.ui.retro.RetroSceneScreen.java
License:Apache License
public RetroSceneScreen() { screenViewport = new SceneFitViewport(); worldViewport = new Viewport() { // This is the World Viewport. It is like a ScreenViewport but the // camera is the same that the screenViewport; @Override//from w w w. j av a2 s . c om public void apply(boolean centerCamera) { HdpiUtils.glViewport(getScreenX(), getScreenY(), getScreenWidth(), getScreenHeight()); getCamera().viewportWidth = getScreenWidth(); getCamera().viewportHeight = getScreenHeight(); if (centerCamera) getCamera().position.set(getScreenWidth() / 2, getScreenHeight() / 2, 0); getCamera().update(); } }; worldViewport.setCamera(screenViewport.getCamera()); }