Home Game Development java – libGDX using Stage and Actor produces different camera angles on desktop and Android Phone

java – libGDX using Stage and Actor produces different camera angles on desktop and Android Phone

0
java – libGDX using Stage and Actor produces different camera angles on desktop and Android Phone

[ad_1]

libGDX using Stage and Actor produces different camera angles on desktop and Android Phone.

Here are pictures demonstrating the problem: http://brandonyuh.minus.com/mFpdTSgN17VUq

On the desktop version, the image takes up most all the screen. On the Android phone it only takes up a bit of the screen.

Here’s the code (not my actual project but I isolated the problem):

package com.me.mygdxgame2;
import com.badlogic.gdx.*;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.*;
import com.badlogic.gdx.scenes.scene2d.*;
public class MyGdxGame2 implements ApplicationListener {
    private Stage stage;
    public void create() {
        stage = new Stage();
        stage.addActor(new ActorHi());
    }
    public void render() {
        Gdx.gl.glClearColor(0, 1, 0, 1);
        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
        stage.draw();
    }
    public void dispose() {}
    public void resize(int width, int height) {}
    public void pause() {}
    public void resume() {}
    public class ActorHi extends Actor {
        private Sprite sprite;
        public ActorHi() {
            Texture texture = new Texture(Gdx.files.internal("data/hi.png"));
            texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
            sprite = new Sprite(new TextureRegion(texture, 0, 0, 128, 128));
            sprite.setBounds(0, 0, 300.0f, 300.0f);
        }
        public void draw(SpriteBatch batch, float parentAlpha) {
            sprite.draw(batch);
        }
    }
}

Why does this happen?

[ad_2]