Hello everyone,
is there any way to add an event listener (collision) to a table?
Here my code so far:
--table 2 local wordTable2 = {"Air","Breath" } local word = {} for i,v in ipairs (wordTable2) do word[i] = display.newText (wordGroup, v, 250, 200, robotoFont, 25) word[i]:setFillColor( 1, 0, 0 ) physics.addBody(word[i], "dynamic",{density=1, friction =.3}) physics.setGravity( 1, 10 ) wordTable2.name = "word2" word[i].isVisible = false print( k,v) end word[currentWord].isVisible = true local function wordCollision ( self,event) if event.phase == "began" then for i,v in ipairs (#wordTable2) do if (self == wordTable2[i] and other == player) then display.remove (wordTable2[i]) wordTable2[i] = nil score = score +1 updateText() end end end end wordTable2.collision = wordCollision wordTable2:addEventListener("collision", wordTable2)
the attempt to call event listener is a nil value
any help is appreciated,
tks in advanced
Patricia