Fix virtual button method

This commit is contained in:
SweetSea-ButImNotSweet
2024-05-27 20:18:24 +07:00
parent 5cc3cae343
commit 7cf450868a
4 changed files with 9 additions and 4 deletions

View File

@@ -45,6 +45,8 @@ local buttonList = {
local menuKey -- MENU key used to go main menu XD
function GameScene:new(player_name, replay_file, replay_grade)
VCTRL[9].show = false
menuKey = BUTTON.new{
text = "MENU",
x = 265, y = 0, w = 60, h = 25,
@@ -130,7 +132,7 @@ end
function GameScene:onInputPress(e)
if e.type == "mouse" or (e.type == "touch" and not VCTRL.press(e.x, e.y, e.id)) then
BUTTON.press(buttonList, e.x, e.y, e.id)
if self.game.input_playback then BUTTON.press(buttonList, e.x, e.y, e.id) end
menuKey:press(e.x, e.y, e.id)
elseif (self.game.game_over or self.game.completed) and (e.input == "menu_decide" or e.input == "menu_back" or e.input == "rotate_right") and self.game.game_over_frames > 50 then
SCENE = TitleScene()
@@ -171,7 +173,7 @@ end
function GameScene:onInputRelease(e)
if e.type == "mouse" or (e.type == "touch" and not VCTRL.release(e.id)) then
BUTTON.release(buttonList, e.x, e.y, e.id)
if self.game.input_playback then BUTTON.release(buttonList, e.x, e.y, e.id) end
menuKey:release(e.x, e.y, e.id)
elseif e.input and string.sub(e.input, 1, 5) ~= "menu_" then
self.inputs[e.input] = false

View File

@@ -15,6 +15,8 @@ local main_menu_screens = {
}
function TitleScene:new()
VCTRL.clearAll() -- Reset the RESTART button state
VCTRL.new(SETTINGS.input.virtual)
if SOUNDS['bgm_firsthalf']:isPlaying() or SOUNDS['bgm_secondhalf']:isPlaying() or not SETTINGS["music"] then
love.audio.stop()
end

View File

@@ -57,6 +57,8 @@ function TrainingScene:onInputPress(e)
SCENE = TitleScene()
elseif (e.input == "menu_back") then
SCENE = TitleScene()
elseif e.input == "restart" or e.input == "menu_decide" then
SCENE = TrainingScene()
elseif e.input and string.sub(e.input, 1, 5) ~= "menu_" then
self.inputs[e.input] = true
end

View File

@@ -25,8 +25,7 @@ local _defaultSettings = {
{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},
{type='button',x=320, y=420,key= 'restart',r=35,iconSize=60,alpha=0.4},
}
},
tvMode = false -- 79338732