私はこのチュートリアルに従っています: http://www.java-gaming.org/index.php?topic=25685.newと仮想の幅と高さを使用しています。
私の要件は次のとおりです。
背景画像は画面全体に表示する必要があります
ゲーム アセットのアスペクト比を維持する必要があります。私の仮想幅、高さは 800,600 です。ゲーム アセットの 1 つは初期仮想位置が 450,20 であるため、次のように設定します。
playerSprite.setPosition(450, 20);//I assume (450,20) would be virtual
問題は、メイン関数でウィンドウ サイズを 200X200 に設定すると、プレーヤー (ゲーム アセット) が表示されないことです。アセット (サイズと位置) はアスペクト比を維持しながら自動的にスケーリングされると思いました。ただし、画面サイズを 800X600 に設定してから (手動で) 200X200 にサイズ変更すると、アセットは適切にスケーリングされ、配置されました。メイン関数で200X200を設定することと、後で大きなウィンドウのサイズを200X200に変更することの違いは何ですか。
私のレンダリング機能:
Gdx.gl.glClearColor(0, 0, 0,
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
//Stretch background to cover the entire screen
if(backgroundTR!=null){
//Gdx.gl.glViewport(0, 0, screenWidth, screenHeight);
batch.begin();
batch.draw(backgroundTR, 0, 0,screenWidth,screenHeight);
batch.end();
}
//Preserve aspect ratios of assets as per the tutorial
orthographicCamera.update();
orthographicCamera.apply(Gdx.gl10);
Gdx.gl.glViewport((int)viewport.x, (int)viewport.y, (int)viewport.width, (int)viewport.height);
batch.begin();
batch.draw(titleTR,160f,450f);
//batch.draw(playerTR,450f,20f);
playerSprite.draw(batch);
batch.end();
背景も塗りつぶされていません。何か助けはありますか?