Hi everybody!
I’m currently experiencing an issue where I can’t stop the ability to drag.
Let me explain, your dragging things about with your finger THEN you press the play button and you sit back and watch what you’ve done, while no longer being able to drag - you must have seen this a thousand times before.
I’ve got most of that done however once you’ve clicked the play button instead of stopping the dragging from working completely it just ‘drops’ whatever your holding after a second or two then puts it back in the air, then drops it again and so on.
If anyone knew a good way of correcting this, you’d be doing me a real favour 
All help is appreciated as always!
- Sam Jackson
[code]
local transparentball = display.newImage(“graphics/transparentball.png”) – displays image
transparentball.xScale = 1 – sets image scale
transparentball.yScale = 1
local btn2 = display.newImage(“graphics/button.png”)
btn2.x = 300
btn2.y = 10
btn2.xScale = 0.300
btn2.yScale = 0.300
local arguments =
{
{ x=50, y=10, w=100, h=100, r=10, red=255, green=0, blue=128 },
{ x=10, y=50, w=100, h=100, r=10, red=0, green=128, blue=255 },
{ x=90, y=90, w=100, h=100, r=10, red=255, green=255, blue=0 }
}
local function onTouch( event )
local t = event.target
local phase = event.phase
if “began” == phase then
– Make target the top-most object
local parent = t.parent
parent:insert( t )
display.getCurrentStage():setFocus( t )
– Spurious events can be sent to the target, e.g. the user presses
– elsewhere on the screen and then moves the finger over the target.
– To prevent this, we add this flag. Only when it’s true will “move”
– events be sent to the target.
t.isFocus = true
– Store initial position
t.x0 = event.x - t.x
t.y0 = event.y - t.y
elseif t.isFocus then
if “moved” == phase then
– Make object move (we subtract t.x0,t.y0 so that moves are
– relative to initial grab point, rather than object “snapping”).
t.x = event.x - t.x0
t.y = event.y - t.y0
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false
end
end
– Important to return true. This tells the system that the event
– should not be propagated to listeners of any objects underneath.
return true
end
local function physicsStart(event)
physics.start()
onTouch:removeSelf()
onTouch = nil
end
physics.addBody(transparentball, “dynamic”, {density=0.9, friction=0.3, bounce=0.2})
transparentball:addEventListener( “touch”, onTouch )
btn2:addEventListener(“touch”, physicsStart)
end[/code] [import]uid: 90223 topic_id: 16425 reply_id: 316425[/import]
[import]uid: 52491 topic_id: 16425 reply_id: 62176[/import]