TipsUI.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. const {ccclass, property} = cc._decorator;
  2. import PrefabUtil from '../utils/manager/PrefabUtil';
  3. import UIbase from '../utils/UIbase';
  4. @ccclass
  5. export default class TipsUI extends UIbase {
  6. private static _inst:TipsUI;
  7. public static get inst()
  8. {
  9. if(this._inst==null)
  10. {
  11. let v=cc.instantiate(PrefabUtil.get("TipsUI"));
  12. this._inst=v.getComponent(TipsUI);
  13. }
  14. return this._inst;
  15. }
  16. @property(cc.Label)
  17. tipsLabel:cc.Label=null; //计时器
  18. private tw:cc.Tween;
  19. public showTips( str:string)
  20. {
  21. this.tipsLabel.string=str;
  22. this.showUI();
  23. this.node.zIndex=9999;
  24. this.node.x=cc.winSize.width/2;
  25. this.node.y=cc.winSize.height/2-40;
  26. this.node.opacity=0;
  27. if(this.tw ==null)
  28. {
  29. this.tw = cc.tween(this.node)
  30. .to(0.3,{opacity:255,y:cc.winSize.height/2})
  31. .delay(1)
  32. .to(0.3,{opacity:0,y:cc.winSize.height/2+40})
  33. .call(()=>{
  34. this.hideUI();
  35. })
  36. .start();
  37. }
  38. else
  39. {
  40. this.tw.stop();
  41. this.tw.start();
  42. }
  43. }
  44. }