当我在主文件中运行时,我的代码运行得很流畅,但是当我在其他lua文件中编写代码并在director.lua的帮助下调用该文件时,它无法识别触摸时的结束事件阶段。请帮帮我。提前谢谢。这是我的代码。
function touched( event )
if event.phase == "ended" then
if(event.x - event.xStart > 30)then
sliding = true;
line = display.newLine(event.xStart, event.yStart, event.x, event.y)
line:setColor(255,0,0)
line.width = 5
else
print("just a touch")
end
end
end
Runtime:addEventListener("touch", touched , -1)发布于 2012-09-12 00:48:18
我刚刚使用Director使用一个标准的Director main.lua文件和一个scene1.lua文件测试了这一点,该文件只包含您在上面帖子中的代码,它工作得很好。
你可以提供更多的代码,上传你的项目的压缩文件,或者分享任何关于你的项目的笔记,这可能有助于找出为什么会发生这种情况。
我建议你像我刚刚做的那样创建一个基本的应用程序,并尝试运行它;如果问题仍然存在,你可以提交一个bug,尽管正如我上面所说的,事件阶段对我来说工作得很好。
https://stackoverflow.com/questions/12328502
复制相似问题