Im trying to study a book to learn LibGDX game engine but i have a problem with rendering tiled maps. i think i wrote the same code with book but i couldnt get the same result.
its a simple game with a character and a map. When i rendered my character and background, there was no problem.
its looking like this;
http://i66.tinypic.com/nb97nq.png
but after i add my tmx map screen shows just some part of the game and no map..
i dont know how to fix this.. im really confused.
enter link description here
those are my GameManager and ScreenManager classes, maybe you can figure out what i did wrong..
public class GameManager {
static TiledMap map;
public static TiledMapRenderer renderer;/////
//region paddle
static TextureRegion leftPaddleTexture;
static TextureRegion rightPaddleTexture;
static Sprite leftPaddleSprite;
static Sprite rightPaddleSprite;
public static final float PADDLE_RESIZE_FACTOR = 700f;
public static final float PADDLE_ALPHA = 0.25f;
public static final float PADDLE_HORIZ_POS_FACTOR = 0.02f;
public static final float PADDLE_VERT_POSITION_FACTOR = 0.01f;
//endregion
static AssetManager assetManager;
static TextureAtlas texturePack;
static Bob bob;
static TextureRegion bobSpriteSheet;
public static Sprite backgroundSprite;
public static Texture backgroundTexture;
public static final float BOB_RESIZE_FACTOR = 400f;
public static void loadAssets()
{
assetManager.load(GameConstants.backgroundImage, Texture.class);
assetManager.load(GameConstants.texturePack, TextureAtlas.class);
assetManager.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver()));
assetManager.load(GameConstants.level1, TiledMap.class);
assetManager.finishLoading();
}
public static void initialize(float width, float height)
{
assetManager = new AssetManager();
loadAssets();
map = assetManager.get(GameConstants.level1);
renderer = new OrthogonalTiledMapRenderer(map, GameConstants.unitScale);
GameScreen.camera.setToOrtho(false, 35,20);
GameScreen.camera.update();
renderer.setView(GameScreen.camera);
texturePack = assetManager.get(GameConstants.texturePack);
initializeLeftPaddle(width,height);
initializeRightPaddle(width, height);
bob = new Bob();
bobSpriteSheet = texturePack.findRegion(GameConstants.bobSpriteSheet);
bob.initialize(width,height,bobSpriteSheet);
bob.bobSprite = new Sprite(bobSpriteSheet);
//set the size of the bob
bob.bobSprite.setSize((walkSheet.getRegionWidth()/ANIMATION_FRAME_SIZE) * (width/BOB_RESIZE_FACTOR),
walkSheet.getRegionHeight()*(width/BOB_RESIZE_FACTOR));
bob.bobSprite.setPosition(width / 2f, 0);
backgroundTexture =assetManager.get(GameConstants.backgroundImage);
backgroundSprite = new Sprite(backgroundTexture);
backgroundSprite.setSize(width, height);
}
public static void renderGame(SpriteBatch batch)
{
backgroundSprite.draw(batch);
bob.update();
bob.render(batch);
leftPaddleSprite.draw(batch);
rightPaddleSprite.draw(batch);
}
public static void dispose()
{
assetManager.unload(GameConstants.backgroundImage);
assetManager.clear();
}
public static void initializeLeftPaddle(float width, float height)
{
leftPaddleTexture = texturePack.findRegion(GameConstants.leftPaddleImage);
leftPaddleSprite = new Sprite(leftPaddleTexture);
leftPaddleSprite.setSize(leftPaddleSprite.getWidth()*width/PADDLE_RESIZE_FACTOR,
leftPaddleSprite.getHeight()*width/PADDLE_RESIZE_FACTOR);
leftPaddleSprite.setPosition(width * PADDLE_HORIZ_POS_FACTOR, height * PADDLE_VERT_POSITION_FACTOR);
leftPaddleSprite.setAlpha(PADDLE_ALPHA);
}
public static void initializeRightPaddle(float width, float height)
{
rightPaddleTexture = texturePack.findRegion(GameConstants.rightPaddleImage);
rightPaddleSprite = new Sprite(rightPaddleTexture);
rightPaddleSprite.setSize(rightPaddleSprite.getWidth()*width/PADDLE_RESIZE_FACTOR,
rightPaddleSprite.getHeight()*width/PADDLE_RESIZE_FACTOR);
rightPaddleSprite.setPosition(leftPaddleSprite.getX() + leftPaddleSprite.getWidth() + width * PADDLE_HORIZ_POS_FACTOR,
height * PADDLE_VERT_POSITION_FACTOR);
rightPaddleSprite.setAlpha(PADDLE_ALPHA);
}
}
public class GameScreen implements Screen {
MainGame game;
SpriteBatch batch;
public static OrthographicCamera camera;
public GameScreen(MainGame game)
{
this.game = game;
float height = Gdx.graphics.getHeight();
float width = Gdx.graphics.getWidth();
camera = new OrthographicCamera(width, height);
camera.setToOrtho(false);
batch = new SpriteBatch();
GameManager.initialize(width, height);
Gdx.input.setInputProcessor(new InputManager(camera));
}
#Override
public void show() {
}
#Override
public void render(float delta) {
Gdx.gl.glClearColor(1,1,1,1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.setProjectionMatrix(camera.combined);
GameManager.renderer.render();
batch.begin();
GameManager.renderGame(batch);
batch.end();
}
#Override
public void resize(int width, int height) {
}
#Override
public void pause() {
}
#Override
public void resume() {
}
#Override
public void hide() {
}
#Override
public void dispose() {
batch.dispose();
GameManager.dispose();
}
}
I hope you can help, i searched on site to find same problem but i couldnt..
static TiledMap map;
Let's define the path for the map file in the GameConstants class:
public static final String level1 = "data/maps/level1.tmx";
To queue the map for loading, add these lines of code to the loadAssets() method
of GameManager before the finishedLoading() method's call:
// set the tiled map loader for the assetmanager
assetManager.setLoader(TiledMap.class, new TmxMapLoader(new
InternalFileHandleResolver()));
//load the tiled map
assetManager.load(GameConstants.level1, TiledMap.class);
//blocking method to load all assets
assetManager.finishLoading();
Now, you can get the map instance loaded into the initialize() method:
loadAssets();
// get the map instance loaded
map = assetManager.get(GameConstants.level1);
To render the map, we need a map renderer. As we are using an orthogonal map,
the OrthogonalTiledMapRenderer from the Tiled package is suitable for this
purpose. Declare its instance in the GameManager class:
public static OrthogonalTiledMapRenderer renderer;
// map renderer
Related
I am trying to draw a game character in my "MainGameScreen.java" class from the "germans.java" class when I touch the screen of my phone.Unfortunately my program does not draw the image nor does it give me a warning or an error.
MainGameScreen.java:
import com.daenni.trenchwarfare.mygdx.enteties.germans;
public class MainGameScreen implements Screen, InputProcessor {
Trench_Warfare game;
public SpriteBatch batch;
//Enemies
ArrayList<germans> german;
public MainGameScreen (Trench_Warfare game) {
this.game = game;
batch = new SpriteBatch();
//Enemies
//Initialise Array
german = new ArrayList<germans>();
}
#Override
public void render(float delta) {
//Colours
Gdx.gl.glClearColor(116/255f,102/255f,91/255f,1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
//Create Germans
if (Gdx.input.justTouched()){
german.add(new germans(300));
german.add(new germans(400));
}
//Update Germans
for (germans german : german) {
german.update(delta);
}
game.batch.begin();
//Render Germans
for (germans germans : german) {
germans.render(game.batch);
}
//Background
game.batch.draw(background,0,0);
game.batch.draw(background_links,-background_links.getWidth(),0);
game.batch.draw(background_rechts,background.getWidth(),0);
game.batch.end();
}
This is all of the code that I use to render it in the "MainGameScreen.java" file.
This is my class:
public class germans {
//Set speed
public static final int speed = 25;
//Constant
public static final int default_x = 300;
//Every german uses the same Texture
private static Texture texture;
//Position
float x, y;
public boolean remove = false;
//Create german
public germans(float y) {
this.x = default_x;
this.y = y;
y = 200;
if (texture == null) { //When texture is never loaded
//Set Texture
texture = new Texture("de_s1_default.png");
}
}
public void update (float deltaTime){
x += speed * deltaTime;
}
public void render (SpriteBatch batch) {
batch.draw(texture,x,y);
}
}
Although I am not keen on how libgdx exactly works I am pretty sure first drawing your "germans" and then the background is not what you want.
Try swapping it around:
//Background
game.batch.draw(background,0,0);
game.batch.draw(background_links,-background_links.getWidth(),0);
game.batch.draw(background_rechts,background.getWidth(),0);
//Render Germans
for (germans germans : german) {
germans.render(game.batch);
}
I have problems to draw an image ( Texture ) on a TiledMap. When I try to call batch.draw(mytexture,x,y) the only image displayed is the map below; I tried to search on web a feasible solution, but i have not solved the problem yet..
i
Here's my code
public class GameTest implements ApplicationListener{
private Player player;
private Batch batch;
private MyTexture texture;
private OrthographicCamera camera;
private OrthogonalTiledMapRenderer renderer;
private TiledMap map;
public GameTest() {
//init camera and player
}
#Override
public void create() {
background = new Background();
batch = new SpriteBatch();
texture = new MyTexture();
map = new TmxMapLoader().load(Asset.FIRST_LEVEL);
renderer = new OrthogonalTiledMapRenderer(map);
camera.setToOrtho(false, 1280,512);
renderer.setView(camera);
camera.update();
}
#Override
public void render() {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
background.update(Gdx.graphics.getDeltaTime());
batch.begin();
if(Gdx.input.isKeyJustPressed(Input.Keys.RIGHT)){
game.movePlayer('r', 1);
camera.position.x += 5;
}
camera.update();
renderer.setView(camera);
renderer.render();
// batch.setProjectionMatrix(camera.combined);
batch.draw(texture.getTexture("100"), (player.getPosition().y) * 64, ((7
- player.getPosition().x) * 64));
batch.end();
}
}
Here's MyTexture class. I create a map where I put a String as a key and a Texture corresponding to the image I want to display
public MyTexture() {
....
map.put("100",new Texture(Gdx.files.internal(Asset.PLAYER)));
}
public static final Texture getTexture(String key){
return map.get(key);
}
And here my Asset class, where I create only static field for imgaes path
public class Asset {
public static Map<String, String> map = new HashMap<String,String>();
public static final String FIRST_LEVEL = "levels/firstLevel.tmx";
public static String BACKGROUND = "asset/Background.png";
public static String PLAYER = "asset/Player.png";
...
}
Are you use you want to draw with a unit-scale of 1.0?
When calling the constructor of OrthogonalTiledMapRenderer that only takes a TmxTileMap as parameter the unit scale is defaulted to 1.0.
That means that a single tile takes up the as many world-units as there are pixels in a tile.
Try calling it with 1.0f / your_tile_size_in_pixels.
So if the tiles for your map are 64 by 64 pixels change
renderer = new OrthogonalTiledMapRenderer(map);
to
renderer = new OrthogonalTiledMapRenderer(map, 1.0f / 64.0f);
I'm trying to create simple 2d game in Java with libGDX.
I stuck on creating 2d animation from sprite sheet in PNG file.
I have AbstractScreen class which holds 'things' for every screen.
GameScreen class for drawing my game and Player class with animation code.
Player class is from https://github.com/libgdx/libgdx/wiki/2D-Animation example.
Firstly i created AbstractScreen and MainMenuScreen (based on AbstractScreen). It's works but now i'm trying to create GameScreen with my animated player. Something is wrong because i haven't any error and player is not visible on app screen. How to properly implement sprite sheet animation for skeleton of my app?
My game screen:
class GameScreen extends AbstractScreen {
Player player;
public GameScreen(NinjaGame game) {
super(game);
init();
}
#Override
protected void init() {
initPlayer();
}
private void initPlayer() {
player = new Player();
player.setDebug(true);
stage.addActor(player);
}
#Override
public void render(float delta) {
super.render(delta);
update();
spriteBatch.begin();
stage.draw();
spriteBatch.end();
}
private void update() {
stage.act();
}
}
My AbstractScreen class:
public abstract class AbstractScreen implements Screen {
protected NinjaGame game;
protected Stage stage;
private OrthographicCamera camera;
protected SpriteBatch spriteBatch;
public AbstractScreen(NinjaGame game) {
this.game = game;
createCamera();
/* Stage for actors */
stage = new Stage(new StretchViewport(NinjaGame.SCREEN_WIDTH, NinjaGame.SCREEN_HEIGHT, camera));
/* Batch for sprites */
spriteBatch = new SpriteBatch();
/* Stage takes user inputs */
Gdx.input.setInputProcessor(stage);
init();
}
protected abstract void init();
private void createCamera() {
/* Orthographic means like in CAD drawings */
camera = new OrthographicCamera();
camera.setToOrtho(false, NinjaGame.SCREEN_WIDTH, NinjaGame.SCREEN_HEIGHT);
camera.update();
}
/** Clean screen on black color between render frames */
private void clearScreen() {
Gdx.gl.glClearColor(0, 0, 0, 0);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}
#Override
public void render(float delta) {
clearScreen();
camera.update();
spriteBatch.setProjectionMatrix(camera.combined);
}
}
My player class:
public class Player extends Actor {
private static final int FRAME_COLS = 10, FRAME_ROWS = 1;
Animation<TextureRegion> walkAnimation;
Texture walkSheet;
private final static int STARTING_X = 50;
private final static int STARTING_Y = 50;
public Player(){
createIdleAnimation();
this.setPosition(STARTING_X, STARTING_Y);
}
private void createIdleAnimation() {
walkSheet = new Texture(Gdx.files.internal("sheets/ninja-idle-sheet.png"));
TextureRegion[][] tmp = TextureRegion.split(walkSheet,
walkSheet.getWidth() / FRAME_COLS,
walkSheet.getHeight() / FRAME_ROWS);
TextureRegion[] walkFrames = new TextureRegion[FRAME_COLS * FRAME_ROWS];
int index = 0;
for (int i = 0; i < FRAME_ROWS; i++) {
for (int j = 0; j < FRAME_COLS; j++) {
walkFrames[index++] = tmp[i][j];
}
}
walkAnimation = new Animation<TextureRegion>(0.025f, walkFrames);
}
#Override
public void act(float delta) {
super.act(delta);
}
#Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
}
}
UPDATE 1
NinjaGame class
public class NinjaGame extends Game{
public final static int SCREEN_WIDTH = 800;
public final static int SCREEN_HEIGHT = 480;
public final static String GAME_NAME = "ninja vs zombie";
private boolean paused;
#Override
public void create() {
this.setScreen(new GameScreen(this));
}
}
Make small modification in your Player class so that it draw player Animation frame. You need to overloaded draw method of Actor and draw texture of Player.
public class Player extends Actor {
private static final int FRAME_COLS = 10, FRAME_ROWS = 1;
Animation<TextureRegion> walkAnimation;
Texture walkSheet;
private final static int STARTING_X = 50;
private final static int STARTING_Y = 50;
TextureRegion reg;
float stateTime;
public Player(){
createIdleAnimation();
this.setPosition(STARTING_X, STARTING_Y);
}
private void createIdleAnimation() {
walkSheet = new Texture(Gdx.files.internal("sheets/ninja-idle-sheet.png"));
TextureRegion[][] tmp = TextureRegion.split(walkSheet,
walkSheet.getWidth() / FRAME_COLS,
walkSheet.getHeight() / FRAME_ROWS);
TextureRegion[] walkFrames = new TextureRegion[FRAME_COLS * FRAME_ROWS];
int index = 0;
for (int i = 0; i < FRAME_ROWS; i++) {
for (int j = 0; j < FRAME_COLS; j++) {
walkFrames[index++] = tmp[i][j];
}
}
walkAnimation = new Animation<TextureRegion>(0.025f, walkFrames);
stateTime = 0f;
reg=walkAnimation.getKeyFrame(0);
}
#Override
public void act(float delta) {
super.act(delta);
stateTime += delta;
reg = walkAnimation.getKeyFrame(stateTime,true);
}
#Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
Color color = getColor();
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
batch.draw(reg,getX(),getY(),getWidth()/2,getHeight()/2,getWidth(),getHeight(),getScaleX(),getScaleY(),getRotation());
}
}
EDIT
You need to resize viewport of stage according to your device screen width and height so override resize method and also no need to call begin and end of spritebatch. you're using stage that having own SpriteBatch
class GameScreen extends AbstractScreen {
Player player;
public GameScreen(NinjaGame game) {
super(game);
init();
}
#Override
protected void init() {
initPlayer();
}
private void initPlayer() {
player = new Player();
player.setDebug(true);
stage.addActor(player);
}
#Override
public void render(float delta) {
super.render(delta);
update();
stage.draw();
}
private void update() {
stage.act();
}
#Override
public void resize(int width, int height){
stage.getViewport().update(width,height);
}
}
EDIT 2
private void initPlayer() {
player = new Player();
player.setSize(100,150);
player.setDebug(true);
stage.addActor(player);
}
I have been having a hell of a time trying to get this stage thing figured out. I basically want to draw a background image that fills the entire stage. The image is 1920x1080. The problem is that the image is being drawn at half the width and half of the height that it should be. The application is set to fullscreen and the inside corner of the image is at the center of the screen. I have tested the dimensions of the camera, the viewport, and the stage. All are correct. What am I doing wrong? By the way, I am using a custom game state manager to handle different screens so I apologize for the seemingly needless extra code.
Application.java
public class Application extends ApplicationAdapter {
public static boolean DEBUG = false;
public static final String TITLE = "Hexatan";
public static final int V_WIDTH = 720, V_HEIGHT = 480;
public static final float SCALE = 2.0f;
private GameStateManager gsm;
private OrthographicCamera camera;
private FitViewport vp;
private SpriteBatch batch;
private Stage stage;
private float w, h;
#Override
public void create() {
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
batch = new SpriteBatch();
camera = new OrthographicCamera();
camera.setToOrtho(true, w / SCALE, h / SCALE);
vp = new FitViewport(w, h, camera);
stage = new Stage(vp, batch);
gsm = new GameStateManager(this);
}
#Override
public void render() {
gsm.update(Gdx.graphics.getDeltaTime());
gsm.render();
}
#Override
public void pause() {
}
#Override
public void resume() {
}
#Override
public void dispose() {
gsm.dispose();
batch.dispose();
}
#Override
public void resize(int width, int height) {
gsm.resize((int)(width / SCALE), (int)(height / SCALE));
}
public SpriteBatch getBatch() {
return this.batch;
}
public OrthographicCamera getCamera(){
return this.camera;
}
public Stage getStage(){
return this.stage;
}
}
GameStateManager.java
public class GameStateManager {
private final Application app;
private Stack<GameState> states;
public enum State {
SPLASH, MAINMENU, GAME
}
public GameStateManager(final Application app){
this.app = app;
this.states = new Stack<GameState>();
this.setState(State.GAME);
}
public Application getApp(){
return app;
}
public void update(float delta){
states.peek().update(delta);
}
public void render(){
states.peek().render();
}
public void dispose(){
for(GameState gs : states){
gs.dispose();
}
states.clear();
}
public void resize(int w, int h){
states.peek().resize(w, h);
}
public void setState(State state){
if(states.size() >= 1) {
states.pop().dispose();
}
states.push(getState(state));
}
public GameState getState(State state){
return new GameLoop(this);
}
}
GameState.java
public abstract class GameState {
protected GameStateManager gsm;
protected Application app;
protected SpriteBatch batch;
protected OrthographicCamera camera;
public GameState(GameStateManager gsm){
this.gsm = gsm;
this.app = gsm.getApp();
batch = app.getBatch();
camera = app.getCamera();
}
public void resize(int w, int h){
camera.setToOrtho(true, w, h);
camera.update();
}
public abstract void update(float delta);
public abstract void render();
public abstract void dispose();
}
GameLoop.java
public class GameLoop extends GameState {
private boolean DEV_MODE = true;
private int WIDTH, HEIGHT;
private float mouseX, mouseY;
private Stage stage;
private Game game;
private Application app;
Texture hexture, water, island, robber, highlight, scoreboard;
BitmapFont font = new BitmapFont(Gdx.files.internal("core/assets/Playbill.fnt"));
BitmapFont devFont = new BitmapFont(Gdx.files.internal("core/assets/Arial.fnt"));
public GameLoop(GameStateManager gsm){
super(gsm);
app = gsm.getApp();
WIDTH = Gdx.graphics.getWidth();
HEIGHT = Gdx.graphics.getHeight();
stage = app.getStage();
System.out.println(stage.getCamera().position.x);
Gdx.input.setInputProcessor(stage);
water = new Texture(Gdx.files.internal("core/assets/img/water.png"));
island = new Texture(Gdx.files.internal("core/assets/img/island.png"));
highlight = new Texture(Gdx.files.internal("core/assets/img/highlightVertex.png"));
scoreboard = new Texture(Gdx.files.internal("core/assets/img/scoreboard.png"));
Image waterImg = new Image(new TextureRegionDrawable(new TextureRegion(water)));
waterImg.setWidth(WIDTH);
waterImg.setHeight(HEIGHT);
stage.addActor(waterImg);
}
#Override
public void render() {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
app.getStage().act(Gdx.graphics.getDeltaTime());
app.getStage().draw();
}
#Override
public void update(float delta) {
}
#Override
public void dispose() {
}
#Override
public void resize(int w, int h){
camera.setToOrtho(true, w, h);
app.getStage().getViewport().update(w, h, true);
}
I am having an issue when switching screens in libgdx. I am building a asteroids game clone. So first my MainMenuScreen class (which uses a Fitviewport) is rendered and then I call setScreen() to GameScreen (GameScreen doesn't use a Fitviewport) and that works except that the second screen renders as if its using a Fitviewport. If I resize the second screen then the whole window is used for rendering. Why is this happening? Here are some pictures:
MainMenuScreen class:
GameScreen class after switching screens, the screen has black bars on the side (I colored the boundary in red for you) which I don't want:
I want the GameScreen to use all the window area for rendering, and not have black bars like the MainMenu. I am not using any Fitviewport in GameScreen also.
Here are relevant parts of my MainMenuScreen class:
public class MainMenuScreen implements Screen
{
private static final String TAG = "MainMenu";
private static final int VIRTUAL_WIDTH = 400;
private static final int VIRTUAL_HEIGHT = 400;
MyGdxGame game;
...
public MainMenuScreen(MyGdxGame game)
{
this.game = game;
viewport = new FitViewport(VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
stage = new Stage(viewport);
// Play button listener
btnPlay.addListener( new ClickListener() {
#Override
public void clicked(InputEvent event, float x, float y) {
Gdx.app.log(TAG, "PLAY");
MainMenuScreen.this.game.setScreen(MainMenuScreen.this.game.gameScreen);
};
});
....
}
Here is my GameScreen class:
MyGdxGame game;
OrthographicCamera guiCam;
World world;
WorldRenderer renderer;
public GameScreen(MyGdxGame game, SpriteBatch batch)
{
this.game = game;
guiCam = new OrthographicCamera(400, 400);
guiCam.position.set(400 / 2, 400 / 2, 0);
world = new World();
renderer = new WorldRenderer(game, batch, world);
}
public void draw()
{
GL20 gl = Gdx.gl;
gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
renderer.render();
}
#Override
public void show()
{
world.createLevel();
}
#Override
public void render(float delta)
{
draw();
}
#Override
public void resize(int width, int height)
{
}
#Override
public void pause()
{
}
#Override
public void resume()
{
}
#Override
public void hide()
{
}
#Override
public void dispose()
{
}
The problem is this line of code:
public void resize(int width, int height)
{
viewport.update(width, height, true);
}
Whenever you update the viewport, you are also updating the underlying opengl viewport and this causes the black bars to persist to the second screen (https://github.com/libgdx/libgdx/wiki/Viewports). Thus if you want to reset it back to normal you must use the following line of code in your second screen show() method (https://github.com/libgdx/libgdx/wiki/Scene2d):
Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());