Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lua 如何迭代字典/文本框表?_Lua_Moai - Fatal编程技术网

Lua 如何迭代字典/文本框表?

Lua 如何迭代字典/文本框表?,lua,moai,Lua,Moai,我有一个文本框表,其中的键是位置的名称,右上角,左上角 一次创建和配置一个可以正常工作: kanaAt = {} function startKanas () kanaAt.topLeft = MOAITextBox.new() kanaAt.topLeft:setFont(font) ... kanaAt.topLeft:setString("か") layer:insertProp (kanaAt.topLeft) kanaAt.topR

我有一个文本框表,其中的键是位置的名称,右上角,左上角

一次创建和配置一个可以正常工作:

kanaAt = {}
function startKanas ()
    kanaAt.topLeft = MOAITextBox.new()  
    kanaAt.topLeft:setFont(font)
    ...
    kanaAt.topLeft:setString("か")
    layer:insertProp (kanaAt.topLeft)

    kanaAt.topRight = MOAITextBox.new()
    kanaAt.topRight:setFont(font)
    ...
    kanaAt.topRight:setString("た")
    layer:insertProp (kanaAt.topRight)
end
但当我尝试遍历它时,情况并非如此:

kanaAt = {}
function startKanas ()
    kanaAt.topLeft = MOAITextBox.new()
    kanaAt.topRight = MOAITextBox.new() 
    kanaAt.bottomLeft = MOAITextBox.new()
    kanaAt.bottomRight = MOAITextBox.new()          

    for name, text in ipairs(kanaAt) do
        text:setFont(font)
        text:setTextSize(90,60)
        text:setYFlip(true)
        text:setRect(-50,-50,50,50)
        layer:insertProp (text)
    end

    kanaAt.topLeft:setString("か")
    kanaAt.topLeft:setLoc(-325, 225)
    kanaAt.topRight:setString("た")
    kanaAt.topRight:setLoc(325, 225)
    kanaAt.bottomLeft:setString("ち")
    kanaAt.bottomLeft:setLoc(-325, -225)
    kanaAt.bottomRight:setString("つ")
    kanaAt.bottomRight:setLoc(325, -225)

end

我做错了什么?

使用对而不是IPAIR。

使用对而不是IPAIR