TipSpriteItemUI.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 { TIP_SPRITEITEM_TYPE } from "../../mgr/EffectMgr";
  8. import PoolMgr, { NODEPOOLPREFABTYPE } from "../../mgr/PoolMgr";
  9. const { ccclass, property } = cc._decorator;
  10. @ccclass
  11. export default class TipSpriteItemUI extends cc.Component {
  12. @property(cc.Sprite)
  13. public spr_tipSpr: cc.Sprite = null;
  14. // LIFE-CYCLE CALLBACKS:
  15. // onLoad () {}
  16. start() {
  17. }
  18. // update (dt) {}
  19. init(tipSpriteItemType: TIP_SPRITEITEM_TYPE) {
  20. this.spr_tipSpr.node.active = false;
  21. let url = `game/texture/tip/${tipSpriteItemType}`;
  22. mk.loader.load(url,cc.SpriteFrame).then((spriteFrame)=>{
  23. this.spr_tipSpr.spriteFrame = spriteFrame;
  24. this.spr_tipSpr.node.active = true;
  25. this.move();
  26. })
  27. }
  28. //移动
  29. move() {
  30. this.node.scaleX = this.node.scaleY = 0;
  31. cc.tween(this.node).to(0.5, { scale: 1 }, { easing: "backOut" })
  32. .delay(0.5)
  33. .to(0.1, { scale: 1.2 })
  34. .to(0.2, { scale: 0 })
  35. .call(() => {
  36. PoolMgr.Inst.recyclePoolPrefab(NODEPOOLPREFABTYPE.TipSpriteItemUI, this.node);
  37. })
  38. .start();
  39. }
  40. }