I’m still new to Corona and Lua. I just had a question. I have the following code:
[lua]-- Display Constants
_H = display.contentHeight;
_W = display.contentWidth;
local word = “tree”
wordLength = string.len(word)
for c = 1, wordLength do
local letter = {}
local letter = string.sub(word, c, c)
local letters = display.newText(letter, 0,0,“Times”,76)
letters.x = _W / 2 + (c * 55) - 150
letters.y = _H / 2
function letters:touch(e)
if(e.phase == “ended”) then
letters:removeSelf(self)
end
end
letters:addEventListener(“touch”, letters)
end[/lua]
It does exactly what I need it to do. But I wondered if it’s okay to have the majority of my code sitting in a loop. Is it better to create a function to host the majority, and then call it in the loop somehow?
Sorry. Still new at this. But I want to make it as easy as possible so I can use the letters in the “letter” table somewhere else in the code, without having to stay in the loop. Unless it’s okay to stay in the loop, in which case, please let me know. [import]uid: 14084 topic_id: 6687 reply_id: 306687[/import]