I'm doing a 2D game on android, and everything works just fine. The problem is the character moves really fast on my phone (Xperia) but on a phone with a much more wider screen he runs really slow. I tried getting the screen width and divide by 100 and set it as the step so the character will have a step depending on the width- didn't work. Is there some way to get some sort of scaled pixel or something. Appreciate the help :)
here's who i do it:
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
height = displaymetrics.heightPixels;
width = displaymetrics.widthPixels;
ideas?
Multiply your step width with displaymetrics.density
. That effectively turns a "px" value into a "dp" value, i.e. it should be the same physical width on all devices.