MoreGamePopNode.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * @description 互推弹出红包界面
  3. * @author kaka
  4. */
  5. import JsbSystem from "../../../mk/system/JsbSystem";
  6. const { ccclass, property } = cc._decorator;
  7. @ccclass
  8. export default class MoreGamePopNode extends cc.Component {
  9. @property(cc.Sprite)
  10. icon: cc.Sprite = null;
  11. @property(cc.Label)
  12. labName: cc.Label = null;
  13. data = null
  14. start() {
  15. gData.moreGame.init_moreGameList = true;
  16. }
  17. update() {
  18. if (gData.moreGame.init_moreGameList) {
  19. this.init();
  20. }
  21. }
  22. lateUpdate() {
  23. gData.moreGame.init_moreGameList = false;
  24. }
  25. init() {
  26. this.data = gData.moreGame.getRandomNormal();
  27. if (this.data) {
  28. //pc不加载,加载会报错
  29. if (cc.sys.os != cc.sys.OS_WINDOWS) {
  30. cc.loader.load(this.data.icon, (err, res) => {
  31. if (err) {
  32. console.log('err:', err);
  33. return;
  34. }
  35. let tex: cc.Texture2D = res as cc.Texture2D;
  36. this.icon.spriteFrame = new cc.SpriteFrame(tex);
  37. })
  38. }
  39. this.labName.string = this.data.title
  40. }
  41. }
  42. cool = false
  43. creatorDownLoadTask() {
  44. mk.audio.playEffect('button');
  45. if (this.cool) {
  46. return
  47. }
  48. this.cool = true
  49. if (!JsbSystem.ifCanStartGame(this.data.packageName, true)) {
  50. gData.moreGame.createNewTask(this.data)
  51. }
  52. }
  53. onClosePanel() {
  54. // mk.audio.playEffect('getGold');
  55. mk.tip.pop('红包币+300');
  56. // GameM.commonData.updateRedMoney(300, RecordTYPE.online)
  57. mk.fly.PlayCoinAnim(1, 20, cc.v2(0, -300), cc.v2(0, 0));
  58. }
  59. }