diff --git a/game/vctrl.lua b/game/vctrl.lua index 047a835..e87f74d 100644 --- a/game/vctrl.lua +++ b/game/vctrl.lua @@ -98,8 +98,9 @@ function control_type.button:getDistance(x,y) end local touches={} +local global_toggle=false VCTRL={} -VCTRL.focus=nil -- Focusing buttons +-- VCTRL.focus=nil -- Focusing buttons ---@param ... table ---@class data @@ -120,6 +121,7 @@ function VCTRL.new(...) end function VCTRL.press(x,y,id) + if not global_toggle then return end local obj,closestDist=false,1e99 for i=1,#VCTRL do local w=VCTRL[i] @@ -133,12 +135,13 @@ 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 function VCTRL.release(id) + if not global_toggle then return end if touches[id] then touches[id]:release() return true @@ -147,15 +150,23 @@ function VCTRL.release(id) end function VCTRL.drag(dx,dy,id) + if not global_toggle then return end if touches[id] then touches[id]:drag(dx,dy) end end function VCTRL.draw(forceLight) + if not global_toggle then return end for i=1,#VCTRL do if VCTRL[i].show then VCTRL[i]:draw(forceLight) end end +end + +---@param toggle boolean|false +---Enabling virtual control or not +function VCTRL.toggle(toggle) + global_toggle=toggle end \ No newline at end of file diff --git a/main.lua b/main.lua index 2ee96df..c6d424f 100644 --- a/main.lua +++ b/main.lua @@ -67,8 +67,8 @@ function love.load() require "scene" require "game.vctrl" -- VCTRL - SCENE = SETTINGS.firstTime and InputConfigScene() or TitleScene() - + SCENE = SETTINGS.firstTime and InputConfigScene(true) or TitleScene() + VCTRL.toggle(love.system.getOS()=='Android') VCTRL.new{ -- {type='button',x= 100,y=320,key= 'up',icon= 'up',r=35,iconSize=60,alpha=1}, -- {type='button',x= 160,y=380,key='right',icon= 'right',r=35,iconSize=60,alpha=1},