@@ -7,13 +7,6 @@ local function screen_to_world(x, y, z, camera_id)
7
7
local view = camera.get_view(camera_id)
8
8
local w, h = window.get_size()
9
9
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
-
17
10
-- https://defold.com/manuals/camera/#converting-mouse-to-world-coordinates
18
11
local inv = vmath.inv(projection * view)
19
12
x = (2 * x / w) - 1
33
26
function on_input(self, action_id, action)
34
27
if action_id == hash("touch") and action.pressed then
35
28
-- 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")
37
30
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)
39
32
end
40
- end
33
+ end
0 commit comments