I’m creating a task where participants are supposed to click on a specific location on the screen and when they do, I change the opacity of an image hiding there from 0 to 1 so that it becomes visible.
I’ve got that working, but I’d really like to delay the change in opacity to only occur after 2 seconds have passed since the mouse click, and have that mouse-click timer reset after each time. Maybe I missed it in another thread, but is there built-in mouse time we can access? Or would I need to start a timer within the mouse-click if-statement, and then
Current JS code in Each Frame:
if ((mouse.getPressed()[0] === 1)) {
if (mouse.isPressedIn(corrDiffPoly1_L)) {
corrImage1L_opac = 1;
corrImage1_isDone = 1;
} else {
corrImage1L_opac = 0;
What I’m guessing I’d need to do if there is no builtin mouse timer is something like:
if ((mouse.getPressed()[0] === 1)) {
if (mouse.isPressedIn(corrDiffPoly1_L)) {
mouseTimer = new util.Clock();
if ((mouseTimer >= 2)) {
corrImage1L_opac = 1;
corrImage1_isDone = 1;
} else {
corrImage1L_opac = 0;
Any suggestions?