开发者

Ensure camera position is always the center of the screen?

开发者 https://www.devze.com 2023-01-13 07:34 出处:网络
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 zo

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
0

精彩评论

暂无评论...
验证码 换一张
取 消