Hi - thank you all for the replies and suggestions.
I have worked a bit on this concept after finding a ‘throwing’ code on the forums. The current code allows for me to touch anywhere on the screen and drag, causing the player object to mimic the same drag behavior as created by the touch drag.
Now I would like for the dragging to feel more fluid/less choppy. Currently once the drag is stopped, the player instantly stops. However, I would like to make it so the motion is delayed upon the start of the swipe/is slow at the start, moves for a majority of the swipe, then slows again as it approaches the end of the swipe, as illustrated in the following video:
https://vimeo.com/93206523#t=68s
I know this effect is rather simple using transitions, but physics is necessary as other objects can affect the course. If anybody can help out with this easing effect on the player, please let me know.
Here’s the current code:
local physics = require("physics") local \_x50 = display.contentCenterX local \_y50 = display.contentCenterY local player = display.newRect(\_x50, \_y50, 16, 16) physics.addBody(player) player:setFillColor(1) player.gravityScale = 0 local touchMask function playerSwipe(event) if (event.phase == "began") then touchMask = display.newCircle(event.x, event.y, 64, 64, 32) touchMask:setFillColor(1, 1, 1, 0.75) touchMask.isVisible = true physics.addBody(touchMask) touchMask.isSensor = true touchMask.joint = physics.newJoint("touch", touchMask, event.x, event.y) function touchMask.enterFrame(event) local vx, vy = touchMask:getLinearVelocity() player:setLinearVelocity(vx, vy) player.angularVelocity = touchMask.angularVelocity end Runtime:addEventListener("enterFrame", touchMask) elseif (event.phase == "moved") then touchMask.joint:setTarget(event.x, event.y) elseif (event.phase == "cancelled") or (event.phase == "ended") then player:setLinearVelocity(0, 0) touchMask:setLinearVelocity(0, 0) Runtime:removeEventListener("enterFrame", touchMask) touchMask.joint:removeSelf() end end Runtime:addEventListener("touch", playerSwipe)