Let's say that I have a spritesheet with 4 sprites (standing, breathing player).

When I load it with

player_bitmap = BitmapFactory.decodeResource(resources, R.drawable.player_standing);

it sets it's width and height to for example 100/50 and I have to divide it by 4 and I get four sprites 25x50.

Problem is here that when I switch the app to tablet (I was on phone) sprites have different sizes when loaded.

How to solve issues like this?

Thank you


It seems as though the pixel density for your phone and tablet are different.

If so a few of options are,

1) Have a set of spritesheets created for varying pixel density displays and pick the closest one that matches the pixel density it was created for. You could end up with a lot of spritesheets

2) Scale your sprites when you draw them.

You can use a mixture of both techniques.

If your phone has a pixel density of 100, and your tablet has a pixel density of 200, then your sprites would seem half the size on the tablet. In this case if you chose option 2 then you'd need to double the scale

You can find a handy PPI list for various devices here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy