of course … and here’s the whole function
[code]
local cancel=10 – a tracing flag
local timerNew – timer to cancel the joint
prevPause=0 – a flag variable for pausing game
local notFall = 0 – a tracing variable for the stone if it hasn’t been thrown yet
local function onClick (event)
local phase = event.phase
function cancelEvent()
stones[c].tempJoint:removeSelf()
touched=false
cancel=cancel+1
print("cancel "…cancel)
notFall=1
end
if “began” == phase then
if(event.y>50) then
stones[c].bodyType = “dynamic”
stones[c].isBullet = true
touched = true
cancel=10
print(“began”)
notFall=0
deltaX = stones[c].x - event.x; – in order to drag the object from
deltaY = stones[c].y - event.y; – anywhere on the screen
stones[c].tempJoint = physics.newJoint( “touch”, stones[c], stones[c].x, stones[c].y )
Runtime:removeEventListener(“enterFrame”, moveStone) – as the stone is moving at some kind of path
timerf=timer.performWithDelay(50,cancelEvent,1) – to not holding the stone too much
timerNew=timer.performWithDelay(100,newRound,1) – generate a new stone
prevPause=0
end
elseif touched then
if(event.y > 10) then
stones[c].tempJoint:setTarget( event.x + deltaX, event.y + deltaY )
–///// calc. the velocity
vx, vy = stones[c]:getLinearVelocity()
print("velocityX : "…vx)
print("velocityY : "…vy)
if vx > 100 then
vx=100
elseif vx < -100 then
vx=-100
end
if vy>300 then
vy=300
elseif vy vy=-300
end
stones[c]:setLinearVelocity( vx, vy )
v1, v2 = stones[c]:getLinearVelocity()
print("new velocity X : "…v1)
print("new velocity Y : "…v2)
– ////////////////
print(“dragged”)
if notFall==0 and cancel==10 then
timer.cancel(timerf)
timer.cancel(timerNew)
timerf=timer.performWithDelay(50,cancelEvent,1)
timerNew=timer.performWithDelay(100,newRound,1)
notFall=1
end
end
if “ended” == phase then
if cancel==10 then
notFall=1
timer.cancel(timerf)
timer.cancel(timerNew)
timerNew=timer.performWithDelay(10,newRound,1)
cancelEvent()
end
end
end
end
sky:addEventListener(“touch”, onClick)
[/code] [import]uid: 96659 topic_id: 19962 reply_id: 78533[/import]