Everytime I put my function BackGround code in a function of a class the output was different. Can somebody help me? Please. Thank you! 
Here is my code:
sample=gideros.class(Sprite)
function sample:init()
...
stage:addEventListener(Event.ENTER_FRAME, self.onEnterFrame, self)
...
end
local bg1 = Bitmap.new(Texture.new("background.jpg"),true)
local bg2 = Bitmap.new(Texture.new("background.jpg"),true)
local bgX=0
function sample:onEnterFrame()
	if self.started then
function BackGround()
   bgX = bgX - 1
	local newBgX = bg1:getWidth() -(-bgX)
	if newBgX <=0 
then
		bgX=0
		bg1:setX(bgX)
	else
	bg1:setX(bgX)
	bg2:setX(newBgX)	
end
end
self:addEventListener(Event.ENTER_FRAME, BackGround)
	self:addChild(bg1)
	self:addChild(bg2)
end
end	
*By the way the output here was about the background that goes to right then goes back to the left. Also the speed was increasing. Please I really need your help guys. Thank you!                
                
             
        
Comments
You need something more like this: