Graphics 800,600,0,2
SetBuffer BackBuffer()
Dim buttonAnim(2)
For i=0 To 2
buttonAnim(i)=CreateImage(32,32)
Next
Rect 0,0,32,32,True
CopyRect 0,0,32,32,0,0,BackBuffer(),ImageBuffer(buttonAnim(0))
Cls : Rect 8,8,16,16,True
CopyRect 0,0,32,32,0,0,BackBuffer(),ImageBuffer(buttonAnim(1))
Cls : Rect 8,8,16,16,False
CopyRect 0,0,32,32,0,0,BackBuffer(),ImageBuffer(buttonAnim(2))
Global mouseHotSpot = CreateImage(1,1)
Rect 0,0,1,1,True : GrabImage mouseHotSpot,0,0
Type button
Field xPos
Field yPos
Field frame
Field transitionDelay
End Type
For i=0 To 3
currentButton.button=New button
currentButton\xPos=i*64
currentButton\yPos=100
currentButton\frame=0
currentButton\transitionDelay=0
Next
While Not KeyHit(1)
For currentButton=Each button
If ImagesOverlap (buttonAnim(currentButton\frame),currentButton\xPos,currentButton\yPos,mouseHotSpot,MouseX(),MouseY())
If currentButton\frame=0
currentButton\frame=1
currentButton\transitionDelay=10
Else
If currentButton\transitionDelay>0 Then currentButton\transitionDelay=currentButton\transitionDelay-1
If currentButton\transitionDelay=0 Then currentButton\frame=2
EndIf
Else
If currentButton\frame=2
currentButton\frame=1
currentButton\transitionDelay=10
Else
If currentButton\transitionDelay>0 Then currentButton\transitionDelay=currentButton\transitionDelay-1
If currentButton\transitionDelay=0 Then currentButton\frame=0
EndIf
EndIf
DrawImage buttonAnim(currentButton\frame),currentButton\xPos,currentButton\yPos
Next
Flip
Cls
Wend