Joints don't move (x,y) with display group (physics bodies contained in a group)

Hi, has anyone run into a workaround for this issue? I've submitted an offcial bug report but thought I'd throw it out there in case others have had the same problem.

The problem occurs when you:

1. Make two physics bodies and connect them via pivot joints (haven't tried all joint types)
2. Add them to a display group.
3. Move the X,Y coords of the display group ( helps visually to turn on 'physics.setDrawMode( "hybrid" ) ')

The joints do not move relative to the physics bodies and seem to be locked down to the original 0,0 display coords!

Example code follows, thanks! To see it work properly comment out this line:
transition.to( world, { time=2000, y=ragdoll.y-200, transition=easing.inOutExpo } )

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
--> Setup Display
display.setStatusBar (display.HiddenStatusBar)
 
system.activate ("multitouch")
 
local gameUI = require("gameUI")
 
--> Start Physics
local physics = require ("physics")
 
physics.start ()
physics.setGravity (0, 10)
physics.setDrawMode ("hybrid")
 
local world = display.newGroup()
 
-- Make walls
 
local walls = display.newGroup()
        
local leftWall  = display.newRect (0, 0, 1, display.contentHeight)
local rightWall = display.newRect (display.contentWidth, 0, 1, display.contentHeight)
local ceiling   = display.newRect (0, 0, display.contentWidth, 1)
local floor     = display.newRect (0, display.contentHeight, display.contentWidth, 1)
 
physics.addBody (leftWall, "static", {bounce = 0.0, friction = 10})
physics.addBody (rightWall, "static", {bounce = 0.0, friction = 10})
physics.addBody (ceiling, "static", {bounce = 0.0, friction = 10})
physics.addBody (floor, "static", {bounce = 0.0, friction = 10})
 
walls:insert(leftWall)
walls:insert(rightWall)
walls:insert(ceiling)
walls:insert(floor)
 
 
-- Make our bodies
local originX = 100
local originY = 200
local ragdoll = display.newGroup ()
         
local head = display.newCircle( 0, 0, 8 )
head.x = originX
head.y = originY
head:setFillColor (255, 255, 255, 128)
ragdoll:insert (head)
 
local torso = display.newCircle( 0, 0, 15 )
torso.x = originX
torso.y = head.y + head.height
torso:setFillColor (255, 255, 255, 128)
ragdoll:insert (torso)
 
 
physics.addBody (head, {bounce = 0.0, friction = 1.0})
physics.addBody (torso, {bounce = 0.0, friction = 1.0})
 
 
function ragdoll:addFrictionJoint(a, b, posX, posY, rFrom, rTo, mT) 
        local j = physics.newJoint ("pivot", a, b, posX, posY, rFrom, rTo)
        j.isLimitEnabled = true
        j:setRotationLimits (rFrom, rTo)
        j.isMotorEnabled = true
        j.motorSpeed = 0
        j.maxMotorTorque = mT or .05
        return j
end
        
-- head
ragdoll:addFrictionJoint(head, torso, torso.x, torso.y, -2, 2, 0.1)
 
-- torso 
--ragdoll:addFrictionJoint(torso, head, head.x, torso.y-5, -4, 4, 0.5)
 
function ragdoll:touch( event )
        gameUI.dragBody( event )
end
 
head:addEventListener ( "touch", ragdoll )
torso:addEventListener ( "touch", ragdoll )
 
 
world:insert(walls)
world:insert(ragdoll)
 
transition.to( world, { time=2000, y=ragdoll.y-200, transition=easing.inOutExpo } )
views:1643 update:2011/10/11 22:13:38
corona forums © 2003-2011