TipItemUI.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. import PoolMgr, { NODEPOOLPREFABTYPE } from "../../mgr/PoolMgr";
  8. const { ccclass, property } = cc._decorator;
  9. @ccclass
  10. export default class TipItemUI extends cc.Component {
  11. @property(cc.Node)
  12. node_bg: cc.Label = null;
  13. @property(cc.Label)
  14. label_tip: cc.Label = null;
  15. // LIFE-CYCLE CALLBACKS:
  16. // onLoad () {}
  17. start() {
  18. }
  19. // update (dt) {}
  20. init(tip: string) {
  21. this.node.y = 320;
  22. this.node.opacity = 255;
  23. this.label_tip.string = tip;
  24. cc.tween(this.node)
  25. .to(0.5, { y: 420 })
  26. .delay(0.5)
  27. .to(0.5, { opacity: 0 })
  28. .call(() => {
  29. PoolMgr.Inst.recyclePoolPrefab(NODEPOOLPREFABTYPE.TipItemUI, this.node);
  30. })
  31. .start();
  32. }
  33. }