Landscape Scrolling Background help.

Hello everyone, I used this code to create an endless scrolling background in my game. As soon as it starts I get a black line from the top of the screen going all the way to the bottom. After a new background covers up the screen it goes away and does not return. It just does it at the start of the game for some reason.

[lua]--------------------------------------------------attempt to scroll forever----------------------------------

–First half of scrolling background
local bg1 = display.newImage(“frame1.png”,0,0)
bg1:setReferencePoint(display.TopLeftReferencePoint)
bg1.x = 0
bg1.y = 0
localGroup:insert(bg1)

– Second half of scrolling background
local bg2 = display.newImage(“frame2.png”,display.contentWidth * 1,0)
bg2:setReferencePoint(display.TopLeftReferencePoint)
bg2.x = 480
bg2.y = 0
localGroup:insert(bg2)

local tPrevious = system.getTimer()
local function move(event)
local tDelta = event.time - tPrevious
tPrevious = event.time

– Change this to adjust the speed of the background
local xOffset = ( 0.05 * tDelta )

bg1.x = bg1.x - xOffset
bg2.x = bg2.x - xOffset

if (bg1.x + bg1.contentWidth) < 0 then
bg1:translate( 480 * 2, 0)
end
if (bg2.x + bg2.contentWidth) < 0 then
bg2:translate(480 * 2, 0)
end
end

[import]uid: 49863 topic_id: 28911 reply_id: 328911[/import]

Never mind I found the solution. changing local xOffset = ( 0.05 * tDelta ) to local xOffset = ( 0.10 * tDelta ) fixed it. [import]uid: 49863 topic_id: 28911 reply_id: 116421[/import]

Actually upon closer inspection when I decreased the size of the simulator the problem returned. Then I changed local xOffset = ( 0.10 * tDelta ) to local xOffset = (0.12 * tDelta) it worked as far as you can zoom out. I guess based on the screen size this becomes an issue. Which would explain why it appeared on my ipod touch but no on my android which has a larger screen. [import]uid: 49863 topic_id: 28911 reply_id: 116423[/import]

I think the black bar might’ve been because the background wasn’t in the position to cover the whole screen at the start. If you move the backgrounds a bit you might have better results.

Try initialising the backgrounds a bit further back, like bg1.x = -100, bg2.x = 380, see if that helps. [import]uid: 144339 topic_id: 28911 reply_id: 116632[/import]