Add `SCENE:onInputMove`

This commit is contained in:
Squishy (C6H12O6+NaCl+H2O)
2024-04-28 20:44:56 +07:00
parent 5eced5bf8d
commit dbbc73546c
3 changed files with 17 additions and 3 deletions

View File

@@ -159,7 +159,7 @@ function VCTRL.press(x,y,id)
if obj then
touches[id]=obj
obj:press(x,y,id)
-- VCTRL.focus=obj
VCTRL.focus=obj
return true
end
end

View File

@@ -136,6 +136,12 @@ function love.touchpressed(id,x,y)
SCENE:onInputPress{type = "touch", x = x, y = y, dx = 0, dy = 0, id = id}
end
end
function love.touchdragged(id,x,y,dx,dy)
local x,y=GLOBAL_TRANSFORM:inverseTransformPoint(x,y)
if not VCTRL.press(x,y,id) then
SCENE:onInputMove{type = "touch", x = x, y = y, dx = dx, dy = dy, id = id}
end
end
function love.touchreleased(id,x,y)
local x,y=GLOBAL_TRANSFORM:inverseTransformPoint(x,y)
if not VCTRL.release(id) then

View File

@@ -5,8 +5,16 @@ SCENE = Object:extend()
function SCENE:new() end
function SCENE:update() end
function SCENE:render() end
function SCENE:onInputPress() end
function SCENE:onInputRelease() end
-- e in 3 below functions will contain:
-- key - input, key, scancode
-- joystick - input, button, name
-- touch - x, y, dx, dy, id
-- virtual - key
function SCENE:onInputPress(e) end
function SCENE:onInputMove(e) end
function SCENE:onInputRelease(e) end
ExitScene = require "scene.exit"