This issue has been resolved. If anyone cares for the code, here it is:
P.S. Thank you hasty for suggesting the greater than / less than method for my touch event. That’s what tipped me off to write this code below.
motionx = 0; – Variable used to move character along x axis
speed = 4; – Set Walking Speed
– Insert the background image and stretch to fit the screen
local background = display.newImage(“skybg.png”)
background.x = display.contentWidth / 2
background.y = display.contentHeight / 2
local function movePlayer(event)
myPlayer.x = myPlayer.x + motionx;
end
Runtime:addEventListener(“enterFrame”, movePlayer)
local function stopPlayer (event)
if event.phase ==“ended” then
motionx = 0;
end
end
Runtime:addEventListener(“touch”, stopPlayer )
function playerVelocity(event)
if (event.phase == “began”) then
if event.x >= display.contentCenterX then
motionx = speed
myPlayer.xScale = 1
elseif event.x <= display.contentCenterX then
motionx = -speed
myPlayer.xScale = -1
end
end
end
Runtime:addEventListener(“touch”, playerVelocity)