我正在用电晕 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)
--------------------------------------------------------------------------------------
提前致谢...