The If..ElseIf..Else conditional in your For..Each loop will never enter your Else block; the loop will iterate twice, once for each of your hotspot objects.
Whenever possible, eliminate nested blocks to simplify your code. Your logic can be broken down into two steps: (1) figure out which hotspot the mouse is over, then (2) draw the correct mouse cursor.
It's also better to poll your mouse position only once, since it can change while your code is executing, leading to confusing results!
Try this instead:
Whenever possible, eliminate nested blocks to simplify your code. Your logic can be broken down into two steps: (1) figure out which hotspot the mouse is over, then (2) draw the correct mouse cursor.
It's also better to poll your mouse position only once, since it can change while your code is executing, leading to confusing results!
Try this instead:
local mouse_x = mousex() local mouse_y = mousey() local active_hotspot.hotspot = NULL for h.hotspot = each hotspot if RectsOverlap(H\HX%,H\HY%,H\HW%,H\HH%,Mouse_X,Mouse_Y,1,1) then active_hotspot = h : exit next if active_hotspot <> NULL then DrawImage hand,Mouse_X,Mouse_Y if mousedown(1) then text 100,100,"clicked hotspot id " + active_hotspot\HID + "!" else DrawImage pointer,Mouse_X,Mouse_Y endif