Hi,
adding a menu to my game. On the main menu page I have amongst others an "options" & "quit" button. When they click "quit" the game closes. When they click "options" the options pages is displayed.
On the options page in the same position as the quit button there a "done" button to return them to the main page.
It all works lovely but if I don't 'stab' the "done" button then the "quit" button event is triggered. So is there a way to clear the mousedown buffer so that I can be sure they actually pressed the "quit" button deliberately?
Code:
function DoMenu()
drawimage(splash1, 0,0)
-- MAIN PAGE
if MENU_PAGE == 1 then
drawimage(btn_start, SCREEN_CENTRE_X - (BUTTON_WIDTH/2),120)
drawimage(btn_options, SCREEN_CENTRE_X - (BUTTON_WIDTH/2),160)
drawimage(btn_quit, SCREEN_CENTRE_X - (BUTTON_WIDTH/2),240)
if blend > 0 then
fadescreen()
blend = blend - FADE_SPEED_IN
end
-- START
if mousein(SCREEN_CENTRE_X - (BUTTON_WIDTH/2), 120, SCREEN_CENTRE_X - (BUTTON_WIDTH/2)+BUTTON_WIDTH, 120+32) then
if (mousedown() > 0) then
BLOCK_SIZE = 16
BLOCK_OFFSET = BLOCK_SIZE / 2
CURRENT_STATE = STATE_MENU_FADEOUT
LoadGame()
end
end
-- OPTIONS
if mousein(SCREEN_CENTRE_X - (BUTTON_WIDTH/2), 160, SCREEN_CENTRE_X - (BUTTON_WIDTH/2)+BUTTON_WIDTH, 160+32) then
if (mousedown() > 0) then
MENU_PAGE = 2
end
end
-- QUIT
if mousein(SCREEN_CENTRE_X - (BUTTON_WIDTH/2), 240, SCREEN_CENTRE_X - (BUTTON_WIDTH/2)+BUTTON_WIDTH, 240+32) then
if (mousedown() > 0) then
CURRENT_STATE = STATE_QUIT_FADEOUT
end
end
-- OPTIONS PAGE
elseif MENU_PAGE == 2 then
drawimage(btn_done, SCREEN_CENTRE_X - (BUTTON_WIDTH/2),240)
-- DONE
if mousein(SCREEN_CENTRE_X - (BUTTON_WIDTH/2), 240, SCREEN_CENTRE_X - (BUTTON_WIDTH/2)+BUTTON_WIDTH, 240+32) then
if (mousedown() > 0) then
MENU_PAGE = 1
end
end
end
end