Hi all ! I’m new to Corona SDK and I’m trying hard to create a simple game that features a scrolling background by moving 2 identic images from right to left.
The thing is that only my 2nd image returns to its initial position when reaches -450 (out of screen), and my 1st image doesn’t. So, I’m getting a black gap where my 1st image was supposed to be. I’m having no problem with the 2nd one.
I’m aiming 800x1200 resolution and my background images are 900x1425.
Here’s the code:
local bg = display.newImage(“bg_test.png”, 900, 1425)
bg.x = _W/2; bg.y= _H/2
background:insert(bg)
local bg2 = display.newImage(“bg_test.png”, 900, 1425)
bg2.x = 400 + bg.width; bg2.y =_H/2
background:insert(bg2)
function scrollbg (self, event)
if self.x < -450 then
self.x = 450
else
self.x = self.x-6
end
end
bg.enterFrame = scrollbg
Runtime:addEventListener(“enterFrame”, bg)
bg2.enterFrame = scrollbg
Runtime:addEventListener (“enterFrame”, bg2)
Can’t figure what’s going on, I would sincerely appreciate your help!
Cheers