FANDOM


local myObject = display.newRect( 0, 0, 100, 100 )
myObject:setFillColor( 255 )
 
-- touch listener function
function myObject:touch( event )
    if event.phase == "began" then
 
        self.markX = self.x    -- store x location of object
        self.markY = self.y    -- store y location of object
 
    elseif event.phase == "moved" then
 
        local x = (event.x - event.xStart) + self.markX
        local y = (event.y - event.yStart) + self.markY
 
        self.x, self.y = x, y    -- move object based on calculations above
    end
 
    return true
end
 
-- make 'myObject' listen for touch events
myObject:addEventListener( "touch", myObject )

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.