Mousewheel for zoom
BlitzMax Forums/BlitzMax Programming/Mousewheel for zoom
| ||
Hello. Having a little problem with this. I've already written code to make my map zoom in and out - that's not the issue. I was going to use MouseZ() so I can control the zoom level with the mousewheel. The problem is that if I scroll the mouse up one click, MouseZ() returns 1, and continues to return 1 until I move it up another click, then it returns 2. I need to change the zoom factor smoothly-ish between 0.5028, and 1. I'm really not interested in how far the mousewheel has been scrolled, just whether its moved up or down. What's your thoughts on how best to achieve this? Is there some way I can reset the mouseZ counter? I know I could store the value of the last MouseZ() and calculate + or - that way but it seems a bit kludgy. Must be a better way? [edit] I've just discovered that FlushMouse will do this, but I don't want everything to do with the mouse to be reset with it. |
| ||
I'd just build a function for this, what is what you suggested anyways.Function MouseZSpeed:Int() Global _mz:Int Local mz:Int = MouseZ() If mz = _mz Then Return 0 EndIf If mz > _mz Then _mz = mz Return 1 EndIf _mz = mz Return -1 End Function |
| ||
Yep, I'd probably resort to MouseZSpeed as well |
| ||
Yep, had stuff of my own in the code archives similar to that although mine only catered for mouse x/y speed. It does work pretty well, just wish there'd been a more elegant solution. cheers. :) |
| ||
Yeah I just ended up holding the last value in memory and looking for a change. |