Every 20 seconds I want a shield to appear and when that collides with the plane the spikes will stop spawning for about 5 seconds then when that 5 seconds are over the spikes will start appearing. But I can only get the timer to pause and I dont know how to resume the timer.
local shield = {} local fTimer local fCounter = 1 local function spawnShields() local xRandom = math.random( centerX - actualW, centerX + actualW ) shield[fCounter] = display.newImageRect( "Shield.png", 80, 75 ) shield[fCounter].myName = "forceField" shield[fCounter].x = xRandom shield[fCounter].y = -200 physics.addBody( shield[fCounter], "dynamic", { radius = 20 } ) shield[fCounter].gravityScale = 0 shield[fCounter]:setLinearVelocity( 0, 200 ) shield.isHitTestable = false sceneGroup:insert(shield[fCounter]) shield[fCounter].value = fCounter fCounter = fCounter + 1 end fTimer = timer.performWithDelay( 20000, spawnShields, 5 ) local function onCollision( event ) if event.phase == "began" then if event.target.myName == "airPlane" and event.other.myName == "forceField" then timer.pause( sTimer ) print( "YEs it worked") display.remove( forceField ) end end end Plane:addEventListener("collision", onCollision )