backspaces
Junior Member
Offline
Posts: 66
loop()/noLoop() switching does not adjust pmouse?
May 25th , 2006, 6:54pm
I have a complex model of a stadium: http://www.backspaces.net/models/Stadium/applet/ ..that I want to be able to pause, but still be able to navigate around to see what's happening. Unfortunately, while toggling between paused (using noLoop()), and temporarily enabled (using loop()) for mouse navigation, the pmouseX/Y appear to be incorrectly set. To make things easy to debug, I've built a much simpler version of the problem. http://backspaces.net/files/test/applet It is a cube that changes color every step of the model. "P" pauses the model by using noLoop(). But to enable navigation, when the mouse button is used during the pause state, we use loop() and noLoop() to turn back on the draw() routine, but without changing the current color (i.e. not "running the model"). To see the problem, start the applet and navigate with the mouse to get a feel for how it works. Then press "P" to go into the paused state. Before clicking the mouse to navigate, move it around a bit from where it was when you paused. Now when you click, the navigation "jumps". If the mouse does not move between up/down transitions in the paused state, all is well. But anytime you move the mouse after a mouse up and then mouse down again, you'll see the jump. If you then toggle pause via "P", you'll NOT see the same behavior .. i.e. moving the mouse between clicks will work as you'd expect. If even the simplified test is too complicated, let me know and I'll build a REALLY simple test! The source is here: http://backspaces.net/files/test.tar.gz Owen