[lua]-- the slice event
local function onTouch( event )
local t = event.target
local phase = event.phase
local x,y = t:localToContent( t.x - t.xOrigin, t.y - t.yOrigin )
local dx = event.x - x
local dy = event.y - y
local angle = math.atan2( dy, dx )
if “began” == phase then
display.getCurrentStage():setFocus( t )
t.isFocus = true
t.xStart = t.x
t.yStart = t.y
t.angleStart = angle
t.rotationStart = t.rotation
elseif t.isFocus then
if “moved” == phase then
local pi = math.pi
local delta = (angle - t.angleStart)
delta = delta*180/pi
t.rotation = t.rotationStart + delta
if ((xpos > 140) and (xpos < 180)) then
if ((t.rotation < -40) and (t.rotation > -60)) then
suspendGame();
isSliced = true;
timer.performWithDelay( 1500, resetPos,1);
end
end
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false
t.rotation = kStartAngle
local coord = t.x … “,” … t.y
end
end
return true
end[/lua] [import]uid: 6645 topic_id: 4880 reply_id: 15720[/import]