LevelRedPacketItem.ts 1.4 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. import LevelRedPacketUI from "../LevelRedPacketUI";
  9. import GamePlay from "../../GamePlay";
  10. import GameMgr, { UIITEM_NAME, UI_NAME } from "../../mgr/GameMgr";
  11. const { ccclass, property } = cc._decorator;
  12. @ccclass
  13. export default class LevelRedPacketItem extends cc.Component {
  14. @property(cc.Animation)
  15. ani_waggle: cc.Animation = null;
  16. // LIFE-CYCLE CALLBACKS:
  17. // onLoad () {}
  18. start() {
  19. this.node.on(cc.Node.EventType.TOUCH_END, this.onClick, this);
  20. }
  21. // update (dt) {}
  22. onClick() {
  23. GameMgr.Inst.sendEvent(UIITEM_NAME.LevelRedPacketItem,"点击随机红包");
  24. mk.ui.openPanel("game/prefab/uiPanel/LevelRedPacketUI").then((node)=>{
  25. node.getComponent(LevelRedPacketUI).init(GamePlay.Inst.cleanedVecArr.length);
  26. })
  27. this.recycle();
  28. }
  29. recycle() {
  30. PoolMgr.Inst.recyclePoolPrefab(NODEPOOLPREFABTYPE.LevelRedPacketItem, this.node);
  31. }
  32. }