0
votes

I am working on libGDX project. I want to set the screen size to 480x800. In desktop version we can use

config.Width() = 480;
config.Height() = 800;

in DesktopLauncher class. It works on desktop, but not on android. I want to set the screen at 480x800 so it will work on android device as well. Right now my screen looks like following. enter image description here

How can I solve this issue? Note: I have already used following code

    OrthographicCamera camera; 
camera = new OrthographicCamera();
 camera.setToOrtho(false, GameInfo.SCREEN_WIDTH, GameInfo.SCREEN_HEIGHT);
game.getBatch().setProjectionMatrix(game.getCamera().combined);

It works, but it's not a permanant solution. Because, if I want to move the screen I need to set up another orthographicCamera and that doesn't work out at all. Is there any command like there is in DesktopLauncher class?

1
Not clear on what you're actually asking, and why you're bringing up the DesktopLauncher class. That has nothing to do with moving the view, only setting the dimensions of the window. Since phone games are always full-screen, that's irrelevant. You can't change the dimensions of the physical hardware of the phone or its resolution. - Tenfour04
Actually if I play it on desktop simulator then using the config.width works(i.e. screen becomes full size. covers entire emulator area). But as can be seen in the photo, the same thing doesn't happen for connected android device. As you can see the image doesn't get resized automatically. For that reason I was asking. - hyperCoder

1 Answers

0
votes

If you want to move screen, you can change the position of your camera.

Sprite man;

private void render(float delta){

    //...
    camera.translate(man.getX(),man.getY());
    camera.update();

}