I am using a function that sets up a cloud table, and has clouds move down the screen. This function clouds is in an external module, and i am basing my work off of the “star” example.
I am trying to use director with my program, and when i change the scene, clouds continue to fall.
function Clouds ()
function moveGround()
moveTheGround = transition.to(ground, { delay = 0,
time= 6000,
y=\_H + 500
}) -- Move the Cloud
end
local cloudTable = {} -- Set up cloud table
function initCloud()
local cloud1 = {}
cloud1.imgpath = "cloud2.png"; --Set Image Path for cloud
cloud1.movementSpeed = (-jetpackNumber + 6) \* 500; --Determines the movement speed of cloud
table.insert(cloudTable, cloud1); --Insert Cloud into cloudTable
local cloud2 = {}
cloud2.imgpath = "cloud1.png";
cloud2.movementSpeed = (-jetpackNumber + 6) \* 500;
table.insert(cloudTable, cloud2);
local cloud3 = {}
cloud3.imgpath = "cloud1.png";
cloud3.movementSpeed = (-jetpackNumber + 6) \* 1000;
table.insert(cloudTable, cloud3);
end --END initCloud()
function getRandomCloud()
local temp = cloudTable[math.random(1, #cloudTable)] -- Get a random cloud from cloudTable
local randomCloud = display.newImage(temp.imgpath) -- Set image path for object
randomCloud.myName = "cloud" -- Set the name of the object to cloud
randomCloud.movementSpeed = temp.movementSpeed; -- Set how fast the object will move
randomCloud.x = math.random(0,\_W) -- Set starting point of cloud at a random X position
randomCloud.y = - 50 -- Start the cloud off screen
cloudMove = transition.to(randomCloud, {
time=randomCloud.movementSpeed,
y=\_H + 150,
onComplete = function(self) self.parent:remove(self); self = nil; end
}) -- Move the cloud
end--END getRandomCloud()
function startGame()
cloudTimer1 = timer.performWithDelay(1000,getRandomCloud, 0)
cloudTimer2 = timer.performWithDelay(1300,getRandomCloud, 0)
end--END startGame()
initCloud()
startGame()
moveGround()
end
Any one know what i am doing wrong?
Thanks [import]uid: 24708 topic_id: 24805 reply_id: 324805[/import]
