Hi, I’m using the following code to create a scrolling background with more than 2 images, I’ve tried several different ways but it doesn’t work
local bgSpeed = 10; -- speed to move the backgrounds at
local bg1 = display.newImage("backGround01.png", 0, 0); -- place bg1 at the origin
local bg2 = display.newImage("backGround02.png", 0, bg1.y + (bg1.height \* 1.5)); -- place bg2 right after bg1
local moveBG = function(e)
bg1:translate(0, bgSpeed); -- move bg1 bgSpeed on the y plane
bg2:translate(0, bgSpeed); -- move bg2 bgSpeed on the y plane
if ((bg1.y - bg1.height / 2) \> display.contentHeight) then
bg1.y = bg2.y - bg2.height;
elseif((bg2.y - bg2.height / 2) \> display.contentHeight) then
bg2.y = bg1.y - bg1.height;
end
end
where’s the mistake?
thanks
[import]uid: 76800 topic_id: 24640 reply_id: 324640[/import]