Thanks slimboyfat but what when both depends of events. Drag event move the object and showing a gear (circle) around but rotate rotating the object that you touch before via touching a gear.
[code]
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
dragItem(event.target).rotation = gear.rotation----- I want compare gear rotation to event.target from dragItem function
end
gear:addEventListener(“touch”, rotate)
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
levelOneGroup:insert(t)
transition.to(box, {time = 400, alpha =0 , onComplete = function() box.isVisible = false; end })
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
event.target.bodyType = “static”
physics.addBody(t, “static” ,{density = 2.0, friction = 1.3, bounce = 0.2} )
end
end
end
return true
end
[/code] [import]uid: 13156 topic_id: 5753 reply_id: 19716[/import]