美素佳儿 litter wizard小游戏
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vor 5 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 (d, b) {
  5. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  6. function __() { this.constructor = d; }
  7. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8. };
  9. //////////////////////////////////////////////////////////////////////////////////////
  10. //
  11. // Copyright (c) 2014-present, Egret Technology.
  12. // All rights reserved.
  13. // Redistribution and use in source and binary forms, with or without
  14. // modification, are permitted provided that the following conditions are met:
  15. //
  16. // * Redistributions of source code must retain the above copyright
  17. // notice, this list of conditions and the following disclaimer.
  18. // * Redistributions in binary form must reproduce the above copyright
  19. // notice, this list of conditions and the following disclaimer in the
  20. // documentation and/or other materials provided with the distribution.
  21. // * Neither the name of the Egret nor the
  22. // names of its contributors may be used to endorse or promote products
  23. // derived from this software without specific prior written permission.
  24. //
  25. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  26. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  27. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  28. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  29. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  30. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  31. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  32. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  33. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  34. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. //
  36. //////////////////////////////////////////////////////////////////////////////////////
  37. var egret;
  38. (function (egret) {
  39. var native;
  40. (function (native) {
  41. /**
  42. * @private
  43. */
  44. var NativeNetContext = (function (_super) {
  45. __extends(NativeNetContext, _super);
  46. function NativeNetContext() {
  47. var _this = _super.call(this) || this;
  48. _this.urlData = {};
  49. return _this;
  50. }
  51. /**
  52. * @method egret.HTML5NetContext#proceed
  53. * @param loader {URLLoader}
  54. */
  55. NativeNetContext.prototype.proceed = function (loader) {
  56. var self = this;
  57. if (loader.dataFormat == egret.URLLoaderDataFormat.TEXTURE) {
  58. self.loadTexture(loader);
  59. return;
  60. }
  61. if (loader.dataFormat == egret.URLLoaderDataFormat.SOUND) {
  62. self.loadSound(loader);
  63. return;
  64. }
  65. var request = loader._request;
  66. var virtualUrl = self.getVirtualUrl(egret.$getUrl(request));
  67. var httpRequest = new egret.HttpRequest();
  68. httpRequest.open(virtualUrl, request.method == egret.URLRequestMethod.POST ? egret.HttpMethod.POST : egret.HttpMethod.GET);
  69. var length = request.requestHeaders.length;
  70. for (var i = 0; i < length; i++) {
  71. var urlRequestHeader = request.requestHeaders[i];
  72. httpRequest.setRequestHeader(urlRequestHeader.name, urlRequestHeader.value);
  73. }
  74. httpRequest.addEventListener(egret.Event.COMPLETE, function () {
  75. loader.data = httpRequest.response;
  76. egret.Event.dispatchEvent(loader, egret.Event.COMPLETE);
  77. }, this);
  78. httpRequest.addEventListener(egret.IOErrorEvent.IO_ERROR, function () {
  79. egret.IOErrorEvent.dispatchIOErrorEvent(loader);
  80. }, this);
  81. httpRequest.responseType = loader.dataFormat == egret.URLLoaderDataFormat.BINARY ? egret.HttpResponseType.ARRAY_BUFFER : egret.HttpResponseType.TEXT;
  82. httpRequest.send(request.data);
  83. };
  84. NativeNetContext.prototype.loadSound = function (loader) {
  85. var self = this;
  86. var virtualUrl = this.getVirtualUrl(loader._request.url);
  87. var sound = new egret.Sound();
  88. sound.addEventListener(egret.Event.COMPLETE, onLoadComplete, self);
  89. sound.addEventListener(egret.IOErrorEvent.IO_ERROR, onError, self);
  90. sound.addEventListener(egret.ProgressEvent.PROGRESS, onPostProgress, self);
  91. sound.load(virtualUrl);
  92. function onPostProgress(event) {
  93. loader.dispatchEvent(event);
  94. }
  95. function onError(event) {
  96. removeListeners();
  97. loader.dispatchEvent(event);
  98. }
  99. function onLoadComplete(e) {
  100. removeListeners();
  101. loader.data = sound;
  102. var loadedFunc = function () {
  103. loader.dispatchEventWith(egret.Event.COMPLETE);
  104. };
  105. if (__global.setTimeout) {
  106. __global.setTimeout(loadedFunc, 0);
  107. }
  108. else {
  109. egret.$callAsync(loadedFunc, self);
  110. }
  111. }
  112. function removeListeners() {
  113. sound.removeEventListener(egret.Event.COMPLETE, onLoadComplete, self);
  114. sound.removeEventListener(egret.IOErrorEvent.IO_ERROR, onError, self);
  115. sound.removeEventListener(egret.ProgressEvent.PROGRESS, onPostProgress, self);
  116. }
  117. };
  118. NativeNetContext.prototype.loadTexture = function (loader) {
  119. var self = this;
  120. var request = loader._request;
  121. var virtualUrl = self.getVirtualUrl(request.url);
  122. var imageLoader = new egret.ImageLoader();
  123. imageLoader.addEventListener(egret.Event.COMPLETE, onLoadComplete, self);
  124. imageLoader.addEventListener(egret.IOErrorEvent.IO_ERROR, onError, self);
  125. imageLoader.addEventListener(egret.ProgressEvent.PROGRESS, onPostProgress, self);
  126. imageLoader.load(virtualUrl);
  127. function onPostProgress(event) {
  128. loader.dispatchEvent(event);
  129. }
  130. function onError(event) {
  131. removeListeners();
  132. loader.dispatchEvent(event);
  133. }
  134. function onLoadComplete(e) {
  135. removeListeners();
  136. var bitmapData = imageLoader.data;
  137. //bitmapData.setAttribute("bitmapSrc", virtualUrl);
  138. var texture = new egret.Texture();
  139. texture._setBitmapData(bitmapData);
  140. loader.data = texture;
  141. var loadedFunc = function () {
  142. loader.dispatchEventWith(egret.Event.COMPLETE);
  143. };
  144. if (__global.setTimeout) {
  145. __global.setTimeout(loadedFunc, 0);
  146. }
  147. else {
  148. egret.$callAsync(loadedFunc, self);
  149. }
  150. }
  151. function removeListeners() {
  152. imageLoader.removeEventListener(egret.Event.COMPLETE, onLoadComplete, self);
  153. imageLoader.removeEventListener(egret.IOErrorEvent.IO_ERROR, onError, self);
  154. imageLoader.removeEventListener(egret.ProgressEvent.PROGRESS, onPostProgress, self);
  155. }
  156. };
  157. /**
  158. * 是否是网络地址
  159. * @param url
  160. * @returns {boolean}
  161. */
  162. NativeNetContext.prototype.isNetUrl = function (url) {
  163. return url.indexOf("http://") != -1 || url.indexOf("HTTP://") != -1 || url.indexOf("https://") != -1 || url.indexOf("HTTPS://") != -1;
  164. };
  165. /**
  166. * 获取虚拟url
  167. * @param url
  168. * @returns {string}
  169. */
  170. NativeNetContext.prototype.getVirtualUrl = function (url) {
  171. return url;
  172. };
  173. NativeNetContext.getNetContext = function () {
  174. if (NativeNetContext._instance == null) {
  175. NativeNetContext._instance = new NativeNetContext();
  176. }
  177. return NativeNetContext._instance;
  178. };
  179. return NativeNetContext;
  180. }(egret.HashObject));
  181. NativeNetContext.__use_asyn = egret_native.readFileAsync == null ? false : true;
  182. native.NativeNetContext = NativeNetContext;
  183. __reflect(NativeNetContext.prototype, "egret.native.NativeNetContext", ["egret.NetContext"]);
  184. egret.NetContext = NativeNetContext;
  185. })(native = egret.native || (egret.native = {}));
  186. })(egret || (egret = {}));