mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
Add touch gesture for replay and input configuration scene
This commit is contained in:
@@ -7,7 +7,45 @@ local menu_screens = {
|
||||
TouchConfigScene
|
||||
}
|
||||
|
||||
local buttonList
|
||||
|
||||
function ConfigScene:new(first_time)
|
||||
buttonList = {
|
||||
BUTTON.new{
|
||||
text = "1", font = FONT_big,
|
||||
x = 75, y = 160, w = 40, h = 40,
|
||||
codeWhenReleased = function()
|
||||
if self.menu_state ~= 1 then
|
||||
self.menu_state = 1
|
||||
else
|
||||
SCENE = KeyConfigScene()
|
||||
end
|
||||
end
|
||||
},
|
||||
BUTTON.new{
|
||||
text = "2", font = FONT_big,
|
||||
x = 75, y = 200, w = 40, h = 40,
|
||||
codeWhenReleased = function()
|
||||
if self.menu_state ~= 2 then
|
||||
self.menu_state = 2
|
||||
else
|
||||
SCENE = StickConfigScene()
|
||||
end
|
||||
end
|
||||
},
|
||||
BUTTON.new{
|
||||
text = "3", font = FONT_big,
|
||||
x = 75, y = 240, w = 40, h = 40,
|
||||
codeWhenReleased = function()
|
||||
if self.menu_state ~= 3 then
|
||||
self.menu_state = 3
|
||||
else
|
||||
SCENE = TouchConfigScene()
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
self.menu_state = 1
|
||||
if first_time then
|
||||
self.first_time = true
|
||||
@@ -28,12 +66,13 @@ function ConfigScene:render()
|
||||
end
|
||||
|
||||
love.graphics.setColor(1, 1, 1, 0.5)
|
||||
love.graphics.rectangle("fill", 75, 118 + 50 * self.menu_state, 300, 35)
|
||||
love.graphics.rectangle("fill", 75, 120 + 40 * self.menu_state, 300, 40)
|
||||
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
for i, screen in pairs(menu_screens) do
|
||||
drawText(screen.title, 80, 120 + 50 * i, 300, "left")
|
||||
drawText(screen.title, 130, 130 + 40 * i, 300, "left")
|
||||
end
|
||||
BUTTON.draw(buttonList)
|
||||
end
|
||||
|
||||
function ConfigScene:changeOption(rel)
|
||||
@@ -41,8 +80,16 @@ function ConfigScene:changeOption(rel)
|
||||
self.menu_state = (self.menu_state + len + rel - 1) % len + 1
|
||||
end
|
||||
|
||||
function ConfigScene:onInputMove(e)
|
||||
if e.type == "mouse" then
|
||||
BUTTON.checkHovering(buttonList, e.x, e.y)
|
||||
end
|
||||
end
|
||||
|
||||
function ConfigScene:onInputPress(e)
|
||||
if e.input == "menu_decide" or e.input == "rotate_left" or e.scancode == "return" then
|
||||
if e.type == "touch" or e.type == "mouse" then
|
||||
BUTTON.press(buttonList, e.x, e.y, e.id)
|
||||
elseif e.input == "menu_decide" or e.input == "rotate_left" or e.scancode == "return" then
|
||||
SCENE = menu_screens[self.menu_state]()
|
||||
elseif e.input == "up" or e.scancode == "up" then
|
||||
self:changeOption(-1)
|
||||
@@ -54,5 +101,10 @@ function ConfigScene:onInputPress(e)
|
||||
SCENE = TitleScene()
|
||||
end
|
||||
end
|
||||
function ConfigScene:onInputRelease(e)
|
||||
if e.type == "touch" or e.type == "mouse" then
|
||||
BUTTON.release(buttonList, e.x, e.y, e.id)
|
||||
end
|
||||
end
|
||||
|
||||
return ConfigScene
|
||||
|
||||
Reference in New Issue
Block a user