Example usage for com.badlogic.gdx.utils.viewport Viewport setWorldSize

List of usage examples for com.badlogic.gdx.utils.viewport Viewport setWorldSize

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils.viewport Viewport setWorldSize.

Prototype

public void setWorldSize(float worldWidth, float worldHeight) 

Source Link

Usage

From source file:com.mk.apps.superm.mtx.AbstractScreen.java

License:Apache License

/**
 * Construct the screen//from   w w w  .  jav  a  2  s.  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(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   ww  w. ja  va 2  s  . c om
 * <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();
}