Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local myObj = display.newRect(display.contentWidth * 0.5, display.contentHeight * 0.5, 25, 25)
- myObj.strokeWidth = 3
- myObj:setFillColor(140, 140, 140)
- myObj:setStrokeColor(180, 180, 180)
- local onTouch = function( event )
- if event.phase == "began" or event.phase == "moved" then
- local objDistance = math.sqrt((event.x-myObj.x)^2+(event.y-myObj.y)^2)
- local objVelocity = 0.1
- local objTime = objDistance / objVelocity
- local tween = transition.to( myObj, { x = event.x, y = event.y, time = objTime } )
- end
- end
- local function startGame()
- Runtime:addEventListener( "touch", onTouch )
- end
- startGame()
Advertisement
Add Comment
Please, Sign In to add comment