mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
Fix some bugs (TEST)
This commit is contained in:
11
main.lua
11
main.lua
@@ -96,14 +96,13 @@ function love.load()
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local scale_factor
|
|
||||||
function love.resize(w, h)
|
function love.resize(w, h)
|
||||||
scale_factor = math.min(w / 640, h / 480)
|
SCREEN_SCALE_FACTOR = math.min(w / 640, h / 480)
|
||||||
GLOBAL_TRANSFORM:setTransformation(
|
GLOBAL_TRANSFORM:setTransformation(
|
||||||
(w - scale_factor * 640) / 2,
|
(w - SCREEN_SCALE_FACTOR * 640) / 2,
|
||||||
(h - scale_factor * 480) / 2,
|
(h - SCREEN_SCALE_FACTOR * 480) / 2,
|
||||||
0,
|
0,
|
||||||
scale_factor
|
SCREEN_SCALE_FACTOR
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -152,7 +151,7 @@ end
|
|||||||
function love.mousemoved(x, y, dx, dy, isTouch)
|
function love.mousemoved(x, y, dx, dy, isTouch)
|
||||||
if isTouch then return end
|
if isTouch then return end
|
||||||
local x,y=GLOBAL_TRANSFORM:inverseTransformPoint(x,y)
|
local x,y=GLOBAL_TRANSFORM:inverseTransformPoint(x,y)
|
||||||
local dx,dy=dx/scale_factor,dy/scale_factor
|
local dx,dy=dx/SCREEN_SCALE_FACTOR,dy/SCREEN_SCALE_FACTOR
|
||||||
SCENE:onInputMove{type = "mouse", x = x, y = y, dx = dx, dy = dy}
|
SCENE:onInputMove{type = "mouse", x = x, y = y, dx = dx, dy = dy}
|
||||||
end
|
end
|
||||||
function love.wheelmoved(dx, dy)
|
function love.wheelmoved(dx, dy)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ local menuKey -- MENU key used to go main menu XD
|
|||||||
function GameScene:new(player_name, replay_file, replay_grade)
|
function GameScene:new(player_name, replay_file, replay_grade)
|
||||||
menuKey = BUTTON.new{
|
menuKey = BUTTON.new{
|
||||||
text = "MENU",
|
text = "MENU",
|
||||||
x = 270, y = 5, w = 50, h = 20,
|
x = 265, y = 0, w = 60, h = 25,
|
||||||
codeWhenReleased = function()
|
codeWhenReleased = function()
|
||||||
if self.game.input_playback or self.game.game_over or self.game.completed then
|
if self.game.input_playback or self.game.game_over or self.game.completed then
|
||||||
SCENE = TitleScene()
|
SCENE = TitleScene()
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ buttonList = {
|
|||||||
}
|
}
|
||||||
sliderList = {}
|
sliderList = {}
|
||||||
sliderList.opacity = newSlider(
|
sliderList.opacity = newSlider(
|
||||||
130, 20-1, 100, 100, 0, 100,
|
135, 20+2.5, 100, 100, 0, 100,
|
||||||
function()
|
function()
|
||||||
local v
|
local v
|
||||||
if focusingButton then
|
if focusingButton then
|
||||||
@@ -89,10 +89,10 @@ sliderList.opacity = newSlider(
|
|||||||
sliderList.opacity.value = v
|
sliderList.opacity.value = v
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
{width = 10, knob = 'circle', track = 'roundrect'}
|
{width = 20}
|
||||||
)
|
)
|
||||||
sliderList.size = newSlider(
|
sliderList.size = newSlider(
|
||||||
130, 40-1, 100, 45, 0, 120,
|
135, 50+2.5, 100, 45, 0, 120,
|
||||||
function(v)
|
function(v)
|
||||||
if focusingButton then
|
if focusingButton then
|
||||||
local v = math.roundUnit(v, 5)
|
local v = math.roundUnit(v, 5)
|
||||||
@@ -103,7 +103,7 @@ sliderList.size = newSlider(
|
|||||||
sliderList.size.value = v / 120
|
sliderList.size.value = v / 120
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
{width = 10, knob = 'circle', track = 'roundrect'}
|
{width = 20}
|
||||||
)
|
)
|
||||||
local gridSizeTable = {1, 2, 5, 10, 20, 50, 100}
|
local gridSizeTable = {1, 2, 5, 10, 20, 50, 100}
|
||||||
sliderList.gridSize = newSlider(
|
sliderList.gridSize = newSlider(
|
||||||
@@ -113,7 +113,7 @@ sliderList.gridSize = newSlider(
|
|||||||
sliderList.gridSize.value = v
|
sliderList.gridSize.value = v
|
||||||
gridSize = gridSizeTable[math.roundUnit(v * (#gridSizeTable - 1) + 1, 1)]
|
gridSize = gridSizeTable[math.roundUnit(v * (#gridSizeTable - 1) + 1, 1)]
|
||||||
end,
|
end,
|
||||||
{width = 10, knob = 'circle', track = 'roundrect'}
|
{width = 20}
|
||||||
); sliderList.gridSize.forceLight = true
|
); sliderList.gridSize.forceLight = true
|
||||||
|
|
||||||
local function sliderList_draw()
|
local function sliderList_draw()
|
||||||
@@ -130,15 +130,13 @@ end
|
|||||||
|
|
||||||
local function sliderList_update()
|
local function sliderList_update()
|
||||||
local x, y
|
local x, y
|
||||||
if love.mouse.isDown(1) then
|
if #love.touch.getTouches() == 1 then
|
||||||
x, y = GLOBAL_TRANSFORM:inverseTransformPoint(love.mouse.getPosition())
|
x, y = GLOBAL_TRANSFORM:inverseTransformPoint(love.touch.getPosition(love.touch.getTouches()[1]))
|
||||||
elseif #love.touch.getTouches() == 1 then
|
|
||||||
x, y = love.touch.getPosition(love.touch.getTouches()[1])
|
|
||||||
else
|
else
|
||||||
return
|
x, y = GLOBAL_TRANSFORM:inverseTransformPoint(love.mouse.getPosition())
|
||||||
end
|
end
|
||||||
for _, s in pairs(sliderList) do
|
for _, s in pairs(sliderList) do
|
||||||
s:update(x, y, true)
|
s:update(x, y, #love.touch.getTouches() == 1 or love.mouse.isDown(1))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -181,7 +179,7 @@ function TouchConfigScene:render()
|
|||||||
|
|
||||||
love.graphics.setColor(0, 0, 0, 0.7)
|
love.graphics.setColor(0, 0, 0, 0.7)
|
||||||
-- Opacity and Size
|
-- Opacity and Size
|
||||||
love.graphics.rectangle("fill", 10, 5, 227, 50)
|
love.graphics.rectangle("fill", 10, 5, 227, 58)
|
||||||
-- Snap to grid
|
-- Snap to grid
|
||||||
love.graphics.rectangle("fill", 335, 5, 130, 50)
|
love.graphics.rectangle("fill", 335, 5, 130, 50)
|
||||||
|
|
||||||
@@ -189,8 +187,8 @@ function TouchConfigScene:render()
|
|||||||
drawText("Opacity", 20, 10, 100, "left")
|
drawText("Opacity", 20, 10, 100, "left")
|
||||||
drawText(string.format("%3.1d%%", focusingButton and focusingButton.alpha * 100 or 0), 190, 10, 40, "left")
|
drawText(string.format("%3.1d%%", focusingButton and focusingButton.alpha * 100 or 0), 190, 10, 40, "left")
|
||||||
-- Size
|
-- Size
|
||||||
drawText("Size", 20, 30, 100, "left")
|
drawText("Size", 20, 40, 100, "left")
|
||||||
drawText(string.format("%3.1dpx", focusingButton and focusingButton.r or 0), 190, 30, 40, "left")
|
drawText(string.format("%3.1dpx", focusingButton and focusingButton.r or 0), 190, 40, 40, "left")
|
||||||
-- Snap to grid
|
-- Snap to grid
|
||||||
drawText(string.format("Snap to grid: %3s", gridSize), 340, 10, 140, "left")
|
drawText(string.format("Snap to grid: %3s", gridSize), 340, 10, 140, "left")
|
||||||
|
|
||||||
@@ -231,12 +229,11 @@ function TouchConfigScene:onInputMove(e)
|
|||||||
end
|
end
|
||||||
---@param e SCENE_onInput
|
---@param e SCENE_onInput
|
||||||
function TouchConfigScene:onInputPress(e)
|
function TouchConfigScene:onInputPress(e)
|
||||||
if e.type ~= "virtual" and e.input == 'menu_back' then SCENE = InputConfigScene() end
|
|
||||||
if e.type == "mouse" or e.type == "touch" then
|
if e.type == "mouse" or e.type == "touch" then
|
||||||
if not (
|
if not (
|
||||||
VCTRL.press(e.x, e.y, e.id and e.id or 1, true) or
|
VCTRL.press(e.x, e.y, e.id and e.id or 1, true) or
|
||||||
BUTTON.press(buttonList, e.x, e.y, e.id) or
|
BUTTON.press(buttonList, e.x, e.y, e.id) or
|
||||||
(e.x >= 75 and e.x <= 185 and e.y >= 12 and e.y <= 44)
|
(e.x >= 75 and e.x <= 195 and e.y >= 12 and e.y <= 63)
|
||||||
) then
|
) then
|
||||||
VCTRL.focus = nil
|
VCTRL.focus = nil
|
||||||
focusingButton = nil
|
focusingButton = nil
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ local menuKey
|
|||||||
function TrainingScene:new()
|
function TrainingScene:new()
|
||||||
menuKey = BUTTON.new{
|
menuKey = BUTTON.new{
|
||||||
text = "MENU",
|
text = "MENU",
|
||||||
x = 270, y = 5, w = 50, h = 20,
|
x = 265, y = 0, w = 60, h = 25,
|
||||||
codeWhenReleased = function() SCENE = TitleScene() end
|
codeWhenReleased = function() SCENE = TitleScene() end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user