私はグラフィックを表示するためにbox2Dレンダリングを使用しています(テクスチャを使用しようとしましたが、まったく同じ結果になります)画面サイズが普通のように画面に収まらない
public void render()
{
long startTime = System.nanoTime();
world.step(Gdx.app.getGraphics().getDeltaTime(), 3, 3);
float updateTime = (System.nanoTime() - startTime)/1000000000.0f;
startTime = System.nanoTime();
float renderTime = (System.nanoTime() - startTime)/1000000000.0f;
GL10 gl = Gdx.app.getGraphics().getGL10();
camera.update();
camera.apply(gl);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
batch.setProjectionMatrix(camera.combined);
renderer.render(world, camera.combined);
batch.begin();
font.setScale(0.020f);
font.draw(batch, "fps:" + Gdx.graphics.getFramesPerSecond() + ", update: " + updateTime + ", render: " + renderTime, 0,
20);
batch.end();
}
これは、デスクトップのバージョンで絶対に問題なく動作します。
あなたはそのトップ部分にのみ取るに押しつぶされて見ることができるように:私は自分の携帯電話上でそれを起動したときしかし、私は私が望むものではありませんこれは、これを取得
画面の
libgdxにバグはありますか、何か不足していますか?
編集:コンプリート作成コード:
Vector2 pouchPos = new Vector2(0, -12);
slingshotListener = new SlingshotListener(pouchPos);
batch = new SpriteBatch();
camera = new OrthographicCamera(32, 48);
Gdx.input.setInputProcessor(slingshotListener);
font = new BitmapFont();
renderer = new Box2DDebugRenderer();
world = new World(new Vector2(0, -10), true);
BodyDef bd = new BodyDef();
ground = world.createBody(bd);
EdgeShape shape = new EdgeShape();
shape.set(new Vector2(-16, -20), new Vector2(16, -20));
FixtureDef fd = new FixtureDef();
fd.shape = shape;
ground.createFixture(fd);
shape.dispose();
Misc.createLine(new Vector2(-3, -16), pouchPos, camera, world).setSensor(true);
Misc.createLine(new Vector2(3, -16), pouchPos, camera, world).setSensor(true);
pic = new Texture(Gdx.files.internal("pong/ball.png"));
どのようにあなたのビューポートとカメラの位置を設定していますか? –
私はそれがディスプレイの解像度の違いによって2つの表示が異なって見えると思います。この質問に対する答えは、あなたの設定が少し違っても(libgdxの2Dシーングラフを使っているようには見えませんが)、助けになるかもしれません:http://stackoverflow.com/q/9198932/324625要点は、ビューポートを中央に配置してカメラを配置する必要があることです。これらは 'resize()'を扱うときに行うべきです。 –