sayng hello and a ?

hey all new here, corona, and lua coming from gamesalad which i like but like the extra control of corona better so ill be making the switch but still use gamesalad from time to time for prototyping apps

my ? is how to make a continuous scrolling background ive look in the forum and found a example but it only scrolls for two images and the timing is right one image moves faster then the other what i want is for the same image to scroll over and over without stopping and if possible keep it simple as i just started learning
ps im not making an app yet just trying to learn to do a few individual things first [import]uid: 7911 topic_id: 1558 reply_id: 301558[/import]

Hey, welcome, I think you’ll enjoy Corona.

As for your question, I think you’re starting a little too specific. I would learn all the basics first so you have a thorough understanding of the SDK.

But, from a high level, I would use two background images, each slightly longer than the width of the screen. In an enterFrame event handler, move each background in the direction you want it to go. Let’s say you’re moving the backgrounds to the left. Each frame check if the right edge of any of the background graphics is less than 0 (the left side of the screen). If it is, just move it to the x of the right side of the other background. This will create a shuffle effect so they just keep looping. This isn’t the only way to do it, but that’s how I usually do it. [import]uid: 6678 topic_id: 1558 reply_id: 4413[/import]

thanks DFox i do have some programming experience with vb so i dont think ill have too many problems *fingers crossed* although it has been many years. I love learning by example i think its the best way for me but many of the examples i find online give u the main.lua file but has very little comments in them and the only video tutorials i found on youtube explain whats happening good but are just too simple to really learn anything, anybody can learn hello world i have never liked the hello world example for any language ive looked at do you or anyone else know whats the best book to start learning lua and or there any corona books either online or in store thanks [import]uid: 7911 topic_id: 1558 reply_id: 4414[/import]

I haven’t read any books on Lua, but I remember some people here have, but I can’t remember the book. If you’ve done VB, I would say you could probably swing learning what you need to know in Lua pretty easily without a book. But still, it can’t hurt to read one :slight_smile:

Anyway, maybe this will help, this is just off the top of my head though, so there might be mistakes, but you’ll get the point:
[lua]local bgSpeed = 4; – speed to move the backgrounds at
local bg1 = display.newImage(“bgimagename.png”, 0, 0); – place bg1 at the origin
local bg2 = display.newImage(“bgimagename.png”, bg1.x + bg1.width / 2, 0); – place bg2 right after bg1

local moveBG = function(e)
bg1:translate(bgSpeed, 0); – move bg1 bgSpeed on the x plane
bg2:translate(bgSpeed, 0); – move bg2 bgSpeed on the x plane

if ((bg1.x + bg1.width / 2) < 0) then – if the right of bg1 is off of the screen bring it back around
bg1.x = bg2.x + bg2.width;
elseif((bg2.x + bg2.width / 2) < 0) then
bg2.x = bg1.x + bg1.width;
end
end

Runtime:addEventListener(“enterFrame”, moveBG); – add an enterFrame listener to call moveBG[/lua]

This can be optimized a little and improved, but I think you’ll get the idea.

Hope this helps, let me know if it has any issues, I did it quickly. [import]uid: 6678 topic_id: 1558 reply_id: 4415[/import]

thanks it works good in the x plane after i changed the speed to -4
but in the y plane if i keep the neg. speed only one image scrolls then a blank the the image
with a pos. speed it only passes by once in either x or y
but thanks this is a great start for me to look at, play with, and learn [import]uid: 7911 topic_id: 1558 reply_id: 4416[/import]

Oh yeah, sorry, my bad, the speed should have been -4. What do you mean y plane? Do you want to to scroll horizontal or vertical? [import]uid: 6678 topic_id: 1558 reply_id: 4417[/import]

wanting to scroll from top down i changed all of the .x to .y all the width to height and swapped the translate variables to 0, bgspeed but it only shows one image then a blank equal to the image size then another image over and over [import]uid: 7911 topic_id: 1558 reply_id: 4418[/import]

Hmm, try this, it should work, you have to change a lot of the calculations:
[lua]local bgSpeed = 4; – speed to move the backgrounds at

local bg1 = display.newImage(“bgimagename.png”, 0, 0); – place bg1 at the origin
local bg2 = display.newImage(“bgimagename.png”, 0, bg1.y - (bg1.height * 1.5)); – place bg2 right after bg1

local moveBG = function(e)
bg1:translate(0, bgSpeed); – move bg1 bgSpeed on the y plane
bg2:translate(0, bgSpeed); – move bg2 bgSpeed on the y plane

if ((bg1.y - bg1.height / 2) > display.contentHeight) then
bg1.y = bg2.y - bg2.height;
elseif((bg2.y - bg2.height / 2) > display.contentHeight) then
bg2.y = bg1.y - bg1.height;
end
end

Runtime:addEventListener(“enterFrame”, moveBG);[/lua]

Let me know if that works, I think it should. [import]uid: 6678 topic_id: 1558 reply_id: 4419[/import]

that worked except i had to change the bg1.y+bg1.height/2 to a minus then it showed one image then a blank the a continuous scrolling bg so i changed the minus to a plus it the bg2 newImage and it works perfect thanks for all the help [import]uid: 7911 topic_id: 1558 reply_id: 4420[/import]