function getButton()
local moveLeft = display.newImageRect(“button_left.png”,100,100)
moveLeft.x = 230
moveLeft.y = 720
return moveLeft
end
function player:tick(millisecondsPassed)
if self.direction == nil then return false end
if self.direction == “left” then
self.x = self.x - self.speed
end
end
function player:moveLeft()
self.direction = “left”
end
function player:stopMoving()
self.direction = nil
end
gameLoop:addLoop(player)
local moveLeftButton = getButton()
function moveLeftButton:touch(event)
if event.phase == “began” then
player:moveLeft()
return true
elseif event.phase == “ended” then
player:stopMoving()
return true
end
end
moveLeftButton:addEventListener(“touch”, moveLeftButton)
jumpButton.x = moveLeftButton.x + moveLeftButton.width + moveRightButton.x + moveRightButton.width + 500