timer.resume()

Type Function
Library timer.*
Return value Number
Revision Release 2024.3703
Keywords timer, resume, pause
See also timer.pause()
timer.performWithDelay()

Overview

Resumes a specific timer or all timers with the same tag that were paused with timer.pause().

If a specific timer is resumed, then the function returns a number that represents the amount of time remaining in the timer.

Syntax

timer.resume( whatToResume )
whatToResume (required)

Object or String. The timer ID from, or tag passed to, timer.performWithDelay(). Note: Using tag requires Solar2D 2020.3611 or a newer build.

Example

local function listener( event )
    print( "listener called" )
end
 
timer1 = timer.performWithDelay( 2000, listener )  -- wait 2 seconds

-- sometime later...
local pauseTime = timer.pause( timer1 )
print( "Time remaining is " .. pauseTime )

-- sometime later...
local resumeTime = timer.resume( timer1 )
print( "Resume time is " .. resumeTime )
local function listener( event )
    print( "listener called" )
end
 
timer1 = timer.performWithDelay( 2000, listener, "red" )  -- wait 2 seconds
timer2 = timer.performWithDelay( 3000, listener, "blue" )  -- wait 3 seconds

-- sometime later...
timer.pause( "red" )

-- sometime later...
timer.resume( "red" )