我是Corona SDK的初学者。 我有2个场景A & B.使用故事板似乎禁用触摸事件?
在场景中我有一个OnRelease事件按钮。 此按钮已创建并添加到场景创建事件中的组中。 点击按钮将我带到场景B(storyboard.gotoScene(“B”))。
在场景B我有一个盒子上的触摸事件(箱子图像)。 触摸侦听器添加到场景中的已启动事件中,并在现场退出事件中删除。 点击箱子把我带回A(storyboard.gotoScene(“A”))。
所以这里是真正令人讨厌的问题: 回到A后,此场景中的所有事件现在都被禁用。 即我不能再点击按钮(无事件)。
如果我缺少上述信息,将提供代码片段。 谢谢。
*更新*
取约从这个休息后,我今天回去又开始调试这一点。我很快就发现了这个问题。这个问题与我触摸的事件处理程序有关(导致从场景B到A的过渡)。
低于片断导致此问题:
function testTouched(event)
-- process cue-touched event...
--local t = event.target -- commenting this was the fix.
local phase = event.phase
if "began" == phase then
print(" -> back to menu")
--display.getCurrentStage():setFocus(t) -- commenting this was the fix.
--t.isFocus = true -- commenting this was the fix.
storyboard.gotoScene("menu", "flipFadeOutIn", 500)
end
-- Stop further propagation of touch event
return true
是的,你应该提供代码片段 – cctan 2012-02-23 08:30:30