3.x的 触摸机制好复杂 请问 我要让一个cclayer能捕捉时间 应该怎么做 点击不了啊 如果我自定义一个继承cclayer 有触摸事件需要怎么写 其实2.x的版本我都是会写 一道3.x 我多久觉得奇怪怎么写都不对
不懂这样的设计模式到底是谁相处来 原来一句话setEnabled就可以解决的问题 现在 弄这么负责 我觉得这样会给别的人设计带来很大的问题 还有关于渲染 如果说自己把渲染指令 封装好和每次调用 这些都是看游戏来的 我就----- 不懂为什么搞这么复杂 性能也没有优化多少
local layer = cc.Layer:create()
local background = cc.Sprite:create(“res/jz0201.jpg”)
background:setScale(1)
layer:addChild(background)
layer:setTouchEnabled(true)
layer:setTouchMode(2)
layer:setSwallowsTouches(true)
layer addNodeEventListener(cc.NODE_TOUCH_EVENT, function(event)
local name = event.name
if name == “began” then
print(“began”)
– return cc.TOUCH_BEGAN – stop event dispatching
– cc.TOUCH_BEGAN_NO_SWALLOWS – continue event dispatchin
return true
elseif name == "ended" then
print("ended")
else
end
end)
layer:addTo(self)
print("22")