cc.Class({ extends: cc.Component, properties: { label: cc.Label, }, onLoad() { }, show(message) { clearInterval(this.timer); this.label.string = message; this.node.active = true; this.node.y = - this.node.height; let anim = cc.spawn(cc.moveBy(0.3, 0, this.node.height), cc.fadeIn(0.3)); this.node.runAction(anim); this.timer = setInterval(() => { this.close(); }, 1000); }, // update (dt) {}, close() { clearInterval(this.timer); let anim = cc.spawn(cc.moveBy(0.3, 0, this.node.height), cc.fadeOut(0.3)); let end = cc.callFunc(() => { this.node.active = false; }); this.node.runAction(cc.sequence(anim, end)); }, });