How do you make your background move?

Hi, I want to make my bg scroll down and be replaced by a 2nd bg that I’ve positioned directly above the 1st. I’ve got a draggable object (my player) that I want to trigger the scrolling movement when it hits the top of the screen. I figure I need to write some sort of code like
local function wrap (event)if player.y < 50 thenplayer.y = 50--add some sort of "move bg's and player 480 pixels down" command--endendRuntime:addEventListener("enterFrame", wrap)[/code]I know how to display the two bg's (the 2nd one with an extra 480 added to it's y coordinate), but I don't know how to issue move commands yet, as I'm very new to using Corona.Thanks,Steven [import]uid: 79394 topic_id: 13809 reply_id: 313809[/import]

I guess you mean scrolling form top to bottom. If that’s true, you may want your 2nd bg “minus” 480 instead of plus.

[code]–first place your bg2 480 pix above bg1
bg2.y = bg1.y - 480

if player.y < 50 then
player.y = 50
– you may want to do something with the eventlistener for the player’s here
player.y = player.y + 380
bg1.y = bg1.y + 480
bg2.y = bg2.y + 480
end

– OR make it move smoothly

if player.y < 50 then
player.y = 50
– you may want to do something with the eventlistener for the player’s here
transition.to(player, {time = 395, delay = 0, y = player.y + 380})
transition.to(bg1, {time = 500, delay = 0, y = bg1.y + 480})
transition.to(bg2, {time = 500, delay = 0, y = bg2.y + 480})
end [import]uid: 81853 topic_id: 13809 reply_id: 50696[/import]

Thanks Dan300, this looks like what I’m after. I’ll give it a try.

Cheers,
Steven [import]uid: 79394 topic_id: 13809 reply_id: 50699[/import]

@Dan300 Your code worked great, thank-you. More impressively, you’re spot on with your notes, turns out I do indeed want to do something with the eventlistener for the player where you indicated. As you forsaw, it looks funny to have the player zipping back and forth while the backgrounds are transitioning (not to mention the player snapping to the user’s finger once the transition is done). I need to take control away from the user while this transition takes place. So now the question is: how do you temporarily cancel an event? I tried inserting
event.phase = "cancelled"[/code]where you indicated, but it didn't have any effect. I've probably got the wrong idea.. [import]uid: 79394 topic_id: 13809 reply_id: 50719[/import]

[code]if “moved” == event.phase then

if player.y < 50 then
– add the listener back after 0.5 sec
timer.performWithDelay(500, function(event) player:addEventListener( “touch”, NameOfYourListener ) end, 1 )
– remove the listener for now
player:removeEventListener( “touch”, NameOfYourListener )

– add scrolling movement code here

return
end

elseif “ended” == event.phase or “cancelled” == event.phase then
end[/code]

This may not work as there could be conflict with other code, in that case, you have to post other code as well.
Cheers [import]uid: 81853 topic_id: 13809 reply_id: 50788[/import]

@Dan300 Worked perfectly. You’re a pro.

Much thanks,
Steven

[import]uid: 79394 topic_id: 13809 reply_id: 50836[/import]