Tuesday, January 15, 2019

Recommended way to handle sprite assets for different screen densities (Android)


I am currently working on a 2D game for Android. All of the images that I render were created as SVG's and then exported to PNG's which I have placed in my assets directory. These images are also all sprites that I render using a sprite batcher.


My question is around using different versions of the sprites for devices with different densities. I know that when developing a traditional android app you could place separate directories for separate density levels inside of res and then place the correctly sized versions of the images in question in these sub-directories of res.


What is a good approach when dealing with sprite images in the asset directory? Should I just have one copy of the sprites at a really high density / resolution that I use for everything and I just render them on a coordinate system that is independent of screen size or should I resize the image based on screen density before I process it to create all my texture regions? Or is there another solution entirely?


Currently I have one high resolution set of sprites that I use for everything, it just seems wasteful and inefficient for the lower density devices.




Answer



After having used multiple asset resolutions on a couple of projects it has proven to be fairly painful in the long run to work with, even though it's usually just running a batch script. More complex support and build processes when updating slow down iteration.


The growing range of aspect ratios and resolutions makes the process questionable. Code that relies on detecting certain resolutions becomes more and more prone to needing rework. Most recently the 'retina' resolutions of iOS caused nearly a week's worth of restructuring to update an old game, since the old code had not considered such an eventuality.


I would recommend keeping your current line of using the highest resolution set only. If performance is a problem, perhaps generating scaled down versions of the assets could be handled on initialization.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...