Hi guys, I am working on an simple word search game. Ill attach an image to understand more my question. My question is how am I be able to remove the letter that is not being touch anymore. In the image I touched the letter Z to O then moved to Z to I but the selected letter is still Z I Q O. How am I be able to remove the letter that is not touched anymore? Thanks in advance
Keep track of the objects you’ve touched in a table, then if you exit an object at the end of this list and return to one before it, you know you need to remove the end item.
You would actually do this at touch begin:
- List empty
- first touch begin on Z object - Add Z object to list.
- second touch begin on I object - Add I object to list
- third touch begin on Z object - Remove I object from list
Hi, yeah I get it. I think I need to rework my touch function, I forgot to that I created a flag if the objects is already touched it will return true as long as it is touched. How to know if the touch already exit the object?
if ( event.phase == “began” ) then
initX = event.target.x
initY = event.target.y
alphabet[event.target.id].alreadytouched = true
alphabet[event.target.idj].alreadytouchedj = true
elseif (event.phase == “moved”) then
if (alphabet[event.target.id].alreadytouched == false or alphabet[event.target.idj].alreadytouchedj == false ) then
alphabet[event.target.id].alreadytouched = true
alphabet[event.target.idj].alreadytouchedj = true
assembledWord = assembledWord…event.target.value
assembleWord(assembledWord)
print(assembledWord)
end
watch for an ended phase
If I removed the the flag the output will be like this when touching a letter
For the ended phase I just return the flag as false
Hi. I’ve helped as much as I can.
Keep plugging at it. I’m sure you can solve it.
Keep track of the objects you’ve touched in a table, then if you exit an object at the end of this list and return to one before it, you know you need to remove the end item.
You would actually do this at touch begin:
- List empty
- first touch begin on Z object - Add Z object to list.
- second touch begin on I object - Add I object to list
- third touch begin on Z object - Remove I object from list
Hi, yeah I get it. I think I need to rework my touch function, I forgot to that I created a flag if the objects is already touched it will return true as long as it is touched. How to know if the touch already exit the object?
if ( event.phase == “began” ) then
initX = event.target.x
initY = event.target.y
alphabet[event.target.id].alreadytouched = true
alphabet[event.target.idj].alreadytouchedj = true
elseif (event.phase == “moved”) then
if (alphabet[event.target.id].alreadytouched == false or alphabet[event.target.idj].alreadytouchedj == false ) then
alphabet[event.target.id].alreadytouched = true
alphabet[event.target.idj].alreadytouchedj = true
assembledWord = assembledWord…event.target.value
assembleWord(assembledWord)
print(assembledWord)
end
watch for an ended phase
If I removed the the flag the output will be like this when touching a letter
For the ended phase I just return the flag as false
Hi. I’ve helped as much as I can.
Keep plugging at it. I’m sure you can solve it.