FBA The Creator

The True Multiplatform PC / PocketPC Opensource Development Tool - Read Only Mode - Kept only for historical purposes - Thank you all ;)
It is currently Thu Jun 04, 2026 3:51 am

All times are UTC




Post new topic  Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Thu Jun 26, 2008 12:16 pm 
Offline
FBA Startup-Logo Creator
FBA Startup-Logo Creator
User avatar

Joined: Wed Jun 18, 2008 11:40 am
Posts: 100
Location: Brighton, UK
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


_________________
http://www.boiledsweets.com


Top
   
PostPosted: Thu Jun 26, 2008 12:37 pm 
Offline
FBA Administrator
FBA Administrator
User avatar

Joined: Fri Mar 21, 2008 11:19 pm
Posts: 238
Location: Rome - Italy
Actually there isn't a way to do that, you could workaround this using the stylus events, instead of checking the mouse position inside your logic.


Top
   
PostPosted: Thu Jun 26, 2008 12:51 pm 
Offline
FBA Startup-Logo Creator
FBA Startup-Logo Creator
User avatar

Joined: Wed Jun 18, 2008 11:40 am
Posts: 100
Location: Brighton, UK
Was just following the examples given with FBA....

_________________
http://www.boiledsweets.com


Top
   
PostPosted: Thu Jun 26, 2008 12:57 pm 
Offline
FBA Administrator
FBA Administrator
User avatar

Joined: Fri Mar 21, 2008 11:19 pm
Posts: 238
Location: Rome - Italy
I know, but for your case, with alternate pages and several buttons on same position, it won't work well :)
I thought a reset function for mousedown counter wouldn't be useful, but i'll add it if it will be necessary :)


Top
   
PostPosted: Thu Jun 26, 2008 1:00 pm 
Offline
FBA Startup-Logo Creator
FBA Startup-Logo Creator
User avatar

Joined: Wed Jun 18, 2008 11:40 am
Posts: 100
Location: Brighton, UK
Hi,

well more functionality would be nice :-)

But I have recoded...

Code:
function onstylusdown(x,y)

        if CURRENT_STATE == STATE_MENU then

                if MENU_PAGE == 1 then
                        if mousein(SCREEN_CENTRE_X - (BUTTON_WIDTH/2), 240, SCREEN_CENTRE_X - (BUTTON_WIDTH/2)+BUTTON_WIDTH, 240+32) then     
                                CURRENT_STATE = STATE_QUIT_FADEOUT
                        end
               
                elseif MENU_PAGE == 2 then
               
                        if mousein(SCREEN_CENTRE_X - (BUTTON_WIDTH/2), 240, SCREEN_CENTRE_X - (BUTTON_WIDTH/2)+BUTTON_WIDTH, 240+32) then     
               
                                MENU_PAGE = 1
                        end
               
                end
               
        end

     
end



and works perfectly - THANKS!

Yeah I could use the x, y passed to in see if it's inside the button are but easier to call mousein I think...

_________________
http://www.boiledsweets.com


Last edited by Boiled Sweets on Thu Jun 26, 2008 1:01 pm, edited 1 time in total.

Top
   
PostPosted: Thu Jun 26, 2008 1:01 pm 
Offline
Tutorials Contributor
Tutorials Contributor
User avatar

Joined: Tue Jun 17, 2008 3:39 am
Posts: 59
Location: Midwest, US
I use context-sensitive menus in the program I'm writing, and to make sure that my clicks are going to the write menu, I use some state variables. I got the idea from the Enlight code, where there are different states for the game, the help, and the about screen.

Here's a snippet:
Code:
  elseif mousein(49,96,166,111) then
    -- show info
    if HELP_MENU_CLICKED == 1 then
      HELP_INFO_CLICKED = 1
      HELP_MENU_CLICKED = 0
      MAINSCREEN_SHOWN = false
    end
  elseif mousein(49,112,166,130) then
    -- show about
    if HELP_MENU_CLICKED == 1 then
      HELP_ABOUT_CLICKED = 1
      HELP_MENU_CLICKED = 0
      MAINSCREEN_SHOWN = false
    end


You can see that I check the state of the screen before I allow the click to change anything else.

_________________
Don't look at me. I'm new here.


Top
   
PostPosted: Thu Jun 26, 2008 1:02 pm 
Offline
FBA Startup-Logo Creator
FBA Startup-Logo Creator
User avatar

Joined: Wed Jun 18, 2008 11:40 am
Posts: 100
Location: Brighton, UK
Don't take this the wrong way but I think that method is a little more 'clunky' - THANKS anyhow...

_________________
http://www.boiledsweets.com


Top
   
PostPosted: Thu Jun 26, 2008 1:13 pm 
Offline
Tutorials Contributor
Tutorials Contributor
User avatar

Joined: Tue Jun 17, 2008 3:39 am
Posts: 59
Location: Midwest, US
Oh, I see. You took the same concept but switched around the order of the ifs. I like it.

_________________
Don't look at me. I'm new here.


Top
   
PostPosted: Thu Jun 26, 2008 1:18 pm 
Offline
FBA Startup-Logo Creator
FBA Startup-Logo Creator
User avatar

Joined: Wed Jun 18, 2008 11:40 am
Posts: 100
Location: Brighton, UK
Also notice the const I'm using (the variables in uppercase). Makes it LOADS easier to rearrange the layout as it's all calculated based upon the certain set values - more flexible than hard coding...

Yet to set the button size, i.e. the 32 etc but I'm working flat out :-)

_________________
http://www.boiledsweets.com


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Limited