Implementing my function shouldn't pose a problem in your code. It's designed
to work without interrupting any other loop processes. So, if you have an animation
or something happening in the background for your game menu, just place the function
call(s) at the end of the loop.
Example:
Do
Your code placed here first for the game menu or whatever.
If MakeIcon(110,240,1,1,4,1)>0 Then Goto StartGame
If MakeIcon(320,240,2,2,5,2)>0 Then Goto Options
If MakeIcon(530,240,3,3,6,3)>0 Then Goto Quit
Sync
Loop
The only thing that may cause confusion is the function parameters.
You will have to load your media to be used with the function first.
Below is a detailed list of what the parameters mean to the function.
Parameters:
x,y screen position for current sprite (icon).
IconNumber is the current sprite used during the function call.
IconImage1 is the initial image displayed before the mouse pointer is over the sprite.
IconImage2 is the active image when the mouse pointer is over the sprite.
SFX is the current sound used for the sprite when the pointer is over the sprite.
The function will return the appropriate value (0 or 1) based on user
selection with or without a mouse click.
You could also adapt the function to use pasted images instead of sprites.
The only advantage to using sprites is having the ability to flip or mirror
them in real time as well as collision.
<EDIT>
Because the function uses sprites, you may have to delete the sprite(s)
used for the icons upon exiting the game menu loop. If you use pasted
images, this will not be an issue.
To use pasted images just change the code to:
sync on
sync rate 0
Do
If MakeIcon(110,240,1,4,1)>0 Then Goto StartGame
If MakeIcon(320,240,2,5,2)>0 Then Goto Options
If MakeIcon(530,240,3,6,3)>0 Then Goto Quit
Sync
Loop
Function MakeIcon(x,y,IconImage1,IconImage2,SFX)
ButtonPressed=0
` Temp Sprite Used To Get Icon Image Size
Sprite 200,0,0,IconImage1
IconSizeX=Sprite Width(200)
IconSizeY=Sprite Height(200)
Delete Sprite 200
Paste Image IconImage1,x,y
myx=Mousex():myy=Mousey()
If myx>x-IconSizeX and myx<x+IconSizeX
If myy>y-IconSizeY and myy<y+IconSizeY
ButtonPressed=1
Paste Image IconImage2,x,y
If Sound Playing(SFX)=0 Then Play Sound SFX
Endif
Endif
If MouseClick()=0 Then ButtonPressed=0
Endfunction ButtonPressed
This will also eliminate one of the parameters in the function. You
may have to change the sprite number in the function to something not
used in your game. This is used to get the current size of the icon.