touch事件只有began
-- add touch layer
display.newLayer()
:onTouch(handler(self,self.onTouch))
:addTo(self)
少了这个return,让哥的touch事件只有began,framework就是这么菜
cocos\framework\extends\LayerEx.lua
function Layer:onTouch(callback,isMultiTouches,swallowTouches)
if type(isMultiTouches) ~= "boolean" then isMultiTouches = false end
if type(swallowTouches) ~= "boolean" then swallowTouches = false end
self:registerScriptTouchHandler(function(state,...)
local args = {...}
local event = {name = state}
if isMultiTouches then
args = args[1]
local points = {}
for i = 1,#args,3 do
local x,y,id = args[i],args[i + 1],args[i + 2]
points[id] = {x = x,y = y,id = id}
end
event.points = points
else
event.x = args[1]
event.y = args[2]
end
returncallback(event)
end,宋体"> self:setTouchEnabled(true)
return self
end