のサイズを変更私は(私のボディラッパーの内部で)この方法では、遺体upponスプライトを描画しています:私は窓のサイズを変更しようとするまでボディにスプライトを描画 - カメラビューポートと
private void drawBaseSprite(Batch batch){
Sprite baseSprite = this.getBaseSprite();
Vector3 bodyPixelPos = camera.project(new Vector3(body.getPosition().x, body.getPosition().y, 0));
// TODO: 17/11/16 Review this
float w = scale * (baseSprite.getTexture().getWidth())/camera.zoom;
float h = scale * (baseSprite.getTexture().getHeight())/camera.zoom ;
baseSprite.setSize(w,h);
baseSprite.setOrigin(w/2, h/2);
baseSprite.setPosition(bodyPixelPos.x -w/2, bodyPixelPos.y - h/2);
baseSprite.setRotation(body.getAngle() * MathUtils.radiansToDegrees);
baseSprite.draw(batch);
}
すべてが、良いです。リサイズ前
@Override
public void resize(int width, int height) {
stage.getViewport().update(width, height, true);
stage.camera.setToOrtho(false, Constants.VIEWPORT_HEIGHT *width/(float)height, Constants.VIEWPORT_HEIGHT);
}
:まあ、私はこのサイズ変更ロジックを(画面を実装)は、次のよ リサイズ(広い幅)後:
私はこれが不条理見つけるこのため:
float w = scale * (baseSprite.getTexture().getWidth())/camera.zoom;
float h = scale * (baseSprite.getTexture().getHeight())/camera.zoom ;
は変更されませんが、画像はx軸で表示されます。
答えるためのおかげで、私はスプライトのサイズを追跡: Gdx.app.log(this.getClass()getSimpleName()、 "W: "+ W +" H:" + H)。 カメラのズームが変更されず(ビューポートのみが変更されるため)、サイズ変更後も変更されません。 – neogineer