Hi everyone,
I dont know how to add the scrolling background (vertical direction)
I have this code
local backgroundTiles = {}
– drawBackground()
– The same 480x320 image is used twice
local drawBackground = function()
backgroundTiles[0] = display.newImageRect( “images/background.jpg”, display.contentWidth, display.contentHeight)
backgroundTiles[0].x = display.contentCenterX
backgroundTiles[0].y = display.contentCenterY
localGroup:insert(backgroundTiles[0])
backgroundTiles[1] = display.newImageRect( “images/background.jpg”, display.contentWidth, display.contentHeight)
backgroundTiles[1].x = display.contentCenterX
backgroundTiles[1].y = display.contentCenterY - backgroundTiles[1].contentHeight
localGroup:insert(backgroundTiles[1])
end
– shift the tiles back to starting position when off the screen
local moveBackground = function()
for i=0, 1, 1 do
backgroundTiles[i].y = backgroundTiles[i].y + gameMoveSpeed
if backgroundTiles[i].y - backgroundTiles[i].contentHeight/2 >= display.contentHeight then
backgroundTiles[i].y = 0 - backgroundTiles[i].contentHeight/2
end
end
end
– gameLoop()
local gameLoop = function()
moveBackground()
end
– gameInit()
– Initialise the game and run all the creator functions and add listeners
local gameInit = function()
drawBackground()
Runtime:addEventListener( “enterFrame”, gameLoop )
end
but It can only works with V1 how to make a scrolling background with V2
Thanks