Change opacity when I click on a rectangle

URL of experiment: https://pavlovia.org/Mark/sym1-0

Description of the problem:
Hi! My aim is that when a participant clicks with the mouse on a rectangle, the opacity of the rectangle should change from 0.1 to 1.0. This works fine under normal conditions but not online. Here, the opacity is not changed after clicking on the rectangle.

In a code component I have the following code (recallR1 refers to the name of the first rectangle):

Begin routine:
Python:
recallR1.opacity = 0.1

JS:
recallR1.opacity = 0.1;

Each frame:
Python:
if mouse.isPressedIn(recallR1):
recallR1.opacity = 1
JS:
if (mouse.isPressedIn(recallR1)) {
recallR1.opacity = 1;
}

Many thanks for any help!

Hi,

I also had problems with opacity niìot changing online a while back, but I resolved the issue changing the color of the polygon (since mine was supposed to disappear entirely).

Insted of using recallR1.opacity try naming the opacity inside the builder something like $myOpacity and then change myOpacity in the code component.

Also try changing the opacity setting to change from constant to update every frame if the previous suggestion does not work.

Also just to be sure place the code component at the be very top of the component list!

tandy

1 Like

Hi tandy,

Thank you so much for your answer!
It did not work with the opacity but based on your advices I changed the color. Now it works online, at least with a black/white design :smile:

1 Like

Yeah I don’t know why opacity doesn’t want to cooperate online! :sweat_smile:

Try object.setOpacity(1) with the opacity in the object component set to constant.

However, I have a feeling that there is an opacity related bug in some versions.

There seems to be a big issue with modifying the opacity of visual stimuli in online experiments. It is a known issue since version 2020.2 was released and has not been fixed yet.

Hi, I think I stumbled on the same issue. I noticed all of my older scripts aren´t working any more when recompiled, and I think the reason is I was using opacity to show either one stimulus (polygon) or another in a given trial. Since I updated to the new Psychopy version (2020.2.8) it appears that the opacity values are not updated systematically, so some of the stimuli keep the value from the previous trial. What´s a bit bizarre to me, is that this seems to happen completely randomly.

Does anybody know what the latest version was, that one could re-install to avoid the bug?

Thanks!

Matteo