Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

LoadingUI.js 5.6KB

5 lat temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. var __reflect = (this && this.__reflect) || function (p, c, t) {
  2. p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;
  3. };
  4. var __extends = this && this.__extends || function __extends(t, e) {
  5. function r() {
  6. this.constructor = t;
  7. }
  8. for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]);
  9. r.prototype = e.prototype, t.prototype = new r();
  10. };
  11. var GlobalSetting = easy.GlobalSetting;
  12. /**
  13. * Copyright (c) 2014,www.easygame.org
  14. * All rights reserved.
  15. * Redistribution and use in source and binary forms, with or without
  16. * modification, are permitted provided that the following conditions are met:
  17. *
  18. * * Redistributions of source code must retain the above copyright
  19. * notice, this list of conditions and the following disclaimer.
  20. * * Redistributions in binary form must reproduce the above copyright
  21. * notice, this list of conditions and the following disclaimer in the
  22. * documentation and/or other materials provided with the distribution.
  23. * * Neither the name of the easygame.org nor the
  24. * names of its contributors may be used to endorse or promote products
  25. * derived from this software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY EASYEGRET.COM AND CONTRIBUTORS "AS IS" AND ANY
  28. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  29. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  30. * DISCLAIMED. IN NO EVENT SHALL EGRET-LABS.ORG AND CONTRIBUTORS BE LIABLE FOR ANY
  31. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  32. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  33. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  34. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  35. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  36. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37. */
  38. var LoadingUI = (function (_super) {
  39. __extends(LoadingUI, _super);
  40. function LoadingUI() {
  41. var _this = _super.call(this) || this;
  42. _this.groupProgress = null;
  43. _this.imgTiaoBg = null;
  44. _this.imgTiao = null;
  45. _this.imgTxt = null;
  46. _this.imgLogo = null;
  47. _this.groupMask = null;
  48. return _this;
  49. }
  50. /**
  51. * 初始化主场景的组件
  52. * 这个方法在对象new的时候就调用,因为有些ui必须在加入stage之前就准备好
  53. * 子类覆写该方法,添加UI逻辑
  54. */
  55. LoadingUI.prototype.createChildren = function () {
  56. _super.prototype.createChildren.call(this);
  57. this.setSize(easy.GlobalSetting.STAGE_WIDTH, easy.GlobalSetting.STAGE_HEIGHT);
  58. //groupProgress
  59. this.groupProgress = new easy.BaseGroup(true);
  60. this.groupProgress.name = "groupProgress";
  61. this.addChild(this.groupProgress);
  62. this.groupProgress.width = 500;
  63. this.groupProgress.height = 500;
  64. this.groupProgress.x = easy.GlobalSetting.DISPLAY_WIDTH / 2 - this.groupProgress.cx;
  65. this.groupProgress.y = easy.GlobalSetting.DISPLAY_HEIGHT / 2 - this.groupProgress.cy;
  66. //imgTiaoBg
  67. this.imgTiaoBg = new easy.Image(true);
  68. this.imgTiaoBg.name = "imgTiaoBg";
  69. this.groupProgress.addChild(this.imgTiaoBg);
  70. this.imgTiaoBg.x = -45.5;
  71. this.imgTiaoBg.y = 324.5;
  72. this.imgTiaoBg.width = 591;
  73. this.imgTiaoBg.height = 33;
  74. //imgTxt
  75. this.imgTxt = new easy.Image(true);
  76. this.imgTxt.name = "imgTxt";
  77. this.groupProgress.addChild(this.imgTxt);
  78. this.imgTxt.x = 193;
  79. this.imgTxt.y = 384.5;
  80. this.imgTxt.width = 114;
  81. this.imgTxt.height = 31;
  82. //imgLogo
  83. this.imgLogo = new easy.Image(true);
  84. this.imgLogo.name = "imgLogo";
  85. this.groupProgress.addChild(this.imgLogo);
  86. this.imgLogo.x = 125;
  87. this.imgLogo.width = 250;
  88. this.imgLogo.height = 250;
  89. //groupMask
  90. this.groupMask = new easy.Group(true);
  91. this.groupMask.name = "groupMask";
  92. this.groupProgress.addChild(this.groupMask);
  93. this.groupMask.x = -43.5;
  94. this.groupMask.y = 327;
  95. this.groupMask.width = 587;
  96. this.groupMask.height = 28;
  97. this.groupMask.showBg = false;
  98. this.groupMask.width = 1;
  99. this.groupMask.clip = true;
  100. //imgTiao
  101. this.imgTiao = new easy.Image(true);
  102. this.imgTiao.name = "imgTiao";
  103. this.groupMask.addChild(this.imgTiao);
  104. this.imgTiao.width = 587;
  105. this.imgTiao.height = 28;
  106. //设置材质
  107. this.groupProgress.drawDelay = false;
  108. this.imgTiaoBg.texture = RES.getRes("loading_bg");
  109. this.imgTiaoBg.drawDelay = false;
  110. this.imgTiao.texture = RES.getRes("loading_tiao");
  111. this.imgTiao.drawDelay = false;
  112. this.imgTxt.texture = RES.getRes("loading_txt");
  113. this.imgTxt.drawDelay = false;
  114. this.imgLogo.texture = RES.getRes("logo");
  115. this.imgLogo.drawDelay = false;
  116. this.groupMask.drawDelay = false;
  117. };
  118. /**
  119. * 进度的展示
  120. * @param current
  121. * @param total
  122. */
  123. LoadingUI.prototype.setProgress = function (current, total) {
  124. this.groupMask.width = this.imgTiao.width * (current / total);
  125. };
  126. /**
  127. * loading enter
  128. */
  129. LoadingUI.prototype.enter = function () {
  130. };
  131. /**
  132. * loading outer
  133. */
  134. LoadingUI.prototype.outer = function () {
  135. this.removeFromParent();
  136. };
  137. return LoadingUI;
  138. }(easy.BaseGroup));
  139. __reflect(LoadingUI.prototype, "LoadingUI");