
--裁剪
local layer = cc.LayerGradIEnt:create(cc.c4b(255,255,255),cc.c4b(0,255)) --渐变层
self:addChild(layer) --裁剪容器 local clipPingNode = cc.ClipPingNode:create() clipPingNode:setposition(Const["CENTER_X"],Const["CENTER_Y"] + 150) -- clipPingNode:setInverted(true) --设为true则会显示stencil模板外的区域,默认是显示模板stencil的区域 self:addChild(clipPingNode) --向容器中添加内容 local str = ccui.Text:create() :setFontSize(34) :setTextcolor(cc.c3b(255,0)) :setString("哈哈哈哈--1-2-3-4-5-6-7-8-9-0--哈哈哈哈") clipPingNode:addChild(str) --设容器模板,默认显示出模板 local stencil = cc.Layercolor:create(cc.c3b(220,0)) stencil:setContentSize(cc.size(25,100)) stencil:ignoreAnchorPointForposition(false) stencil:setAnchorPoint(cc.p(0.5,0.5)) clipPingNode:setStencil(stencil) --模板移动,可看的区域移动 local moveBy1 = cc.MoveBy:create(2.5,cc.p(str:getContentSize().wIDth / 2 - 10,0)) local moveBy2 = cc.MoveBy:create(2.5,cc.p(-(str:getContentSize().wIDth / 2) + 10,0)) local action = cc.RepeatForever:create(cc.Sequence:create(moveBy2,moveBy1,moveBy2)) stencil:runAction(action) 总结以上是内存溢出为你收集整理的裁剪全部内容,希望文章能够帮你解决裁剪所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)