My object attaches with a joint perfectly fine.
When I exit the area to breakjoint, it does display the break according to the printed message. It just doesn’t break the joint with otherobject.touchJoint:removeSelf()
This is based off the Radial Gravity project.
I’m just struggling with the Joint Break Point, it just isn’t breaking and keeps a hold of the object.
local function BlackHoleCollision(self,event) local otherobject = event.other local function joint(event) local action = "" if ( event.source ) then action = event.source.action ; timer.cancel( event.source ) end if action == "makejoint" then print (action) self.isSensor = true otherobject.hasJoint = true otherobject.touchJoint = physics.newJoint( "touch", otherobject,otherobject.x, otherobject.y) otherobject.touchJoint.frequency = magnetPull otherobject.touchJoint.dampingRatio = 0.3 otherobject.touchJoint:setTarget( self.x, self.y ) else if action == "breakjoint" then print (action) otherobject.hasJoint = false otherobject.touchJoint:removeSelf() otherobject.touchJoint = nil end end end if ( event.phase == "began" ) then print("started") local tr = timer.performWithDelay(50, joint) tr.action = "makejoint" else if ( event.phase == "ended" ) then print("ended") local tr = timer.performWithDelay(50, joint) tr.action = "breakjoint" end end end field.collision = BlackHoleCollision field:addEventListener( "collision", field ) end
This is the error:
2013-06-06 17:13:33.708 Corona Simulator[383:707] Runtime error ...dom/Desktop/Build 6/Class Objects/BlackholeClass.lua:58: attempt to call method 'removeSelf' (a nil value) stack traceback: [C]: in function 'removeSelf' ...dom/Desktop/Build 6/Class Objects/BlackholeClass.lua:58: in function '\_listener' ?: in function \<?:141\> ?: in function \<?:218\>