Rotating a n-blade visual&physical carrousel

Hi!

I need to build a carrousel composed of blades and an axis (blades have a body as well as the axis).

I am currently facing a blocking issue in regard to the rotation of an object that is both visual and physical, which is within a display group that has coordinates different from 0 (i.e. a relative referential of the stage): I can’t maintain the overlaying of the visual over the physical when I try to use an arbitrary (x,y) coordinates as the rotation center (the x, y being the coordinates of the display group my carrousel lies within).

Have you ever had the same problem and how had you it solved?

Many thanks!

PS: I’m using the Corona SDK version 2011.484 btw. [import]uid: 40274 topic_id: 12001 reply_id: 312001[/import]

Here is a sample of what I did, if you ever need any samples:

-- variables  
world = display.newGroup()  
masks = { ..., }  
  
-- functions  
setupAxis = nil  
onTap = nil  
  
setupAxis = function(object)  
 object.dg = display.newGroup()  
 world:insert(object.dg)  
 object.dg.x = object.x  
 object.dg.y = object.y  
  
 local blades = {}  
 for i=1,#object.blades do  
 local params = object.blades[i]  
  
 local blade = display.newImage(object.dg, "blade.png", 0, 0)  
 blade.x = params.x - object.dg.x  
 blade.y = params.y - object.dg.y  
 blade.rotation = params.rotation  
  
 local filter = {  
 categoryBits = masks.delimiter.categoryBits,  
 maskBits = masks.delimiter.maskBits,  
 }  
 physics.addBody(blade, "static", {  
 density = 1.0,  
 friction = 0.0,  
 bounce = 0.0,  
 filter = filter,  
 })  
  
 blades[#blades+1] = blade  
 end  
  
 object.axis = display.newImage("axis.png", 0, 0)  
 object.axis.x = 0  
 object.axis.y = 0  
 object.axis.blades = blades  
  
 object.dg:addEventListener("tap", onTap)  
  
 return  
end  
  
onTap = function(event)  
 local object = event.target.object  
 local time = (object.time or 1000)  
 local step = (object.step or 90)  
 local rstep = step \* math.pi/180  
 local easingx = require("easing")  
  
 for i=1,#object.axis.blades do  
 local blade = object.axis.blades[i]  
 if not blade.rotationTransition then  
 blade.rotationTransition = transition.to(blade, {  
 time = time,  
 rotation = blade.rotation - step,  
 transition = easingx.easeOutBounce,  
 onComplete = function()  
 if blade.rotationTransition then  
 blade.rotationTransition = nil  
 end  
 end  
 })  
 end  
 end  
  
 if not object.dg.rotationTransition then  
 object.dg.rotationTransition = transition.to(blade, {  
 time = time,  
 rotation = object.dg.rotation - step,  
 transition = easingx.easeOutBounce,  
 onComplete = function()  
 if object.dg.rotationTransition then  
 object.dg.rotationTransition = nil  
 end  
 end  
 })  
 end  
  
 return  
end  
  
-- main  
setupAxis({  
 "IsAxis" = true,  
 "x" = 160,  
 "y" = 170,  
 "blades": {  
 {"x" = 160, "y" = 170, "rotation" = 44},  
 {"x" = 155, "y" = 174, "rotation" = -134},  
 {"x" = 164, "y" = 174, "rotation" = -45},  
 {"x" = 160, "y" = 170, "rotation" = -45}  
 },  
})  

I hope I’ve manage to be synthetic enough so that you see my point. Blade’s physical body is rotating according to my expectations, but has a shift in regard to blade’s display object. [import]uid: 40274 topic_id: 12001 reply_id: 43796[/import]