mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
Not showing virtual control on computer
This commit is contained in:
@@ -98,8 +98,9 @@ function control_type.button:getDistance(x,y)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local touches={}
|
local touches={}
|
||||||
|
local global_toggle=false
|
||||||
VCTRL={}
|
VCTRL={}
|
||||||
VCTRL.focus=nil -- Focusing buttons
|
-- VCTRL.focus=nil -- Focusing buttons
|
||||||
|
|
||||||
---@param ... table
|
---@param ... table
|
||||||
---@class data
|
---@class data
|
||||||
@@ -120,6 +121,7 @@ function VCTRL.new(...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function VCTRL.press(x,y,id)
|
function VCTRL.press(x,y,id)
|
||||||
|
if not global_toggle then return end
|
||||||
local obj,closestDist=false,1e99
|
local obj,closestDist=false,1e99
|
||||||
for i=1,#VCTRL do
|
for i=1,#VCTRL do
|
||||||
local w=VCTRL[i]
|
local w=VCTRL[i]
|
||||||
@@ -133,12 +135,13 @@ function VCTRL.press(x,y,id)
|
|||||||
if obj then
|
if obj then
|
||||||
touches[id]=obj
|
touches[id]=obj
|
||||||
obj:press(x,y,id)
|
obj:press(x,y,id)
|
||||||
VCTRL.focus=obj
|
-- VCTRL.focus=obj
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function VCTRL.release(id)
|
function VCTRL.release(id)
|
||||||
|
if not global_toggle then return end
|
||||||
if touches[id] then
|
if touches[id] then
|
||||||
touches[id]:release()
|
touches[id]:release()
|
||||||
return true
|
return true
|
||||||
@@ -147,15 +150,23 @@ function VCTRL.release(id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function VCTRL.drag(dx,dy,id)
|
function VCTRL.drag(dx,dy,id)
|
||||||
|
if not global_toggle then return end
|
||||||
if touches[id] then
|
if touches[id] then
|
||||||
touches[id]:drag(dx,dy)
|
touches[id]:drag(dx,dy)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function VCTRL.draw(forceLight)
|
function VCTRL.draw(forceLight)
|
||||||
|
if not global_toggle then return end
|
||||||
for i=1,#VCTRL do
|
for i=1,#VCTRL do
|
||||||
if VCTRL[i].show then
|
if VCTRL[i].show then
|
||||||
VCTRL[i]:draw(forceLight)
|
VCTRL[i]:draw(forceLight)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param toggle boolean|false
|
||||||
|
---Enabling virtual control or not
|
||||||
|
function VCTRL.toggle(toggle)
|
||||||
|
global_toggle=toggle
|
||||||
|
end
|
||||||
4
main.lua
4
main.lua
@@ -67,8 +67,8 @@ function love.load()
|
|||||||
require "scene"
|
require "scene"
|
||||||
require "game.vctrl" -- VCTRL
|
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{
|
VCTRL.new{
|
||||||
-- {type='button',x= 100,y=320,key= 'up',icon= 'up',r=35,iconSize=60,alpha=1},
|
-- {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},
|
-- {type='button',x= 160,y=380,key='right',icon= 'right',r=35,iconSize=60,alpha=1},
|
||||||
|
|||||||
Reference in New Issue
Block a user