Having an issue with Graphics 2.0; I’m trying to make a wheel spin around its centre point. It worked fine before changing to Graphics 2.0. How do I replace the “t:setReferencePoint(display.CenterReferencePoint)” part of my code. I have tried anchor points. Thanks! The displaygroup is being rotated rather than the wheel because i have images pinned to the wheel and they all rotate together.
**The width of the wheel image is 1020px and the height is 1012px. Im building the app in landscape for iPhone4, (960x640)
[lua]
wheel = display.newImage(group2, “images/game_screen/wheel.png”,509.5,505.5)
wheel.anchorX=0.5; wheel.anchorY=0.5;
local function rotatewheel(event)
local t = event.target
t:setReferencePoint(display.CenterReferencePoint)
local phase = event.phase
if (phase == “began”) then
display.getCurrentStage():setFocus( t )
t.isFocus = true
– Store initial position of finger
t.x1 = event.x
print("event.x = " … event.x)
t.y1 = event.y
print("event.y = " … event.y)
elseif t.isFocus then
if (phase == “moved”) then
t.x2 = event.x
t.y2 = event.y
angle1 = 180/math.pi * math.atan2(t.y1 - t.y , t.x1 - t.x)
--print("angle1 = "…angle1)
angle2 = 180/math.pi * math.atan2(t.y2 - t.y , t.x2 - t.x)
--print("angle2 = "…angle2)
rotationAmt = angle1 - angle2
– it
t.rotation = t.rotation - rotationAmt
print ("t.rotation = "…t.rotation)
t.x1 = t.x2
t.y1 = t.y2
elseif (phase == “ended”) then
display.getCurrentStage():setFocus( nil )
t.isFocus = false
end
end
– Stop further propagation of touch event
return true
end
group2:addEventListener(“touch”, rotatewheel)
[/lua]