So say I have a module called car.lua and within that module I have:
[lua]function new(params)
newCar = display.newImage(blah blah) – create a car object from image
… – car functions
function spawnCar(event)
– if a car has moved 15 pixels from its original position, spawn another one
end
end[/lua]
and in my main, I call:
[lua]Runtime:addEventListener(“enterFrame”, car.spawnCar)[/lua]
Which returns the error:
[lua]Runtime error
assertion failed!
stack traceback:
[C]: ?
[C]: in function ‘assert’
?: in function ‘getOrCreateTable’
?: in function ‘addEventListener’
?: in function ‘addEventListener’[/lua]
I know that doesn’t work because it’s inside new(), but I need it there because it needs access to newCar which is local, to compare the car coordinates to know when to spawn the next one.
How should I solve this? [import]uid: 106739 topic_id: 20385 reply_id: 320385[/import]