Jump to content
  • Advertisement
Sign in to follow this  

2d image position

This topic is 1142 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post

Link to post
Share on other sites

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.

Edited by dpadam450

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!