You can still change the opacity, just don’t call win.flip()
. Code in this tab of the code component runs once per win.flip()
that Builder calls. If you insert another one here, you will interrupt the timing of every other aspect of Builder: it’s expecting the code in this tab to be complete within one screen refresh, but you’ve just inserted a whole new pause for another refresh. So on a 60 Hz screen, this code will take 33.4 ms to execute, rather than 16.7 ms.
So what you need to do is add some logic so that you can flip the opacity across successive runs of the code in this tab. e.g. something like:
Begin experiment tab:
opacity_low = False
Every frame tab:
# check if the stimulus opacity was changed on the last refresh. If so, set it
# back to 1.0 and then end the routine after it is shown again:
if opacity_low:
stimulus1.opacity = 1 # make it fully visible again
opacity_low = False # reset for next trial
continueRoutine = False # end trial after showing stimulus on next frame.
else: # check for mouse clicks:
for stimulus1 in [ uh, oh, ah, au, u, o, a]:
if mouse.isPressedIn(stimulus1):
thisExp.addData('clicked', stimulus1.name)
stimulus1.opacity = 0.2
opacity_low = True
So now, on a mouse press, the stimulus opacity is set to 0.2 and the routine continues. On the next frame, the stimulus is set back to 1.0 and the routine will end after that.
This is the same arrangement you had before, but now you are working within Builder’s drawing loop, rather than disrupting it by inserting your own win.flip()