Scrolling background from the top to the bottom instead from the bottom to the top of the screen

Hi guys, I need your help: I followed the guide at

http://mobile.tutsplus.com/tutorials/corona/creating-a-scrolling-background-with-corona-sdk/

and I was wondering how can I do the same thing but with the star that falling from the top to the bottom instead from the bottom to the top (of the screen)

Thanks a lot!! :smiley: [import]uid: 76800 topic_id: 21787 reply_id: 321787[/import]

check this out
http://j-strahan.com/main/?category_name=scroll

or just multiply the y value by -1 [import]uid: 7911 topic_id: 21787 reply_id: 86509[/import]

Interesting my module does more than that one, maybe I should start charging. :slight_smile: [import]uid: 118379 topic_id: 21787 reply_id: 86577[/import]

thanks, but I didn’t find a solution to my problem.

The code I’m actually using is the following:

display.setStatusBar( display.HiddenStatusBar )   
  
\_W = display.contentWidth; --Returns Screen Width  
\_H = display.contentHeight; --Returns Screen Height  
local starTable = {} -- Set up star table  
  
function initStar()  
 local star1 = {}  
 star1.imgpath = "star1.png"; --Set Image Path for Star  
 star1.movementSpeed = 10000; --Determines the movement speed of star  
 table.insert(starTable, star1); --Insert Star into starTable  
  
 local star2 = {}  
 star2.imgpath = "star2.png";  
 star2.movementSpeed = 12000;  
 table.insert(starTable, star2);   
  
 local star3 = {}  
 star3.imgpath = "star3.png";  
 star3.movementSpeed = 14000;  
 table.insert(starTable, star3);  
end --END initStar()   
  
function getRandomStar()  
 local temp = starTable[math.random(1, #starTable)] -- Get a random star from starTable  
 local randomStar = display.newImage(temp.imgpath) -- Set image path for object  
 randomStar.myName = "star" -- Set the name of the object to star  
 randomStar.movementSpeed = temp.movementSpeed; -- Set how fast the object will move  
 randomStar.x = math.random(0,\_W) -- Set starting point of star at a random X position  
 randomStar.y = \_H + 50 -- Start the star off screen  
 randomStar.rotation = math.random(0,360) -- Rotate the object  
 starMove = transition.to(randomStar, {  
 time=randomStar.movementSpeed,   
 y=-45,  
 onComplete = function(self) self.parent:remove(self); self = nil; end  
 }) -- Move the star  
end--END getRandomStar()  
  
function startGame()  
 starTimer1 = timer.performWithDelay(1700,getRandomStar, 0)  
 starTimer2 = timer.performWithDelay(2300,getRandomStar, 0)  
 starTimer3 = timer.performWithDelay(2700,getRandomStar, 0)   
end--END startGame()  
  
initStar()  
startGame()  

Can you please post the right code? Thanks! :slight_smile:

[import]uid: 76800 topic_id: 21787 reply_id: 86930[/import]

here you are notice ive swapped random.y with transition y:

[code]
display.setStatusBar( display.HiddenStatusBar )

_W = display.contentWidth; --Returns Screen Width
_H = display.contentHeight; --Returns Screen Height
local starTable = {} – Set up star table

function initStar()
local star1 = {}
star1.imgpath = “star1.png”; --Set Image Path for Star
star1.movementSpeed = 10000; --Determines the movement speed of star
table.insert(starTable, star1); --Insert Star into starTable

local star2 = {}
star2.imgpath = “star2.png”;
star2.movementSpeed = 12000;
table.insert(starTable, star2);

local star3 = {}
star3.imgpath = “star3.png”;
star3.movementSpeed = 14000;
table.insert(starTable, star3);
end --END initStar()

function getRandomStar()
local temp = starTable[math.random(1, #starTable)] – Get a random star from starTable
local randomStar = display.newRect(0,0,20,20) – Set image path for object
randomStar.myName = “star” – Set the name of the object to star
randomStar.movementSpeed = temp.movementSpeed; – Set how fast the object will move
randomStar.x = math.random(0,_W) – Set starting point of star at a random X position
randomStar.y = -50 – Start the star off screen
randomStar.rotation = math.random(0,360) – Rotate the object
starMove = transition.to(randomStar, {
time=randomStar.movementSpeed,
y=_H,
onComplete = function(self) self.parent:remove(self); self = nil; end
}) – Move the star
end–END getRandomStar()

function startGame()
starTimer1 = timer.performWithDelay(1700,getRandomStar, 0)
starTimer2 = timer.performWithDelay(2300,getRandomStar, 0)
starTimer3 = timer.performWithDelay(2700,getRandomStar, 0)
end–END startGame()

initStar()
startGame()
[/code] [import]uid: 118379 topic_id: 21787 reply_id: 86931[/import]

Thanks a lot!!! [import]uid: 76800 topic_id: 21787 reply_id: 86937[/import]