So it looks like you are displaying a text object. That is one whole object. If you use the isVisible property on it, the entire word is going to go invisible/visible. You cannot just do one specific letter. You would have to change the entire text in it if you want to hide some letters and show others. This is controlled by the text property (in this case, currentWord.text). You are then going to have to rebuild the word each and every time you want to show a new letter. It feels like this would be unnecessarily complex.
It might actually be a little easier if you make a separate text object for each letter. Then you would control the isVisible property of each letter. And looking at the code snippet you provided, that is what it looks like you were trying to do (currentWord.isVisible(aa)). But you are going to have to create a table to do that properly. Like below.
local theWord = wordList[mRand]
local currentWord = {}
local nextX = 10
local nextY = 100
for j=1,string.len(theWord) do
--this loop will create a table, where each entry is a letter in the word
--get the current letter
local currentLetter = string.sub(theWord,j,j)
--make a text object out of the current letter
local displayLetter = display.newText(currentLetter, 10, 100, "Times New Roman", 20)
displayLetter.isVisible = false
displayLetter.x = nextX
displayLetter.y = nextY
--give the text object a custom property so that we can compare to it later
displayLetter.letter = string.upper(currentLetter)
--need to offset this letter from the previous one, so that they are not all in the same position
nextX = nextX + displayLetter.contentWidth + 2
--add text object to table
currentWord[#currentWord+1] = displayLetter
end
local function gamePlay(event)
local self = event.target
local checkLetter = string.upper(self.name)
for j=1,#currentLetter do
if currentLetter[j].letter == checkLetter then
currentLetter[j].isVisible = true
end
end
end
I didn’t actually test the code above, but I think it should work. [import]uid: 94868 topic_id: 30491 reply_id: 122295[/import]