Hi there,
I’m using PsychoPy version 2022.2.4. I’m new to both PsychoPy and python and trying to get my very first PsychoPy experiment working.
I have imported pygame in the “Before experiment” section of the code component in PsychoPy and then in the “Each frame” section I included the below to test if it works:
if event.type == pygame.MOUSEBUTTONUP:
print("MOUSE CLICKED")
pos = pygame.mouse.get_pos()
# if the click event of the mouse cursor actually happened on my image then replay my audio from the start with no loops
if clicked_image.rect.collidepoint(pos)
# make sure the audio file is stopped and replay from the beginning
mysound.stop()
mysound.play(loops=None)
Eventually when this works, I want it to capture each new click that happens on a specific image, replay an audio file from the beginning (no audio loop).
However I’m getting this error:
AttributeError: module 'psychopy.event' has no attribute 'type'
So I feel I’m on stalemate for the past week on this…
I need something that will work and successfully translated in PsychoJS eventually, since my experiment will be online.
I’ve read on stackoverflow that is better to use MOUSEBUTTONUP rather than mouse.get_pressed()[0] as there are issues with potential infinite loops with the latter if not refreshed properly each time.
Many thanks,
Constantina