/** * tips */ const {ccclass, property} = cc._decorator; @ccclass export default class TipsManager extends cc.Component { private static __instance: TipsManager; public static get Instance() { if (null == this.__instance) { this.__instance = new TipsManager(); } return this.__instance; } private tipsPrefab: cc.Prefab = null; public pool: cc.NodePool = null; public poolName: string = "TipUI"; public Initial() { this.pool = new cc.NodePool(this.poolName); if (this.tipsPrefab) return; let self = this cc.resources.load('Prefab/Ui/tips', (err, prefab) => { if(err) return console.log('加载tips',err) self.tipsPrefab = prefab as cc.Prefab }); } public createTips(content: string) { // LogHelp.log("######createTips") let node: cc.Node = this.pool.get(); if (node == null) { node = cc.instantiate(this.tipsPrefab); } let str = cc.find('str', node).getComponent(cc.Label) str.string = content node.position = cc.v3(cc.winSize.width/2, cc.winSize.height/2) cc.tween(node) .delay(0.5) .to(1,{position:cc.v3(node.x, node.y+100,0)}) .call(()=>{ if(node){ node.removeFromParent(true) } }) .start() node.zIndex = 255 node.parent = cc.director.getScene(); } }