Example usage for com.badlogic.gdx.scenes.scene2d Stage getViewport

List of usage examples for com.badlogic.gdx.scenes.scene2d Stage getViewport

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d Stage getViewport.

Prototype

public Viewport getViewport() 

Source Link

Usage

From source file:com.suiton2d.editor.ui.render.RenderAdapter.java

License:Open Source License

@Override
public void resize(int width, int height) {
    Scene scene = sceneManager.getCurrentScene();
    if (scene != null) {
        Stage stage = scene.getStage();
        Viewport viewport = stage.getViewport();
        viewport.update(width, height);/*from   w w w. jav a  2 s. c  o m*/
    }
}

From source file:Libraries.Button.java

public Button(Stage scene, int type) {
    Texture tempText;/*from  w  w  w .  j  av a2s . co m*/
    int posX, posY;
    posX = posY = 0;
    switch (type) {
    case 0:
        tempText = Main.MANAGER.get("gameover.png", Texture.class);

        break;
    case 1:
        tempText = Main.MANAGER.get("start.png", Texture.class);
        posX = scene.getViewport().getViewportWidth() / 2 - 100;
        System.out.println(scene.getViewport().getViewportHeight());
        posY = scene.getViewport().getViewportHeight() - 200;
        break;
    case 2:
        tempText = Main.MANAGER.get("quit.png", Texture.class);
        posX = scene.getViewport().getViewportWidth() / 2 - 100;
        posY = scene.getViewport().getViewportHeight() - 400;
        break;
    default:
        tempText = null;
    }

    _button = new TextureRegion(tempText, 0, 0, tempText.getWidth(), tempText.getHeight());

    setPosition(posX, posY);
    setSize(tempText.getWidth(), tempText.getHeight());
    _touched = false;

    addListener(new InputListener() {

        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            _touched = true;
            return false;
        }
    });
}