Created
January 15, 2013 14:33
-
-
Save sixman9/4539074 to your computer and use it in GitHub Desktop.
How to drag and drop in Marmalade Quick (Lua), code fragment (incomplete)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--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