BonusTip.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import PoolMgr, { NODEPOOLPREFABTYPE } from "../../mgr/PoolMgr";
  2. const { ccclass, property } = cc._decorator;
  3. @ccclass
  4. export default class BonusTip extends cc.Component {
  5. public curBonusNum: number = 0;
  6. // LIFE-CYCLE CALLBACKS:
  7. // onLoad () {}
  8. start() {
  9. }
  10. // update (dt) {}
  11. public init(bonusNum: number) {
  12. this.node.getComponent(cc.Sprite).enabled = false;
  13. if (this.curBonusNum != bonusNum) {
  14. this.curBonusNum = bonusNum;
  15. let index = bonusNum - 4 + 1;
  16. //LogUtil.log("【BonusTip】bonusNum", bonusNum);
  17. mk.loader.load(`game/texture/tip/${index}`,cc.SpriteFrame).then((spriteFrame)=>{
  18. this.node.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  19. this.node.getComponent(cc.Sprite).enabled = true;
  20. })
  21. }
  22. else {
  23. this.node.getComponent(cc.Sprite).enabled = true;
  24. }
  25. this.node.opacity = 255;
  26. this.node.scaleX = this.node.scaleY = 0.8;
  27. this.node.setPosition(0, 0);
  28. //礼物
  29. cc.tween(this.node)
  30. .to(0.3, { scale: 1.2 }, { easing: "smooth" })
  31. .to(0.1, { scale: 1 }, { easing: "smooth" })
  32. .delay(0.2)
  33. .to(0.2, { scale: 2, opacity: 0 }, { easing: "smooth" })
  34. .call(() => {
  35. PoolMgr.Inst.recyclePoolPrefab(NODEPOOLPREFABTYPE.BonusTip, this.node);
  36. })
  37. .start();
  38. }
  39. }