Hi everyone 
i am working with tables and need some help to remove the objects that collides with a spawner
function spawner:collision (event)
if event.phase == "began" then
for i = 1, #block1, 1 do
if block1[i].id == event.other.id then
block1[i]:removeSelf()
table.remove(block1,i)
return true
end
end
end
end
it is my spawner collision function.
Some time ago i use a tables code like it:
local block1 {}
local function myspawner (event)
block1[#block1+1] = display.newImage("my image")
block1[#block1].x = 100
block1[#block1].y=100
local function my\_function\_to\_do\_everything (event)
block1[#block1]. some code etc etc
end
block1[#block1]:addEventListener("collision", my\_function\_to\_do\_everything)
end
and now i have some code like
P.S : attention inside the function “my_function_to_do_everything”
local block1 {}
local function myspawner (event)
block1[#block1+1] = display.newImage("my image")
block1[#block1].x = 100
block1[#block1].y=100
local function my\_function\_to\_do\_everything (event)
block1[1]. some code etc etc
block1[2]. some code etc etc
etc
end
block1[#block1]:addEventListener("collision", my\_function\_to\_do\_everything)
end
now inside the function when i need, i use the blocks separete, like, block1[1], block1[2] etc dont use block1[#block1] and the spawner collision function dont work with this new code used on tables, only work with the old code when i use block1[#block1], anyone can give me some help?
Thanks
[import]uid: 26056 topic_id: 17889 reply_id: 317889[/import]