1

当我在主文件中运行时,我的代码运行顺利,但是当我在其他一些 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)
4

1 回答 1

0

I just tested this using Director with a standard Director main.lua file and a scene1.lua file containing only your code from the above post and it worked just fine.

You could provide more code, upload a zip of your project or share any notes about your project that may help figure out why this would be happening.

I would suggest you create a basic app as I just did and try running that; if the issue persists you could file a bug, although as I said above event phases are working fine for me.

于 2012-09-11T16:48:18.450 回答