I am having trouble setting up a static background with a moving cloud graphic overlayed on top. My problem is tht I am trying to get the cloud graphic to endlessly repeat after the first one scrolls by but I keep having a gap inbetween the graphics…This is my code, I am very very new to lua, this is my first app so the answer will most likely be obvious…thank you for your time!
local background = display.newImageRect(“background.png”, 713, 450 )
background.x = display.contentCenterX
background.y = display.contentCenterY
local cloud1 = display.newImageRect(“cloud1.png”, 713, 450)
cloud1.x = display.contentCenterX
cloud1.y = display.contentCenterY
local cloud2 = display.newImageRect(“cloud1.png”, 713, 450 )
cloud2.x = 713
cloud2.y = display.contentCenterY
function scrollCloud(self,event)
if self.x < -713 then
self.x = 715
else
self.x = self.x - 3
end
end
cloud1.enterFrame = scrollCloud
Runtime:addEventListener(“enterFrame”, cloud1)
cloud2.enterFrame = scrollCloud
Runtime:addEventListener(“enterFrame”, cloud2)
I cannot figure out how to know where along the x axis to put the second graphic to make the scrolling seamless…