Ensure camera position is always the center of the screen?
Given 2 functions Translate(x,y) and Scale(x), I want the camera's position to always be the center of the screen. There is also a开发者_JAVA百科 scalefactor variable and by modifying it it either zooms in or out from the center of the screen. Given that I know the dimensions of the screen in pixels, how could I achieve this? Thanks
Something like this:
screen_coords = (world_coords - camera_world_coords) * camera_zoom + 0.5 * screen_dimension
精彩评论