How to add a delay in a function

local function onShake (event)     if event.isShake then timer.performWithDelay (1000 )         composer.gotoScene("levels.question10a") print(" Going To question 10a")     end end

How do I make it so there is a delay before it goes to the next scene after you shake.

All it does right now is goto the next scene without having a delay.

You need to use the listener. Something like this : 

local function onShake (event) local listener = {} function listener:timer( event ) print( "listener called" ) composer.gotoScene("levels.question10a") print(" Going To question 10a") end     if event.isShake then timer.performWithDelay( 1000, listener )     end end

You need to use the listener. Something like this : 

local function onShake (event) local listener = {} function listener:timer( event ) print( "listener called" ) composer.gotoScene("levels.question10a") print(" Going To question 10a") end     if event.isShake then timer.performWithDelay( 1000, listener )     end end