0
我創建了一個基團,並且增加了以下事件偵聽器調用一個函數:RemoveEventListener:用於屬性查找供給零鍵
catinBalloon:addEventListener("touch", catinBalloontouch)
隨後,我插入兩個對象成團catinBalloon和添加的組的表:
table.insert(catandBalloonTable, #catandBalloonTable+1, catinBalloon)
作爲另一個函數的一部分,我想通過表循環刪除偵聽器事件。
for i = #catandBalloonTable, 1, -1 do
print_r(catandBalloonTable[i])
catandBalloonTable[i]:removeEventListener("touch", catinBalloontouch)
end
錯誤之前的print_r的輸出是:
04:20:03.364 table: 0DACC088 {
04:20:03.364 [_proxy] => userdata: 0DAD20E0
04:20:03.364 [_functionListeners] => table: 0DACC088 {
04:20:03.364 [touch] => table: 0DADA0C0 {
04:20:03.364 [1] => function: 04080198
04:20:03.364 [2] => function: 0DA0E6E0
04:20:03.364 }
04:20:03.364 }
04:20:03.364 [activeObjectWord] => "ant"
04:20:03.364 [_class] => table: 0DACC088 {
04:20:03.364 [removeEventListener] => function: 04245CE8
04:20:03.364 [addEventListener] => function: 04247968
04:20:03.364 [__index] => table: 0425AE40 {
04:20:03.364 *table: 0425AE40
04:20:03.364 }
04:20:03.364 }
04:20:03.364 [removeSelf] => function: 0433B9B8
04:20:03.364 [active] => "yes"
04:20:03.364 [activeObjectSound] => userdata: 0A0CAAE0
04:20:03.364 }
和錯誤是:
04:20:03.364 ERROR: nil key supplied for property lookup.
04:20:03.364 stack traceback:
04:20:03.364 [C]: ?
04:20:03.364 ?: in function 'removeEventListener'
04:20:03.364 ?: in function 'removeEventListener'
04:20:03.364 ?: in function 'removeEventListener'
謝謝。