Showing an image after click with 500 ms delay

Hi,

I want an image to appear on the screen 500 ms after a mouse press. The solution I have right now is very unreliable (i.e. the image doesn’t always show) and I suspect it has to do with the timer, but I don’t understand why.

What I have right now is this:

timer = core.Clock()

in my code component in tab Begin Routine:

startdelay = False
waitforit = True

Each Frame

if startdelay:
    while timer.getTime() < 0.5:
        waitforit = True
        if timer.getTime() > 0.5:
            waitforit = False # image component starts when waitforit is False
            break
elif vtreplay.isPressedIn(rpVT):
    startdelay = True
    timer.reset()

What am I missing?

-Sabine

Don’t use while in Builder

lol seriously? So it should work online? I haven’t tried it online yet because my exp is huge and syncing takes ages on my old pc.

I’ll try it out tomorrow.

Thanks for the quick response though!

Back on a laptop. Personally for this job I’d just use t (time since start of routine).

Begin Routine:

startdelay = 0
waitforit = True

Each Frame

if startdelay > 0 and t > startdelay+.5:
            waitforit = False # image component starts when waitforit is False
elif vtreplay.isPressedIn(rpVT):
    startdelay = t

Except I’ve never used conditional starts so I’d probably actually .setOpacity(1) instead.

You could use your own clock but it would need to be created in a Both component (see my crib sheet).