Hi all, I’m new to coding and new to corona. I’m messing around trying to learn my way around.
I’m getting a little stuck on my code. I am trying to move an object on the screen a specific amount for every time a finger drags along the screen a specific amount, kind of like tetris.
For example every time my finger moves 100 pixels on along the x-axis I want to move the object 50 pixels on the axis in the direction I am moving my finger (east - west).
Here is my code I tried… it only moves once then stops
Thanks
[lua]
local scrollSpeed = 100
function controlBar:touch( event )
startPosition = event.xStart
currentPosition = event.x
newPosition = event.x
slide = startPosition -currentPosition
if event.phase == “moved” then
if slide == scrollSpeed then
baseBlock001.x = baseBlock001.x - baseBlock001.contentWidth
currentPosition = 0
elseif slide == -scrollSpeed then
baseBlock001.x = baseBlock001.x + baseBlock001.contentWidth – determine speed
currentPosition = 0
end
slide = newPosition - currentPosition
end
end
[/lua]