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]