2012-03-22 10 views
1

私はグラフィックを表示するために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(); 


} 

これは、デスクトップのバージョンで絶対に問題なく動作します。

enter image description here

あなたはそのトップ部分にのみ取るに押しつぶされて見ることができるように:私は自分の携帯電話上でそれを起動したときしかし、私は私が望むものではありませんこれは、これを取得 enter image description here

画面の

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")); 
+0

どのようにあなたのビューポートとカメラの位置を設定していますか? –

+0

私はそれがディスプレイの解像度の違いによって2つの表示が異なって見えると思います。この質問に対する答えは、あなたの設定が少し違っても(libgdxの2Dシーングラフを使っているようには見えませんが)、助けになるかもしれません:http://stackoverflow.com/q/9198932/324625要点は、ビューポートを中央に配置してカメラを配置する必要があることです。これらは 'resize()'を扱うときに行うべきです。 –

答えて

0

私はAndroidManifest.xmlをでこれを入れて、問題を解決するように見えた:

<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="13" /> 
+0

答えに表示されるように、XMLの前に4つのスペースを追加する必要があります。 –

+0

また、期待されるバージョンを変更するとディスプレイが変更されたのはなぜですか? –

+0

480x320までの解像度しかサポートしないminiSdkVersion 3と何かが関係しているため、480x320を超える解像度の携帯電話で互換モードでゲームを実行することができます。 – Derek

関連する問題