DynamicLoadingBg.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // Learn cc.Class:
  2. // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
  3. // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
  4. // Learn Attribute:
  5. // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
  10. cc.Class({
  11. extends: cc.Component,
  12. properties: {
  13. upLeft: {
  14. default: null,
  15. type: cc.Node,
  16. serializable: true,
  17. },
  18. upRight: {
  19. default: null,
  20. type: cc.Node,
  21. serializable: true,
  22. },
  23. downLeft: {
  24. default: null,
  25. type: cc.Node,
  26. serializable: true,
  27. },
  28. downRight: {
  29. default: null,
  30. type: cc.Node,
  31. serializable: true,
  32. },
  33. farmerUpLeft: {
  34. default: null,
  35. tip: "农民图片",
  36. type: cc.SpriteFrame,
  37. serializable: true,
  38. visible: false
  39. },
  40. farmerUpRight: {
  41. default: null,
  42. tip: "农民图片",
  43. type: cc.SpriteFrame,
  44. serializable: true,
  45. visible: false
  46. },
  47. farmerDownLeft: {
  48. default: null,
  49. tip: "农民图片",
  50. type: cc.SpriteFrame,
  51. serializable: true,
  52. visible: false
  53. },
  54. farmerDownRight: {
  55. default: null,
  56. tip: "农民图片",
  57. type: cc.SpriteFrame,
  58. serializable: true,
  59. visible: false
  60. },
  61. villageUpLeft: {
  62. default: null,
  63. tip: "村长图片",
  64. type: cc.SpriteFrame,
  65. serializable: true,
  66. },
  67. villageUpRight: {
  68. default: null,
  69. tip: "村长图片",
  70. type: cc.SpriteFrame,
  71. serializable: true,
  72. },
  73. villageDownLeft: {
  74. default: null,
  75. tip: "村长图片",
  76. type: cc.SpriteFrame,
  77. serializable: true,
  78. },
  79. villageDownRight: {
  80. default: null,
  81. tip: "村长图片",
  82. type: cc.SpriteFrame,
  83. serializable: true,
  84. },
  85. mayorUpLeft: {
  86. default: null,
  87. tip: "镇长图片",
  88. type: cc.SpriteFrame,
  89. serializable: true,
  90. },
  91. mayorUpRight: {
  92. default: null,
  93. tip: "镇长图片",
  94. type: cc.SpriteFrame,
  95. serializable: true,
  96. },
  97. mayorDownLeft: {
  98. default: null,
  99. tip: "镇长图片",
  100. type: cc.SpriteFrame,
  101. serializable: true,
  102. },
  103. mayorDownRight: {
  104. default: null,
  105. tip: "镇长图片",
  106. type: cc.SpriteFrame,
  107. serializable: true,
  108. },
  109. },
  110. onLoad() {
  111. this.farmerUpLeft = this.upLeft.getComponent(cc.Sprite).spriteFrame;
  112. this.farmerUpRight = this.upRight.getComponent(cc.Sprite).spriteFrame;
  113. this.farmerDownLeft = this.downLeft.getComponent(cc.Sprite).spriteFrame;
  114. this.farmerDownRight = this.downRight.getComponent(cc.Sprite).spriteFrame;
  115. },
  116. /**
  117. * 设置面板信息
  118. */
  119. setInfo(_level) {
  120. // console.log("DynamicLoadingBg,",_level);
  121. if (0 === _level) {
  122. this.upLeft.getComponent(cc.Sprite).spriteFrame = this.farmerUpLeft;
  123. this.upRight.getComponent(cc.Sprite).spriteFrame = this.farmerUpRight;
  124. this.downLeft.getComponent(cc.Sprite).spriteFrame = this.farmerDownLeft;
  125. this.downRight.getComponent(cc.Sprite).spriteFrame = this.farmerDownRight;
  126. } else if (1 === _level) {
  127. this.upLeft.getComponent(cc.Sprite).spriteFrame = this.villageUpLeft;
  128. this.upRight.getComponent(cc.Sprite).spriteFrame = this.villageUpRight;
  129. this.downLeft.getComponent(cc.Sprite).spriteFrame = this.villageDownLeft;
  130. this.downRight.getComponent(cc.Sprite).spriteFrame = this.villageDownRight;
  131. } else if (2 === _level) {
  132. this.upLeft.getComponent(cc.Sprite).spriteFrame = this.mayorUpLeft;
  133. this.upRight.getComponent(cc.Sprite).spriteFrame = this.mayorUpRight;
  134. this.downLeft.getComponent(cc.Sprite).spriteFrame = this.mayorDownLeft;
  135. this.downRight.getComponent(cc.Sprite).spriteFrame = this.mayorDownRight;
  136. }
  137. },
  138. });