How do i make a objects randomly fall from top of the screen.?

Ok so i lets say  i have an image (“cirlce.png”, 30, 30 ) i want that certain amount to fall from the top of the screen forever… non stop they just fall… is that understandable? lol … early thanks to all and any for the help :slight_smile:

you can write a function to create the object, and another function to randomly ‘drop’ that object  from above screen.

local function createObject() local img = display.newImageRect( 'YourImageFilename', 100, 100 ) displayGroup:insert( img ) img.y = -img.contentHeight -- This will make sure it is off-screen on TOP img.x = math.random( 0, display.viewableContentWidth ) -- This will make the x-position random transition.to( img, { time = 5000, y = display.viewableContentHeight + img.contentHeight } end local function dropObjects() timer.performWithDelay( 1000, createObject, 0 ) -- make this loop indif. end

See the below video where the blocks fall from the top. It is easy in Corona.

https://www.youtube.com/watch?t=14&v=sJtjpquO4mk

You can download the code and use the template from http://webplusmobileapps.com/corona-sdk-app-development/word-shuffle-app-corona-sdk-word-game-template/

Hey, so i added the code into my lua file and it doesnt do anything… there was a problem( a missing one of these “)”  )but that was any easy fix… but over all the code doesnt seem to do anything.

Ok so i made a video of what id like… please watch and if you dont understand ask questions!! thanks!

https://youtu.be/7g94s97qOTM

you can write a function to create the object, and another function to randomly ‘drop’ that object  from above screen.

local function createObject() local img = display.newImageRect( 'YourImageFilename', 100, 100 ) displayGroup:insert( img ) img.y = -img.contentHeight -- This will make sure it is off-screen on TOP img.x = math.random( 0, display.viewableContentWidth ) -- This will make the x-position random transition.to( img, { time = 5000, y = display.viewableContentHeight + img.contentHeight } end local function dropObjects() timer.performWithDelay( 1000, createObject, 0 ) -- make this loop indif. end

See the below video where the blocks fall from the top. It is easy in Corona.

https://www.youtube.com/watch?t=14&v=sJtjpquO4mk

You can download the code and use the template from http://webplusmobileapps.com/corona-sdk-app-development/word-shuffle-app-corona-sdk-word-game-template/

Hey, so i added the code into my lua file and it doesnt do anything… there was a problem( a missing one of these “)”  )but that was any easy fix… but over all the code doesnt seem to do anything.

Ok so i made a video of what id like… please watch and if you dont understand ask questions!! thanks!

https://youtu.be/7g94s97qOTM