mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
Final update for touch configuration scene
This commit is contained in:
33
main.lua
33
main.lua
@@ -35,6 +35,21 @@ function love.load()
|
||||
math.randomseed(os.time())
|
||||
require "settings"
|
||||
|
||||
if SETTINGS.input.virtual == nil then
|
||||
SETTINGS.input.virtual = {
|
||||
{type='button',x= 70,y=280,key= 'up',r=45,iconSize=60,alpha=0.4},
|
||||
{type='button',x= 70,y=430,key= 'down',r=45,iconSize=60,alpha=0.4},
|
||||
{type='button',x= -5,y=355,key= 'left',r=45,iconSize=60,alpha=0.4},
|
||||
{type='button',x= 145,y=355,key= 'right',r=45,iconSize=60,alpha=0.4},
|
||||
{type='button',x=640- -5,y=355,key= 'rotate_left',r=45,iconSize=60,alpha=0.4},
|
||||
{type='button',x=640-145,y=355,key= 'rotate_left2',r=45,iconSize=60,alpha=0.4},
|
||||
{type='button',x=640- 70,y=430,key= 'rotate_right',r=45,iconSize=60,alpha=0.4},
|
||||
{type='button',x=640- 70,y=280,key='rotate_right2',r=45,iconSize=60,alpha=0.4},
|
||||
{type='button',x=320- 40,y=420,key= 'menu_decide',r=35,iconSize=60,alpha=0.4},
|
||||
{type='button',x=320+ 40,y=420,key= 'menu_back',r=35,iconSize=60,alpha=0.4},
|
||||
}
|
||||
end
|
||||
|
||||
-- Window stuffs
|
||||
love.window.setMode(love.graphics.getWidth(), love.graphics.getHeight(), {resizable = true});
|
||||
love.window.setFullscreen(SETTINGS["fullscreen"])
|
||||
@@ -45,8 +60,8 @@ function love.load()
|
||||
|
||||
-- Now it's real time to load all stuffs!
|
||||
require "load" -- Most game's resources are loaded in here
|
||||
require "scene"
|
||||
require "game.vctrl" -- VCTRL
|
||||
require "scene"
|
||||
|
||||
function SCENE.update()
|
||||
SCENE = SETTINGS.firstTime and InputConfigScene(true) or TitleScene()
|
||||
@@ -78,8 +93,9 @@ function love.load()
|
||||
}
|
||||
end
|
||||
|
||||
local scale_factor
|
||||
function love.resize(w, h)
|
||||
local scale_factor = math.min(w / 640, h / 480)
|
||||
scale_factor = math.min(w / 640, h / 480)
|
||||
GLOBAL_TRANSFORM:setTransformation(
|
||||
(w - scale_factor * 640) / 2,
|
||||
(h - scale_factor * 480) / 2,
|
||||
@@ -123,16 +139,17 @@ end
|
||||
function love.mousepressed(x, y, b, isTouch, presses)
|
||||
if isTouch then return end
|
||||
local x,y=GLOBAL_TRANSFORM:inverseTransformPoint(x,y)
|
||||
SCENE:onInputPress{type = "mouse", x = x, y = y, button = b, presses = presses}
|
||||
SCENE:onInputPress{type = "mouse", x = x, y = y, id = b, presses = presses}
|
||||
end
|
||||
function love.mousereleased(x, y, b, isTouch, presses)
|
||||
if isTouch then return end
|
||||
local x,y=GLOBAL_TRANSFORM:inverseTransformPoint(x,y)
|
||||
SCENE:onInputRelease{type = "mouse", x = x, y = y, button = b, presses = presses}
|
||||
SCENE:onInputRelease{type = "mouse", x = x, y = y, id = b, presses = presses}
|
||||
end
|
||||
function love.mousemoved(x, y, dx, dy)
|
||||
function love.mousemoved(x, y, dx, dy, isTouch)
|
||||
if isTouch then return end
|
||||
local x,y=GLOBAL_TRANSFORM:inverseTransformPoint(x,y)
|
||||
local dx,dy=GLOBAL_TRANSFORM:inverseTransformPoint(dx,dy)
|
||||
local dx,dy=dx/scale_factor,dy/scale_factor
|
||||
SCENE:onInputMove{type = "mouse", x = x, y = y, dx = dx, dy = dy}
|
||||
end
|
||||
function love.wheelmoved(dx, dy)
|
||||
@@ -141,7 +158,7 @@ end
|
||||
|
||||
function love.touchpressed(id,x,y)
|
||||
local x,y=GLOBAL_TRANSFORM:inverseTransformPoint(x,y)
|
||||
SCENE:onInputPress{type = "touch", x = x, y = y, dx = 0, dy = 0, id = id}
|
||||
SCENE:onInputPress{type = "touch", x = x, y = y, dx = 0, dy = 0, id = id}
|
||||
end
|
||||
function love.touchdragged(id,x,y,dx,dy)
|
||||
local x,y=GLOBAL_TRANSFORM:inverseTransformPoint(x,y)
|
||||
@@ -161,7 +178,7 @@ function love.keypressed(key, scancode)
|
||||
love.window.setFullscreen(SETTINGS["fullscreen"])
|
||||
elseif scancode == "f2" and SCENE.title ~= "Input Config" and SCENE.title ~= "Game" then
|
||||
SCENE = InputConfigScene()
|
||||
elseif scancode == "f12" then REQUEST_BREAK()
|
||||
elseif scancode == "f12" then LLDEBUGGER.requestBreak()
|
||||
-- function keys are reserved
|
||||
elseif string.match(scancode, "^f[1-9]$") or string.match(scancode, "^f1[0-2]+$") then
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user