We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I'm attempting some simple simulations of analogue control systems like sliders, and controlP5 looks great!
At the moment, I have a slider that controls the rotation speed of an object. I would like it if the slider would return to a specified position upon releasing the mouse button. I have tried this as a quick hack to see what happens:
if (mousePressed == true) {
sliderValue = sliderValue;
} else {
sliderValue = 0;
}
sliderValue does indeed return to 0 when the mouse is released (and the object stops spinning). However, the slider position remains at wherever it was until the mouse was released. Is it possible to have the slider position also return to 0? (it would also be ideal if the return to 0 was smooth, as if it were a sprung-loaded lever). Thanks in advance.
Answers
Don't set the variable, set the slider.
Post a small runnable example, if you want us to show you how.
Thank you. I looked through the various methods at the end of the example and haven't identified how to do it. I've now got sliderValue slowly going back to 0, but the slider position issue still persists. I would be grateful for any help (as small as I could get it, sorry):
Ok, some pointers:
Adapted Code
Thank you for both the improved code and the explanation, very useful. :)