@@ -7,13 +7,6 @@ local function screen_to_world(x, y, z, camera_id)
77 local view = camera.get_view(camera_id)
88 local w, h = window.get_size()
99
10- -- The window.get_size() function will return the scaled window size,
11- -- ie taking into account display scaling (Retina screens on macOS for
12- -- instance). We need to adjust for display scaling in our calculation.
13- local scale = window.get_display_scale()
14- w = w / scale
15- h = h / scale
16-
1710 -- https://defold.com/manuals/camera/#converting-mouse-to-world-coordinates
1811 local inv = vmath.inv(projection * view)
1912 x = (2 * x / w) - 1
3326function on_input(self, action_id, action)
3427 if action_id == hash("touch") and action.pressed then
3528 -- convert mouse/touch screen position to world position
36- local worldx, worldy = screen_to_world(action.x , action.y , 0, "#camera")
29+ local worldx, worldy = screen_to_world(action.screen_x , action.screen_y , 0, "#camera")
3730 local world = vmath.vector3(worldx, worldy, 0)
38- go.animate(".", "position", go.PLAYBACK_ONCE_FORWARD, world, go.EASING_LINEAR, 0.5, 0, moved_to_position) -- <8>
31+ go.animate(".", "position", go.PLAYBACK_ONCE_FORWARD, world, go.EASING_LINEAR, 0.5, 0)
3932 end
40- end
33+ end
0 commit comments