我有一个带有令牌的单词搜索游戏,用户可以使用它们来显示他们必须找到的单词。但我的问题是,在我单击标记后,我无法突出显示在单词搜索中找到的单词,而是每次单击时都会带走标记,无论在关卡的哪个位置。我试过 token:removeEventListener 但这不起作用,也许我把它放在了错误的位置
function token:touch( event )
if event.phase == "began" then
if storyboard.state.score >0 then
storyboard.state.score = storyboard.state.score - 1
score.text = tostring(storyboard.state.score)
clueText.isVisible = false
answerText.isVisible = true
display.getCurrentStage():setFocus( event.target )
event.target.isFocus = true
elseif event.target.isFocus then
if event.phase == "moved" then
print( "user has moved their finger off the token." )
elseif event.phase == "ended" then
print( "user has used a token" )
display.getCurrentStage():setFocus( nil )
event.target.isFocus = false
end
end
return true
end
end
menubutton:addEventListener( "touch", menubutton)
token:addEventListener( "touch", token)
有任何想法吗?