Polygon color changed with a flash in the next trial

Description of the problem:

Psychopy Version: 2021.2.3

Description of problem: I set the color of a polygon changeable in ‘each frame’ with response to the button press. For example, the polygon would change from gray to blue if I press the corresponding button. However, in the next trial, the polygon will quickly change its color from blue to gray.

I have set the color (for example, op1fillcolor) to default both in “begin routine” and “end routine”.

the example of code:

Begin routine

op1fillcolor = bgcolor

Each frame

if choice_resp.keys == "left":
    op1fillcolor = opnumcolor

End routine

op1fillcolor = bgcolor

I would be very gradeful for your help!!

I think this might be a bug where the color of the stim isn’t set on the first frame. To check that, please could you please try in your begin routine tab

polygon.setColor(bgcolor)

where polygon is the name of your polygon component?

Thanks for your reply!!!

But I tried .setColor but it failed. However, it inspired me to use .setFillColor since I mainly aimed at controling the fill color of the polygon.

code example in Begin Routine

Op1.setFillColor(bgcolor)
Op2.setFillColor(bgcolor)

The code worked! Thank you very much!