cc.Class({
extends: cc.Component,
properties: {
layerBg: cc.Node,
labelPfb: cc.Prefab,
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
g_tipsMgr = this
},
start () {
this.rollNoticeList = []
},
createShowNode(str) {
let label = cc.instantiate(this.labelPfb)
this.layerBg.addChild(label)
this.rollNoticeList.push(label)
if (this.rollNoticeList.length > 3) {
let note = this.rollNoticeList.shift()
// note.removeFromParent(false)
note.destroy()
}
let rnum = this.rollNoticeList.length
let spos = cc.v2(0, 0)
let idx = 1
for (let i = rnum - 1; i >= 0; --i) {
let lb = this.rollNoticeList[i]
if (i == rnum) {
spos = cc.v2(lb.x, lb.y)
} else {
let newy = spos.y + idx * lb.height
lb.y = newy
idx = idx + 1
}
}
label.getComponent(cc.Label).string = str
return label
},
showRollNotice(str) {
let label = this.createShowNode(str)
//时间 秒数
let holdTime = 5
// var callback = cc.callFunc(this.onComplete, this);
let sequence = cc.sequence(cc.fadeTo(holdTime, 0), cc.callFunc(function(target, score) {
this.rollNoticeList.shift()
// target.removeFromParent(false)
target.destroy()
}, this))//动作完成后删除
label.runAction(sequence)
},
// update (dt) {},
});
网友评论