I have recently learnt how to use Types to good effect but have ran into a little problem.
I have created a type to hold Hotspots on a screen i.e when the mouse moves to a certain area on screen and colides with the hotspot, the pointer changes to a hand icon. When moving away from the hotsopt it should turn back into a pointer again. In this case it does not. Its slightly doing my nut but it is probably something i missed.
Code as follows with 2 on screen hotspots, (2 images are required for the collision)
Type HOTSPOT
Field HID% ; Hotspot ID
Field HX% ; X Pos
Field HY% ; Y Pos
Field HW% ; Hotspot Width
Field HH% ; Hotspot Height
End Type
Graphics3D 300,300,32,2
SetBuffer BackBuffer()
Global hand=LoadImage("hand.bmp"); Mouse Pointer
Global pointer=LoadImage("redsq.bmp"); Mouse Pointer
HandleImage hand,7,0
HotCreate(0,0,0,10,10)
HotCreate(1,100,0,10,10)
HidePointer()
While Not KeyHit(1)
Cls
hotspotupdate()
Flip
Wend
End
Function HotCreate(HID%,HX%,HY%,HW%,HH%)
H.HOTSPOT = New HOTSPOT
H\HID% = HID%
H\HX% = HX%
H\HY% = HY%
H\HW% = HW%
H\HH% = HH%
Return True
End Function
Function hotspotupdate()
For H.HOTSPOT = Each HOTSPOT
If H\HID%=0
If RectsOverlap(H\HX%,H\HY%,H\HW%,H\HH%,MouseX(),MouseY(),1,1)
DrawImage hand,MouseX(),MouseY()
If MouseDown(1)
Text 100,100,"Hotspot!!!!"
End If
End If
Else If H\HID%=1
If RectsOverlap(H\HX%,H\HY%,H\HW%,H\HH%,MouseX(),MouseY(),1,1)
DrawImage hand,MouseX(),MouseY()
If MouseDown(1)
Text 100,100,"Hotspot2!!!!"
End If
End If
Else
DrawImage pointer,MouseX(),MouseY()
End If
Next
Return True
end Function
I have created a type to hold Hotspots on a screen i.e when the mouse moves to a certain area on screen and colides with the hotspot, the pointer changes to a hand icon. When moving away from the hotsopt it should turn back into a pointer again. In this case it does not. Its slightly doing my nut but it is probably something i missed.
Code as follows with 2 on screen hotspots, (2 images are required for the collision)
Type HOTSPOT
Field HID% ; Hotspot ID
Field HX% ; X Pos
Field HY% ; Y Pos
Field HW% ; Hotspot Width
Field HH% ; Hotspot Height
End Type
Graphics3D 300,300,32,2
SetBuffer BackBuffer()
Global hand=LoadImage("hand.bmp"); Mouse Pointer
Global pointer=LoadImage("redsq.bmp"); Mouse Pointer
HandleImage hand,7,0
HotCreate(0,0,0,10,10)
HotCreate(1,100,0,10,10)
HidePointer()
While Not KeyHit(1)
Cls
hotspotupdate()
Flip
Wend
End
Function HotCreate(HID%,HX%,HY%,HW%,HH%)
H.HOTSPOT = New HOTSPOT
H\HID% = HID%
H\HX% = HX%
H\HY% = HY%
H\HW% = HW%
H\HH% = HH%
Return True
End Function
Function hotspotupdate()
For H.HOTSPOT = Each HOTSPOT
If H\HID%=0
If RectsOverlap(H\HX%,H\HY%,H\HW%,H\HH%,MouseX(),MouseY(),1,1)
DrawImage hand,MouseX(),MouseY()
If MouseDown(1)
Text 100,100,"Hotspot!!!!"
End If
End If
Else If H\HID%=1
If RectsOverlap(H\HX%,H\HY%,H\HW%,H\HH%,MouseX(),MouseY(),1,1)
DrawImage hand,MouseX(),MouseY()
If MouseDown(1)
Text 100,100,"Hotspot2!!!!"
End If
End If
Else
DrawImage pointer,MouseX(),MouseY()
End If
Next
Return True
end Function