Lua Gideros:触摸画线

时间:2014-09-28 14:16:02

标签: android graphics lua gideros

在我使用Lua和Gideros工作室的游戏中,我希望有人能够通过触摸屏幕的线的起点以及它们释放的线的末端来绘制直线触摸。当我运行我的代码(下面)时,我总是收到这条消息:

main.lua:66:尝试索引全局'事件'(零值) 堆栈追溯:     main.lua:66:在主要块

这是我的代码:

local function onMouseDown(event)
    event.x = startx
    event.y = starty

    event:stopPropagation()
end

local function onMouseUp(event)
    event.x = endx
    event.y = endy
    event:stopPropagation()
    local line = Shape.new()
    line:setLineStyle(5, 0x0000ff, 1)
    line:beginPath()
    line:moveTo(startx,starty)
    line:lineTo(endx,endy)
    line:endPath()

end

下一行是我的代码中的第66行:

scene:addEventListener(event.MOUSE_DOWN, onMouseDown)
scene:addEventListener(event.MOUSE_UP, onMouseUp)

有人知道为什么会这样吗?谢谢!

1 个答案:

答案 0 :(得分:0)

因为它是Event.MOUSE_DOWN,Lua区分大小写。