Skip to content

Instantly share code, notes, and snippets.

@Nunocky
Created December 10, 2014 23:32
Show Gist options
  • Save Nunocky/8614b228cde33a26c932 to your computer and use it in GitHub Desktop.
Save Nunocky/8614b228cde33a26c932 to your computer and use it in GitHub Desktop.
書きかけ
void calcWorldSize() {
final float screenRatio = ((float)Gdx.graphics.getWidth()) / Gdx.graphics.getHeight();
final float worldRatio = W / H;
if (screenRatio > worldRatio) {
worldBottomLeft.y = 0;
worldTopRight.y = H;
float w = screenRatio * H;
worldBottomLeft.x = - (w - W)/2;
worldTopRight.x = W + (w - W)/2;
}
else {
worldBottomLeft.x = 0;
worldTopRight.x = W;
float h = W / screenRatio;
worldBottomLeft.y = - (h - H)/2;
worldTopRight.y = H + (h - H)/2;
}
Gdx.app.log(TAG, "worldBottomLeft : " + worldBottomLeft.toString());
Gdx.app.log(TAG, "worldTopRight : " + worldTopRight.toString());
worldWidth = worldTopRight.x - worldBottomLeft.x;
worldHeight = worldTopRight.y - worldBottomLeft.y;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment