私はコロナSDKで物理アプリをやっています。その中で、私は関節を備えた複合物理体を作成しています。必要なのは:'新しい結合されたボディをその中心で回転させる必要があります'。私はコードを与えています。誰か助けてください...
--------------------------------------------------------------------------------------
local physics = require( "physics" )
physics.start()
physics.setDrawMode("debug")
---------------------------
-- Creating bodies --
---------------------------
local body_1 = display.newRect(0,0,40,40)
local body_2 = display.newRect(0,0,40,40)
local body_3 = display.newRect(0,0,40,40)
local base_1 = display.newRect(0,display.contentHeight,display.contentWidth,display.contentHeight)
body_1.x = 100; body_1.y = 250;
body_2.x = 100; body_2.y = 300;
body_3.x = 150; body_3.y = 275;
---------------------------
-- Adding Physics --
---------------------------
physics.addBody( body_1, { density=1.6, friction=0.5, bounce=0.0} )
physics.addBody( body_2, { density=1.6, friction=0.5, bounce=0.0} )
physics.addBody( body_3, { density=1.6, friction=0.5, bounce=0.02, radius = 20} )
physics.addBody( base_1, "static", { density=1.6, friction=0.5, bounce=0.2} )
---------------------------
-- Creating Joints --
---------------------------
local myJoint_1 = physics.newJoint( "weld", body_1, body_2, 100,250 )
local myJoint_2 = physics.newJoint( "pivot", body_1, body_3, 100,250 )
local myJoint_2 = physics.newJoint( "pivot", body_2, body_3, 100,300 )
---------------------------
-- My Function --
---------------------------
local function rotateTheGroup()
-- I want to rotate the combined body here. And I need to know the newBodie's referencepoint.
end
Runtime:addEventListener("tap",rotateTheGroup)
--------------------------------------------------------------------------------------
前もって感謝します...