Hello, I have been trying to get my image sprite position at the same spot regardless of the screen device size but I have big issues! Can someone guide me toward achieving it, please?
I am attaching 2 screenshots from 2 Android phones
It is not an easy task. You have to designate a reference screen size(for example what you use to program/test it) and derivate the positions of the sprites calculating from the actual screen and that reference size. Lets say you have 100 pixels width and 200 pixels height screen. The sprite position on that screen is for example X,Y -> (40,20).
If you want to position the sprite to the same ratio of the screen on a 150x250 screen, you have to use some math like: X=40/100x150, Y=20/200*250.
I dont think there is better way to position accurately.
Hello, I found a solution that logically makes sense, and that is to have the canvas sized in pixels and the sprites in percentages because they are located within the canvas!
Thank you.
Because the common smaller screen resolution for Mobile in 2024 is 360 x 800 then it is logical to have the canvas sized to 340 x 600 and that is what I did,