I am currently trying to get a snippet of code working to have 10 projectiles fire 1 after another. For the life of me I can’t figure out how to get them to respond to the touch listener. The only projectile that fires is the last one generated. I know I"m getting the 10 projectiles generated offscreen from a higher function as they display in terminal. Below is my code, and I have spent a good 6 hours on it and would appreciate a second (or third) set of eyes. I know I’m missing something obvious but I am totally blind to it. Let me know if I need to post more code. Thanks!
[lua]local function fireRifle(event)
for a=1, 10, 1 do
if event.phase == “began” then
if event.time - timeLastBullet >= 650 then
bolt.x = player.x + 28
bolt.y = player.y - 20
transition.to(bolt, {time = 2000, bolt:setLinearVelocity(500, 0),
onComplete = function(bolt) bolts = nil; end
})
print(“FIRE!”)
timeLastBullet = event.time
end
end[/lua]
[import]uid: 135394 topic_id: 29183 reply_id: 329183[/import]