My Android game uses screen co-ordinates based on real space co-ordinates and my conversion goes like this: All this is pseudo code, but I've highlighted as code
Real-space=(position/480); (so for example 240/480 would be halfway across the screen)
Velocity = 1/Time; (Time = seconds)
Real-space= Real-space+ (Velocity * delta time);
Screen Coordinates = Real-space* screen width / length
Now the problem I have is that in my game, I have the need to match the screen co-ordinates of 2 sprites, so they move together (with one on top of the other, so I'm simply using something like
Sprite1_Screen_Coords = (Sprite_2_Screen_Coords-Sprite1 Height)
(All hights are scaled so are relative to the screen size the app is currently being run on)
This works OK, but I have the need to match the 'real space' co-ordinates.
Obviously I can do something like:
Sprite1-Real-Co-ordinates = Sprite2-Real-Co-ordinates
which means they would be the same but what value would I subtract from this so it 'sits' perfectly on top of the other sprite? How do I derive this missing value from/for the sprites I have? So to summerise, I need something like:
Sprite1-Real-Co-ordinates = (Sprite2-Real-Co-ordinates - something representing the sprites height)
Thank all! :-)
The answer was that I simply divided the sprite's scaled height by the current screen height and used that value - seems to work on the 3 resolutions I tested it on.