I have game and when you get your special, all the crates on the field destroy. As I hit the first crate, all the crates play the “destroy” animation. As I keep playing and do it a second time it says… "attempt to call method ‘setSequence’ (a nil value).
here is the code…
function special(event) for i=1,#objectsArray do if objectsArray[i] ~= nil and objectsArray[i].name == "crate" then local child = objectsArray[i].item if child ~= nil then child:setSequence("destroy") child:play() child.isBodyActive = false child = nil end end end end
just in case, the setSequence is stored here…
local objectProperties = { ------------------------------------------------------------------- crate = {--START OF CRATE id = "crate", xp = 0, stackable = "no", damage = 50, category = "normal", score = 50, sprite = { imageSheet = "crateImageSheet.png", imageSheetInfo = "crateImageSheet", sequenceData = { default = { start = "crate\_01", count = 1, loopCount= 1 }, destroy = { start = "crate\_01", count = 7, time = 450, loopCount = 1 } } },
I would like for all of the crates to be destroyed and erased out of the table, however I still need to access the table again without getting nils.