Star background animation

Here’s the 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.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 + -500 -- 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()   

How can I make the stars go from top to bottom instead of bottom to top? [import]uid: 72845 topic_id: 12573 reply_id: 312573[/import]

do you have a config file in the folder ?
try creating one with

[lua]application =
{
content =
{
width = 320,
height = 480,
scale = “zoomEven”
}
}[/lua]

when testing your code I got entirely different results with and with out the config file.

with the config file i can make the stars go down the screen by just setting the ‘y’ value in the transition.to to any positive value.

try and let me know how it works for you. [import]uid: 71210 topic_id: 12573 reply_id: 45985[/import]

This is my config.lua

  
application =  
{  
 content =  
 {  
 width = 768,  
 height = 914,  
 scale = "zoomEven",  
 fps = 30,  
 antialias = false,  
 xalign = "center",  
 yalign = "center",  
  
 imageSuffix =   
 {  
 ["@2"] = 2  
 }  
  
 }  
}  

I’ve tried messing with my y settings but nothing seems to change. [import]uid: 72845 topic_id: 12573 reply_id: 46011[/import]

the y position of your star is contentHeight - 500
ie 914(according to your config.lua file) - 500 = 414

so it starts at location y = 414 and will transition to y = 45
that is why the stars are going up… you may try putting y = 914 then the stars will move downwards… [import]uid: 71210 topic_id: 12573 reply_id: 46016[/import]

Thanks again : ) [import]uid: 72845 topic_id: 12573 reply_id: 46021[/import]