Hi, I’m new with Corona SDK.
I’m trying make my background with endless scrolling, but never looks right.
I’m using the code below:
–>add background image
local background = display.newImage(“test.png”, true)
background.x = display.contentWidth / 2
background.y = display.contentHeight / 2
local background2 = display.newImage(“test.png”, true)
background2.x = display.contentWidth / 2
background2.y = display.contentHeight / 2
and the function:
local tPrevious = system.getTimer()
local function move(event)
local tDelta = event.time - tPrevious
tPrevious = event.time
local xOffset = ( 0.2 * tDelta )
background.x = background.x - xOffset
background2.x = background2.x - xOffset
if (background.x + background.contentWidth) < 0 then
background:translate( 610 * 2, 0)
end
if (background2.x + background2.contentWidth) < 0 then
background2:translate( 610 * 2, 0)
end
end
Runtime:addEventListener( “enterFrame”, move );
Thank you for the help.