We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › loop()/noLoop() switching does not adjust pmouse
Page Index Toggle Pages: 1
loop()/noLoop() switching does not adjust pmouse? (Read 817 times)
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
Re: loop()/noLoop() switching does not adjust pmou
Reply #1 - May 25th, 2006, 7:14pm
 
I just did another test to prove the problem is with the first time through draw() after a noLoop/loop transition.  Here is the slightly modified applet:
http://backspaces.net/files/test1/applet

I added a boolean "skip" which tells the draw() loop to just skip this time through, so that everything resynchs.  When I do that, everything works as desired.  If the first line in draw() is commented out, we're back to the old behavior.

Source is here:
http://backspaces.net/files/test1.tar.gz

Owen
Page Index Toggle Pages: 1