One the keyboard component, there is a checkbox called discard previous. I don’t think you want it ticked.
However, here’s some sample Each Frame code from one of my experiments, which you can try out here: https://run.pavlovia.org/Wake/change-detection-rsvp:
if drawn == nObjects*2+2:
continueRoutine=False
elif drawn > nObjects+1:
if hidden==1 and myClock.getTime() > gapTime:
pic[drawn-nObjects-2].setAutoDraw(True)
print('waxon',drawn,'t',t)
hidden=0
myClock.reset()
elif hidden==0 and myClock.getTime() > frameSpeed:
pic[drawn-nObjects-2].setAutoDraw(False)
print('waxoff',drawn,'t',t)
drawn+=1
hidden=1
myClock.reset()
elif drawn == nObjects+1:
if myClock.getTime() > maskTime:
imageNoise.setAutoDraw(False)
drawn+=1
hidden=1
myClock.reset()
elif drawn == nObjects:
imageNoise.setAutoDraw(True)
drawn+=1
print('drawn2',drawn,'t',t)
if thisCondition[1]==1:
shuffle(thisOrder)
pic[thisOrder[0]].fillColor=colours[thisOrder[1]][1]
pic[thisOrder[1]].fillColor=colours[thisOrder[0]][1]
pic[thisOrder[0]].lineColor=colours[thisOrder[1]][1]
pic[thisOrder[1]].lineColor=colours[thisOrder[0]][1]
thisExp.addData('Swap1',thisOrder[0])
thisExp.addData('Swap2',thisOrder[1])
print('Swap1',thisOrder[0])
print('Swap2',thisOrder[1])
if thisCondition[0]==1:
shuffle(thisOrder)
else:
thisOrder=[0,1,2,3,4]
print('Order',thisOrder)
thisExp.addData('Order',thisOrder)
myClock.reset()
elif hidden==1 and myClock.getTime() > gapTime:
pic[drawn].setAutoDraw(True)
print('waxon',drawn,'t',t)
hidden=0
myClock.reset()
elif hidden==0 and myClock.getTime() > frameSpeed:
pic[drawn].setAutoDraw(False)
print('waxoff',drawn,'t',t)
drawn+=1
hidden=1
myClock.reset()
This uses an array of polygon objects created in Begin Routine
shuffle(shapes)
shuffle(colours)
pic=[]
for Idx in range(nObjects):
pic.append(visual.ShapeStim(
win=win,
fillColor=colours[Idx][1],
lineColor=colours[Idx][1],
vertices=shapes[Idx],
pos = (0,0),
size=scale
))
Alternatively, you could have load the images into a list before the trial using my interleaved list principle and then .setImage at intervals in the Each Frame code.