Hi,
I know how to remove everything from a table but not just one item.
So any advice would be most helpful.
I have created for objects and added them to a table, I just want to remove say the second object, I have tried various methods but none seem to work.
I tried the table.remove(roadBlocks,3) , using k,v in pairs(roadBlocks) etc and iterating backwards
Apologies for the formatting the tags dont seem to work for me.
local roadBlocks = {}
local function createRoadBlock(layer)
local layer = layer or display.currentStage
local roadBlockPosX = {100,220,100,200 }
local roadBlockPosY = {50,50,430,430 }
local roadBlockRotation ={-45,45,45,-45}
for i =1, 4 do
local roadBlock = display.newRect(0,0,40,5)
roadBlock.x = roadBlockPosX[i]
roadBlock.y = roadBlockPosY[i]
roadBlock.rotation = roadBlockRotation[i]
roadBlocks[roadBlock] = roadBlock
end
timer.performWithDelay(2000, function()
---------- remove roadblock 3 here from the table and the display object----------
end)
end