blackbird192
blackbird192

Reputation: 1

corona sdk spawn and make an object fall

I want to spawn some random objects and i managed to do it from the top of the screen. Then i'd like to make them fall like in an endless runner game. But the code doesn't work and it gives me an error. Here is it:

local function spawn()
local object1 = display.newImage(group[i1],29,1)   <---this refers to a position in a group of objects
object1:scale(1.23,1.30)
end
timer.performWithDelay(2000,spawn,-1)

local function fall()
object1.y = object1.y + 10    <---it says that this is a nil value
timer.performWithDelay(100,fall,-1)

Upvotes: 0

Views: 379

Answers (1)

THECODER
THECODER

Reputation: 1

The problem is that you are calling one function variable from another function. Object 1 is a local variable within the spawn function, so it is more or less nonexistent when called from another function.

Upvotes: 0

Related Questions