A simple code snippet in corona for drag and drop:
local function onTouch( event )
local t = event.target
local phase = event.phase
if “began” == phase then
t.isFocus = true
t.x0 = event.x – t.x
t.y0 = event.y – t.y
elseif t.isFocus then
if “moved” == phase then
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
t.setFillColor( 0, 255, 0 )
end
end
return true
end
local function onComplete( event )
print “Completed”
end
local rect = display.newRect( 50, 50, 100, 100)
rect:setFillColor( 255, 0, 0 )
rect:addEventListener( “touch”, onTouch )
local circle = display.newCircle(100, 70, 30)
circle:setFillColor( 0, 255, 0 )
circle:addEventListener( “touch”, onTouch )
local abc = display.newImage(“button.png”)
abc.x = display.contentWidth / 2
abc.y = display.contentHeight / 2
abc:addEventListener( “tap”, abc )
function abc:tap( event )
print “button clicked”
end
Incoming search terms:
- drag and drop corona
- corona drag and drop example
- corona drag button
- simple drag and drop image in android with example
- ejemplo drag and drop android
- drang and drop sample games for corona
- drag drop corona
- drag and drop corona code
- Corona Drag ps
- simple drag and drop in corona