I had an example menu for a while that I found in the code database here. I have been messing around with it but I am having some trouble. When I click on the START button it loads a 2nd menu but if I move my mouse over the screen the buttons from the first menu screen show through the 2nd menu screen. I cant figure out how to stop this, I tried everything I could think of. Is there a way to CLEAR the images from the first menu once the user makes a selection?
set display mode 1600,900,32
global CMenu
global nextfreeimage as integer
` Image numbers. Note that over images are followed by their respective down image.
mainmenu = freeImage()
optiononeover = freeImage()
optiononedown = freeImage()
optiontwoover = freeImage()
optiontwodown = freeImage()
optionthreeover = freeImage()
optionthreedown = freeImage()
menutwo = freeImage()
` load menus
load image "Images/Title.png",mainmenu,1
load image "Images/Title2.png",menutwo,1
` Load each selected text
load image "Images/Menu1Select.png",optiononeover,1
load image "ImagesMenu2Select.png",optiontwoover,1
load image "Images/Menu3Select.png",optionthreeover,1
`Load down state text
load image "Images/Menu1click.png",optiononedown,1
load image "ImagesMenu2click.png",optiontwodown,1
load image "Images/Menu3click.png",optionthreedown,1
Load Sound "Sound/Menu.wav", 1
loop sound 1
sync on
` Set the starting menu
CMenu=1
do
Menu( CMenu, optiononeover, optionthreedown, 653, 482)
sync
loop
function freeImage()
` Find the first free image number
repeat
` Go to the next image number (Starts at 1 to not produce an error)
inc nextfreeimage
` Don't leave the loop till the image doesn't exist
until image exist(nextfreeimage)=0
endfunction nextfreeimage
function Menu(menuID, mstart, mend, x, y)
`set local y value to check for clicked images
local resety as integer : resety = y
` Show the background
paste image menuID,0,0
` Go though each menu selection image
for t= mstart to mend step 2
` Check if the mouse is on the menu selection
if mousex()=>x and mousey()=>y and mousex()<=x+image width(t) and mousey()<=y+image height(t)
` Show the current selected image
paste image t,x,y,1
` Check for mouse clicks
if mouseclick()>0
` Show clicked version of the image
paste image t+1,x,y,1
sync
` Wait for the user to let go of the mouse buttons
MouseWait()
` Check again to make sure the mouse is still in the right area for a click
if mousex()=>x and mousey()=>y and mousex()<=x+image width(t) and mousey()<=y+image height(t)
` Call the MenuSelect() function
MenuSelect(t)
endif
endif
endif
` Go to the next menu selection; inc value is about the image size plus space between.
inc y,116
next t
endfunction
function MenuSelect(Choice)
` Selected by mouseover image number
select Choice
` Menu Option 1
case 2
` Change to the first menu
CMenu=1
endcase
` Menu Option 2
case 4
endcase
` Menu Option 3
case 6
` Change to the other menu
`CMenu=8
end
endcase
case default
endcase
endselect
endfunction
function MouseWait()
` Wait for the user to let go of the mouse buttons
repeat
until mouseclick()=0
endfunction