The code below can be easily modified to have only one plank in the rotating seesaw group, ie: no group, just the seesaw.
Can anyone tell me why, when the group of two images is used, that the seesaw group starts rotating on its own and doesn’t stop. However, when a single image is used, anchored at the same place the group is, there is no rotation at all, unless something collides with it…?
Btw, I’ve referenced images found in the Collision samples.
local physics = require( “physics” )
physics.start()
local seesaw = display.newImage( “board.png” )
seesaw.x = display.contentWidth / 2 - 80
seesaw.y = display.contentHeight - 150
local seesaw2 = display.newImage( “board.png” )
seesaw2.x = display.contentWidth / 2 + 80
seesaw2.y = display.contentHeight - 150
local group = display.newGroup()
group:insert( seesaw ) – assume rect1 is an existing display object
group:insert( seesaw2 ) – assume rect2 is an existing display object
for i = 1, group.numChildren do
local child = group[i]
local description = (child.isVisible and “visible”) or “not visible”
print( “child[”…i…"] is " … description )
end
local anchor = display.newImage( “rock.png” )
anchor.x = display.contentWidth / 2
anchor.y = display.contentHeight - 150
anchor.myName = “anchor”
physics.addBody( anchor, “static”, { density=1.0, friction=0.5, bounce=0.0 } )
local body = physics.addBody( group, { density=1.0, friction=0.5, bounce=0.0 } )
local myJoint = physics.newJoint( “pivot”, anchor, group, anchor.x, anchor.y )
[import]uid: 8271 topic_id: 2033 reply_id: 302033[/import]