MouseZSpeed ( )
Parameters
| None. |
Description
|
Returns how many wheel notches the mouse wheel has turned since the last time you asked. This is the easy way to read the wheel. Call it once a frame and you get 0 when the wheel has not moved, a positive number for notches rolled away from you and a negative number for notches rolled towards you - normally 1 or -1, but more if the player spun the wheel hard between calls. It is the natural control for cycling weapons, zooming a camera, or scrolling a list: add the value to your selection index and wrap or clamp it. Because it is a difference you do not have to remember the previous value yourself, which is what makes it nicer to use than the running total from MouseZ. The value is the change since your previous call to this same command, not since the previous frame, so call it exactly once per loop and store the result if more than one part of your code needs it. Calling it twice means the second call reports nothing. Gotchas: wheel movement is only counted while your window has the focus, and losing focus resets the wheel total, which can show up as one odd reading when you come back. Plenty of mice have no wheel at all, so give anything important a keyboard alternative as well. See also: MouseZ, MouseXSpeed, MouseYSpeed, MouseHit. |
Example
; MouseZSpeed Example ; ------------------- Graphics 640,480,0,2 SetBuffer BackBuffer() ang#=0 While Not KeyDown(1) Cls ; MouseZSpeed returns the wheel movement since the last call: ; -1 rolled towards you, 0 still, 1 rolled away from you. zs=MouseZSpeed() ; Spin the radar sweep arm with the wheel ang=ang+zs*15 ; Radar dish: a circle with the rotating sweep arm inside Color 0,170,0 Oval 220,140,200,200,False Line 320,240,320+Cos(ang)*95,240+Sin(ang)*95 Color 255,255,255 Text 0,0,"Roll the mouse wheel to spin the radar arm Esc: exit" Text 0,20,"MouseZSpeed() this frame: "+zs+" arm angle: "+Int(ang) Flip Wend End
Index