cocos2d3.5新手引导

cocos2d3.5新手引导,第1张

概述游戏中,新手引导经常要用到。这次是基于3.5版本。 思路:创建遮罩,显示区触摸,下层响应。 让引导层继承widget local Guide = class("Guide",function () return ccui.Widget:create()end) 把guide设置描点为self:setAnchorPoint(cc.p(0,0))。这样方便坐标计算。 这样可以方便处理触摸区域的响应

游戏中,新手引导经常要用到。这次是基于3.5版本。

思路:创建遮罩,显示区触摸,下层响应。

让引导层继承Widget

local GuIDe = class("GuIDe",function ()	return ccui.Widget:create()end)

guIDe设置描点为self:setAnchorPoint(cc.p(0,0))。这样方便坐标计算。

这样可以方便处理触摸区域的响应。通过点击的落点是否在显示区域,然后设置self.Listener:setSwallowtouches(true),可以向下层穿透,响应事件;

function OperationalVIEw:ontouchBegan(touch_,event_)  	print(" OperationalVIEw:ontouchBegan  began")	local pos = touch_:getLocation()	self._touchPos = cc.p(pos.x,pos.y)	if self._blackBg then 	else		self._Listener:setSwallowtouches(false)	end	if rectIntersectsPoint(self._stencil:getBoundingBox(),cc.p(pos.x,pos.y)) then 		self._Listener:setSwallowtouches(false)	end    return trueend  



遮罩可以使用cc.Layercolor:create(cc.c4b(0,0))来创建

实现镂空

self._clipPingNode = cc.ClipPingNode:create()self._clipPingNode:addChild(self._stencil)self._clipPingNode:setStencil(self._stencil)self._clipPingNode:setInverted(true)

self._stencil可以是图片资源,也可以使用cc.DrawNode:create()来创建;

对于下层的响应,设计框架时,按钮的监听事件都通过统一回调处理。或者把Widget封装多一层。响应按钮事件后通知guIDe,下层响应完毕。

总结

以上是内存溢出为你收集整理的cocos2d3.5新手引导全部内容,希望文章能够帮你解决cocos2d3.5新手引导所遇到的程序开发问题。

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

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

原文地址: http://www.outofmemory.cn/web/1060273.html

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

发表评论

登录后才能评论

评论列表(0条)

保存