• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Keep sprite movement speed the same on every device.

tylers12345

Lurker
Feb 13, 2015
2
0
Hello,
I have made a simple android game, similar to flappy birds. When testing, I have found what the speed of the movements such as flying up or falling are good on my One Plus One (1920x1080 401 ppi), but when I tested on a smaller phone with a resolution of 480 x 854 and 196 ppi I found that it was a lot faster flying up and falling.

Is there any way of keeping the speed the same across all device sizes and types?

This is my movement code:

In my bird sprite file:
Java:
private int GRAVITY_LIMIT = -30;
public int gravity = 0;

//gravity
        if(gravity>GRAVITY_LIMIT){
            gravity= gravity-2;
        }
        //fall
        y= y-gravity;

When rendering:
Java:
canvas.drawBitmap(bmp1, x, y, null);

When jump is triggered:
Java:
bird.gravity=30;
Feel free to ask for more information :) Thankyou to anyone who helps.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones