【发布时间】:2013-06-27 10:29:59
【问题描述】:
无法从表中删除条目。
这是我的代码
dropItem = dropList[ math.random( #dropList ) ]
dropSomething[brick.index] = crackSheet:grabSprite(dropItem, true)
dropSomething[brick.index].x = brick.x
dropSomething[brick.index].y = brick.y
dropSomething[brick.index].name = dropItem
dropSomething[brick.index].type = "dropppedItems"
碰撞
function bounce(event)
local item = event.other
if item.type == "dropppedItems" then
if item.name == "bomb" then
Lives = Lives - 1
LivesNum.text = tostring(Lives)
end
item:removeSelf();
end
end
我尝试过的:
item:removeSelf(); -- removes the whole table
item = nil -- seems to do nothing, the object continue
-- to move and i still see the image
我可以从屏幕上删除对象的唯一方法是使用 transition.to(item, {time = 100, alpha = 0})
【问题讨论】:
-
event.other = nil呢? -
我只能假设您的函数必须位于事件侦听器的顶部,否则您可以为其添加其他代码
标签: arrays sdk lua coronasdk lua-table