libGDX : desgin game assets according different size screens
I
develop and design the game’s Assets (backgrounds, buttons, etc.), but when I design any Assets, I don’t know which screen size should I design? Many screen sizes are different in Android devices or iOS
devices. So, if I start with the largest screen, the screen size of the other devices will be bad, the Assets on the old device will be too heavy, and conversely, if I start designing from the small screen, the screen resolution of the other device will be low (if I use e.g. StrecthViewport
).
For example:
stage = new Stage(new StretchViewport(480, 800));
This line on the Galaxy note 3 (1080 x 1920) is low resolution
Does Game Assets have a standard design?
Can anyone help me?
Solution
Well, there are many ways to achieve your goals. It depends a lot on the game you create, so I can only give a brief overview of which game is right for me:
Create assets that are larger than the largest screen you support. F.e. You support 2560×1600 and choose a resolution such as 3200×2000.
Create a TextureAtlas for each TEXTURE_SIZE you support. The smartphone has an MAX_TEXTURE_SIZE that can be loaded into memory. It is usually 1024×1024, 2048×2048, 4096×4096 (newer phone and desktop graphics cards may even support more, such as 8192×8192 or larger)
Then I created 3 TextureAtlas: 4096 scale 1:1, 2048 scale 50%, 1024 scale 25%.
Reading the MAX_TEXTURE_SIZE on the device, this snippet does just that.
public final static int maxTextureSize() {
/**
* See http://lwjgl.org/forum/index.php?topic=1314.0;wap2
*/
IntBuffer max = BufferUtils.newIntBuffer(16);
max.clear();
Gdx.gl.glGetIntegerv(GL20.GL_MAX_TEXTURE_SIZE, max);
return max.get(0);
}
Then load TextureAtlas according to the supported MAX_TEXTURE_SIZE.
You can go even further. Just some thoughts:
You can calculate the perfect Texel size for your current device and repackage TextureAtlas with 1:1 screen pixels that fit the Assets pixel. It is then loaded from the atlas.
Some devices may accept a 4096 texture size, but they have a very small screen, so the 2048 version will also work, and then load the smaller version.