0
我在清除LUA表中的數據時遇到問題。我使用Scene插件,只要玩家前進到下一個場景,我想重置表格中的數據。清除日暈中的表
我用這個功能來創建遊戲元素:
local function createGrips()
local originX = 0
local originY = height -75
for i=0,numberGrips do
r = math.random(3)
local x = originX + math.random(width)
local y = originY - math.random(2*height)
grip[i] = display.newRect(allElements, x, y, gripSize[r].w, gripSize[r].h)
grip[i].status = "active"
grip[i].size = gripSize[r].s
if (r == 1) then
grip[i]:setFillColor(51,255,0)
elseif (r == 2) then
grip[i]:setFillColor(255,51,51)
elseif (r == 3) then
grip[i]:setFillColor(51,51,255)
end
end
end
createGrips()
當我移動到下一個場景我已經tryed所有這些選項清檯:
grip={}
或這一個
for i=#grip,0, -1 do
table.remove(grip,i)
end
但結果保持不變。元素保持在屏幕上。唯一可行的是grip = nil。但是,只要我返回函數createGrips(),就會產生一個錯誤。
任何人都可以請幫忙嗎? 重置所有數據的最佳方法是什麼?我爲所有字符使用removeSelf()函數。
它幫助。我使用storyboard.purgeScene(),它的工作。非常感謝你的幫助。 – jumbee
嗯,我很高興,我幫你解決問題。順便說一句,你可以投我的答案 – DevfaR