Hi,
I have a problem where I am trying to implement a scrolling background using one image that I repeat to scroll along the x-axis. The simulator is set to landscape mode and I have an image 570 wide by 228 high.
The problem is that there is a gap between the two instances of the image during scrolling and I cannot identify the cause of this. My code is as follows:
[blockcode]
local sky = display.newImage(“Stage_1_Level_1_sky.jpg”)
sky.y = display.contentHeight / 2
sky.x = display.contentWidth / 2
local mountains1 = display.newImage(“Stage_1_Level_1_mountains.png”)
mountains1:setReferencePoint(display.CenterLeftReferencePoint)
mountains1.x = 0
mountains1.y = 228
–localGroup:insert(mountains1)
local mountains2 = display.newImage(“Stage_1_Level_1_mountains.png”)
mountains2:setReferencePoint(display.CenterLeftReferencePoint)
mountains2.x = 570
mountains2.y = 228
–localGroup:insert(mountains2)
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.15 * tDelta)
mountains1.x = mountains1.x + xOffset
mountains2.x = mountains2.x + xOffset
if mountains1.x > 570 then
mountains1:translate(-570 * 2, 0)
end
if mountains2.x > 570 then
mountains2:translate(-570 * 2, 0)
end
end
– Gets the background moving
Runtime:addEventListener(“enterFrame”, move)
[/blockcode]
Any ideas appreciated. Thanks. [import]uid: 52069 topic_id: 17414 reply_id: 317414[/import]