in my game, there's a main menu. on the main menu, there's 2 buttons, a start button and a quit button. both of which are animated so when you click on them, they change size a little bit. the problem is that I have a "if imagesoverlap"... and it seems that only the first in the program seems to work. If the if imagesoverlap for the quit button is right above the if imagesoverlap for the start button, only the quit will work. If the if imagesoverlap for the start button is right above the if imagesoverlap for the quit button, only the start will work. what can I do to fix it?
2 buttons
Blitz3D Forums/Blitz3D Beginners Area/2 buttons oh, and the other image is the cursor, just incase you need to know
It could be the IF..THEN is wrong, or maybe the y-coordinate is misspelled somehow. It could also be a logical problem, like first setting the flag in the first IF, then resetting it in the second one.
You could also try drawing some debug output to the screen, like:
if imagesoverlap(mouse, image1) then text 0, 0, "button1"
if imagesoverlap(mouse, image2) then text 0, 20, "button2"
You could also try drawing some debug output to the screen, like:
if imagesoverlap(mouse, image1) then text 0, 0, "button1"
if imagesoverlap(mouse, image2) then text 0, 20, "button2"
no, I did it all right, tried a debug and it still doesn't work,
I'm ok with any changes in the program, so if anybody knows how to do some sort of main menu, with a quit and start button, that would be great if you could tell me
-Thanks
I'm ok with any changes in the program, so if anybody knows how to do some sort of main menu, with a quit and start button, that would be great if you could tell me
-Thanks
Here, try this then:
;setup graphics Graphics 800, 600, 0, 2 SetBuffer BackBuffer() Dim button(2) Global mouseimage ;create 2 images for the buttons button(1) = bCreateImage(160, 80, 255, 64, 64, "Button1") button(2) = bCreateImage(160, 80, 64, 255, 64, "Button2") ;create mouse image mouseimage = bCreateImage(8, 8, 255, 255, 255) ;main loop Repeat Cls ;draw buttons For i = 1 To 2 DrawBlock button(i), 320, 100 + i * 100 Next ;draw mouse DrawBlock mouseimage, MouseX(), MouseY() ;test what button has the mouse on it sel = 0 For i = 1 To 2 If ImagesOverlap(mouseimage, MouseX(), MouseY(), button(i), 320, 100 + i * 100) Then sel = i Next ;exit if a button has been selected If MouseHit(1) And sel > 0 Then Exit Flip ;esc = exit Until KeyHit(1) ;show message if a button was selected If sel > 0 Then Cls Text 400, 300, "You selected Button" + sel, 1, 1 Flip Delay 200 FlushKeys() FlushMouse() Repeat Delay 50 If GetKey() <> 0 Then Exit Until MouseHit(1) End If End ;----------------------------------------------------------------------------------------------------- ; bCreateImage() ;----------------------------------------------------------------------------------------------------- ;creates an empty image with a certain color Function bCreateImage(w, h, r, g, b, s$ = "") oldr = ColorRed() oldg = ColorGreen() oldb = ColorBlue() oldbuffer = GraphicsBuffer() im = CreateImage(w, h) SetBuffer ImageBuffer(im) Color r, g, b Rect 0, 0, w, h Color 0, 0, 0 Text w/2, h/2, s$, 1, 1 Color oldr, oldg, oldb SetBuffer oldbuffer Return im End Function
thank you very much, bram32!