Hey all here is my code. I would like the background image to keep scrolling across the screen. But all it does is move 5 pixels and then stop. What am i doing wrong? Thanks
local composer = require( “composer” )
local scene = composer.newScene()
function scene:create( event )
local sceneGroup = self.view
end
function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == “will” ) then
– Called when the scene is still off screen (but is about to come on screen).
elseif ( phase == “did” ) then
b1x=b1x-5
b2x=b2x-5
if b1x<=-570 then
b1x=(display.viewableContentWidth / 2)+570
end
if b2x<=-570 then
b2x=(display.viewableContentWidth / 2)+570
end
local back1 = display.newImage(back1,b1x,b1y)
local back2 = display.newImage(back2,b2x,b2y)
sceneGroup:insert(back1)
sceneGroup:insert(back2)
end
end
scene:addEventListener( “create”, scene )
scene:addEventListener( “show”, scene )
scene:addEventListener( “hide”, scene )
scene:addEventListener( “destroy”, scene )
return scene