CarAddGold.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 "../manager/PoolMgr";
  8. import Sciencen_M from "../utils/Sciencen_M";
  9. const { ccclass, property } = cc._decorator;
  10. @ccclass
  11. export default class CarAddGold extends cc.Component {
  12. @property(cc.Label)
  13. lab: cc.Label = null;
  14. @property(cc.Animation)
  15. ani: cc.Animation = null;
  16. // onLoad () {}
  17. start() {
  18. }
  19. init(gold: string) {
  20. this.ani.play('upFade', 0)
  21. this.ani.on(cc.Animation.EventType.FINISHED, this.onFinish, this)
  22. this.lab.string = '+' + Sciencen_M.instance.format(gold)
  23. }
  24. onFinish() {
  25. //FC:-
  26. //this.node.destroy()
  27. this.ani.off(cc.Animation.EventType.FINISHED, this.onFinish, this)
  28. //FC:+ 对象池
  29. PoolMgr.Inst.recyclePoolPrefab(NODEPOOLPREFABTYPE.CarAddGold, this.node);
  30. }
  31. // update (dt) {}
  32. }