Hi everyone, I’ve been on this for hours and feel a bit stupid… Considering the complexity of my current code, basic syntax seems to be causing me a problem.
I’m trying to create a pivot joint between two colliding physics objects (at the point of collision). I’m well aware of the limitations of running a script whilst a collision event is ‘calculating’, so I’ve followed the advise; ‘add a timer before triggering the event’. I just can’t get it to work, I’m tearing my hair out. I know I’m missing something obvious, but I’ve been looking at the code for that long my brain is starting to fry.
Example:
[lua]local jointSensor = display.newCircle( 200, 420, 20 )
physics.addBody( jointSensor, {isSensor=true, radius = 60 } )
jointSensor.isVisible = true
local connect = function (event, self)
if event.other.name == “ball” and event.phase == “began” then
physics.newJoint( “pivot”, jointSensor, mainball, 30, 36 )
end
timer.performWithDelay(10, connect, 1)
end
jointSensor:addEventListener(“collision”, connect)[/lua]
‘ball’ is a dynamic physics object… Obviously I’ve implemented the timer function in the wrong way. Terminal reports: “attempt to call field ‘performWithDelay’ (a nil value)”.
Really bashing my head against the wall, any help will be gratefully received.
Mark
[import]uid: 176868 topic_id: 35467 reply_id: 335467[/import]