diff --git a/game/vctrl.lua b/game/vctrl.lua index 3321fcd..f12b89b 100644 --- a/game/vctrl.lua +++ b/game/vctrl.lua @@ -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 diff --git a/main.lua b/main.lua index ed8a4fb..7b28dfd 100644 --- a/main.lua +++ b/main.lua @@ -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 diff --git a/scene.lua b/scene.lua index d3e143b..813e5e2 100644 --- a/scene.lua +++ b/scene.lua @@ -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"