I am working on a car racing game and one of the things I am trying to achieve is to ensure that the background image moves vertically infinitely while at the same time when you touch the background, it changes the car's lanes.
function scene:create( event )
physics.start();
physics.setGravity(0, 0);
local group = self.view;
local bg = display.newImageRect(group, "IMG/bg.png", 384, totalHeight);
bg.x, bg.y = centerX, centerY;
function bg:touch(event)
if event.phase == "began" then
if event.x < centerX then
redCar:changeLane();
else
blueCar:changeLane();
end
end
end
bg:addEventListener("touch", bg);
end
I have tried different articles online but none works well. Any guide would be appreciated. Thanks