hey guys I’m trying to make a function that will spawn and move sprites
local function spawnBerry( event )
local berry = display.newImageRect("Berry.png", 50, 60)
berry.x, berry.y = math.random(50, 420), math.random(1, 300)
berry.x = berry.x - 1 -- Moves berry
end
timer.performWithDelay(500, spawnBerry, 99999999999999)
There is my code and the line that says (Moves Berry) obviously isn’t doing its job. I’m a newbie to lua and to corona. So any help on how I could get the berry to move would be great
local function spawnBerry( event )
local berry = display.newImageRect("Berry.png", 50, 60)
berry.x, berry.y = math.random(50, 420), math.random(1, 300)
transition.to(berry, {time=2000, x=0})
return berry
end
timer.performWithDelay(math.random(500, 1000), spawnBerry, 0)
Play around with the values in math.random to vary the speed they are created. Or you can just specific a number like you did before. [import]uid: 84637 topic_id: 14632 reply_id: 54210[/import]