I use physics.joint which work fine in Codea, but when I use it in the Codea runtime as a xcode project, the joints seem to break (also in the 1.5 beta). Anyone seen anything similar? Is the implementation different or is it just coincidence that it happens?
-- connecting two circle bodys
self.a, self.b = a,b
local v1,v2 = vec2(a.body.x, a.body.y), vec2(b.body.x, b.body.y)
local mid = v1 + (v2-v1)*0.5
self.w, self.h = (v1-v2):len(),50
local hw,hh = self.w/2,self.h/2
self.body = physics.body(POLYGON,
vec2(-hw,-hh), vec2(hw,-hh), vec2(hw,hh))
self.body.x = mid.x
self.body.y = mid.y
local j = physics.joint(REVOLUTE, a.body, self.body, a.body.position)
local j2 = physics.joint(REVOLUTE, b.body, self.body, b.body.position)
THANK YOU! I was really trying hard to understand what was going on with my code, suddenly I realized #body.joints was becoming ZERO at some random point. Could not figure out why until I find your post. Thank you a lot @tnlogy.
Thanks, I had the same problem, but in codea itself. Though I would expect the bodies the selfs to have references to the joints, since they have a joints property. Anyway, this does fix my problem, thx