Cocos 2d-x 3.6 touch事件只有began 坑~

Cocos 2d-x 3.6 touch事件只有began 坑~,第1张

概述touch事件只有began -- add touch layer     display.newLayer()         :onTouch(handler(self, self.onTouch))         :addTo(self) 少了这个return,让哥的touch事件只有began,framework就是这么菜 cocos\framework\extends\LayerEx.

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

总结

以上是内存溢出为你收集整理的Cocos 2d-x 3.6 touch事件只有began 坑~全部内容,希望文章能够帮你解决Cocos 2d-x 3.6 touch事件只有began 坑~所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1070305.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-26
下一篇2022-05-26

发表评论

登录后才能评论

评论列表(0条)

    保存