Issue with physics pause/resume

Hi!
I’m trying to make a zoom function in my game. When you zoom in, the physics pause and when you zoom out, the physics resume. In my project, the physics must resume when the zoom out transition animation is finished. So I used the “onComplete” parameter. But it doesn’t work… Any suggestion welcome :slight_smile:

[code]local function zoom( event )
if isZoom == true then
physics.pause()
transition.to( level, { time=600, xScale=0.3, yScale=0.3, xReference=level.width/2, x=_W/2, yReference=level.height/2, y=_H/2, transition=easing.inOutExpo } )
transition.to( spaceBackground, { time=600, xScale=1, yScale=1, transition=easing.inOutExpo } )
isZoom = false
else
transition.to( level, { time=600, xScale=1, yScale=1, xReference=hero.xOrigin, yReference=hero.yOrigin, x=_W/2, y=_H/2, transition=easing.inOutQuad } )
transition.to( spaceBackground, { time=600, xScale=1.4, yScale=1.4, onComplete=switchPhysics, transition=easing.inOutQuad } )
isZoom = true
end
end

local function switchPhysics()
physics.start()
end[/code] [import]uid: 25327 topic_id: 7680 reply_id: 307680[/import]

Declare the completion function first:

local switchPhysics  
  
local function zoom( event )  
 -- etc  
end  
  
function switchPhysics()   
 physics.start()  
end  
  

Unfortunately you don’t get an error but it doesn’t get called if not pre-declared. [import]uid: 3953 topic_id: 7680 reply_id: 27745[/import]

Oops! Thanks :slight_smile: [import]uid: 25327 topic_id: 7680 reply_id: 29287[/import]