Hi
I have a problem with rotating object…
Almost every thing is ok but when I touch the object, gear shows up I can rotate the object while touching gear but when I touch another object and I am rotating it both object are rotating first one and the second one. I know this is problem witch t.rotating = gear.rotating but I don’t know how to resolve this…
Maybe my idea of doing this is wrong, but I thing I’am so close…
Can you help me with this please. I’am a beginner…
Thank You
[code]
local dragItem = function(event)
local t = event.target
local phase = event.phase
if “began” == phase and ball.isActive == false then
display.getCurrentStage():setFocus( t )
t.isFocus = true
t.x0 = event.x - t.x
t.y0 = event.y - t.y
event.target.bodyType = “kinetic”
gear.isVisible = true
gear.alpha = 0.3
gear.x = event.target.x
gear.y = event.target.y
event.target:toFront()
elseif t.isFocus then
if “moved” == phase and ball.isActive == false then
t.x = event.x - t.x0
t.y = event.y - t.y0
gear.x = event.target.x
gear.y = event.target.y
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil)
t.isFocus = false
if (not event.target.isPlatform ) then
t.isFocus = false
local rotate = function(event)
local xOffset = gear.x
local yOffset = gear.y
local angleBetween = mCeil(mAtan2( (event.y - yOffset), (event.x - xOffset) ) * 180 / mPi) + 90
gear.rotation = angleBetween + 180
T.ROTATION = GEAR.ROTATION !!!
end
event.target.bodyType = “static”
physics.addBody(t, “static” ,{density = 2.0, friction = 1.3, bounce = 0.2,} )
gear:addEventListener(“touch”, rotate)
end
end
end
return true
end
[import]uid: 13156 topic_id: 5541 reply_id: 305541[/import]
[import]uid: 13156 topic_id: 5541 reply_id: 18883[/import]