[SOLVED] How calculate zoomed, rotated screen_to_world and versa?

Does anyone have code snippet to calculate screen_to_world and versa IF your window size is different that display size?

I’m using following to calculate correct world position:

camera.screen_xy_to_world(action.x * 2, action.y * 2)

In portrait mode 180x320 scaled to 360x640 it works, but snippet doesn’t work if you maximize window size or rotate it.

it should be action.screen_x and action.screen_y not action.x and action.y

You can read more about it here Requested display width and height is not always obeyed? - #9 by AGulev

1 Like

thanks! this definitely need to be documented somewhere.

1 Like

Are you referring to action.x vs action.screen_x? The API reference example uses screen_x:

I’ve also updated the Screen to World example just now: Screen to World (it should be available in a couple of minutes)

4 Likes