I'm creating a top-downshooter and I want to keep track of all my bullets in a table, so I can iterate through them so I can later delete them ,and also move them during the update loop.
table.insert(bulletsCollider,HC:addCircle(playerX,playerY,bulletRadius))
-- also tried
table.insert(bulletsCollider,Collider:addCircle(playerX,playerY,bulletRadius))
during my bullet creation function, but I get errors. (attempt to call method 'addCircle' (a nil value) )
If you get errors when trying to update a table, try a conditional statement, since HC:addCircle() returns a value you can check if its holding a valid value and then apply it to a table eliminating the error.
if HC:addCircle(playerX, playerY, bulletRadius) ~= nil then
table.insert(bulletsCollider, HC:addCircle(playerX, playerY, bulletRadius))
else
-- else code here or just use the if the statement
end