首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在corona中清理表格

在corona中清理表格
EN

Stack Overflow用户
提问于 2013-07-02 23:04:45
回答 1查看 397关注 0票数 0

我在清除LUA表中的数据时遇到了问题。我使用场景插件,只要玩家前进到下一个场景,我就想重置表格中的数据。

我使用这个函数来创建游戏元素:

代码语言:javascript
复制
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()

当我移动到下一个场景时,我尝试了所有这些选项来清理表格:

代码语言:javascript
复制
grip={}

或者是这个

代码语言:javascript
复制
for i=#grip,0, -1 do
    table.remove(grip,i)
end

但结果保持不变。元素一直停留在屏幕上。唯一起作用的就是grip=nil。但是当我返回到函数createGrips()时,这就产生了一个错误。

重置所有数据的最佳方法是什么?我对所有字符都使用了removeSelf()函数。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-07-03 00:16:33

在corona中有类似的问题,就像我在前面的回答中所说的,如果你想在你的故事板中重新创建所有的数据和值,你必须在转到另一个场景后移除你的场景,或者你可以在场景中重置你的值:Enterscene()函数,所以如果你回到上一个场景,它将重置这些值

也许这个链接可以帮助你

为storyboard http://www.coronalabs.com/blog/2011/11/14/introducing-the-storyboard-api/删除和清除scene http://www.coronalabs.com/blog/2012/07/31/storyboard-scene-purging-vs-removal/

  • and this的
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17429095

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档