hey
I have a cross…and button which makes the cross rotate…when it rotates, that box should also move accordingly… see the pic to get clarified
So when that cross rotates,box should also move
hey
I have a cross…and button which makes the cross rotate…when it rotates, that box should also move accordingly… see the pic to get clarified
So when that cross rotates,box should also move
You could use a weld joint
https://docs.coronalabs.com/daily/guide/physics/physicsJoints/index.html#weld
That didnt worked
cross = display.newImage("cross.png") cross.x , cross.y = centerX, centerY + 50 physics.addBody(cross,"static") star = display.newRect(0,0,80,80) star.x = cross.x + cross.width \* 0.3 star.y = cross.y - cross.height \* 0.3 physics.addBody(star,"static") pJoint = physics.newJoint("weld",star,cross,star.x,cross.x) local function onSwitchTouch( event ) -- body if (event.phase == "began") then trans = transition.to(cross,{rotation = cross.rotation + 90, time = 100}) end return true end switchBtn:addEventListener("touch",onSwitchTouch)
It is because you are using transition.to
So no other way ?
Let me take a look
Thanks for that ! 
Could you not put them both into a display group and then rotate the group?
(At work at the mo so cannot test it!)
NOpe… That too didn’t worked
--Math functions local Cos = math.cos local Sin = math.sin local Rad = math.rad local Atan2 = math.atan2 local Deg = math.deg local physics = require("physics") local cross = display.newImage("cross.png") cross.x , cross.y = display.contentCenterX, display.contentCenterX + 50 physics.addBody(cross,"static") local star = display.newRect(0,0,80,80) star.x = cross.x + cross.width \* 0.3 star.y = cross.y - cross.height \* 0.3 physics.addBody(star,"static") local pJoint = physics.newJoint("weld",star,cross,star.x,cross.x) local angle = 90 local radius = (cross.height/2) local function onSwitchTouch( event ) if (event.phase == "began") then star.x = cross.x + Cos(Rad(angle)) \* radius star.y = cross.y + Sin(Rad(angle)) \* radius angle = angle + 45 cross.rotation = cross.rotation +45 end return true end local rect = display.newRect( display.contentCenterX, display.contentCenterY+150, 100, 100 ) rect:addEventListener("touch",onSwitchTouch)
Worked! Thanks
You could use a weld joint
https://docs.coronalabs.com/daily/guide/physics/physicsJoints/index.html#weld
That didnt worked
cross = display.newImage("cross.png") cross.x , cross.y = centerX, centerY + 50 physics.addBody(cross,"static") star = display.newRect(0,0,80,80) star.x = cross.x + cross.width \* 0.3 star.y = cross.y - cross.height \* 0.3 physics.addBody(star,"static") pJoint = physics.newJoint("weld",star,cross,star.x,cross.x) local function onSwitchTouch( event ) -- body if (event.phase == "began") then trans = transition.to(cross,{rotation = cross.rotation + 90, time = 100}) end return true end switchBtn:addEventListener("touch",onSwitchTouch)
It is because you are using transition.to
So no other way ?
Let me take a look
Thanks for that ! 
Could you not put them both into a display group and then rotate the group?
(At work at the mo so cannot test it!)
NOpe… That too didn’t worked
--Math functions local Cos = math.cos local Sin = math.sin local Rad = math.rad local Atan2 = math.atan2 local Deg = math.deg local physics = require("physics") local cross = display.newImage("cross.png") cross.x , cross.y = display.contentCenterX, display.contentCenterX + 50 physics.addBody(cross,"static") local star = display.newRect(0,0,80,80) star.x = cross.x + cross.width \* 0.3 star.y = cross.y - cross.height \* 0.3 physics.addBody(star,"static") local pJoint = physics.newJoint("weld",star,cross,star.x,cross.x) local angle = 90 local radius = (cross.height/2) local function onSwitchTouch( event ) if (event.phase == "began") then star.x = cross.x + Cos(Rad(angle)) \* radius star.y = cross.y + Sin(Rad(angle)) \* radius angle = angle + 45 cross.rotation = cross.rotation +45 end return true end local rect = display.newRect( display.contentCenterX, display.contentCenterY+150, 100, 100 ) rect:addEventListener("touch",onSwitchTouch)