cocos creator 滚动字幕公告如何实现?

上节点图


creator节点


g_bg是公告的背景图 mask 为遮罩组件节点  gundongzi为label组件节点

运行效果


运行的效果

实现步骤、

1建立一个js组件 绑定 上节点中 mask gundongzi 两个节点


画红框的部分为绑定的节点

具体实现代码

//滚动公告字幕

gundongText:function(){

var self = this;

setTimeout(function(){

var notifyRes = JSON.parse(cc.sys.localStorage.getItem('notify'));

var gundongNode = cc.find("Canvas/gundong");

if(notifyRes != null){

if(gundongNode){

gundongNode.active = true;

}

self.Gundong.string = notifyRes;

}else{

if(gundongNode){

gundongNode.active = false;

}

}

var text = self.Gundong;

var width = self.Zhezhao.node.width;

text.node.runAction(cc.repeatForever(cc.sequence(

cc.moveTo(text.node.width/width*10,cc.p(-text.node.width-width/5,text.node.y)),

cc.callFunc(function(){

text.node.x = width;

}))));

},300);

},

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容