Windows: Windows 10, 64 bit
PsychoPy version : 2021.1.4
Standard Standalone? (y/n) y
What are you trying to achieve?:
When clicking (with the mouse) on one of three stimuli, the opacity of the clicked stimulus (a jpg image) should change and after 0.5 seconds the routine should end. We want a delay of 0.5 seconds to allow participants to receive visual feedback on where they clicked (the opacity change). The three stimuli shown on the screen are called: Stim_1, Stim_2, Stim_3. We are working with code components in builder view for now, but will eventually want to transfer to Pavlovia.
There are two parts to this: (1) opacity change of stimulus and (2) waiting 0.5 s after a stimulus is clicked and then ending the routine. Both code components work separately but not together.
What did you try to make it work?:
(1) Here is the code for the opacity change:
In ‘Begin Routine’ tab:
timer = core.Clock() Stim_1.opacity = 1 Stim_2.opacity = 1 Stim_3.opacity = 1
In ‘Each Frame’ tab:
if mouse.isPressedIn(Stim_1): ````Stim_1.opacity = 0.1 elif mouse.isPressedIn(Stim_2): ````Stim_2.opacity = 0.1 elif mouse.isPressedIn(Stim_3): ````Stim_3.opacity = 0.1
(2) This is the code for ending the routine, also entered in ‘Each Frame’:
if (Stim_1.opacity==0.1) or (Stim_2.opacity==0.1) or (Stim_3.opacity==0.1): ````timer.reset() ````while timer.getTime()<0.5: ``````continueRoutine=True ````else: ``````continueRoutine=False
What specifically went wrong when you tried that?:
If we run the first code component and fix the durations of all components in the routine (e.g. to 2s), we see the clicked stimulus change opacity. However, the change of opacity ‘runs into’ the next routine (i.e. that Stim is still grey in the next repeat of the loop). If the second code is added (now leaving the durations of all components empty), then we do not see the opacity change anymore, but it does go to the next routine after 0.5 s. Any tips or insights greatly appreciated!