physics.pause()

Type Function
Library physics.*
Return value none
Revision 2017.3060
Keywords physics, pause, pausing, simulation
See also physics.start()

Overview

Pause the physics engine.

Syntax

physics.pause()

Example

local isPaused = false

function pausePhysics( event )
    if "began" == event.phase then
        if isPaused == false then
            physics.pause()
            isPaused = true
        elseif isPaused == true then
            physics.start()
            isPaused = false
        end
    end
end

Runtime:addEventListener( "touch", pausePhysics )
physics.start()
-- pause physics simulation after 3 seconds
timer.performWithDelay( 3000, function()

    physics.pause()

end, 1 )