if you had a large background image of Micky mouse how can you insure that the main character image always starts standing on Mickey's nose no matter what the resolution is. if you try and code the position in pixels this will change with resolution correct? I have a background image and I want my character to be placed in a certain spot on the background image. however I dont know if it will be in the proper place if the resolution changes.
2d image position
Change your ortho/perspective matrix to be in a known range such as 0 to 1 or -1 to 1. This way you are dealing with more or less percentage of position from the bottom left hand corner to the upper right hand corner. Or if you want to have your perspective matrix in pixel values instead:
For instance if you are building a level in 1024x768 and you want a sprite in the middle of the screen:
x = 512
y = 384
Scale to range 0 to 1
x = .5
y = .5
Someone with resolution 1920 x 1080 plays game. Take your scaled values and put them in the 1920x1080 range:
new x = .5*1920
new y = .5*1080
Your image is now always in the middle of the screen.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement