MoreGamePopNode.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 (cc.sys.isNative && !JsbSystem.ifCanStartGame(this.data.packageName, true)) {
  51. gData.moreGame.createNewTask(this.data)
  52. }
  53. gData.moreGame.popNodeGetRedBag();
  54. }
  55. }