How do I display array elements in Lua?

前端 未结 3 915
Happy的楠姐
Happy的楠姐 2021-01-14 03:35

I\'m having an issue displaying the elements of an array in Lua programming language. Basically, i created an array with 3 elements, and i\'m trying to display its contents

3条回答
  •  悲&欢浪女
    2021-01-14 04:09

    What happens when you change your loop to this:

    for i = 1, #myText do
        local myText = display.newText( myText[i], 0, 0, native.systemFont, 35 )
    end
    

    Or this:

    for i, v in ipairs(myText) do
        local myText = display.newText( v, 0, 0, native.systemFont, 35 )
    end
    

提交回复
热议问题