I’m new to Corona. I’m trying to make my scrollable background move. Anyone wanna help? thanks [import]uid: 16789 topic_id: 5175 reply_id: 305175[/import]
change its .x property [import]uid: 6645 topic_id: 5175 reply_id: 17187[/import]
There is a Scroll View sample project: http://developer.anscamobile.com/content/scroll-view [import]uid: 6787 topic_id: 5175 reply_id: 17197[/import]
This is what I did. Hope it helps.
[code]
require “sprite”
display.setStatusBar( display.HiddenStatusBar )
– Background
– When one of the background images slides offscreen, we move it to the bottom of the next one.
local background = display.newImage( “Background.png” )
background:setReferencePoint( display.CenterLeftReferencePoint )
background.x = 0
background.y = 240
local background2 = display.newImage( “Background.png” )
background2:setReferencePoint( display.CenterLeftReferencePoint )
background2.x = 0
background2.y = -240
– A per-frame event to move the elements
local tPrevious = system.getTimer()
local function move(event)
local tDelta = event.time - tPrevious
tPrevious = event.time
local yOffset = ( 0.1 * tDelta )
background.y = background.y - yOffset
background2.y = background2.y - yOffset
if (background.y + background.stageHeight) < 240 then
background:translate( 0, 480 * 2)
end
if (background2.y + background2.stageHeight) < 240 then
background2:translate( 0, 480 * 2)
end
end
– Start everything moving
Runtime:addEventListener( “enterFrame”, move );
[/code] [import]uid: 21827 topic_id: 5175 reply_id: 17359[/import]