Hi,
I have a situation where I am firing multiple laser beams from multiple enemies at a random interval. I am spawning each beam into a table. I am letting each beam live for about half a second.
I need to remove the beams in the order they were fired, from first to last. I have my beams in a table.
Do I do a removeself() and nil from the table specifing 1 as the index until the table is empty?
Thanks for any help, Greg
local spawn1 = spawnbeam({
x1= kx,
y1 = ky,
x2 = player.x,
y2=player.y,
layer= layer2,
color = “red”,
})
timer.performWithDelay(600, function() …have to remove the beams in order here… end, 1)
function spawnbeam(params)
local beam = display.newLine(params.layer,params.x1, params.y1, params.x2,params.y2, params.color )
if params.color == “red” then
beam:setStrokeColor( 1,0,0)
elseif params.color ==“green” then
beam:setStrokeColor( 0,1,0)
else
beam:setStrokeColor( 0,0,1)
end
beam.strokeWidth = 3
beam.objTable = beamtable
beam.index = #beam.objTable +1
beam.myName=“beam”…beam.index
beam.objTable[beam1.index]=beam1
return beam
end