I dont know why but i need to “deep press” or “multiple press rapidly” the same image to drag the image.Can anyone explain me why is this happening? [import]uid: 82446 topic_id: 16675 reply_id: 316675[/import]
post your code [import]uid: 16142 topic_id: 16675 reply_id: 62330[/import]
Seeing code would help with this. Also, what size is your image and what device are you using? [import]uid: 52491 topic_id: 16675 reply_id: 62485[/import]
local startDrag = function( event )
if isReady then
if event.phase == "began" then
finalPiece = lastPiece
check=true
if shadowOn then
finalShadow = lastShadow
end
if finalPiece then
Xposition = finalPiece.x
Yposition = finalPiece.y
if shadowOn then
finalShadow.isVisible = true
finalShadow:toFront()
XSposition = finalShadow.x
YSposition = finalShadow.y
end
finalPiece:toFront()
transition.to(finalPiece , { time =500 , xScale = 1.0 , yScale = 1.0 } )
if shadowOn then
transition.to( finalShadow , { time =500 , xScale = 1.0 , yScale = 1.0 } )
end
end
elseif event.phase == "ended" then
isDragging = false
isSelected = false
if finalPiece and check then
transition.to( finalPiece , { time =500 , x = Xposition , y = Yposition , xScale = .45 , yScale = .45 } )
else
transition.to( finalPiece , { time =500 , xScale = 1 , yScale = 1 } )
end
if finalShadow and check then
finalShadow.isVisible = false
transition.to( finalShadow , { time =500 , x=XSposition , y = YSposition, xScale = .45 , yScale = .45 } )
else
transition.to( finalShadow , { time =500 , xScale = 1 , yScale = 1 } )
end
end
if isDragging and finalPiece then
finalPiece.x = event.x
finalPiece.y = event.y
if shadowOn then
finalShadow.x = event.x
finalShadow.y = event.y
end
end
end
end
Size is bacially 250*250 and I am using it in ipad.Hope this would work.or anything else is required? [import]uid: 82446 topic_id: 16675 reply_id: 63762[/import]
Please help me out my images are not dragging on one touch…I need to deep press the image to move along…Can anybody help me out?I mind got screwed.Can anybody help me out please?
[import]uid: 82446 topic_id: 16675 reply_id: 65246[/import]
The reason why you’re having to press multiple times or “deep press” is likely due to a focus issue.
In your began phase, be sure to set the focus to the object, and then remove focus on your ended/cancelled phase:
local function startDrag( self, event ) -- don't forget self if event.phase == "began" then display.getCurrentStage():setFocus( self ) self.isFocus = true elseif self.isFocus then if event.phase == "moved" then -- moved phase code here elseif event.phase == "cancelled" or event.phase == "ended" then display.getCurrentStage():setFocus( nil ) self.isFocus = nil end end return trueend[/code] [import]uid: 52430 topic_id: 16675 reply_id: 65334[/import]
I am getting an error…
attempt to index local 'event'
[code]
local function startDrag( self, event )
if isReady then
if event.phase == “began” then
display.getCurrentStage():setFocus( self )
self.isFocus = true
finalPiece = lastPiece
check=true
elseif self.isFocus then
if event.phase == “moved” then
– moved phase code here
finalPiece = lastPiece
check=true
if shadowOn then
finalShadow = lastShadow
end
if finalPiece then
Xposition = finalPiece.x
Yposition = finalPiece.y
if shadowOn then
finalShadow.isVisible = true
finalShadow:toFront()
XSposition = finalShadow.x
YSposition = finalShadow.y
end
finalPiece:toFront()
transition.to(finalPiece , { time =500 , xScale = 1.0 , yScale = 1.0 } )
if shadowOn then
transition.to( finalShadow , { time =500 , xScale = 1.0 , yScale = 1.0 } )
end
end
if isDragging and finalPiece then
finalPiece.x = event.x
finalPiece.y = event.y
if shadowOn then
finalShadow.x = event.x
finalShadow.y = event.y
end
end
elseif event.phase == “cancelled” or event.phase == “ended” then
display.getCurrentStage():setFocus( nil )
self.isFocus = nil
isDragging = false
isSelected = false
if finalPiece and check then
transition.to( finalPiece , { time =500 , x = Xposition , y = Yposition , xScale = .45 , yScale = .45 } )
else
transition.to( finalPiece , { time =500 , xScale = 1 , yScale = 1 } )
end
if finalShadow and check then
finalShadow.isVisible = false
transition.to( finalShadow , { time =500 , x=XSposition , y = YSposition, xScale = .45 , yScale = .45 } )
else
transition.to( finalShadow , { time =500 , xScale = 1 , yScale = 1 } )
end
end
end
return true
end
end
[/code] [import]uid: 82446 topic_id: 16675 reply_id: 65407[/import]