MoreGamePopNode.ts 1.9 KB

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