cc.Class({ extends: cc.Component, properties: { nameLabel: cc.Label, contentLabel: cc.Label, typeLabel: cc.Label, }, // onLoad () {}, show(name, type) { if (!this.node.active) { this.node.active = true; this.node.runAction(cc.moveBy(0.3, this.node.width, 0)); if (this.timer) { clearInterval(this.timer); } this.timer = setInterval(() => { this.close(); }, 4000); } this.nameLabel.string = name; if (type == 1) { this.contentLabel.string = '金币产出' this.typeLabel.string = 'x2'; } else { this.contentLabel.string = '产出时间' this.typeLabel.string = '-50%'; } }, close() { if (this.timer) { clearInterval(this.timer); } let finish = cc.callFunc(() => { this.node.active = false; }); this.node.runAction(cc.sequence(cc.moveBy(0.3, -this.node.width, 0), finish)); }, });