Skip to content

Instantly share code, notes, and snippets.

@sixman9
Created January 15, 2013 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sixman9/4539074 to your computer and use it in GitHub Desktop.
Save sixman9/4539074 to your computer and use it in GitHub Desktop.
How to drag and drop in Marmalade Quick (Lua), code fragment (incomplete)
--https://devnet.madewithmarmalade.com/questions/3537/drag-and-drop-marmalade-quick.html
local box = director:createRectangle(director.displayCenterX, director.displayCenterY, 100, 100)
box.color = color.green
function box:touch(event)
if event.phase == "began" then
self.color = color.red
box.xLast = event.x
box.yLast = event.y
elseif event.phase == "ended" then
self.color = color.green
elseif event.phase == "moved" then
local dx = event.x - self.xLast
local dy = event.y - self.yLast
self.x = self.x + dx
self.y = self.y + dy
box.xLast = event.x
box.yLast = event.y
end
end
box:addEventListener("touch", box)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment