diff --git a/.DS_Store b/.DS_Store index 25b38d7..5008ddf 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/helloworld/.DS_Store b/helloworld/.DS_Store deleted file mode 100644 index 25b38d7..0000000 Binary files a/helloworld/.DS_Store and /dev/null differ diff --git a/helloworld/.wing/launch.json b/helloworld/.wing/launch.json deleted file mode 100644 index 536bb0b..0000000 --- a/helloworld/.wing/launch.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "Launch Wing Player", - "type": "chrome", - "request": "launch", - "file": "index.html", - "runtimeExecutable": "${execPath}", - "useBuildInServer": true, - "sourceMaps": true, - "webRoot": "${workspaceRoot}", - "preLaunchTask":"build", - "port":5317 - }, - { - "name": "Launch Chrome", - "type": "chrome", - "request": "launch", - "file": "index.html", - "useBuildInServer": true, - "sourceMaps": true, - "webRoot": "${workspaceRoot}", - "preLaunchTask":"build", - "userDataDir":"${tmpdir}", - "port":5317 - } - ] -} \ No newline at end of file diff --git a/helloworld/.wing/settings.json b/helloworld/.wing/settings.json deleted file mode 100644 index 372e43c..0000000 --- a/helloworld/.wing/settings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "search.exclude": { - "**/bin-debug": true, - "**/bin-release": true - } -} \ No newline at end of file diff --git a/helloworld/.wing/tasks.json b/helloworld/.wing/tasks.json deleted file mode 100644 index 521f0c8..0000000 --- a/helloworld/.wing/tasks.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "version": "0.1.0", - "command": "egret", - "isShellCommand": true, - "suppressTaskName": true, - "tasks": [ - { - "taskName": "build", - "showOutput": "always", - "args": [ - "build", - "-sourcemap" - ], - "problemMatcher": "$tsc" - }, - { - "taskName": "clean", - "showOutput": "always", - "args": [ - "build", - "-e" - ], - "problemMatcher": "$tsc" - }, - { - "taskName": "publish", - "showOutput": "always", - "args": [ - "publish" - ], - "problemMatcher": "$tsc" - } - ] -} \ No newline at end of file diff --git a/helloworld/bin-debug/LoadingUI.js b/helloworld/bin-debug/LoadingUI.js deleted file mode 100644 index 4a831d5..0000000 --- a/helloworld/bin-debug/LoadingUI.js +++ /dev/null @@ -1,60 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var __reflect = (this && this.__reflect) || function (p, c, t) { - p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; -}; -var __extends = this && this.__extends || function __extends(t, e) { - function r() { - this.constructor = t; -} -for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]); -r.prototype = e.prototype, t.prototype = new r(); -}; -var LoadingUI = (function (_super) { - __extends(LoadingUI, _super); - function LoadingUI() { - var _this = _super.call(this) || this; - _this.createView(); - return _this; - } - LoadingUI.prototype.createView = function () { - this.textField = new egret.TextField(); - this.addChild(this.textField); - this.textField.y = 300; - this.textField.width = 480; - this.textField.height = 100; - this.textField.textAlign = "center"; - }; - LoadingUI.prototype.onProgress = function (current, total) { - this.textField.text = "Loading..." + current + "/" + total; - }; - return LoadingUI; -}(egret.Sprite)); -__reflect(LoadingUI.prototype, "LoadingUI", ["RES.PromiseTaskReporter"]); -//# sourceMappingURL=LoadingUI.js.map \ No newline at end of file diff --git a/helloworld/bin-debug/LoadingUI.js.map b/helloworld/bin-debug/LoadingUI.js.map deleted file mode 100644 index a6c222d..0000000 --- a/helloworld/bin-debug/LoadingUI.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"LoadingUI.js","sourceRoot":"","sources":["../src/LoadingUI.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,EAAE;AACF,iDAAiD;AACjD,wBAAwB;AACxB,sEAAsE;AACtE,+EAA+E;AAC/E,EAAE;AACF,uEAAuE;AACvE,sEAAsE;AACtE,0EAA0E;AAC1E,4EAA4E;AAC5E,6EAA6E;AAC7E,8CAA8C;AAC9C,6EAA6E;AAC7E,8EAA8E;AAC9E,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,2EAA2E;AAC3E,gFAAgF;AAChF,gFAAgF;AAChF,8EAA8E;AAC9E,6EAA6E;AAC7E,wEAAwE;AACxE,gFAAgF;AAChF,sDAAsD;AACtD,EAAE;AACF,sFAAsF;;;;;;;;;;;AAEtF;IAAwB,6BAAY;IAEhC;QAAA,YACI,iBAAO,SAEV;QADG,KAAI,CAAC,UAAU,EAAE,CAAC;;IACtB,CAAC;IAIO,8BAAU,GAAlB;QACI,IAAI,CAAC,SAAS,GAAG,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACvC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC9B,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,GAAG,CAAC;QACvB,IAAI,CAAC,SAAS,CAAC,KAAK,GAAG,GAAG,CAAC;QAC3B,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,GAAG,CAAC;QAC5B,IAAI,CAAC,SAAS,CAAC,SAAS,GAAG,QAAQ,CAAC;IACxC,CAAC;IAEM,8BAAU,GAAjB,UAAkB,OAAe,EAAE,KAAa;QAC5C,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,eAAa,OAAO,SAAI,KAAO,CAAC;IAC1D,CAAC;IACL,gBAAC;AAAD,CAAC,AArBD,CAAwB,KAAK,CAAC,MAAM,GAqBnC;AArBK,UAAA,SAAS,qDAqBd,CAAA"} \ No newline at end of file diff --git a/helloworld/bin-debug/Main.js b/helloworld/bin-debug/Main.js deleted file mode 100644 index 7e60da1..0000000 --- a/helloworld/bin-debug/Main.js +++ /dev/null @@ -1,275 +0,0 @@ -var __reflect = (this && this.__reflect) || function (p, c, t) { - p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; -}; -var __extends = this && this.__extends || function __extends(t, e) { - function r() { - this.constructor = t; -} -for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]); -r.prototype = e.prototype, t.prototype = new r(); -}; -var Main = (function (_super) { - __extends(Main, _super); - function Main() { - var _this = _super.call(this) || this; - //debug模式,使用图形绘制 - _this.isDebug = false; - _this.worldBox = new egret.Sprite(); - // 滚动背景图 - _this.bgscrollView = new egret.ScrollView(); - // 当前物体的总高度 - _this.totalHeight = 0; - // 掉下去了 - _this.isFail = false; - // 上次碰撞的刚体ID - _this.hitID = 0; - // 地面距离舞台的初始高度 - _this.sh = 7; - _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.onAddToStage, _this); - return _this; - } - Main.prototype.onAddToStage = function (event) { - // 设置加载进度界面 - this.loadingView = new LoadingUI(); - this.stage.addChild(this.loadingView); - // 初始化Res资源加载库 - RES.addEventListener(RES.ResourceEvent.CONFIG_COMPLETE, this.onConfigComplete, this); - RES.loadConfig("resource/default.res.json", "resource/"); - }; - /** - * 配置文件加载完成,开始预加载preload资源组 - */ - Main.prototype.onConfigComplete = function (event) { - RES.removeEventListener(RES.ResourceEvent.CONFIG_COMPLETE, this.onConfigComplete, this); - RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onResourceLoadComplete, this); - RES.addEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onResourceProgress, this); - RES.loadGroup("preload"); - }; - /** - * preload 资源组加载完成 - */ - Main.prototype.onResourceLoadComplete = function (event) { - if (event.groupName == "preload") { - this.stage.removeChild(this.loadingView); - RES.removeEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onResourceLoadComplete, this); - RES.removeEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onResourceProgress, this); - this.createGameScene(); - } - }; - /** - * preload资源组加载进度 - */ - Main.prototype.onResourceProgress = function (event) { - if (event.groupName == "preload") { - // this.loadingView.setProgress(event.itemsLoaded, event.itemsTotal); - } - }; - /** - * 添加背景滚动视图 - */ - Main.prototype.addBgScrollView = function () { - var content = this.createBitmapByName("bg_jpg"); - //创建ScrollView - var myscrollView = this.bgscrollView; - myscrollView.setContent(content); - myscrollView.width = this.stage.stageWidth; - myscrollView.height = this.stage.stageHeight; - myscrollView.x = 0; - myscrollView.y = 0; - this.addChild(myscrollView); - content.width = myscrollView.width; - content.height = myscrollView.height * 2; - myscrollView.scrollTop = this.stage.stageHeight; - myscrollView.verticalScrollPolicy = "off"; - }; - // 漂浮动画 - Main.prototype.flowAnimation = function (display) { - var rect = display; - rect.y = 100; - this.addChild(rect); - var duration = 3000; - egret.Tween.get(rect, { loop: true }).to({ x: this.stage.stageWidth + 100 }, duration).to({ x: -100 }, duration); - }; - /** - * 创建刚体 - */ - Main.prototype.createBody = function (boxWidth, boxHeight, factor, m) { - if (m === void 0) { m = 1; } - var display; - //添加方形刚体 - var boxShape = new p2.Box({ width: boxWidth, height: boxHeight }); - var boxBody = new p2.Body({ - mass: m, - angularVelocity: 0, - gravityScale: 2, - damping: 0.7 - }); - boxBody.addShape(boxShape); - if (this.isDebug) { - display = this.createBox(boxShape.width * factor, boxShape.height * factor); - } - else { - display = this.createBitmapByName("rect_png"); - } - display.width = boxShape.width * factor; - display.height = boxShape.height * factor; - display.anchorOffsetX = display.width / 2; - display.anchorOffsetY = display.height / 2; - boxBody.displays = [display]; - this.addChild(display); - return [boxBody, display]; - }; - /** - * 定时添加刚体 - */ - Main.prototype.addBoxByTimer = function (factor, boxWidth, boxHeight, world) { - if (this.flowDisplay || this.isFail) { - return; - } - var array = this.createBody(boxWidth, boxHeight, factor); - var boxBody = array[0]; - var display = array[1]; - this.flowDisplay = display; - this.flowAnimation(display); - this.stage.addEventListener(egret.TouchEvent.TOUCH_TAP, addOneBox, this); - var self = this; - function addOneBox(e) { - if (boxBody.displays[0] == self.flowDisplay) { - self.flowDisplay = null; - var positionX = display.x / factor; - var positionY = Math.floor((egret.MainContext.instance.stage.stageHeight - display.y) / factor); - boxBody.position = [positionX, positionY]; - // 添加到世界 - world.addBody(boxBody); - // 停止动画 - egret.Tween.pauseTweens(display); - // 延迟三秒后添加新的刚体 - egret.setTimeout(function () { - self.addBoxByTimer(factor, boxWidth, boxHeight, world); - }, 1, 3000); - } - } - }; - /** - * 碰撞 - */ - Main.prototype.hit = function () { - var sound = RES.getRes("hit_mp3"); - sound.play(0, 1); - var self = this; - var count = this.world.bodies.length; - egret.setTimeout(function () { - var boxHieght = 3; - for (var i = 0; i < count; i++) { - var body = self.world.bodies[i]; - var positionY = body.position[1]; - positionY -= boxHieght; - body.position = [body.position[0], positionY]; - } - self.bgscrollView.scrollTop -= boxHieght * 50; - }, 0, 2000); - }; - Main.prototype.fail = function () { - var sound = RES.getRes("break_mp3"); - sound.play(0, 1); - }; - /** - * 创建游戏场景 - * Create a game scene - */ - Main.prototype.createGameScene = function () { - // 添加背景 - this.addBgScrollView(); - //egret.Profiler.getInstance().run(); - var factor = 50; - //创建world - var world = new p2.World(); - world.sleepMode = p2.World.BODY_SLEEPING; - world.defaultContactMaterial.restitution = 0; - this.world = world; - //创建一个地基 - var array = this.createBody(8, this.sh, 50, 0); - var baseBody = array[0]; - baseBody.position = [this.stage.stageWidth / 100, this.sh * 0.5]; - world.addBody(baseBody); - // 刚体在物理世界的宽和高 - var boxWidth = 6; - var boxHeight = 3; - egret.Ticker.getInstance().register(function (dt) { - if (dt < 10) { - return; - } - if (dt > 1000) { - return; - } - world.step(dt / 1000); - var stageHeight = egret.MainContext.instance.stage.stageHeight; - var l = world.bodies.length; - for (var i = 0; i < l; i++) { - var lastBody = world.bodies[l - 1]; - var lastBox = lastBody.displays[0]; - if (lastBox && l != 1) { - lastBox.y = Math.floor(stageHeight - lastBody.position[1] * factor); - // let limitHeight = stageHeight - (l - 2) * boxHeight * factor; - var limitHeight = Math.floor(stageHeight - lastBox.anchorOffsetY); - if (lastBox.y > limitHeight + 20) { - console.log("掉下去了!!!!!!!!!!!---->", l - 1, lastBox.y); - if (this.isFail == false) { - this.isFail = true; - this.fail(); - } - } - else if (lastBox.y >= limitHeight - this.sh * factor - 20) { - console.log("碰撞上了---->", l - 1); - if (lastBody.id != this.hitID) { - this.hitID = lastBody.id; - this.hit(); - } - } - } - var boxBody = world.bodies[i]; - var box = boxBody.displays[0]; - if (box) { - box.x = boxBody.position[0] * factor; - box.y = stageHeight - boxBody.position[1] * factor; - box.rotation = 360 - (boxBody.angle + boxBody.shapes[0].angle) * 180 / Math.PI; - if (boxBody.sleepState == p2.Body.SLEEPING) { - box.alpha = 0.5; - } - else { - box.alpha = 1; - } - } - } - }, this); - this.addBoxByTimer(factor, boxWidth, boxHeight, world); - }; - /** - * 判断是否叠放成功 - */ - Main.prototype.testPlaceSafe = function (world) { - }; - /** - * 根据name关键字创建一个Bitmap对象。name属性请参考resources/resource.json配置文件的内容。 - * Create a Bitmap object according to name keyword.As for the property of name please refer to the configuration file of resources/resource.json. - */ - Main.prototype.createBitmapByName = function (name) { - var result = new egret.Bitmap(); - var texture = RES.getRes(name); - result.texture = texture; - return result; - }; - /** - * 创建一个方形 - */ - Main.prototype.createBox = function (width, height) { - var shape = new egret.Shape(); - shape.graphics.beginFill(0xfff000); - shape.graphics.drawRect(0, 0, width, height); - shape.graphics.endFill(); - return shape; - }; - return Main; -}(egret.DisplayObjectContainer)); -__reflect(Main.prototype, "Main"); -//# sourceMappingURL=Main.js.map \ No newline at end of file diff --git a/helloworld/bin-debug/Main.js.map b/helloworld/bin-debug/Main.js.map deleted file mode 100644 index 6d0ae71..0000000 --- a/helloworld/bin-debug/Main.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Main.js","sourceRoot":"","sources":["../src/Main.ts"],"names":[],"mappings":";;;;;;;;;;AACA;IAAmB,wBAA4B;IAQ3C;QAAA,YACI,iBAAO,SAEV;QA4CD,gBAAgB;QACR,aAAO,GAAY,KAAK,CAAC;QAEzB,cAAQ,GAAiB,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QAEpD,QAAQ;QACA,kBAAY,GAAqB,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QAEhE,WAAW;QACH,iBAAW,GAAW,CAAC,CAAC;QAmIhC,OAAO;QACC,YAAM,GAAY,KAAK,CAAC;QAChC,YAAY;QACJ,WAAK,GAAG,CAAC,CAAC;QAKlB,cAAc;QACN,QAAE,GAAG,CAAC,CAAC;QAlMX,KAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,EAAE,KAAI,CAAC,YAAY,EAAE,KAAI,CAAC,CAAC;;IAC/E,CAAC;IAEO,2BAAY,GAApB,UAAqB,KAAkB;QACnC,WAAW;QACX,IAAI,CAAC,WAAW,GAAG,IAAI,SAAS,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAEtC,cAAc;QACd,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,eAAe,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;QACrF,GAAG,CAAC,UAAU,CAAC,2BAA2B,EAAE,WAAW,CAAC,CAAC;IAC7D,CAAC;IAED;;MAEE;IACM,+BAAgB,GAAxB,UAAyB,KAAwB;QAC7C,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,eAAe,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;QACxF,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,sBAAsB,EAAE,IAAI,CAAC,CAAC;QAC1F,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;QACtF,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;IAED;;MAEE;IACM,qCAAsB,GAA9B,UAA+B,KAAwB;QACnD,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC;YAC/B,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACzC,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,sBAAsB,EAAE,IAAI,CAAC,CAAC;YAC7F,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;YACzF,IAAI,CAAC,eAAe,EAAE,CAAC;QAC3B,CAAC;IAEL,CAAC;IAED;;GAED;IACS,iCAAkB,GAA1B,UAA2B,KAAwB;QAC/C,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC;YAC/B,qEAAqE;QACzE,CAAC;IACL,CAAC;IAaD;;MAEE;IAEM,8BAAe,GAAvB;QACI,IAAI,OAAO,GAAiB,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAE9D,cAAc;QACd,IAAI,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACrC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACjC,YAAY,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;QAC3C,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;QAC7C,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC;QACnB,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAE5B,OAAO,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC;QACnC,OAAO,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;QACzC,YAAY,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;QAChD,YAAY,CAAC,oBAAoB,GAAG,KAAK,CAAC;IAC9C,CAAC;IAMD,OAAO;IACC,4BAAa,GAArB,UAAsB,OAA4B;QAC9C,IAAI,IAAI,GAAG,OAAO,CAAC;QACnB,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;QACb,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACpB,IAAI,QAAQ,GAAG,IAAI,CAAC;QACpB,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;IACrH,CAAC;IAED;;MAEE;IACM,yBAAU,GAAlB,UAAmB,QAAgB,EAAE,SAAiB,EAAE,MAAc,EAAC,CAAY;QAAZ,kBAAA,EAAA,KAAY;QAC/E,IAAI,OAA4B,CAAC;QACjC,QAAQ;QACR,IAAI,QAAQ,GAAa,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;QAC5E,IAAI,OAAO,GAAY,IAAI,EAAE,CAAC,IAAI,CAAC;YAC/B,IAAI,EAAE,CAAC;YACP,eAAe,EAAE,CAAC;YAClB,YAAY,EAAE,CAAC;YACf,OAAO,EAAE,GAAG;SACf,CAAC,CAAC;QACH,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAE3B,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YACf,OAAO,GAAG,IAAI,CAAC,SAAS,CAAU,QAAS,CAAC,KAAK,GAAG,MAAM,EAAW,QAAS,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;QACpG,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAClD,CAAC;QACD,OAAO,CAAC,KAAK,GAAY,QAAS,CAAC,KAAK,GAAG,MAAM,CAAC;QAClD,OAAO,CAAC,MAAM,GAAY,QAAS,CAAC,MAAM,GAAG,MAAM,CAAC;QAEpD,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;QAC1C,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QAC3C,OAAO,CAAC,QAAQ,GAAG,CAAC,OAAO,CAAC,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACvB,MAAM,CAAC,CAAC,OAAO,EAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAED;;KAEC;IACO,4BAAa,GAArB,UAAsB,MAAc,EAAE,QAAgB,EAAE,SAAiB,EAAE,KAAe;QACtF,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YAClC,MAAM,CAAC;QACX,CAAC;QACD,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAC,SAAS,EAAC,MAAM,CAAC,CAAC;QACvD,IAAI,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;QAC3B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAE5B,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;QACzE,IAAI,IAAI,GAAG,IAAI,CAAC;QAEhB,mBAAmB,CAAmB;YAClC,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;gBAC1C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;gBACxB,IAAI,SAAS,GAAW,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC;gBAC3C,IAAI,SAAS,GAAW,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;gBACxG,OAAO,CAAC,QAAQ,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;gBAC1C,QAAQ;gBACR,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBACvB,OAAO;gBACP,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;gBAEjC,cAAc;gBACd,KAAK,CAAC,UAAU,CAAC;oBACb,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;gBAC1D,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;YAChB,CAAC;QACL,CAAC;IACL,CAAC;IAID;;MAEE;IACM,kBAAG,GAAX;QAEI,IAAI,KAAK,GAAgB,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC/C,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACjB,IAAI,IAAI,GAAG,IAAI,CAAC;QAChB,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;QACrC,KAAK,CAAC,UAAU,CAAC;YACb,IAAI,SAAS,GAAG,CAAC,CAAC;YAClB,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC7B,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAChC,IAAI,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;gBACjC,SAAS,IAAI,SAAS,CAAC;gBACvB,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAA;YACjD,CAAC;YACD,IAAI,CAAC,YAAY,CAAC,SAAS,IAAI,SAAS,GAAG,EAAE,CAAC;QAClD,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IAEhB,CAAC;IAEO,mBAAI,GAAZ;QACI,IAAI,KAAK,GAAgB,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACjD,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrB,CAAC;IAaD;;;OAGG;IACK,8BAAe,GAAvB;QAEI,OAAO;QACP,IAAI,CAAC,eAAe,EAAE,CAAC;QAEvB,qCAAqC;QACrC,IAAI,MAAM,GAAW,EAAE,CAAC;QAExB,SAAS;QACT,IAAI,KAAK,GAAa,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC;QACrC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC;QACzC,KAAK,CAAC,sBAAsB,CAAC,WAAW,GAAG,CAAC,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,QAAQ;QACR,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,EAAC,IAAI,CAAC,EAAE,EAAC,EAAE,EAAC,CAAC,CAAC,CAAC;QAC5C,IAAI,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACxB,QAAQ,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,GAAG,EAAC,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;QAChE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAExB,cAAc;QACd,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,IAAI,SAAS,GAAG,CAAC,CAAC;QAElB,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE;YAC5C,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;gBACV,MAAM,CAAC;YACX,CAAC;YACD,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;gBACZ,MAAM,CAAC;YACX,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;YAEtB,IAAI,WAAW,GAAW,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC;YACvE,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;YAC5B,GAAG,CAAC,CAAC,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBACjC,IAAI,QAAQ,GAAY,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC5C,IAAI,OAAO,GAAwB,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;gBACxD,EAAE,CAAC,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBACpB,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;oBACpE,gEAAgE;oBAChE,IAAI,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;oBAClE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,WAAW,GAAG,EAAE,CAAC,CAAC,CAAC;wBAC/B,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;wBACtD,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC;4BACvB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;4BACnB,IAAI,CAAC,IAAI,EAAE,CAAC;wBAChB,CAAC;oBACL,CAAC;oBAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,WAAW,GAAG,IAAI,CAAC,EAAE,GAAG,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;wBAC1D,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;wBAChC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;4BAC5B,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,EAAE,CAAC;4BACzB,IAAI,CAAC,GAAG,EAAE,CAAC;wBACf,CAAC;oBACL,CAAC;gBACL,CAAC;gBACD,IAAI,OAAO,GAAY,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBACvC,IAAI,GAAG,GAAwB,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;gBACnD,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;oBACN,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;oBACrC,GAAG,CAAC,CAAC,GAAG,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;oBACnD,GAAG,CAAC,QAAQ,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC;oBAC/E,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;wBACzC,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC;oBACpB,CAAC;oBACD,IAAI,CAAC,CAAC;wBACF,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC;oBAClB,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC,EAAE,IAAI,CAAC,CAAC;QAET,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;IAED;;MAEE;IACM,4BAAa,GAArB,UAAsB,KAAe;IAErC,CAAC;IAGD;;;OAGG;IACK,iCAAkB,GAA1B,UAA2B,IAAY;QACnC,IAAI,MAAM,GAAG,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QAChC,IAAI,OAAO,GAAkB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9C,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;QACzB,MAAM,CAAC,MAAM,CAAC;IAClB,CAAC;IAED;;OAEG;IACK,wBAAS,GAAjB,UAAkB,KAAa,EAAE,MAAc;QAC3C,IAAI,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC9B,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACnC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QAC7C,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACzB,MAAM,CAAC,KAAK,CAAC;IACjB,CAAC;IAEL,WAAC;AAAD,CAAC,AA3TD,CAAmB,KAAK,CAAC,sBAAsB,GA2T9C;AA3TK,UAAA,IAAI,mBA2TT,CAAA"} \ No newline at end of file diff --git a/helloworld/bin-debug/Platform.js b/helloworld/bin-debug/Platform.js deleted file mode 100644 index ee68280..0000000 --- a/helloworld/bin-debug/Platform.js +++ /dev/null @@ -1,62 +0,0 @@ -var __reflect = (this && this.__reflect) || function (p, c, t) { - p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [0, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var DebugPlatform = (function () { - function DebugPlatform() { - } - DebugPlatform.prototype.getUserInfo = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2 /*return*/, { nickName: "username" }]; - }); - }); - }; - DebugPlatform.prototype.login = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2 /*return*/]; - }); - }); - }; - return DebugPlatform; -}()); -__reflect(DebugPlatform.prototype, "DebugPlatform", ["Platform"]); -if (!window.platform) { - window.platform = new DebugPlatform(); -} -//# sourceMappingURL=Platform.js.map \ No newline at end of file diff --git a/helloworld/bin-debug/Platform.js.map b/helloworld/bin-debug/Platform.js.map deleted file mode 100644 index 8b95647..0000000 --- a/helloworld/bin-debug/Platform.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Platform.js","sourceRoot":"","sources":["../src/Platform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA;IAAA;IAOA,CAAC;IANS,mCAAW,GAAjB;;;gBACI,sBAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAA;;;KAClC;IACK,6BAAK,GAAX;;;;;;KAEC;IACL,oBAAC;AAAD,CAAC,AAPD,IAOC;AAPK,UAAA,aAAa,0CAOlB,CAAA;AAGD,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IACnB,MAAM,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;AAC1C,CAAC"} \ No newline at end of file diff --git a/helloworld/egretProperties.json b/helloworld/egretProperties.json deleted file mode 100644 index bee5679..0000000 --- a/helloworld/egretProperties.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "engineVersion": "5.2.5", - "compilerVersion": "5.2.5", - "template": {}, - "target": { - "current": "web" - }, - "modules": [ - { - "name": "egret" - }, - { - "name": "game" - }, - { - "name": "tween" - }, - { - "name": "physics", - "path":"../libsrc" - }, - { - "name": "assetsmanager" - }, - { - "name": "promise" - } - ], - "targets": { - "android": { - "appname": "helloworld", - "packagename": "com.companyname" - } - } -} diff --git a/helloworld/favicon.ico b/helloworld/favicon.ico deleted file mode 100644 index e4ec42c..0000000 Binary files a/helloworld/favicon.ico and /dev/null differ diff --git a/helloworld/index.html b/helloworld/index.html deleted file mode 100644 index 63fb06f..0000000 --- a/helloworld/index.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - Egret - - - - - - - - - - -
-
- - - - \ No newline at end of file diff --git a/helloworld/libs/modules/assetsmanager/assetsmanager.d.ts b/helloworld/libs/modules/assetsmanager/assetsmanager.d.ts deleted file mode 100644 index 7904a14..0000000 --- a/helloworld/libs/modules/assetsmanager/assetsmanager.d.ts +++ /dev/null @@ -1,1064 +0,0 @@ -declare type ResourceRootSelector = () => T; -declare type ResourceTypeSelector = (file: string) => string; -declare type ResourceNameSelector = (file: string) => string; -declare type ResourceMergerSelector = (file: string) => { - path: string; - alias: string; -}; -declare module RES { - var resourceTypeSelector: ResourceTypeSelector; - var resourceNameSelector: ResourceNameSelector; - var resourceMergerSelector: ResourceMergerSelector | null; - function getResourceInfo(path: string): File | null; - function setConfigURL(url: string, root: string): void; - interface ResourceInfo { - url: string; - type: string; - root: string; - crc32?: string; - size?: number; - name: string; - soundType?: string; - scale9grid?: string; - groupNames?: string[]; - promise?: Promise; - } - interface Data { - resourceRoot: string; - typeSelector: ResourceTypeSelector; - mergeSelector: ResourceMergerSelector | null; - fileSystem: FileSystem; - groups: { - [groupName: string]: string[]; - }; - alias: { - [aliasName: string]: string; - }; - } - /** - * @class RES.ResourceConfig - * @classdesc - * @private - */ - class ResourceConfig { - config: Data; - constructor(); - init(): Promise; - __temp__get__type__via__url(url_or_alias: string): string; - getKeyByAlias(aliasName: string): string; - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - * 可以监听ResourceEvent.CONFIG_COMPLETE事件来确认配置加载完成。 - * @method RES.ResourceConfig#createGroup - * @param name {string} 要创建的加载资源组的组名 - * @param keys {egret.Array} 要包含的键名列表,key对应配置文件里的name属性或sbuKeys属性的一项或一个资源组名。 - * @param override {boolean} 是否覆盖已经存在的同名资源组,默认false。 - * @returns {boolean} - */ - createGroup(name: string, keys: Array, override?: boolean): boolean; - /** - * 添加一个二级键名到配置列表。 - * @method RES.ResourceConfig#addSubkey - * @param subkey {string} 要添加的二级键名 - * @param name {string} 二级键名所属的资源name属性 - */ - addSubkey(subkey: string, name: string): void; - addAlias(alias: any, key: any): void; - /** - * 获取加载项类型。 - * @method RES.ResourceConfig#getType - * @param key {string} 对应配置文件里的name属性或sbuKeys属性的一项。 - * @returns {string} - */ - getType(key: string): string; - addResourceData(data: { - name: string; - type?: string; - url: string; - root?: string; - }): void; - destory(): void; - } -} -declare module RES { - /** - * @class RES.ResourceLoader - * @classdesc - * @private - */ - class ResourceLoader { - /** - * 当前组加载的项总个数,key为groupName - */ - private groupTotalDic; - /** - * 已经加载的项个数,key为groupName - */ - private numLoadedDic; - /** - * 正在加载的组列表,key为groupName - */ - private itemListDic; - /** - * 加载失败的组,key为groupName - */ - private groupErrorDic; - private retryTimesDic; - maxRetryTimes: number; - /** - * 优先级队列,key为priority,value为groupName列表 - */ - private priorityQueue; - private reporterDic; - private dispatcherDic; - private failedList; - private loadItemErrorDic; - private errorDic; - load(list: ResourceInfo[], groupName: string, priority: number, reporter?: PromiseTaskReporter): Promise; - private loadingCount; - thread: number; - private next(); - /** - * 从优先级队列中移除指定的组名 - */ - private removeGroupName(groupName); - private queueIndex; - /** - * 获取下一个待加载项 - */ - private getOneResourceInfo(); - loadResource(r: ResourceInfo, p?: RES.processor.Processor): Promise; - unloadResource(r: ResourceInfo): Promise; - } -} -declare module RES { - /** - * 整个资源加载系统的进程id,协助管理回调派发机制 - */ - var systemPid: number; - let checkCancelation: MethodDecorator; - function profile(): void; - var host: ProcessHost; - var config: ResourceConfig; - var queue: ResourceLoader; - interface ProcessHost { - state: { - [index: string]: number; - }; - resourceConfig: ResourceConfig; - load: (resource: ResourceInfo, processor?: string | processor.Processor) => Promise; - unload: (resource: ResourceInfo) => Promise; - save: (rexource: ResourceInfo, data: any) => void; - get: (resource: ResourceInfo) => any; - remove: (resource: ResourceInfo) => void; - } - class ResourceManagerError extends Error { - static errorMessage: { - 1001: string; - 1002: string; - 1005: string; - 2001: string; - 2002: string; - 2003: string; - 2004: string; - 2005: string; - 2006: string; - }; - /** - * why instanceof e != ResourceManagerError ??? - * see link : https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work - */ - private __resource_manager_error__; - constructor(code: number, replacer?: Object, replacer2?: Object); - } -} -declare namespace RES { - /** - * Promise的回调函数集合 - */ - interface PromiseTaskReporter { - /** - * 进度回调 - */ - onProgress?: (current: number, total: number) => void; - /** - * 取消回调 - */ - onCancel?: () => void; - } -} -declare module RES { - let checkNull: MethodDecorator; - /** - * 功能开关 - * LOADING_STATE:处理重复加载 - */ - let FEATURE_FLAG: { - FIX_DUPLICATE_LOAD: number; - }; - namespace upgrade { - function setUpgradeGuideLevel(level: "warning" | "silent"): void; - } -} -declare module RES.processor { - interface Processor { - onLoadStart(host: ProcessHost, resource: ResourceInfo): Promise; - onRemoveStart(host: ProcessHost, resource: ResourceInfo): Promise; - getData?(host: ProcessHost, resource: ResourceInfo, key: string, subkey: string): any; - } - function isSupport(resource: ResourceInfo): Processor; - function map(type: string, processor: Processor): void; - function getRelativePath(url: string, file: string): string; - var ImageProcessor: Processor; - var BinaryProcessor: Processor; - var TextProcessor: Processor; - var JsonProcessor: Processor; - var XMLProcessor: Processor; - var CommonJSProcessor: Processor; - const SheetProcessor: Processor; - var FontProcessor: Processor; - var SoundProcessor: Processor; - var MovieClipProcessor: Processor; - const MergeJSONProcessor: Processor; - const ResourceConfigProcessor: Processor; - const LegacyResourceConfigProcessor: Processor; - var PVRProcessor: Processor; - const _map: { - [index: string]: Processor; - }; -} -declare module RES { - interface File { - url: string; - type: string; - name: string; - root: string; - } - interface Dictionary { - [file: string]: File | Dictionary; - } - interface FileSystem { - addFile(filename: string, type?: string, root?: string): any; - getFile(filename: string): File | null; - profile(): void; - } - class NewFileSystem { - private data; - constructor(data: Dictionary); - profile(): void; - addFile(filename: string, type?: string): void; - getFile(filename: string): File | null; - private reslove(dirpath); - private mkdir(dirpath); - private exists(dirpath); - } - var fileSystem: FileSystem; -} -declare module RES { - /** - * The events of resource loading. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 资源加载事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class ResourceEvent extends egret.Event { - /** - * Failure event for a load item. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个加载项加载失败事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ITEM_LOAD_ERROR: string; - /** - * Configure file to load and parse the completion event. Note: if a configuration file is loaded, it will not be thrown out, and if you want to handle the configuration loading failure, monitor the CONFIG_LOAD_ERROR event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 配置文件加载并解析完成事件。注意:若有配置文件加载失败,将不会抛出此事件,若要处理配置加载失败,请同时监听 CONFIG_LOAD_ERROR 事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CONFIG_COMPLETE: string; - /** - * Configuration file failed to load. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 配置文件加载失败事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CONFIG_LOAD_ERROR: string; - /** - * Delay load group resource loading progress event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载进度事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static GROUP_PROGRESS: string; - /** - * Delay load group resource to complete event. Note: if you have a resource item loading failure, the event will not be thrown, if you want to handle the group load failure, please listen to the GROUP_LOAD_ERROR event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载完成事件。注意:若组内有资源项加载失败,将不会抛出此事件,若要处理组加载失败,请同时监听 GROUP_LOAD_ERROR 事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static GROUP_COMPLETE: string; - /** - * Delayed load group resource failed event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载失败事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static GROUP_LOAD_ERROR: string; - /** - * Creates an Event object to pass as a parameter to event listeners. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language en_US - */ - /** - * 创建一个作为参数传递给事件侦听器的 Event 对象。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * File number that has been loaded. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 已经加载的文件数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - itemsLoaded: number; - /** - * Total file number to load. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要加载的总文件数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - itemsTotal: number; - /** - * Resource group name. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 资源组名。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - groupName: string; - /** - * An item of information that is finished by the end of a load. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一次加载项加载结束的项信息对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - resItem: ResourceItem; - } -} -declare module RES { - /** - * Resource term. One of the resources arrays in resource.json. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 资源项。对应 resource.json 中 resources 数组中的一项。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - namespace ResourceItem { - /** - * XML file. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * XML 文件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_XML: string; - /** - * Picture file. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 图片文件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_IMAGE: string; - /** - * Binary file. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 二进制文件。 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - const TYPE_BIN: string; - /** - * Text file. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本文件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_TEXT: string; - /** - * JSON file. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * JSON 文件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_JSON: string; - /** - * SpriteSheet file. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * SpriteSheet 文件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_SHEET: string; - /** - * BitmapTextSpriteSheet file. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * BitmapTextSpriteSheet 文件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_FONT: string; - /** - * Sound file. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 声音文件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_SOUND: string; - function convertToResItem(r: ResourceInfo): ResourceItem; - } - interface ResourceItem extends ResourceInfo { - /** - * Name of resource term. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 加载项名称。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - name: string; - /** - * URL of resource term. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要加载的文件地址。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - url: string; - /** - * Type of resource term. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 加载项文件类型。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - type: string; - /** - * The raw data object to be referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的原始数据对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - data: ResourceInfo; - crc32?: string; - size?: number; - soundType?: string; - } -} -declare namespace RES { - namespace path { - const normalize: (filename: string) => string; - const basename: (filename: string) => string; - const dirname: (path: string) => string; - } -} -declare namespace RES { -} -declare module RES { - type GetResAsyncCallback = (value?: any, key?: string) => any; - let nameSelector: (url: any) => string; - /** - * Conduct mapping injection with class definition as the value. - * @param type Injection type. - * @param analyzerClass Injection type classes need to be resolved. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/resource/Resource.ts - * @language en_US - */ - /** - * 以类定义为值进行映射注入。 - * @param type 注入的类型。 - * @param analyzerClass 注入类型需要解析的类。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/resource/Resource.ts - * @language zh_CN - */ - function registerAnalyzer(type: string, analyzerClass: any): void; - /** - * Load configuration file and parse. - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 加载配置文件并解析。 - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function loadConfig(url: string, resourceRoot: string): Promise; - /** - * Load a set of resources according to the group name. - * @param name Group name to load the resource group. - * @param priority Load priority can be negative, the default value is 0. - *
A low priority group must wait for the high priority group to complete the end of the load to start, and the same priority group will be loaded at the same time. - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 根据组名加载一组资源。 - * @param name 要加载资源组的组名。 - * @param priority 加载优先级,可以为负数,默认值为 0。 - *
低优先级的组必须等待高优先级组完全加载结束才能开始,同一优先级的组会同时加载。 - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function loadGroup(name: string, priority?: number, reporter?: PromiseTaskReporter): Promise; - /** - * Check whether a resource group has been loaded. - * @param name Group name。 - * @returns Is loading or not. - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查某个资源组是否已经加载完成。 - * @param name 组名。 - * @returns 是否正在加载。 - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function isGroupLoaded(name: string): boolean; - /** - * A list of groups of loading is obtained according to the group name. - * @param name Group name. - * @returns The resource item array of group. - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 根据组名获取组加载项列表。 - * @param name 组名。 - * @returns 加载项列表。 - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function getGroupByName(name: string): Array; - /** - * Create a custom load resource group, note that this method is valid only after the resource configuration file is loaded. - *
You can monitor the ResourceEvent.CONFIG_COMPLETE event to verify that the configuration is complete. - * @param name Group name to create the load resource group. - * @param keys To be included in the list of key keys, the corresponding configuration file in the name or sbuKeys property one or a resource group name. - * @param override Is the default false for the same name resource group already exists. - * @returns Create success or fail. - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - *
可以监听 ResourceEvent.CONFIG_COMPLETE 事件来确认配置加载完成。 - * @param name 要创建的加载资源组的组名。 - * @param keys 要包含的键名列表,key 对应配置文件里的 name 属性或 sbuKeys 属性的一项或一个资源组名。 - * @param override 是否覆盖已经存在的同名资源组,默认 false。 - * @returns 是否创建成功。 - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function createGroup(name: string, keys: Array, override?: boolean): boolean; - /** - * Check whether the configuration file contains the specified resources. - * @param key A sbuKeys attribute or name property in a configuration file. - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查配置文件里是否含有指定的资源。 - * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function hasRes(key: string): boolean; - /** - * The synchronization method for obtaining the cache has been loaded with the success of the resource. - *
The type of resource and the corresponding return value types are as follows: - *
RES.ResourceItem.TYPE_BIN : ArrayBuffer JavaScript primary object - *
RES.ResourceItem.TYPE_IMAGE : img Html Object,or egret.BitmapData interface。 - *
RES.ResourceItem.TYPE_JSON : Object - *
RES.ResourceItem.TYPE_SHEET : Object - *
1. If the incoming parameter is the name of the entire SpriteSheet is returned is {image1: Texture, "image2": Texture}. - *
2. If the incoming is "sheet.image1", the return is a single resource. - *
3. If the incoming is the name of the "image1" single resource, the return is a single resource. - * But if there are two SpriteSheet in a single picture of the same name, the return of the image after the load. - *
RES.ResourceItem.TYPE_SOUND : HtmlSound Html Object - *
RES.ResourceItem.TYPE_TEXT : string - * @param key A subKeys attribute or name property in a configuration file. - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 同步方式获取缓存的已经加载成功的资源。 - *
资源类型和对应的返回值类型关系如下: - *
RES.ResourceItem.TYPE_BIN : ArrayBuffer JavaScript 原生对象 - *
RES.ResourceItem.TYPE_IMAGE : img Html 对象,或者 egret.BitmapData 接口。 - *
RES.ResourceItem.TYPE_JSON : Object - *
RES.ResourceItem.TYPE_SHEET : Object - *
1. 如果传入的参数是整个 SpriteSheet 的名称返回的是 {"image1":Texture,"image2":Texture} 这样的格式。 - *
2. 如果传入的是 "sheet.image1",返回的是单个资源。 - *
3. 如果传入的是 "image1" 单个资源的名称,返回的是单个资源。但是如果有两张 SpriteSheet 中有单个图片资源名称相同,返回的是后加载的那个图片资源。 - *
RES.ResourceItem.TYPE_SOUND : HtmlSound Html 对象 - *
RES.ResourceItem.TYPE_TEXT : string - * @param key 对应配置文件里的 name 属性或 subKeys 属性的一项。 - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function getRes(key: string): any; - /** - * Asynchronous mode to get the resources in the configuration. As long as the resources exist in the configuration file, you can get it in an asynchronous way. - * @param key A sbuKeys attribute or name property in a configuration file. - * @param compFunc Call back function. Example:compFunc(data,key):void. - * @param thisObject This pointer of call back function. - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 异步方式获取配置里的资源。只要是配置文件里存在的资源,都可以通过异步方式获取。 - * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 - * @param compFunc 回调函数。示例:compFunc(data,key):void。 - * @param thisObject 回调函数的 this 引用。 - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function getResAsync(key: string): Promise; - function getResAsync(key: string, compFunc: GetResAsyncCallback, thisObject: any): void; - /** - * Access to external resources through the full URL. - * @param url The external path to load the file. - * @param compFunc Call back function. Example:compFunc(data,url):void。 - * @param thisObject This pointer of call back function. - * @param type File type (optional). Use the static constants defined in the ResourceItem class. If you do not set the file name extension. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/resource/GetResByUrl.ts - * @language en_US - */ - /** - * 通过完整URL方式获取外部资源。 - * @param url 要加载文件的外部路径。 - * @param compFunc 回调函数。示例:compFunc(data,url):void。 - * @param thisObject 回调函数的 this 引用。 - * @param type 文件类型(可选)。请使用 ResourceItem 类中定义的静态常量。若不设置将根据文件扩展名生成。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/resource/GetResByUrl.ts - * @language zh_CN - */ - function getResByUrl(url: string, compFunc: Function, thisObject: any, type?: string): void; - /** - * Destroy a single resource file or a set of resources to the cache data, to return whether to delete success. - * @param name Name attribute or resource group name of the load item in the configuration file. - * @param force Destruction of a resource group when the other resources groups have the same resource situation whether the resources will be deleted, the default value true. - * @returns Are successful destruction. - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。 - * @param name 配置文件中加载项的name属性或资源组名。 - * @param force 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值 true。 - * @see #setMaxRetryTimes - * @returns 是否销毁成功。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function destroyRes(name: string, force?: boolean): Promise; - /** - * Sets the maximum number of concurrent load threads, the default value is 2. - * @param thread The number of concurrent loads to be set. - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置最大并发加载线程数量,默认值是 2。 - * @param thread 要设置的并发加载数。 - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function setMaxLoadingThread(thread: number): void; - /** - * Sets the number of retry times when the resource failed to load, and the default value is 3. - * @param retry To set the retry count. - * @includeExample extension/resource/Resource.ts - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置资源加载失败时的重试次数,默认值是 3。 - * @param retry 要设置的重试次数。 - * @includeExample extension/resource/Resource.ts - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function setMaxRetryTimes(retry: number): void; - /** - * Add event listeners, reference ResourceEvent defined constants. - * @param type Event name。 - * @param listener Listener functions for handling events. This function must accept the Event object as its only parameter, and can't return any results, - * As shown in the following example: function (evt:Event):void can have any name. - * @param thisObject The this object that is bound to a function. - * @param useCapture Determine the listener is running on the capture or running on the target and the bubbling phase. Set useCapture to true, - * then the listener in the capture phase processing events, but not in the target or the bubbling phase processing events. - * If useCapture is false, then the listener only in the target or the bubbling phase processing events. - * To listen for events in all three stages, please call addEventListener two times: once the useCapture is set to true, once the useCapture is set to false. - * @param priority Event listener priority. Priority is specified by a 32 - bit integer with a symbol. The higher the number, the higher the priority. - * All listeners with a priority for n will be processed before the -1 n listener. - * If two or more listeners share the same priority, they are processed in accordance with the order of their added. The default priority is 0. - * @see RES.ResourceEvent - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 添加事件侦听器,参考 ResourceEvent 定义的常量。 - * @param type 事件的类型。 - * @param listener 处理事件的侦听器函数。此函数必须接受 Event 对象作为其唯一的参数,并且不能返回任何结果, - * 如下面的示例所示: function(evt:Event):void 函数可以有任何名称。 - * @param thisObject 侦听函数绑定的 this 对象。 - * @param useCapture 确定侦听器是运行于捕获阶段还是运行于目标和冒泡阶段。如果将 useCapture 设置为 true, - * 则侦听器只在捕获阶段处理事件,而不在目标或冒泡阶段处理事件。如果 useCapture 为 false,则侦听器只在目标或冒泡阶段处理事件。 - * 要在所有三个阶段都侦听事件,请调用 addEventListener 两次:一次将 useCapture 设置为 true,一次将 useCapture 设置为 false。 - * @param priority 事件侦听器的优先级。优先级由一个带符号的 32 位整数指定。数字越大,优先级越高。优先级为 n 的所有侦听器会在 - * 优先级为 n -1 的侦听器之前得到处理。如果两个或更多个侦听器共享相同的优先级,则按照它们的添加顺序进行处理。默认优先级为 0。 - * @see RES.ResourceEvent - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function addEventListener(type: string, listener: (event: egret.Event) => void, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * Remove event listeners, reference ResourceEvent defined constants. - * @param type Event name。 - * @param listener Listening function。 - * @param thisObject The this object that is bound to a function. - * @param useCapture Is used to capture, and this property is only valid in the display list. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 移除事件侦听器,参考ResourceEvent定义的常量。 - * @param type 事件名。 - * @param listener 侦听函数。 - * @param thisObject 侦听函数绑定的this对象。 - * @param useCapture 是否使用捕获,这个属性只在显示列表中生效。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function removeEventListener(type: string, listener: (event: egret.Event) => void, thisObject: any, useCapture?: boolean): void; - /** - * Adding a custom resource configuration. - * @param data To add configuration. - * @version Egret 3.1.6 - * @platform Web,Native - * @language en_US - */ - /** - * 自定义添加一项资源配置。 - * @param data 要添加的配置。 - * @version Egret 3.1.6 - * @platform Web,Native - * @language zh_CN - */ - function $addResourceData(data: { - name: string; - type: string; - url: string; - }): void; - /** - * @private - */ - class Resource extends egret.EventDispatcher { - /** - * 开始加载配置 - * @method RES.loadConfig - */ - loadConfig(): Promise; - /** - * 检查某个资源组是否已经加载完成 - * @method RES.isGroupLoaded - * @param name {string} - */ - isGroupLoaded(name: string): boolean; - /** - * 根据组名获取组加载项列表 - * @method RES.getGroupByName - * @param name {string} - */ - getGroupByName(name: string): Array; - /** - * 根据组名加载一组资源 - * @method RES.loadGroup - * @param name {string} - * @param priority {number} - */ - loadGroup(name: string, priority?: number, reporter?: PromiseTaskReporter): Promise; - private _loadGroup(name, priority?, reporter?); - loadResources(keys: string[], reporter?: PromiseTaskReporter): Promise; - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - * 可以监听ResourceEvent.CONFIG_COMPLETE事件来确认配置加载完成。 - * @method RES.ResourceConfig#createGroup - * @param name {string} 要创建的加载资源组的组名 - * @param keys {egret.Array} 要包含的键名列表,key对应配置文件里的name属性或一个资源组名。 - * @param override {boolean} 是否覆盖已经存在的同名资源组,默认false。 - * @returns {boolean} - */ - createGroup(name: string, keys: Array, override?: boolean): boolean; - /** - * 检查配置文件里是否含有指定的资源 - * @method RES.hasRes - * @param key {string} 对应配置文件里的name属性或subKeys属性的一项。 - * @returns {boolean} - */ - hasRes(key: string): boolean; - /** - * 通过key同步获取资源 - * @method RES.getRes - * @param key {string} - * @returns {any} - */ - getRes(resKey: string): any; - /** - * 通过key异步获取资源 - * @method RES.getResAsync - * @param key {string} - * @param compFunc {Function} 回调函数。示例:compFunc(data,url):void。 - * @param thisObject {any} - */ - getResAsync(key: string): Promise; - getResAsync(key: string, compFunc: GetResAsyncCallback, thisObject: any): void; - /** - * 通过url获取资源 - * @method RES.getResByUrl - * @param url {string} - * @param compFunc {Function} - * @param thisObject {any} - * @param type {string} - */ - getResByUrl(url: string, compFunc: Function, thisObject: any, type?: string): Promise | void; - /** - * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。 - * @method RES.destroyRes - * @param name {string} 配置文件中加载项的name属性或资源组名 - * @param force {boolean} 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值true - * @returns {boolean} - */ - destroyRes(name: string, force?: boolean): Promise; - /** - * 设置最大并发加载线程数量,默认值是2. - * @method RES.setMaxLoadingThread - * @param thread {number} 要设置的并发加载数。 - */ - setMaxLoadingThread(thread: number): void; - /** - * 设置资源加载失败时的重试次数。 - * @param retry 要设置的重试次数。 - */ - setMaxRetryTimes(retry: number): void; - addResourceData(data: { - name: string; - type: string; - url: string; - }): void; - } -} diff --git a/helloworld/libs/modules/assetsmanager/assetsmanager.js b/helloworld/libs/modules/assetsmanager/assetsmanager.js deleted file mode 100644 index b8d687c..0000000 --- a/helloworld/libs/modules/assetsmanager/assetsmanager.js +++ /dev/null @@ -1,2738 +0,0 @@ -var __reflect = (this && this.__reflect) || function (p, c, t) { - p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; -}; -var __extends = this && this.__extends || function __extends(t, e) { - function r() { - this.constructor = t; -} -for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]); -r.prototype = e.prototype, t.prototype = new r(); -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [0, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var RES; -(function (RES) { - RES.resourceNameSelector = function (p) { return p; }; - function getResourceInfo(path) { - var result = RES.fileSystem.getFile(path); - if (!result) { - path = RES.resourceNameSelector(path); - result = RES.fileSystem.getFile(path); - } - return result; - } - RES.getResourceInfo = getResourceInfo; - var configItem; - function setConfigURL(url, root) { - var type; - if (url.indexOf(".json") >= 0) { - type = "legacyResourceConfig"; - } - else { - type = "resourceConfig"; - } - configItem = { type: type, root: root, url: url, name: url }; - } - RES.setConfigURL = setConfigURL; - /** - * @class RES.ResourceConfig - * @classdesc - * @private - */ - var ResourceConfig = (function () { - function ResourceConfig() { - } - ResourceConfig.prototype.init = function () { - var _this = this; - if (!this.config) { - this.config = { - alias: {}, groups: {}, resourceRoot: configItem.root, - typeSelector: function () { return 'unknown'; }, mergeSelector: null, - fileSystem: null - }; - } - return RES.queue.loadResource(configItem).then(function (data) { - return _this.parseConfig(data); - }).catch(function (e) { - if (!e.__resource_manager_error__) { - console.error(e.stack); - e = new RES.ResourceManagerError(1002); - } - return Promise.reject(e); - }); - }; - /** - * @internal - */ - ResourceConfig.prototype.getGroupByName = function (name, shouldNotBeNull) { - var group = this.config.groups[name]; - var result = []; - if (!group) { - if (shouldNotBeNull) { - throw new RES.ResourceManagerError(2005, name); - } - return null; - } - for (var _i = 0, group_1 = group; _i < group_1.length; _i++) { - var paramKey = group_1[_i]; - var _a = RES.config.getResourceWithSubkey(paramKey, true), key = _a.key, subkey = _a.subkey; - var r = RES.config.getResource(key, true); - if (result.indexOf(r) == -1) { - result.push(r); - } - } - return result; - }; - ResourceConfig.prototype.__temp__get__type__via__url = function (url_or_alias) { - var url = this.config.alias[url_or_alias]; - if (!url) { - url = url_or_alias; - } - if (RES.resourceTypeSelector) { - var type = RES.resourceTypeSelector(url); - if (!type) { - throw new RES.ResourceManagerError(2004, url); - } - return type; - } - else { - console.warn("RES.mapConfig 并未设置 typeSelector"); - return "unknown"; - } - }; - ResourceConfig.prototype.getResourceWithSubkey = function (key, shouldNotBeNull) { - key = this.getKeyByAlias(key); - var index = key.indexOf("#"); - var subkey = ""; - if (index >= 0) { - subkey = key.substr(index + 1); - key = key.substr(0, index); - } - var r = this.getResource(key); - if (!r) { - if (shouldNotBeNull) { - var msg = subkey ? key + "#" + subkey : key; - throw new RES.ResourceManagerError(2006, msg); - } - else { - return null; - } - } - else { - return { - r: r, key: key, subkey: subkey - }; - } - }; - ResourceConfig.prototype.getKeyByAlias = function (aliasName) { - if (this.config.alias[aliasName]) { - return this.config.alias[aliasName]; - } - else { - return aliasName; - } - }; - ResourceConfig.prototype.getResource = function (path_or_alias, shouldNotBeNull) { - var path = this.config.alias[path_or_alias]; - if (!path) { - path = path_or_alias; - } - var r = getResourceInfo(path); - if (!r) { - if (shouldNotBeNull) { - throw new RES.ResourceManagerError(2006, path_or_alias); - } - return null; - } - return r; - }; - /** - * 根据组名获取原始的组加载项列表 - * @method RES.ResourceConfig#getRawGroupByName - * @param name {string} 组名 - * @returns {Array} - * @internal - */ - ResourceConfig.prototype.getGroup = function (name) { - return this.getGroupByName(name); - }; - // public getResourceInfos(folderName: string) { - // this.config.resources[] - // } - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - * 可以监听ResourceEvent.CONFIG_COMPLETE事件来确认配置加载完成。 - * @method RES.ResourceConfig#createGroup - * @param name {string} 要创建的加载资源组的组名 - * @param keys {egret.Array} 要包含的键名列表,key对应配置文件里的name属性或sbuKeys属性的一项或一个资源组名。 - * @param override {boolean} 是否覆盖已经存在的同名资源组,默认false。 - * @returns {boolean} - */ - ResourceConfig.prototype.createGroup = function (name, keys, override) { - if (override === void 0) { override = false; } - if ((!override && this.config.groups[name]) || !keys || keys.length == 0) { - return false; - } - var group = []; - for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { - var key = keys_1[_i]; - if (this.config.groups[key]) { - var groupInfo = this.config.groups[key]; - group = group.concat(groupInfo); - } - else { - group.push(key); - } - } - this.config.groups[name] = group; - return true; - // var groupDic: any = this.groupDic; - // var group: Array = []; - // var length: number = keys.length; - // for (var i: number = 0; i < length; i++) { - // var key: string = keys[i]; - // var g: Array = groupDic[key]; - // if (g) { - // var len: number = g.length; - // for (var j: number = 0; j < len; j++) { - // var item: any = g[j]; - // if (group.indexOf(item) == -1) - // group.push(item); - // } - // } - // else { - // item = this.keyMap[key]; - // if (item) { - // if (group.indexOf(item) == -1) - // group.push(item); - // } - // else { - // egret.$warn(3200, key); - // } - // } - // } - // if (group.length == 0) - // return false; - // this.groupDic[name] = group; - // return true; - }; - /** - * 解析一个配置文件 - * @internal - * @method RES.ResourceConfig#parseConfig - * @param data {any} 配置文件数据 - * @param folder {string} 加载项的路径前缀。 - */ - ResourceConfig.prototype.parseConfig = function (data) { - this.config = data; - RES.fileSystem = data.fileSystem; - // if (!data) - // return; - // var resources: Array = data["resources"]; - // if (resources) { - // var length: number = resources.length; - // for (var i: number = 0; i < length; i++) { - // var item: any = resources[i]; - // var url: string = item.url; - // if (url && url.indexOf("://") == -1) - // item.url = folder + url; - // this.addItemToKeyMap(item); - // } - // } - // var groups: Array = data["groups"]; - // if (groups) { - // length = groups.length; - // for (i = 0; i < length; i++) { - // var group: any = groups[i]; - // var list: Array = []; - // var keys: Array = (group.keys).split(","); - // var l: number = keys.length; - // for (var j: number = 0; j < l; j++) { - // var name: string = keys[j].trim(); - // item = this.keyMap[name]; - // if (item && list.indexOf(item) == -1) { - // list.push(item); - // } - // } - // this.groupDic[group.name] = list; - // } - // } - }; - /** - * 添加一个二级键名到配置列表。 - * @method RES.ResourceConfig#addSubkey - * @param subkey {string} 要添加的二级键名 - * @param name {string} 二级键名所属的资源name属性 - */ - ResourceConfig.prototype.addSubkey = function (subkey, name) { - this.addAlias(subkey, name + "#" + subkey); - }; - ResourceConfig.prototype.addAlias = function (alias, key) { - if (this.config.alias[key]) { - key = this.config.alias[key]; - } - this.config.alias[alias] = key; - }; - /** - * 获取加载项类型。 - * @method RES.ResourceConfig#getType - * @param key {string} 对应配置文件里的name属性或sbuKeys属性的一项。 - * @returns {string} - */ - ResourceConfig.prototype.getType = function (key) { - return this.getResource(key, true).type; - }; - ResourceConfig.prototype.addResourceData = function (data) { - if (RES.hasRes(data.name)) { - return; - } - if (!data.type) { - data.type = this.__temp__get__type__via__url(data.url); - } - RES.fileSystem.addFile(data.url, data.type, data.root); - if (data.name) { - this.config.alias[data.name] = data.url; - } - }; - ResourceConfig.prototype.destory = function () { - RES.systemPid++; - var emptyFileSystem = { - getFile: function () { - return null; - }, - addFile: function () { - }, - profile: function () { - } - }; - this.config = { groups: {}, alias: {}, fileSystem: emptyFileSystem, typeSelector: function (p) { return p; }, resourceRoot: "resources", mergeSelector: null }; - }; - return ResourceConfig; - }()); - RES.ResourceConfig = ResourceConfig; - __reflect(ResourceConfig.prototype, "RES.ResourceConfig"); -})(RES || (RES = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var RES; -(function (RES) { - /** - * @class RES.ResourceLoader - * @classdesc - * @private - */ - var ResourceLoader = (function () { - function ResourceLoader() { - /** - * 当前组加载的项总个数,key为groupName - */ - this.groupTotalDic = {}; - /** - * 已经加载的项个数,key为groupName - */ - this.numLoadedDic = {}; - /** - * 正在加载的组列表,key为groupName - */ - this.itemListDic = {}; - /** - * 加载失败的组,key为groupName - */ - this.groupErrorDic = {}; - this.retryTimesDic = {}; - this.maxRetryTimes = 3; - /** - * 优先级队列,key为priority,value为groupName列表 - */ - this.priorityQueue = {}; - this.reporterDic = {}; - this.dispatcherDic = {}; - this.failedList = new Array(); - this.loadItemErrorDic = {}; - this.errorDic = {}; - this.loadingCount = 0; - this.thread = 4; - this.queueIndex = 0; - } - ResourceLoader.prototype.load = function (list, groupName, priority, reporter) { - var _this = this; - if (this.itemListDic[groupName]) { - if (!this.dispatcherDic[groupName]) { - var dispatcher_1 = new egret.EventDispatcher(); - this.dispatcherDic[groupName] = dispatcher_1; - } - var promise_1 = new Promise(function (reslove, reject) { - _this.dispatcherDic[groupName].addEventListener("complete", reslove, null); - _this.dispatcherDic[groupName].addEventListener("error", function (e) { - reject(e.data); - }, null); - }); - return promise_1; - } - var total = list.length; - for (var i = 0; i < total; i++) { - var resInfo = list[i]; - if (!resInfo.groupNames) { - resInfo.groupNames = []; - } - resInfo.groupNames.push(groupName); - } - this.itemListDic[groupName] = list; - this.groupTotalDic[groupName] = list.length; - this.numLoadedDic[groupName] = 0; - if (this.priorityQueue[priority]) - this.priorityQueue[priority].push(groupName); - else - this.priorityQueue[priority] = [groupName]; - this.reporterDic[groupName] = reporter; - var dispatcher = new egret.EventDispatcher(); - this.dispatcherDic[groupName] = dispatcher; - var promise = new Promise(function (reslove, reject) { - dispatcher.addEventListener("complete", reslove, null); - dispatcher.addEventListener("error", function (e) { - reject(e.data); - }, null); - }); - this.next(); - return promise; - }; - ResourceLoader.prototype.next = function () { - var _this = this; - var _loop_1 = function () { - var r = this_1.getOneResourceInfo(); - if (!r) - return "break"; - this_1.loadingCount++; - this_1.loadResource(r) - .then(function (response) { - _this.loadingCount--; - RES.host.save(r, response); - var groupName = r.groupNames.shift(); - if (r.groupNames.length == 0) { - r.groupNames = undefined; - } - var reporter = _this.reporterDic[groupName]; - _this.numLoadedDic[groupName]++; - var current = _this.numLoadedDic[groupName]; - var total = _this.groupTotalDic[groupName]; - if (reporter && reporter.onProgress) { - reporter.onProgress(current, total); - } - if (current == total) { - var groupError = _this.groupErrorDic[groupName]; - _this.removeGroupName(groupName); - delete _this.groupTotalDic[groupName]; - delete _this.numLoadedDic[groupName]; - delete _this.itemListDic[groupName]; - delete _this.groupErrorDic[groupName]; - var dispatcher = _this.dispatcherDic[groupName]; - if (groupError) { - var itemList = _this.loadItemErrorDic[groupName]; - delete _this.loadItemErrorDic[groupName]; - var error = _this.errorDic[groupName]; - delete _this.errorDic[groupName]; - dispatcher.dispatchEventWith("error", false, { itemList: itemList, error: error }); - } - else { - dispatcher.dispatchEventWith("complete"); - } - } - _this.next(); - }).catch(function (error) { - if (!error) { - throw r.name + " load fail"; - } - if (!error.__resource_manager_error__) { - throw error; - } - _this.loadingCount--; - delete RES.host.state[r.root + r.name]; - var times = _this.retryTimesDic[r.name] || 1; - if (times > _this.maxRetryTimes) { - delete _this.retryTimesDic[r.name]; - var groupName = r.groupNames.shift(); - if (r.groupNames.length == 0) { - delete r.groupNames; - } - if (!_this.loadItemErrorDic[groupName]) { - _this.loadItemErrorDic[groupName] = []; - } - if (_this.loadItemErrorDic[groupName].indexOf(r) == -1) { - _this.loadItemErrorDic[groupName].push(r); - } - _this.groupErrorDic[groupName] = true; - var reporter = _this.reporterDic[groupName]; - _this.numLoadedDic[groupName]++; - var current = _this.numLoadedDic[groupName]; - var total = _this.groupTotalDic[groupName]; - if (reporter && reporter.onProgress) { - reporter.onProgress(current, total); - } - if (current == total) { - var groupError = _this.groupErrorDic[groupName]; - _this.removeGroupName(groupName); - delete _this.groupTotalDic[groupName]; - delete _this.numLoadedDic[groupName]; - delete _this.itemListDic[groupName]; - delete _this.groupErrorDic[groupName]; - var itemList = _this.loadItemErrorDic[groupName]; - delete _this.loadItemErrorDic[groupName]; - var dispatcher = _this.dispatcherDic[groupName]; - dispatcher.dispatchEventWith("error", false, { itemList: itemList, error: error }); - } - else { - _this.errorDic[groupName] = error; - } - _this.next(); - } - else { - _this.retryTimesDic[r.name] = times + 1; - _this.failedList.push(r); - _this.next(); - return; - } - }); - }; - var this_1 = this; - while (this.loadingCount < this.thread) { - var state_1 = _loop_1(); - if (state_1 === "break") - break; - } - }; - /** - * 从优先级队列中移除指定的组名 - */ - ResourceLoader.prototype.removeGroupName = function (groupName) { - for (var p in this.priorityQueue) { - var queue_1 = this.priorityQueue[p]; - var index = 0; - var found = false; - var length_1 = queue_1.length; - for (var i = 0; i < length_1; i++) { - var name_1 = queue_1[i]; - if (name_1 == groupName) { - queue_1.splice(index, 1); - found = true; - break; - } - index++; - } - if (found) { - if (queue_1.length == 0) { - delete this.priorityQueue[p]; - } - break; - } - } - }; - /** - * 获取下一个待加载项 - */ - ResourceLoader.prototype.getOneResourceInfo = function () { - if (this.failedList.length > 0) - return this.failedList.shift(); - var maxPriority = Number.NEGATIVE_INFINITY; - for (var p in this.priorityQueue) { - maxPriority = Math.max(maxPriority, p); - } - var queue = this.priorityQueue[maxPriority]; - if (!queue || queue.length == 0) { - return undefined; - } - var length = queue.length; - var list = []; - for (var i = 0; i < length; i++) { - if (this.queueIndex >= length) - this.queueIndex = 0; - list = this.itemListDic[queue[this.queueIndex]]; - if (list.length > 0) - break; - this.queueIndex++; - } - if (list.length == 0) - return undefined; - return list.shift(); - }; - ResourceLoader.prototype.loadResource = function (r, p) { - if (!p) { - if (RES.FEATURE_FLAG.FIX_DUPLICATE_LOAD == 1) { - var s = RES.host.state[r.root + r.name]; - if (s == 2) { - return Promise.resolve(RES.host.get(r)); - } - if (s == 1) { - return r.promise; - } - } - p = RES.processor.isSupport(r); - } - if (!p) { - throw new RES.ResourceManagerError(2001, r.name, r.type); - } - RES.host.state[r.root + r.name] = 1; - var promise = p.onLoadStart(RES.host, r); - r.promise = promise; - return promise; - }; - ResourceLoader.prototype.unloadResource = function (r) { - var data = RES.host.get(r); - if (!data) { - console.warn("尝试释放不存在的资源:", r.name); - return Promise.resolve(); - } - var p = RES.processor.isSupport(r); - if (p) { - RES.host.state[r.root + r.name] = 3; - var promise = p.onRemoveStart(RES.host, r); - RES.host.remove(r); - return promise; - } - else { - return Promise.resolve(); - } - }; - return ResourceLoader; - }()); - RES.ResourceLoader = ResourceLoader; - __reflect(ResourceLoader.prototype, "RES.ResourceLoader"); -})(RES || (RES = {})); -var RES; -(function (RES) { - var __tempCache = {}; - /** - * 整个资源加载系统的进程id,协助管理回调派发机制 - */ - RES.systemPid = 0; - RES.checkCancelation = function (target, propertyKey, descriptor) { - var method = descriptor.value; - descriptor.value = function () { - var arg = []; - for (var _i = 0; _i < arguments.length; _i++) { - arg[_i] = arguments[_i]; - } - var currentPid = RES.systemPid; - var result = method.apply(this, arg); - return result.then(function (value) { - if (RES.systemPid != currentPid) { - throw new ResourceManagerError(1005, arg[0]); - } - else { - return value; - } - }); - }; - }; - function profile() { - RES.fileSystem.profile(); - console.log(__tempCache); - //todo - var totalImageSize = 0; - for (var key in __tempCache) { - var img = __tempCache[key]; - if (img instanceof egret.Texture) { - totalImageSize += img.$bitmapWidth * img.$bitmapHeight * 4; - } - } - console.log("gpu size : " + (totalImageSize / 1024).toFixed(3) + "kb"); - } - RES.profile = profile; - RES.host = { - state: {}, - get resourceConfig() { - return RES.config; - }, - load: function (r, processorName) { - var processor = typeof processorName == 'string' ? RES.processor._map[processorName] : processorName; - return RES.queue.loadResource(r, processor); - }, - unload: function (r) { return RES.queue.unloadResource(r); }, - save: function (resource, data) { - RES.host.state[resource.root + resource.name] = 2; - resource.promise = undefined; - __tempCache[resource.url] = data; - }, - get: function (resource) { - return __tempCache[resource.url]; - }, - remove: function (resource) { - RES.host.state[resource.root + resource.name] = 0; - delete __tempCache[resource.url]; - } - }; - RES.config = new RES.ResourceConfig(); - RES.queue = new RES.ResourceLoader(); - var ResourceManagerError = (function (_super) { - __extends(ResourceManagerError, _super); - function ResourceManagerError(code, replacer, replacer2) { - var _this = _super.call(this) || this; - /** - * why instanceof e != ResourceManagerError ??? - * see link : https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work - */ - _this.__resource_manager_error__ = true; - _this.name = code.toString(); - _this.message = ResourceManagerError.errorMessage[code].replace("{0}", replacer).replace("{1}", replacer2); - return _this; - } - ResourceManagerError.errorMessage = { - 1001: '文件加载失败:{0}', - 1002: "ResourceManager 初始化失败:配置文件加载失败", - 1005: 'ResourceManager 已被销毁,文件加载失败:{0}', - 2001: "{0}解析失败,不支持指定解析类型:\'{1}\',请编写自定义 Processor ,更多内容请参见 https://github.com/egret-labs/resourcemanager/blob/master/docs/README.md#processor", - 2002: "Analyzer 相关API 在 ResourceManager 中不再支持,请编写自定义 Processor ,更多内容请参见 https://github.com/egret-labs/resourcemanager/blob/master/docs/README.md#processor", - 2003: "{0}解析失败,错误原因:{1}", - 2004: "无法找到文件类型:{0}", - 2005: "资源配置文件中无法找到特定的资源组:{0}", - 2006: "资源配置文件中无法找到特定的资源:{0}" - }; - return ResourceManagerError; - }(Error)); - RES.ResourceManagerError = ResourceManagerError; - __reflect(ResourceManagerError.prototype, "RES.ResourceManagerError"); -})(RES || (RES = {})); -var RES; -(function (RES) { - RES.checkNull = function (target, propertyKey, descriptor) { - var method = descriptor.value; - descriptor.value = function () { - var arg = []; - for (var _i = 0; _i < arguments.length; _i++) { - arg[_i] = arguments[_i]; - } - if (!arg[0]) { - console.warn("\u65B9\u6CD5" + propertyKey + "\u7684\u53C2\u6570\u4E0D\u80FD\u4E3Anull"); - return null; - } - else { - return method.apply(this, arg); - } - }; - }; - /** - * 功能开关 - * LOADING_STATE:处理重复加载 - */ - RES.FEATURE_FLAG = { - FIX_DUPLICATE_LOAD: 1 - }; - var upgrade; - (function (upgrade) { - var _level = "warning"; - function setUpgradeGuideLevel(level) { - _level = level; - } - upgrade.setUpgradeGuideLevel = setUpgradeGuideLevel; - })(upgrade = RES.upgrade || (RES.upgrade = {})); -})(RES || (RES = {})); -var RES; -(function (RES) { - var processor; - (function (processor_1) { - function isSupport(resource) { - return processor_1._map[resource.type]; - } - processor_1.isSupport = isSupport; - function map(type, processor) { - processor_1._map[type] = processor; - } - processor_1.map = map; - function promisify(loader, resource) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2 /*return*/, new Promise(function (reslove, reject) { - var onSuccess = function () { - var texture = loader['data'] ? loader['data'] : loader['response']; - reslove(texture); - }; - var onError = function () { - var e = new RES.ResourceManagerError(1001, resource.url); - reject(e); - }; - loader.addEventListener(egret.Event.COMPLETE, onSuccess, _this); - loader.addEventListener(egret.IOErrorEvent.IO_ERROR, onError, _this); - })]; - }); - }); - } - function getURL(resource) { - if (resource.url.indexOf("://") != -1) { - return resource.url; - } - var prefix = resource.root; - var url = prefix + resource.url; - if (RES['getRealURL']) { - return RES['getRealURL'](url); - } - else { - return url; - } - } - function getRelativePath(url, file) { - if (file.indexOf("://") != -1) { - return file; - } - url = url.split("\\").join("/"); - var params = url.match(/#.*|\?.*/); - var paramUrl = ""; - if (params) { - paramUrl = params[0]; - } - var index = url.lastIndexOf("/"); - if (index != -1) { - url = url.substring(0, index + 1) + file; - } - else { - url = file; - } - return url + paramUrl; - } - processor_1.getRelativePath = getRelativePath; - // var cache: {[index:string]:egret.Texture} = {}; - processor_1.ImageProcessor = { - onLoadStart: function (host, resource) { - return __awaiter(this, void 0, void 0, function () { - var loader, bitmapData, texture, r, list; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - loader = new egret.ImageLoader(); - loader.load(getURL(resource)); - return [4 /*yield*/, promisify(loader, resource)]; - case 1: - bitmapData = _a.sent(); - texture = new egret.Texture(); - texture._setBitmapData(bitmapData); - r = host.resourceConfig.getResource(resource.name); - if (r && r.scale9grid) { - list = r.scale9grid.split(","); - texture["scale9Grid"] = new egret.Rectangle(parseInt(list[0]), parseInt(list[1]), parseInt(list[2]), parseInt(list[3])); - } - // var config: any = resItem.data; - // if (config && config["scale9grid"]) { - // - // } - return [2 /*return*/, texture]; - } - }); - }); - }, - onRemoveStart: function (host, resource) { - var texture = host.get(resource); - texture.dispose(); - return Promise.resolve(); - } - }; - processor_1.BinaryProcessor = { - onLoadStart: function (host, resource) { - return __awaiter(this, void 0, void 0, function () { - var request, arraybuffer; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - request = new egret.HttpRequest(); - request.responseType = egret.HttpResponseType.ARRAY_BUFFER; - request.open(getURL(resource), "get"); - request.send(); - return [4 /*yield*/, promisify(request, resource)]; - case 1: - arraybuffer = _a.sent(); - return [2 /*return*/, arraybuffer]; - } - }); - }); - }, - onRemoveStart: function (host, resource) { - return Promise.resolve(); - } - }; - processor_1.TextProcessor = { - onLoadStart: function (host, resource) { - return __awaiter(this, void 0, void 0, function () { - var request, text; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - request = new egret.HttpRequest(); - request.responseType = egret.HttpResponseType.TEXT; - request.open(getURL(resource), "get"); - request.send(); - return [4 /*yield*/, promisify(request, resource)]; - case 1: - text = _a.sent(); - return [2 /*return*/, text]; - } - }); - }); - }, - onRemoveStart: function (host, resource) { - return Promise.resolve(); - } - }; - processor_1.JsonProcessor = { - onLoadStart: function (host, resource) { - return __awaiter(this, void 0, void 0, function () { - var text, data; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, host.load(resource, 'text')]; - case 1: - text = _a.sent(); - data = JSON.parse(text); - return [2 /*return*/, data]; - } - }); - }); - }, - onRemoveStart: function (host, request) { - return Promise.resolve(); - } - }; - processor_1.XMLProcessor = { - onLoadStart: function (host, resource) { - return __awaiter(this, void 0, void 0, function () { - var text, data; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, host.load(resource, 'text')]; - case 1: - text = _a.sent(); - data = egret.XML.parse(text); - return [2 /*return*/, data]; - } - }); - }); - }, - onRemoveStart: function (host, resource) { - return Promise.resolve(); - } - }; - processor_1.CommonJSProcessor = { - onLoadStart: function (host, resource) { - return __awaiter(this, void 0, void 0, function () { - var text, f, require, exports; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, host.load(resource, 'text')]; - case 1: - text = _a.sent(); - f = new Function('require', 'exports', text); - require = function () { }; - exports = {}; - try { - f(require, exports); - } - catch (e) { - throw new RES.ResourceManagerError(2003, resource.name, e.message); - } - return [2 /*return*/, exports]; - } - }); - }); - }, - onRemoveStart: function (host, resource) { - return Promise.resolve(); - } - }; - processor_1.SheetProcessor = { - onLoadStart: function (host, resource) { - return __awaiter(this, void 0, void 0, function () { - var data, r, imageName, texture, frames, spriteSheet, subkey, config, texture, str, list; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, host.load(resource, "json")]; - case 1: - data = _a.sent(); - r = host.resourceConfig.getResource(RES.nameSelector(data.file)); - if (!r) { - imageName = getRelativePath(resource.url, data.file); - r = { name: imageName, url: imageName, type: 'image', root: resource.root }; - } - return [4 /*yield*/, host.load(r)]; - case 2: - texture = _a.sent(); - frames = data.frames; - spriteSheet = new egret.SpriteSheet(texture); - spriteSheet["$resourceInfo"] = r; - for (subkey in frames) { - config = frames[subkey]; - texture = spriteSheet.createTexture(subkey, config.x, config.y, config.w, config.h, config.offX, config.offY, config.sourceW, config.sourceH); - if (config["scale9grid"]) { - str = config["scale9grid"]; - list = str.split(","); - texture["scale9Grid"] = new egret.Rectangle(parseInt(list[0]), parseInt(list[1]), parseInt(list[2]), parseInt(list[3])); - } - } - host.save(r, texture); - return [2 /*return*/, spriteSheet]; - } - }); - }); - }, - getData: function (host, resource, key, subkey) { - var data = host.get(resource); - if (data) { - return data.getTexture(subkey); - } - else { - return null; - } - }, - onRemoveStart: function (host, resource) { - var sheet = host.get(resource); - var r = sheet["$resourceInfo"]; - sheet.dispose(); - host.unload(r); - return Promise.resolve(); - } - }; - var fontGetTexturePath = function (url, fntText) { - var file = ""; - var lines = fntText.split("\n"); - var pngLine = lines[2]; - var index = pngLine.indexOf("file=\""); - if (index != -1) { - pngLine = pngLine.substring(index + 6); - index = pngLine.indexOf("\""); - file = pngLine.substring(0, index); - } - url = url.split("\\").join("/"); - var index = url.lastIndexOf("/"); - if (index != -1) { - url = url.substring(0, index + 1) + file; - } - else { - url = file; - } - return url; - }; - processor_1.FontProcessor = { - onLoadStart: function (host, resource) { - return __awaiter(this, void 0, void 0, function () { - var data, config, imageName, r, texture, font; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, host.load(resource, 'text')]; - case 1: - data = _a.sent(); - try { - config = JSON.parse(data); - } - catch (e) { - config = data; - } - if (typeof config === 'string') { - imageName = fontGetTexturePath(resource.url, config); - } - else { - imageName = getRelativePath(resource.url, config.file); - } - r = host.resourceConfig.getResource(RES.nameSelector(imageName)); - if (!r) { - r = { name: imageName, url: imageName, type: 'image', root: resource.root }; - } - return [4 /*yield*/, host.load(r)]; - case 2: - texture = _a.sent(); - font = new egret.BitmapFont(texture, config); - font["$resourceInfo"] = r; - // todo refactor - host.save(r, texture); - return [2 /*return*/, font]; - } - }); - }); - }, - onRemoveStart: function (host, resource) { - var font = host.get(resource); - var r = font["$resourceInfo"]; - host.unload(r); - return Promise.resolve(); - } - }; - processor_1.SoundProcessor = { - onLoadStart: function (host, resource) { - return __awaiter(this, void 0, void 0, function () { - var sound; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - sound = new egret.Sound(); - sound.load(getURL(resource)); - return [4 /*yield*/, promisify(sound, resource)]; - case 1: - _a.sent(); - return [2 /*return*/, sound]; - } - }); - }); - }, - onRemoveStart: function (host, resource) { - return Promise.resolve(); - } - }; - processor_1.MovieClipProcessor = { - onLoadStart: function (host, resource) { - var mcData; - var imageResource; - return host.load(resource, 'json') - .then(function (value) { - mcData = value; - var jsonPath = resource.name; - var imagePath = jsonPath.substring(0, jsonPath.lastIndexOf(".")) + ".png"; - imageResource = host.resourceConfig.getResource(imagePath, true); - if (!imageResource) { - throw new RES.ResourceManagerError(1001, imagePath); - } - return host.load(imageResource); - }).then(function (value) { - host.save(imageResource, value); - var mcTexture = value; - var mcDataFactory = new egret.MovieClipDataFactory(mcData, mcTexture); - return mcDataFactory; - }); - }, - onRemoveStart: function (host, resource) { - var mcFactory = host.get(resource); - mcFactory.clearCache(); - mcFactory.$spriteSheet.dispose(); - // refactor - var jsonPath = resource.name; - var imagePath = jsonPath.substring(0, jsonPath.lastIndexOf(".")) + ".png"; - var imageResource = host.resourceConfig.getResource(imagePath, true); - return host.unload(imageResource); - } - }; - processor_1.MergeJSONProcessor = { - onLoadStart: function (host, resource) { - return __awaiter(this, void 0, void 0, function () { - var data, key; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, host.load(resource, 'json')]; - case 1: - data = _a.sent(); - for (key in data) { - RES.config.addSubkey(key, resource.name); - } - return [2 /*return*/, data]; - } - }); - }); - }, - getData: function (host, resource, key, subkey) { - var data = host.get(resource); - if (data) { - return data[subkey]; - } - else { - console.error("missing resource :" + resource.name); - return null; - } - }, - onRemoveStart: function (host, resource) { - return Promise.resolve(); - } - }; - processor_1.ResourceConfigProcessor = { - onLoadStart: function (host, resource) { - return __awaiter(this, void 0, void 0, function () { - var data, fileSystem; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, host.load(resource, 'commonjs')]; - case 1: - data = _a.sent(); - fileSystem = new RES.NewFileSystem(data.resources); - data.fileSystem = fileSystem; - delete data.resource; - RES.resourceTypeSelector = data.typeSelector; - RES.resourceNameSelector = data.nameSelector ? data.nameSelector : function (p) { return p; }; - return [2 /*return*/, data]; - } - }); - }); - }, - onRemoveStart: function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2 /*return*/]; - }); - }); - } - }; - processor_1.LegacyResourceConfigProcessor = { - onLoadStart: function (host, resource) { - return host.load(resource, 'json').then(function (data) { - var resConfigData = RES.config.config; - var root = resource.root; - var fileSystem = resConfigData.fileSystem; - if (!fileSystem) { - fileSystem = { - fsData: {}, - getFile: function (filename) { - return fsData[filename]; - }, - addFile: function (filename, type, root) { - if (!type) - type = ""; - if (root == undefined) { - root = ""; - } - fsData[filename] = { name: filename, type: type, url: filename, root: root }; - }, - profile: function () { - console.log(fsData); - } - }; - resConfigData.fileSystem = fileSystem; - } - var groups = resConfigData.groups; - for (var _i = 0, _a = data.groups; _i < _a.length; _i++) { - var g = _a[_i]; - groups[g.name] = g.keys.split(","); - } - var alias = resConfigData.alias; - var fsData = fileSystem['fsData']; - var _loop_2 = function (resource_1) { - fsData[resource_1.name] = resource_1; - fsData[resource_1.name].root = root; - if (resource_1.subkeys) { - resource_1.subkeys.split(",").forEach(function (subkey) { - alias[subkey] = resource_1.name + "#" + subkey; - alias[resource_1.name + "." + subkey] = resource_1.name + "#" + subkey; - }); - // ResourceConfig. - } - }; - for (var _b = 0, _c = data.resources; _b < _c.length; _b++) { - var resource_1 = _c[_b]; - _loop_2(resource_1); - } - return resConfigData; - }); - }, - onRemoveStart: function () { - return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { - return [2 /*return*/]; - }); }); - } - }; - var PVRParser = (function () { - function PVRParser() { - } - PVRParser.parse = function (arrayBuffer, callback, errorCallback) { - // the header length of int32 - var headerIntLength = 13; - // get header part of arrayBuffer - var header = new Uint32Array(arrayBuffer, 0, headerIntLength); - // separate buffer and header - var pvrDatas = { - buffer: arrayBuffer, - header: header - }; - // PVR v3 - if (header[0] === 0x03525650) { - PVRParser._parseV3(pvrDatas, callback, errorCallback); - } - else if (header[11] === 0x21525650) { - PVRParser._parseV2(pvrDatas, callback, errorCallback); - } - else { - errorCallback(pvrDatas, "pvr parse error!"); - } - }; - PVRParser._parseV2 = function (pvrDatas, callback, errorCallback) { - var header = pvrDatas.header; - var headerLength = header[0], height = header[1], width = header[2], numMipmaps = header[3], flags = header[4], dataLength = header[5], bpp = header[6], bitmaskRed = header[7], bitmaskGreen = header[8], bitmaskBlue = header[9], bitmaskAlpha = header[10], pvrTag = header[11], numSurfs = header[12]; - var TYPE_MASK = 0xff; - var PVRTC_2 = 24, PVRTC_4 = 25; - var formatFlags = flags & TYPE_MASK; - var bpp, format; - var _hasAlpha = bitmaskAlpha > 0; - if (formatFlags === PVRTC_4) { - format = _hasAlpha ? PVRParser.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG : PVRParser.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; - bpp = 4; - } - else if (formatFlags === PVRTC_2) { - format = _hasAlpha ? PVRParser.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG : PVRParser.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; - bpp = 2; - } - else { - errorCallback(pvrDatas, "pvr v2 parse error"); - console.log("unknow format flags::" + formatFlags); - } - var dataOffset = headerLength; - pvrDatas.pvrtcData = new Uint8Array(pvrDatas.buffer, dataOffset); - pvrDatas.bpp = bpp; - pvrDatas.format = format; - pvrDatas.width = width; - pvrDatas.height = height; - pvrDatas.surfacesCount = numSurfs; - pvrDatas.mipmapsCount = numMipmaps + 1; - // guess cubemap type seems tricky in v2 - // it juste a pvr containing 6 surface (no explicit cubemap type) - pvrDatas.isCubemap = (pvrDatas.surfacesCount === 6); - callback(pvrDatas); - }; - PVRParser._parseV3 = function (pvrDatas, callback, errorCallback) { - var header = pvrDatas.header; - var bpp, format; - var pixelFormat = header[2]; - switch (pixelFormat) { - case 0:// PVRTC 2bpp RGB - bpp = 2; - format = PVRParser.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; - break; - case 1:// PVRTC 2bpp RGBA - bpp = 2; - format = PVRParser.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; - break; - case 2:// PVRTC 4bpp RGB - bpp = 4; - format = PVRParser.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; - break; - case 3:// PVRTC 4bpp RGBA - bpp = 4; - format = PVRParser.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; - break; - default: - errorCallback(pvrDatas, "pvr v3 parse error"); - console.log("unknow pixel format::" + pixelFormat); - } - var dataOffset = 52 + header[12]; - pvrDatas.pvrtcData = new Uint8Array(pvrDatas.buffer, dataOffset); - pvrDatas.bpp = bpp; - pvrDatas.format = format; - pvrDatas.width = header[7]; - pvrDatas.height = header[6]; - pvrDatas.surfacesCount = header[10]; - pvrDatas.mipmapsCount = header[11]; - pvrDatas.isCubemap = (pvrDatas.surfacesCount === 6); - callback(pvrDatas); - }; - PVRParser.COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00; - PVRParser.COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01; - PVRParser.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02; - PVRParser.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03; - return PVRParser; - }()); - __reflect(PVRParser.prototype, "PVRParser"); - if (typeof egret != 'undefined' && egret && egret["web"] && egret["web"].WebGLRenderContext) { - // Calcualates the size of a compressed texture level in bytes - function textureLevelSize(format, width, height) { - switch (format) { - case PVRParser.COMPRESSED_RGB_PVRTC_4BPPV1_IMG: - case PVRParser.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: - return Math.floor((Math.max(width, 8) * Math.max(height, 8) * 4 + 7) / 8); - case PVRParser.COMPRESSED_RGB_PVRTC_2BPPV1_IMG: - case PVRParser.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: - return Math.floor((Math.max(width, 16) * Math.max(height, 8) * 2 + 7) / 8); - default: - return 0; - } - } - egret["web"].WebGLRenderContext.prototype.createTextureFromCompressedData = function (data, width, height, levels, internalFormat) { - var gl = this.context; - if (!this.pvrtcExt) { - this.pvrtcExt = gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"); - } - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - var offset = 0; - // Loop through each mip level of compressed texture data provided and upload it to the given texture. - for (var i = 0; i < levels; ++i) { - // Determine how big this level of compressed texture data is in bytes. - var levelSize = textureLevelSize(internalFormat, width, height); - // Get a view of the bytes for this level of DXT data. - var dxtLevel = new Uint8Array(data.buffer, data.byteOffset + offset, levelSize); - // Upload! - gl.compressedTexImage2D(gl.TEXTURE_2D, i, internalFormat, width, height, 0, dxtLevel); - // The next mip level will be half the height and width of this one. - width = width >> 1; - if (width < 1) - width = 1; - height = height >> 1; - if (height < 1) - height = 1; - // Advance the offset into the compressed texture data past the current mip level's data. - offset += levelSize; - } - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - return texture; - }; - } - processor_1.PVRProcessor = { - onLoadStart: function (host, resource) { - return __awaiter(this, void 0, void 0, function () { - var arraybuffer, width, height, borderWidth, borderHeight, byteArray, list, pvrDataBuffer, i, buffer, dataLength, self, texture; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, host.load(resource, 'bin')]; - case 1: - arraybuffer = _a.sent(); - width = 512; - height = 512; - borderWidth = 0; - borderHeight = 0; - byteArray = new egret.ByteArray(arraybuffer); - byteArray.position = 7; - list = ["body", "ext"]; - for (i = 0; i < list.length; i++) { - buffer = void 0; - switch (list[i]) { - case "body": - byteArray.position += 2; - dataLength = byteArray.readUnsignedInt(); - pvrDataBuffer = byteArray.buffer.slice(byteArray.position, byteArray.position + dataLength); - byteArray.position += dataLength; - break; - case "ext": - byteArray.position += 6; - width = byteArray.readUnsignedShort(); - height = byteArray.readUnsignedShort(); - borderWidth = byteArray.readUnsignedShort(); - borderHeight = byteArray.readUnsignedShort(); - break; - } - } - self = this; - PVRParser.parse(pvrDataBuffer, function (pvrData) { - var bitmapData = new egret.BitmapData(pvrData); - bitmapData.format = "pvr"; - texture = new egret.Texture(); - texture._setBitmapData(bitmapData); - texture.$initData(borderWidth, borderHeight, width, height, 0, 0, width, height, bitmapData.width, bitmapData.height); - }, function () { - console.log("pvr error"); - }); - return [2 /*return*/, texture]; - } - }); - }); - }, - onRemoveStart: function (host, resource) { - return Promise.resolve(); - } - }; - processor_1._map = { - "image": processor_1.ImageProcessor, - "json": processor_1.JsonProcessor, - "text": processor_1.TextProcessor, - "xml": processor_1.XMLProcessor, - "sheet": processor_1.SheetProcessor, - "font": processor_1.FontProcessor, - "bin": processor_1.BinaryProcessor, - "commonjs": processor_1.CommonJSProcessor, - "sound": processor_1.SoundProcessor, - "movieclip": processor_1.MovieClipProcessor, - "pvr": processor_1.PVRProcessor, - "mergeJson": processor_1.MergeJSONProcessor, - "resourceConfig": processor_1.ResourceConfigProcessor, - "legacyResourceConfig": processor_1.LegacyResourceConfigProcessor, - }; - })(processor = RES.processor || (RES.processor = {})); -})(RES || (RES = {})); -var RES; -(function (RES) { - var NewFileSystem = (function () { - function NewFileSystem(data) { - this.data = data; - } - NewFileSystem.prototype.profile = function () { - console.log(this.data); - }; - NewFileSystem.prototype.addFile = function (filename, type) { - if (!type) - type = ""; - filename = RES.path.normalize(filename); - var basefilename = RES.path.basename(filename); - var folder = RES.path.dirname(filename); - if (!this.exists(folder)) { - this.mkdir(folder); - } - var d = this.reslove(folder); - d[basefilename] = { url: filename, type: type }; - }; - NewFileSystem.prototype.getFile = function (filename) { - var result = this.reslove(filename); - if (result) { - result.name = filename; - } - return result; - }; - NewFileSystem.prototype.reslove = function (dirpath) { - if (dirpath == "") { - return this.data; - } - dirpath = RES.path.normalize(dirpath); - var list = dirpath.split("/"); - var current = this.data; - for (var _i = 0, list_1 = list; _i < list_1.length; _i++) { - var f = list_1[_i]; - if (current) { - current = current[f]; - } - else { - return current; - } - } - return current; - }; - NewFileSystem.prototype.mkdir = function (dirpath) { - dirpath = RES.path.normalize(dirpath); - var list = dirpath.split("/"); - var current = this.data; - for (var _i = 0, list_2 = list; _i < list_2.length; _i++) { - var f = list_2[_i]; - if (!current[f]) { - current[f] = {}; - } - current = current[f]; - } - }; - NewFileSystem.prototype.exists = function (dirpath) { - if (dirpath == "") - return true; - dirpath = RES.path.normalize(dirpath); - var list = dirpath.split("/"); - var current = this.data; - for (var _i = 0, list_3 = list; _i < list_3.length; _i++) { - var f = list_3[_i]; - if (!current[f]) { - return false; - } - current = current[f]; - } - return true; - }; - return NewFileSystem; - }()); - RES.NewFileSystem = NewFileSystem; - __reflect(NewFileSystem.prototype, "RES.NewFileSystem"); -})(RES || (RES = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var RES; -(function (RES) { - /** - * The events of resource loading. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 资源加载事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var ResourceEvent = (function (_super) { - __extends(ResourceEvent, _super); - /** - * Creates an Event object to pass as a parameter to event listeners. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language en_US - */ - /** - * 创建一个作为参数传递给事件侦听器的 Event 对象。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language zh_CN - */ - function ResourceEvent(type, bubbles, cancelable) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - var _this = _super.call(this, type, bubbles, cancelable) || this; - /** - * File number that has been loaded. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 已经加载的文件数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.itemsLoaded = 0; - /** - * Total file number to load. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要加载的总文件数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.itemsTotal = 0; - /** - * Resource group name. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 资源组名。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.groupName = ""; - return _this; - } - /** - * 使用指定的EventDispatcher对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @method RES.ResourceEvent.dispatchResourceEvent - * @param target {egret.IEventDispatcher} - * @param type {string} - * @param groupName {string} - * @param resItem {egret.ResourceItem} - * @param itemsLoaded {number} - * @param itemsTotal {number} - * @internal - * @private - */ - ResourceEvent.dispatchResourceEvent = function (target, type, groupName, resItem, itemsLoaded, itemsTotal) { - if (groupName === void 0) { groupName = ""; } - if (resItem === void 0) { resItem = undefined; } - if (itemsLoaded === void 0) { itemsLoaded = 0; } - if (itemsTotal === void 0) { itemsTotal = 0; } - var event = egret.Event.create(ResourceEvent, type); - event.groupName = groupName; - if (resItem) { - event.resItem = RES.ResourceItem.convertToResItem(resItem); - } - event.itemsLoaded = itemsLoaded; - event.itemsTotal = itemsTotal; - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * Failure event for a load item. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个加载项加载失败事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ResourceEvent.ITEM_LOAD_ERROR = "itemLoadError"; - /** - * Configure file to load and parse the completion event. Note: if a configuration file is loaded, it will not be thrown out, and if you want to handle the configuration loading failure, monitor the CONFIG_LOAD_ERROR event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 配置文件加载并解析完成事件。注意:若有配置文件加载失败,将不会抛出此事件,若要处理配置加载失败,请同时监听 CONFIG_LOAD_ERROR 事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ResourceEvent.CONFIG_COMPLETE = "configComplete"; - /** - * Configuration file failed to load. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 配置文件加载失败事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ResourceEvent.CONFIG_LOAD_ERROR = "configLoadError"; - /** - * Delay load group resource loading progress event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载进度事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ResourceEvent.GROUP_PROGRESS = "groupProgress"; - /** - * Delay load group resource to complete event. Note: if you have a resource item loading failure, the event will not be thrown, if you want to handle the group load failure, please listen to the GROUP_LOAD_ERROR event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载完成事件。注意:若组内有资源项加载失败,将不会抛出此事件,若要处理组加载失败,请同时监听 GROUP_LOAD_ERROR 事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ResourceEvent.GROUP_COMPLETE = "groupComplete"; - /** - * Delayed load group resource failed event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载失败事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ResourceEvent.GROUP_LOAD_ERROR = "groupLoadError"; - return ResourceEvent; - }(egret.Event)); - RES.ResourceEvent = ResourceEvent; - __reflect(ResourceEvent.prototype, "RES.ResourceEvent"); -})(RES || (RES = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var RES; -(function (RES) { - /** - * Resource term. One of the resources arrays in resource.json. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 资源项。对应 resource.json 中 resources 数组中的一项。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var ResourceItem; - (function (ResourceItem) { - /** - * XML file. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * XML 文件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_XML = "xml"; - /** - * Picture file. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 图片文件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_IMAGE = "image"; - /** - * Binary file. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 二进制文件。 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - ResourceItem.TYPE_BIN = "bin"; - /** - * Text file. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本文件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_TEXT = "text"; - /** - * JSON file. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * JSON 文件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_JSON = "json"; - /** - * SpriteSheet file. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * SpriteSheet 文件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_SHEET = "sheet"; - /** - * BitmapTextSpriteSheet file. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * BitmapTextSpriteSheet 文件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_FONT = "font"; - /** - * Sound file. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 声音文件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_SOUND = "sound"; - function convertToResItem(r) { - var name = r.name; - if (!RES.config.config) { - name = r.url; - } - else { - for (var aliasName in RES.config.config.alias) { - if (RES.config.config.alias[aliasName] == r.url) { - name = aliasName; - } - } - } - var result = { - name: name, - url: r.url, - type: r.type, - data: r, - root: r.root - }; - return result; - } - ResourceItem.convertToResItem = convertToResItem; - })(ResourceItem = RES.ResourceItem || (RES.ResourceItem = {})); -})(RES || (RES = {})); -var RES; -(function (RES) { - var path; - (function (path_1) { - path_1.normalize = function (filename) { - var arr = filename.split("/"); - return arr.filter(function (value, index) { return !!value || index == arr.length - 1; }).join("/"); - }; - path_1.basename = function (filename) { - return filename.substr(filename.lastIndexOf("/") + 1); - }; - path_1.dirname = function (path) { - return path.substr(0, path.lastIndexOf("/")); - }; - })(path = RES.path || (RES.path = {})); -})(RES || (RES = {})); -var RES; -(function (RES) { - var versionInfo; - /** - * @internal - */ - function native_init() { - if (egret.Capabilities.runtimeType == egret.RuntimeType.NATIVE) { - versionInfo = getLocalData("all.manifest"); - } - } - RES.native_init = native_init; - /** - * @internal - */ - function getRealURL(url) { - if (versionInfo && versionInfo[url]) { - return "resource/" + versionInfo[url].v.substring(0, 2) + "/" + versionInfo[url].v + "_" + versionInfo[url].s + "." + url.substring(url.lastIndexOf(".") + 1); - } - else { - return url; - } - } - RES.getRealURL = getRealURL; - function getLocalData(filePath) { - if (egret_native.readUpdateFileSync && egret_native.readResourceFileSync) { - //先取更新目录 - var content = egret_native.readUpdateFileSync(filePath); - if (content != null) { - return JSON.parse(content); - } - //再取资源目录 - content = egret_native.readResourceFileSync(filePath); - if (content != null) { - return JSON.parse(content); - } - } - return null; - } -})(RES || (RES = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var RES; -(function (RES) { - RES.nameSelector = function (url) { - return RES.path.basename(url).split(".").join("_"); - }; - /** - * Conduct mapping injection with class definition as the value. - * @param type Injection type. - * @param analyzerClass Injection type classes need to be resolved. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/resource/Resource.ts - * @language en_US - */ - /** - * 以类定义为值进行映射注入。 - * @param type 注入的类型。 - * @param analyzerClass 注入类型需要解析的类。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/resource/Resource.ts - * @language zh_CN - */ - function registerAnalyzer(type, analyzerClass) { - throw new RES.ResourceManagerError(2002); - } - RES.registerAnalyzer = registerAnalyzer; - /** - * Load configuration file and parse. - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 加载配置文件并解析。 - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function loadConfig(url, resourceRoot) { - if (resourceRoot.indexOf('://') >= 0) { - var temp = resourceRoot.split('://'); - resourceRoot = temp[0] + '://' + RES.path.normalize(temp[1] + '/'); - } - else { - resourceRoot = RES.path.normalize(resourceRoot + "/"); - url = url.replace(resourceRoot, ''); - } - RES.setConfigURL(url, resourceRoot); - if (!instance) - instance = new Resource(); - return instance.loadConfig(); - } - RES.loadConfig = loadConfig; - /** - * Load a set of resources according to the group name. - * @param name Group name to load the resource group. - * @param priority Load priority can be negative, the default value is 0. - *
A low priority group must wait for the high priority group to complete the end of the load to start, and the same priority group will be loaded at the same time. - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 根据组名加载一组资源。 - * @param name 要加载资源组的组名。 - * @param priority 加载优先级,可以为负数,默认值为 0。 - *
低优先级的组必须等待高优先级组完全加载结束才能开始,同一优先级的组会同时加载。 - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function loadGroup(name, priority, reporter) { - if (priority === void 0) { priority = 0; } - return instance.loadGroup(name, priority, reporter); - } - RES.loadGroup = loadGroup; - /** - * Check whether a resource group has been loaded. - * @param name Group name。 - * @returns Is loading or not. - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查某个资源组是否已经加载完成。 - * @param name 组名。 - * @returns 是否正在加载。 - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function isGroupLoaded(name) { - return instance.isGroupLoaded(name); - } - RES.isGroupLoaded = isGroupLoaded; - /** - * A list of groups of loading is obtained according to the group name. - * @param name Group name. - * @returns The resource item array of group. - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 根据组名获取组加载项列表。 - * @param name 组名。 - * @returns 加载项列表。 - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function getGroupByName(name) { - return instance.getGroupByName(name).map(function (r) { return RES.ResourceItem.convertToResItem(r); }); - } - RES.getGroupByName = getGroupByName; - /** - * Create a custom load resource group, note that this method is valid only after the resource configuration file is loaded. - *
You can monitor the ResourceEvent.CONFIG_COMPLETE event to verify that the configuration is complete. - * @param name Group name to create the load resource group. - * @param keys To be included in the list of key keys, the corresponding configuration file in the name or sbuKeys property one or a resource group name. - * @param override Is the default false for the same name resource group already exists. - * @returns Create success or fail. - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - *
可以监听 ResourceEvent.CONFIG_COMPLETE 事件来确认配置加载完成。 - * @param name 要创建的加载资源组的组名。 - * @param keys 要包含的键名列表,key 对应配置文件里的 name 属性或 sbuKeys 属性的一项或一个资源组名。 - * @param override 是否覆盖已经存在的同名资源组,默认 false。 - * @returns 是否创建成功。 - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function createGroup(name, keys, override) { - if (override === void 0) { override = false; } - return instance.createGroup(name, keys, override); - } - RES.createGroup = createGroup; - /** - * Check whether the configuration file contains the specified resources. - * @param key A sbuKeys attribute or name property in a configuration file. - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查配置文件里是否含有指定的资源。 - * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function hasRes(key) { - return instance.hasRes(key); - } - RES.hasRes = hasRes; - /** - * The synchronization method for obtaining the cache has been loaded with the success of the resource. - *
The type of resource and the corresponding return value types are as follows: - *
RES.ResourceItem.TYPE_BIN : ArrayBuffer JavaScript primary object - *
RES.ResourceItem.TYPE_IMAGE : img Html Object,or egret.BitmapData interface。 - *
RES.ResourceItem.TYPE_JSON : Object - *
RES.ResourceItem.TYPE_SHEET : Object - *
1. If the incoming parameter is the name of the entire SpriteSheet is returned is {image1: Texture, "image2": Texture}. - *
2. If the incoming is "sheet.image1", the return is a single resource. - *
3. If the incoming is the name of the "image1" single resource, the return is a single resource. - * But if there are two SpriteSheet in a single picture of the same name, the return of the image after the load. - *
RES.ResourceItem.TYPE_SOUND : HtmlSound Html Object - *
RES.ResourceItem.TYPE_TEXT : string - * @param key A subKeys attribute or name property in a configuration file. - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 同步方式获取缓存的已经加载成功的资源。 - *
资源类型和对应的返回值类型关系如下: - *
RES.ResourceItem.TYPE_BIN : ArrayBuffer JavaScript 原生对象 - *
RES.ResourceItem.TYPE_IMAGE : img Html 对象,或者 egret.BitmapData 接口。 - *
RES.ResourceItem.TYPE_JSON : Object - *
RES.ResourceItem.TYPE_SHEET : Object - *
1. 如果传入的参数是整个 SpriteSheet 的名称返回的是 {"image1":Texture,"image2":Texture} 这样的格式。 - *
2. 如果传入的是 "sheet.image1",返回的是单个资源。 - *
3. 如果传入的是 "image1" 单个资源的名称,返回的是单个资源。但是如果有两张 SpriteSheet 中有单个图片资源名称相同,返回的是后加载的那个图片资源。 - *
RES.ResourceItem.TYPE_SOUND : HtmlSound Html 对象 - *
RES.ResourceItem.TYPE_TEXT : string - * @param key 对应配置文件里的 name 属性或 subKeys 属性的一项。 - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function getRes(key) { - return instance.getRes(key); - } - RES.getRes = getRes; - function getResAsync(key, compFunc, thisObject) { - return instance.getResAsync.apply(instance, arguments); - } - RES.getResAsync = getResAsync; - /** - * Access to external resources through the full URL. - * @param url The external path to load the file. - * @param compFunc Call back function. Example:compFunc(data,url):void。 - * @param thisObject This pointer of call back function. - * @param type File type (optional). Use the static constants defined in the ResourceItem class. If you do not set the file name extension. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/resource/GetResByUrl.ts - * @language en_US - */ - /** - * 通过完整URL方式获取外部资源。 - * @param url 要加载文件的外部路径。 - * @param compFunc 回调函数。示例:compFunc(data,url):void。 - * @param thisObject 回调函数的 this 引用。 - * @param type 文件类型(可选)。请使用 ResourceItem 类中定义的静态常量。若不设置将根据文件扩展名生成。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/resource/GetResByUrl.ts - * @language zh_CN - */ - function getResByUrl(url, compFunc, thisObject, type) { - if (type === void 0) { type = ""; } - instance.getResByUrl(url, compFunc, thisObject, type); - } - RES.getResByUrl = getResByUrl; - /** - * Destroy a single resource file or a set of resources to the cache data, to return whether to delete success. - * @param name Name attribute or resource group name of the load item in the configuration file. - * @param force Destruction of a resource group when the other resources groups have the same resource situation whether the resources will be deleted, the default value true. - * @returns Are successful destruction. - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。 - * @param name 配置文件中加载项的name属性或资源组名。 - * @param force 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值 true。 - * @see #setMaxRetryTimes - * @returns 是否销毁成功。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function destroyRes(name, force) { - return instance.destroyRes(name, force); - } - RES.destroyRes = destroyRes; - /** - * Sets the maximum number of concurrent load threads, the default value is 2. - * @param thread The number of concurrent loads to be set. - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置最大并发加载线程数量,默认值是 2。 - * @param thread 要设置的并发加载数。 - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function setMaxLoadingThread(thread) { - if (!instance) - instance = new Resource(); - instance.setMaxLoadingThread(thread); - } - RES.setMaxLoadingThread = setMaxLoadingThread; - /** - * Sets the number of retry times when the resource failed to load, and the default value is 3. - * @param retry To set the retry count. - * @includeExample extension/resource/Resource.ts - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置资源加载失败时的重试次数,默认值是 3。 - * @param retry 要设置的重试次数。 - * @includeExample extension/resource/Resource.ts - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function setMaxRetryTimes(retry) { - instance.setMaxRetryTimes(retry); - } - RES.setMaxRetryTimes = setMaxRetryTimes; - /** - * Add event listeners, reference ResourceEvent defined constants. - * @param type Event name。 - * @param listener Listener functions for handling events. This function must accept the Event object as its only parameter, and can't return any results, - * As shown in the following example: function (evt:Event):void can have any name. - * @param thisObject The this object that is bound to a function. - * @param useCapture Determine the listener is running on the capture or running on the target and the bubbling phase. Set useCapture to true, - * then the listener in the capture phase processing events, but not in the target or the bubbling phase processing events. - * If useCapture is false, then the listener only in the target or the bubbling phase processing events. - * To listen for events in all three stages, please call addEventListener two times: once the useCapture is set to true, once the useCapture is set to false. - * @param priority Event listener priority. Priority is specified by a 32 - bit integer with a symbol. The higher the number, the higher the priority. - * All listeners with a priority for n will be processed before the -1 n listener. - * If two or more listeners share the same priority, they are processed in accordance with the order of their added. The default priority is 0. - * @see RES.ResourceEvent - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 添加事件侦听器,参考 ResourceEvent 定义的常量。 - * @param type 事件的类型。 - * @param listener 处理事件的侦听器函数。此函数必须接受 Event 对象作为其唯一的参数,并且不能返回任何结果, - * 如下面的示例所示: function(evt:Event):void 函数可以有任何名称。 - * @param thisObject 侦听函数绑定的 this 对象。 - * @param useCapture 确定侦听器是运行于捕获阶段还是运行于目标和冒泡阶段。如果将 useCapture 设置为 true, - * 则侦听器只在捕获阶段处理事件,而不在目标或冒泡阶段处理事件。如果 useCapture 为 false,则侦听器只在目标或冒泡阶段处理事件。 - * 要在所有三个阶段都侦听事件,请调用 addEventListener 两次:一次将 useCapture 设置为 true,一次将 useCapture 设置为 false。 - * @param priority 事件侦听器的优先级。优先级由一个带符号的 32 位整数指定。数字越大,优先级越高。优先级为 n 的所有侦听器会在 - * 优先级为 n -1 的侦听器之前得到处理。如果两个或更多个侦听器共享相同的优先级,则按照它们的添加顺序进行处理。默认优先级为 0。 - * @see RES.ResourceEvent - * @see #setMaxRetryTimes - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function addEventListener(type, listener, thisObject, useCapture, priority) { - if (useCapture === void 0) { useCapture = false; } - if (priority === void 0) { priority = 0; } - if (!instance) - instance = new Resource(); - instance.addEventListener(type, listener, thisObject, useCapture, priority); - } - RES.addEventListener = addEventListener; - /** - * Remove event listeners, reference ResourceEvent defined constants. - * @param type Event name。 - * @param listener Listening function。 - * @param thisObject The this object that is bound to a function. - * @param useCapture Is used to capture, and this property is only valid in the display list. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 移除事件侦听器,参考ResourceEvent定义的常量。 - * @param type 事件名。 - * @param listener 侦听函数。 - * @param thisObject 侦听函数绑定的this对象。 - * @param useCapture 是否使用捕获,这个属性只在显示列表中生效。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function removeEventListener(type, listener, thisObject, useCapture) { - if (useCapture === void 0) { useCapture = false; } - instance.removeEventListener(type, listener, thisObject, useCapture); - } - RES.removeEventListener = removeEventListener; - /** - * Adding a custom resource configuration. - * @param data To add configuration. - * @version Egret 3.1.6 - * @platform Web,Native - * @language en_US - */ - /** - * 自定义添加一项资源配置。 - * @param data 要添加的配置。 - * @version Egret 3.1.6 - * @platform Web,Native - * @language zh_CN - */ - function $addResourceData(data) { - //这里可能需要其他配置 - instance.addResourceData(data); - } - RES.$addResourceData = $addResourceData; - /** - * @private - */ - var Resource = (function (_super) { - __extends(Resource, _super); - function Resource() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * 开始加载配置 - * @method RES.loadConfig - */ - Resource.prototype.loadConfig = function () { - var _this = this; - RES.native_init(); - return RES.config.init().then(function (data) { - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.CONFIG_COMPLETE); - }, function (error) { - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.CONFIG_LOAD_ERROR); - return Promise.reject(error); - }); - }; - /** - * 检查某个资源组是否已经加载完成 - * @method RES.isGroupLoaded - * @param name {string} - */ - Resource.prototype.isGroupLoaded = function (name) { - var resources = RES.config.getGroupByName(name, true); - return resources.every(function (r) { return RES.host.get(r) != null; }); - }; - /** - * 根据组名获取组加载项列表 - * @method RES.getGroupByName - * @param name {string} - */ - Resource.prototype.getGroupByName = function (name) { - return RES.config.getGroupByName(name, true); //这里不应该传入 true,但是为了老版本的 TypeScriptCompiler 兼容性,暂时这样做 - }; - /** - * 根据组名加载一组资源 - * @method RES.loadGroup - * @param name {string} - * @param priority {number} - */ - Resource.prototype.loadGroup = function (name, priority, reporter) { - var _this = this; - if (priority === void 0) { priority = 0; } - var reporterDelegate = { - onProgress: function (current, total) { - if (reporter && reporter.onProgress) { - reporter.onProgress(current, total); - } - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.GROUP_PROGRESS, name, undefined, current, total); - } - }; - return this._loadGroup(name, priority, reporterDelegate).then(function (data) { - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.GROUP_COMPLETE, name); - }, function (error) { - var itemList = error.itemList; - var length = itemList.length; - for (var i = 0; i < length; i++) { - var item = itemList[i]; - delete item.promise; - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.ITEM_LOAD_ERROR, name, item); - } - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.GROUP_LOAD_ERROR, name); - return Promise.reject(error.error); - }); - }; - Resource.prototype._loadGroup = function (name, priority, reporter) { - if (priority === void 0) { priority = 0; } - var resources = RES.config.getGroupByName(name, true); - return RES.queue.load(resources, name, priority, reporter); - }; - Resource.prototype.loadResources = function (keys, reporter) { - var resources = keys.map(function (key) { - var r = RES.config.getResourceWithSubkey(key, true); - return r.r; - }); - return RES.queue.load(resources, "name", 0, reporter); - }; - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - * 可以监听ResourceEvent.CONFIG_COMPLETE事件来确认配置加载完成。 - * @method RES.ResourceConfig#createGroup - * @param name {string} 要创建的加载资源组的组名 - * @param keys {egret.Array} 要包含的键名列表,key对应配置文件里的name属性或一个资源组名。 - * @param override {boolean} 是否覆盖已经存在的同名资源组,默认false。 - * @returns {boolean} - */ - Resource.prototype.createGroup = function (name, keys, override) { - if (override === void 0) { override = false; } - return RES.config.createGroup(name, keys, override); - }; - /** - * 检查配置文件里是否含有指定的资源 - * @method RES.hasRes - * @param key {string} 对应配置文件里的name属性或subKeys属性的一项。 - * @returns {boolean} - */ - Resource.prototype.hasRes = function (key) { - return RES.config.getResourceWithSubkey(key) != null; - }; - /** - * 通过key同步获取资源 - * @method RES.getRes - * @param key {string} - * @returns {any} - */ - Resource.prototype.getRes = function (resKey) { - var result = RES.config.getResourceWithSubkey(resKey); - if (result) { - var r = result.r; - var key = result.key; - var subkey = result.subkey; - var p = RES.processor.isSupport(r); - if (p && p.getData && subkey) { - return p.getData(RES.host, r, key, subkey); - } - else { - return RES.host.get(r); - } - } - else { - return null; - } - }; - Resource.prototype.getResAsync = function (key, compFunc, thisObject) { - var _this = this; - var paramKey = key; - var _a = RES.config.getResourceWithSubkey(key, true), r = _a.r, subkey = _a.subkey; - return RES.queue.loadResource(r).then(function (value) { - RES.host.save(r, value); - var p = RES.processor.isSupport(r); - if (p && p.getData && subkey) { - value = p.getData(RES.host, r, key, subkey); - } - if (compFunc) { - compFunc.call(thisObject, value, paramKey); - } - return value; - }, function (error) { - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.ITEM_LOAD_ERROR, "", r); - return Promise.reject(error); - }); - }; - /** - * 通过url获取资源 - * @method RES.getResByUrl - * @param url {string} - * @param compFunc {Function} - * @param thisObject {any} - * @param type {string} - */ - Resource.prototype.getResByUrl = function (url, compFunc, thisObject, type) { - var _this = this; - if (type === void 0) { type = ""; } - var r = RES.config.getResource(url); - if (!r) { - if (!type) { - type = RES.config.__temp__get__type__via__url(url); - } - // manager.config.addResourceData({ name: url, url: url }); - r = { name: url, url: url, type: type, root: '' }; - RES.config.addResourceData(r); - r = RES.config.getResource(url); - if (!r) { - throw 'never'; - } - } - return RES.queue.loadResource(r).then(function (value) { - RES.host.save(r, value); - if (compFunc && r) { - compFunc.call(thisObject, value, r.url); - } - return value; - }, function (error) { - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.ITEM_LOAD_ERROR, "", r); - return Promise.reject(error); - }); - }; - /** - * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。 - * @method RES.destroyRes - * @param name {string} 配置文件中加载项的name属性或资源组名 - * @param force {boolean} 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值true - * @returns {boolean} - */ - Resource.prototype.destroyRes = function (name, force) { - if (force === void 0) { force = true; } - return __awaiter(this, void 0, void 0, function () { - var group, remove, _i, group_2, item, item; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - group = RES.config.getGroup(name); - remove = function (r) { - return RES.queue.unloadResource(r); - }; - if (!(group && group.length > 0)) return [3 /*break*/, 5]; - _i = 0, group_2 = group; - _a.label = 1; - case 1: - if (!(_i < group_2.length)) return [3 /*break*/, 4]; - item = group_2[_i]; - return [4 /*yield*/, remove(item)]; - case 2: - _a.sent(); - _a.label = 3; - case 3: - _i++; - return [3 /*break*/, 1]; - case 4: return [2 /*return*/, true]; - case 5: - item = RES.config.getResource(name); - if (!item) return [3 /*break*/, 7]; - return [4 /*yield*/, remove(item)]; - case 6: - _a.sent(); - return [2 /*return*/, true]; - case 7: - console.warn("\u65E0\u6CD5\u5220\u9664\u6307\u5B9A\u7EC4:" + name); - return [2 /*return*/, false]; - } - }); - }); - }; - /** - * 设置最大并发加载线程数量,默认值是2. - * @method RES.setMaxLoadingThread - * @param thread {number} 要设置的并发加载数。 - */ - Resource.prototype.setMaxLoadingThread = function (thread) { - if (thread < 1) { - thread = 1; - } - RES.queue.thread = thread; - }; - /** - * 设置资源加载失败时的重试次数。 - * @param retry 要设置的重试次数。 - */ - Resource.prototype.setMaxRetryTimes = function (retry) { - retry = Math.max(retry, 0); - RES.queue.maxRetryTimes = retry; - }; - Resource.prototype.addResourceData = function (data) { - RES.config.addResourceData(data); - }; - __decorate([ - RES.checkCancelation - ], Resource.prototype, "loadConfig", null); - __decorate([ - RES.checkCancelation - ], Resource.prototype, "_loadGroup", null); - __decorate([ - RES.checkNull - ], Resource.prototype, "hasRes", null); - __decorate([ - RES.checkNull - ], Resource.prototype, "getRes", null); - __decorate([ - RES.checkNull, - RES.checkCancelation - ], Resource.prototype, "getResAsync", null); - __decorate([ - RES.checkNull, - RES.checkCancelation - ], Resource.prototype, "getResByUrl", null); - return Resource; - }(egret.EventDispatcher)); - RES.Resource = Resource; - __reflect(Resource.prototype, "RES.Resource"); - /** - * Resource单例 - */ - var instance; -})(RES || (RES = {})); diff --git a/helloworld/libs/modules/assetsmanager/assetsmanager.min.js b/helloworld/libs/modules/assetsmanager/assetsmanager.min.js deleted file mode 100644 index 1633e3f..0000000 --- a/helloworld/libs/modules/assetsmanager/assetsmanager.min.js +++ /dev/null @@ -1 +0,0 @@ -var __reflect=this&&this.__reflect||function(e,r,t){e.__class__=r,t?t.push(r):t=[r],e.__types__=e.__types__?t.concat(e.__types__):t},__extends=this&&this.__extends||function(e,r){function t(){this.constructor=e}for(var o in r)r.hasOwnProperty(o)&&(e[o]=r[o]);t.prototype=r.prototype,e.prototype=new t},__awaiter=this&&this.__awaiter||function(e,r,t,o){return new(t||(t=Promise))(function(n,i){function a(e){try{u(o.next(e))}catch(r){i(r)}}function s(e){try{u(o["throw"](e))}catch(r){i(r)}}function u(e){e.done?n(e.value):new t(function(r){r(e.value)}).then(a,s)}u((o=o.apply(e,r||[])).next())})},__generator=this&&this.__generator||function(e,r){function t(e){return function(r){return o([e,r])}}function o(t){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,i&&(a=i[2&t[0]?"return":t[0]?"throw":"next"])&&!(a=a.call(i,t[1])).done)return a;switch(i=0,a&&(t=[0,a.value]),t[0]){case 0:case 1:a=t;break;case 4:return u.label++,{value:t[1],done:!1};case 5:u.label++,i=t[1],t=[0];continue;case 7:t=u.ops.pop(),u.trys.pop();continue;default:if(a=u.trys,!(a=a.length>0&&a[a.length-1])&&(6===t[0]||2===t[0])){u=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]i?r:null===o?o=Object.getOwnPropertyDescriptor(r,t):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,r,t,o);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(3>i?n(a):i>3?n(r,t,a):n(r,t))||a);return i>3&&a&&Object.defineProperty(r,t,a),a},RES;!function(e){function r(r){var t=e.fileSystem.getFile(r);return t||(r=e.resourceNameSelector(r),t=e.fileSystem.getFile(r)),t}function t(e,r){var t;t=e.indexOf(".json")>=0?"legacyResourceConfig":"resourceConfig",o={type:t,root:r,url:e,name:e}}e.resourceNameSelector=function(e){return e},e.getResourceInfo=r;var o;e.setConfigURL=t;var n=function(){function t(){}return t.prototype.init=function(){var r=this;return this.config||(this.config={alias:{},groups:{},resourceRoot:o.root,typeSelector:function(){return"unknown"},mergeSelector:null,fileSystem:null}),e.queue.loadResource(o).then(function(e){return r.parseConfig(e)})["catch"](function(r){return r.__resource_manager_error__||(console.error(r.stack),r=new e.ResourceManagerError(1002)),Promise.reject(r)})},t.prototype.getGroupByName=function(r,t){var o=this.config.groups[r],n=[];if(!o){if(t)throw new e.ResourceManagerError(2005,r);return null}for(var i=0,a=o;i=0&&(n=r.substr(o+1),r=r.substr(0,o));var i=this.getResource(r);if(i)return{r:i,key:r,subkey:n};if(t){var a=n?r+"#"+n:r;throw new e.ResourceManagerError(2006,a)}return null},t.prototype.getKeyByAlias=function(e){return this.config.alias[e]?this.config.alias[e]:e},t.prototype.getResource=function(t,o){var n=this.config.alias[t];n||(n=t);var i=r(n);if(!i){if(o)throw new e.ResourceManagerError(2006,t);return null}return i},t.prototype.getGroup=function(e){return this.getGroupByName(e)},t.prototype.createGroup=function(e,r,t){if(void 0===t&&(t=!1),!t&&this.config.groups[e]||!r||0==r.length)return!1;for(var o=[],n=0,i=r;nu;u++){var c=e[u];c.groupNames||(c.groupNames=[]),c.groupNames.push(r)}this.itemListDic[r]=e,this.groupTotalDic[r]=e.length,this.numLoadedDic[r]=0,this.priorityQueue[t]?this.priorityQueue[t].push(r):this.priorityQueue[t]=[r],this.reporterDic[r]=o;var f=new egret.EventDispatcher;this.dispatcherDic[r]=f;var l=new Promise(function(e,r){f.addEventListener("complete",e,null),f.addEventListener("error",function(e){r(e.data)},null)});return this.next(),l},r.prototype.next=function(){for(var r=this,t=function(){var t=o.getOneResourceInfo();return t?(o.loadingCount++,void o.loadResource(t).then(function(o){r.loadingCount--,e.host.save(t,o);var n=t.groupNames.shift();0==t.groupNames.length&&(t.groupNames=void 0);var i=r.reporterDic[n];r.numLoadedDic[n]++;var a=r.numLoadedDic[n],s=r.groupTotalDic[n];if(i&&i.onProgress&&i.onProgress(a,s),a==s){var u=r.groupErrorDic[n];r.removeGroupName(n),delete r.groupTotalDic[n],delete r.numLoadedDic[n],delete r.itemListDic[n],delete r.groupErrorDic[n];var c=r.dispatcherDic[n];if(u){var f=r.loadItemErrorDic[n];delete r.loadItemErrorDic[n];var l=r.errorDic[n];delete r.errorDic[n],c.dispatchEventWith("error",!1,{itemList:f,error:l})}else c.dispatchEventWith("complete")}r.next()})["catch"](function(o){if(!o)throw t.name+" load fail";if(!o.__resource_manager_error__)throw o;r.loadingCount--,delete e.host.state[t.root+t.name];var n=r.retryTimesDic[t.name]||1;if(!(n>r.maxRetryTimes))return r.retryTimesDic[t.name]=n+1,r.failedList.push(t),void r.next();delete r.retryTimesDic[t.name];var i=t.groupNames.shift();0==t.groupNames.length&&delete t.groupNames,r.loadItemErrorDic[i]||(r.loadItemErrorDic[i]=[]),-1==r.loadItemErrorDic[i].indexOf(t)&&r.loadItemErrorDic[i].push(t),r.groupErrorDic[i]=!0;var a=r.reporterDic[i];r.numLoadedDic[i]++;var s=r.numLoadedDic[i],u=r.groupTotalDic[i];if(a&&a.onProgress&&a.onProgress(s,u),s==u){r.groupErrorDic[i];r.removeGroupName(i),delete r.groupTotalDic[i],delete r.numLoadedDic[i],delete r.itemListDic[i],delete r.groupErrorDic[i];var c=r.loadItemErrorDic[i];delete r.loadItemErrorDic[i];var f=r.dispatcherDic[i];f.dispatchEventWith("error",!1,{itemList:c,error:o})}else r.errorDic[i]=o;r.next()})):"break"},o=this;this.loadingCounta;a++){var s=t[a];if(s==e){t.splice(o,1),n=!0;break}o++}if(n){0==t.length&&delete this.priorityQueue[r];break}}},r.prototype.getOneResourceInfo=function(){if(this.failedList.length>0)return this.failedList.shift();var e=Number.NEGATIVE_INFINITY;for(var r in this.priorityQueue)e=Math.max(e,r);var t=this.priorityQueue[e];if(t&&0!=t.length){for(var o=t.length,n=[],i=0;o>i&&(this.queueIndex>=o&&(this.queueIndex=0),n=this.itemListDic[t[this.queueIndex]],!(n.length>0));i++)this.queueIndex++;if(0!=n.length)return n.shift()}},r.prototype.loadResource=function(r,t){if(!t){if(1==e.FEATURE_FLAG.FIX_DUPLICATE_LOAD){var o=e.host.state[r.root+r.name];if(2==o)return Promise.resolve(e.host.get(r));if(1==o)return r.promise}t=e.processor.isSupport(r)}if(!t)throw new e.ResourceManagerError(2001,r.name,r.type);e.host.state[r.root+r.name]=1;var n=t.onLoadStart(e.host,r);return r.promise=n,n},r.prototype.unloadResource=function(r){var t=e.host.get(r);if(!t)return console.warn("尝试释放不存在的资源:",r.name),Promise.resolve();var o=e.processor.isSupport(r);if(o){e.host.state[r.root+r.name]=3;var n=o.onRemoveStart(e.host,r);return e.host.remove(r),n}return Promise.resolve()},r}();e.ResourceLoader=r,__reflect(r.prototype,"RES.ResourceLoader")}(RES||(RES={}));var RES;!function(e){function r(){e.fileSystem.profile(),console.log(t);var r=0;for(var o in t){var n=t[o];n instanceof egret.Texture&&(r+=n.$bitmapWidth*n.$bitmapHeight*4)}console.log("gpu size : "+(r/1024).toFixed(3)+"kb")}var t={};e.systemPid=0,e.checkCancelation=function(r,t,n){var i=n.value;n.value=function(){for(var r=[],t=0;t0;_===h?(i=R?e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,n=4):_===v?(i=R?e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,n=2):(o(r,"pvr v2 parse error"),console.log("unknow format flags::"+_));var m=s;r.pvrtcData=new Uint8Array(r.buffer,m),r.bpp=n,r.format=i,r.width=c,r.height=u,r.surfacesCount=d,r.mipmapsCount=f+1,r.isCubemap=6===r.surfacesCount,t(r)},e._parseV3=function(r,t,o){var n,i,a=r.header,s=a[2];switch(s){case 0:n=2,i=e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;break;case 1:n=2,i=e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;break;case 2:n=4,i=e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;break;case 3:n=4,i=e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;break;default:o(r,"pvr v3 parse error"),console.log("unknow pixel format::"+s)}var u=52+a[12];r.pvrtcData=new Uint8Array(r.buffer,u),r.bpp=n,r.format=i,r.width=a[7],r.height=a[6],r.surfacesCount=a[10],r.mipmapsCount=a[11],r.isCubemap=6===r.surfacesCount,t(r)},e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840,e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841,e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842,e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843,e}();__reflect(c.prototype,"PVRParser"),"undefined"!=typeof egret&&egret&&egret.web&&egret.web.WebGLRenderContext&&(egret.web.WebGLRenderContext.prototype.createTextureFromCompressedData=function(e,r,t,o,n){var i=this.context;this.pvrtcExt||(this.pvrtcExt=i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"));var a=i.createTexture();i.bindTexture(i.TEXTURE_2D,a);for(var u=0,c=0;o>c;++c){var f=s(n,r,t),l=new Uint8Array(e.buffer,e.byteOffset+u,f);i.compressedTexImage2D(i.TEXTURE_2D,c,n,r,t,0,l),r>>=1,1>r&&(r=1),t>>=1,1>t&&(t=1),u+=f}return i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),a}),r.PVRProcessor={onLoadStart:function(e,r){return __awaiter(this,void 0,void 0,function(){var t,o,n,i,a,s,u,f,l,p,d,g,v;return __generator(this,function(h){switch(h.label){case 0:return[4,e.load(r,"bin")];case 1:for(t=h.sent(),o=512,n=512,i=0,a=0,s=new egret.ByteArray(t),s.position=7,u=["body","ext"],l=0;l=0){var o=t.split("://");t=o[0]+"://"+e.path.normalize(o[1]+"/")}else t=e.path.normalize(t+"/"),r=r.replace(t,"");return e.setConfigURL(r,t),R||(R=new _),R.loadConfig()}function o(e,r,t){return void 0===r&&(r=0),R.loadGroup(e,r,t)}function n(e){return R.isGroupLoaded(e)}function i(r){return R.getGroupByName(r).map(function(r){return e.ResourceItem.convertToResItem(r)})}function a(e,r,t){return void 0===t&&(t=!1),R.createGroup(e,r,t)}function s(e){return R.hasRes(e)}function u(e){return R.getRes(e)}function c(e,r,t){return R.getResAsync.apply(R,arguments)}function f(e,r,t,o){void 0===o&&(o=""),R.getResByUrl(e,r,t,o)}function l(e,r){return R.destroyRes(e,r)}function p(e){R||(R=new _),R.setMaxLoadingThread(e)}function d(e){R.setMaxRetryTimes(e)}function g(e,r,t,o,n){void 0===o&&(o=!1),void 0===n&&(n=0),R||(R=new _),R.addEventListener(e,r,t,o,n)}function v(e,r,t,o){void 0===o&&(o=!1),R.removeEventListener(e,r,t,o)}function h(e){R.addResourceData(e)}e.nameSelector=function(r){return e.path.basename(r).split(".").join("_")},e.registerAnalyzer=r,e.loadConfig=t,e.loadGroup=o,e.isGroupLoaded=n,e.getGroupByName=i,e.createGroup=a,e.hasRes=s,e.getRes=u,e.getResAsync=c,e.getResByUrl=f,e.destroyRes=l,e.setMaxLoadingThread=p,e.setMaxRetryTimes=d,e.addEventListener=g,e.removeEventListener=v,e.$addResourceData=h;var _=function(r){function t(){return null!==r&&r.apply(this,arguments)||this}return __extends(t,r),t.prototype.loadConfig=function(){var r=this;return e.native_init(),e.config.init().then(function(t){e.ResourceEvent.dispatchResourceEvent(r,e.ResourceEvent.CONFIG_COMPLETE)},function(t){return e.ResourceEvent.dispatchResourceEvent(r,e.ResourceEvent.CONFIG_LOAD_ERROR),Promise.reject(t)})},t.prototype.isGroupLoaded=function(r){var t=e.config.getGroupByName(r,!0);return t.every(function(r){return null!=e.host.get(r)})},t.prototype.getGroupByName=function(r){return e.config.getGroupByName(r,!0)},t.prototype.loadGroup=function(r,t,o){var n=this;void 0===t&&(t=0);var i={onProgress:function(t,i){o&&o.onProgress&&o.onProgress(t,i),e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.GROUP_PROGRESS,r,void 0,t,i)}};return this._loadGroup(r,t,i).then(function(t){e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.GROUP_COMPLETE,r)},function(t){for(var o=t.itemList,i=o.length,a=0;i>a;a++){var s=o[a];delete s.promise,e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.ITEM_LOAD_ERROR,r,s)}return e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.GROUP_LOAD_ERROR,r),Promise.reject(t.error)})},t.prototype._loadGroup=function(r,t,o){void 0===t&&(t=0);var n=e.config.getGroupByName(r,!0);return e.queue.load(n,r,t,o)},t.prototype.loadResources=function(r,t){var o=r.map(function(r){var t=e.config.getResourceWithSubkey(r,!0);return t.r});return e.queue.load(o,"name",0,t)},t.prototype.createGroup=function(r,t,o){return void 0===o&&(o=!1),e.config.createGroup(r,t,o)},t.prototype.hasRes=function(r){return null!=e.config.getResourceWithSubkey(r)},t.prototype.getRes=function(r){var t=e.config.getResourceWithSubkey(r);if(t){var o=t.r,n=t.key,i=t.subkey,a=e.processor.isSupport(o);return a&&a.getData&&i?a.getData(e.host,o,n,i):e.host.get(o)}return null},t.prototype.getResAsync=function(r,t,o){var n=this,i=r,a=e.config.getResourceWithSubkey(r,!0),s=a.r,u=a.subkey;return e.queue.loadResource(s).then(function(n){e.host.save(s,n);var a=e.processor.isSupport(s);return a&&a.getData&&u&&(n=a.getData(e.host,s,r,u)),t&&t.call(o,n,i),n},function(r){return e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.ITEM_LOAD_ERROR,"",s),Promise.reject(r)})},t.prototype.getResByUrl=function(r,t,o,n){var i=this;void 0===n&&(n="");var a=e.config.getResource(r);if(!a&&(n||(n=e.config.__temp__get__type__via__url(r)),a={name:r,url:r,type:n,root:""},e.config.addResourceData(a),a=e.config.getResource(r),!a))throw"never";return e.queue.loadResource(a).then(function(r){return e.host.save(a,r),t&&a&&t.call(o,r,a.url),r},function(r){return e.ResourceEvent.dispatchResourceEvent(i,e.ResourceEvent.ITEM_LOAD_ERROR,"",a),Promise.reject(r)})},t.prototype.destroyRes=function(r,t){return void 0===t&&(t=!0),__awaiter(this,void 0,void 0,function(){var t,o,n,i,a,a;return __generator(this,function(s){switch(s.label){case 0:if(t=e.config.getGroup(r),o=function(r){return e.queue.unloadResource(r)},!(t&&t.length>0))return[3,5];n=0,i=t,s.label=1;case 1:return nr&&(r=1),e.queue.thread=r},t.prototype.setMaxRetryTimes=function(r){r=Math.max(r,0),e.queue.maxRetryTimes=r},t.prototype.addResourceData=function(r){e.config.addResourceData(r)},__decorate([e.checkCancelation],t.prototype,"loadConfig",null),__decorate([e.checkCancelation],t.prototype,"_loadGroup",null),__decorate([e.checkNull],t.prototype,"hasRes",null),__decorate([e.checkNull],t.prototype,"getRes",null),__decorate([e.checkNull,e.checkCancelation],t.prototype,"getResAsync",null),__decorate([e.checkNull,e.checkCancelation],t.prototype,"getResByUrl",null),t}(egret.EventDispatcher);e.Resource=_,__reflect(_.prototype,"RES.Resource");var R}(RES||(RES={}));var RES;!function(e){var r=function(r){function t(e,t,o){void 0===t&&(t=!1),void 0===o&&(o=!1);var n=r.call(this,e,t,o)||this;return n.itemsLoaded=0,n.itemsTotal=0,n.groupName="",n}return __extends(t,r),t.dispatchResourceEvent=function(r,o,n,i,a,s){void 0===n&&(n=""),void 0===i&&(i=void 0),void 0===a&&(a=0),void 0===s&&(s=0);var u=egret.Event.create(t,o);u.groupName=n,i&&(u.resItem=e.ResourceItem.convertToResItem(i)),u.itemsLoaded=a,u.itemsTotal=s;var c=r.dispatchEvent(u);return egret.Event.release(u),c},t.ITEM_LOAD_ERROR="itemLoadError",t.CONFIG_COMPLETE="configComplete",t.CONFIG_LOAD_ERROR="configLoadError",t.GROUP_PROGRESS="groupProgress",t.GROUP_COMPLETE="groupComplete",t.GROUP_LOAD_ERROR="groupLoadError",t}(egret.Event);e.ResourceEvent=r,__reflect(r.prototype,"RES.ResourceEvent")}(RES||(RES={}));var RES;!function(e){var r;!function(r){function t(r){var t=r.name;if(e.config.config)for(var o in e.config.config.alias)e.config.config.alias[o]==r.url&&(t=o);else t=r.url;var n={name:t,url:r.url,type:r.type,data:r,root:r.root};return n}r.TYPE_XML="xml",r.TYPE_IMAGE="image",r.TYPE_BIN="bin",r.TYPE_TEXT="text",r.TYPE_JSON="json",r.TYPE_SHEET="sheet",r.TYPE_FONT="font",r.TYPE_SOUND="sound",r.convertToResItem=t}(r=e.ResourceItem||(e.ResourceItem={}))}(RES||(RES={}));var RES;!function(e){var r;!function(e){e.normalize=function(e){var r=e.split("/");return r.filter(function(e,t){return!!e||t==r.length-1}).join("/")},e.basename=function(e){return e.substr(e.lastIndexOf("/")+1)},e.dirname=function(e){return e.substr(0,e.lastIndexOf("/"))}}(r=e.path||(e.path={}))}(RES||(RES={}));var RES;!function(e){function r(){egret.Capabilities.runtimeType==egret.RuntimeType.NATIVE&&(n=o("all.manifest"))}function t(e){return n&&n[e]?"resource/"+n[e].v.substring(0,2)+"/"+n[e].v+"_"+n[e].s+"."+e.substring(e.lastIndexOf(".")+1):e}function o(e){if(egret_native.readUpdateFileSync&&egret_native.readResourceFileSync){var r=egret_native.readUpdateFileSync(e);if(null!=r)return JSON.parse(r);if(r=egret_native.readResourceFileSync(e),null!=r)return JSON.parse(r)}return null}var n;e.native_init=r,e.getRealURL=t}(RES||(RES={}));var RES;!function(e){var r=function(){function r(e){this.data=e}return r.prototype.profile=function(){console.log(this.data)},r.prototype.addFile=function(r,t){t||(t=""),r=e.path.normalize(r);var o=e.path.basename(r),n=e.path.dirname(r);this.exists(n)||this.mkdir(n);var i=this.reslove(n);i[o]={url:r,type:t}},r.prototype.getFile=function(e){var r=this.reslove(e);return r&&(r.name=e),r},r.prototype.reslove=function(r){if(""==r)return this.data;r=e.path.normalize(r);for(var t=r.split("/"),o=this.data,n=0,i=t;n - * the capture phase comprises the journey from the root to the last node before the event target's node, the target - * phase comprises only the event target node, and the bubbling phase comprises any subsequent nodes encountered on - * the return trip to the root of the display list. In general, the easiest way for a user-defined class to gain event - * dispatching capabilities is to extend EventDispatcher. If this is impossible (that is, if the class is already extending - * another class), you can instead implement the IEventDispatcher interface, create an EventDispatcher member, and write simple - * hooks to route calls into the aggregated EventDispatcher. - * @see egret.IEventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventDispatcher.ts - * @language en_US - */ - /** - * EventDispatcher 是 Egret 的事件派发器类,负责进行事件的发送和侦听。 - * 事件目标是事件如何通过显示列表层次结构这一问题的焦点。当发生鼠标单击、触摸或按键等事件时, - * 框架会将事件对象调度到从显示列表根开始的事件流中。然后该事件对象在显示列表中前进,直到到达事件目标, - * 然后从这一点开始其在显示列表中的回程。在概念上,到事件目标的此往返行程被划分为三个阶段: - * 捕获阶段包括从根到事件目标节点之前的最后一个节点的行程,目标阶段仅包括事件目标节点,冒泡阶段包括回程上遇到的任何后续节点到显示列表的根。 - * 通常,使用户定义的类能够调度事件的最简单方法是扩展 EventDispatcher。如果无法扩展(即,如果该类已经扩展了另一个类),则可以实现 - * IEventDispatcher 接口,创建 EventDispatcher 成员,并编写一些简单的映射,将调用连接到聚合的 EventDispatcher 中。 - * @see egret.IEventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventDispatcher.ts - * @language zh_CN - */ - class EventDispatcher extends HashObject implements IEventDispatcher { - /** - * create an instance of the EventDispatcher class. - * @param target The target object for events dispatched to the EventDispatcher object. This parameter is used when - * the EventDispatcher instance is aggregated by a class that implements IEventDispatcher; it is necessary so that the - * containing object can be the target for events. Do not use this parameter in simple cases in which a class extends EventDispatcher. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 EventDispatcher 类的实例 - * @param target 此 EventDispatcher 所抛出事件对象的 target 指向。此参数主要用于一个实现了 IEventDispatcher 接口的自定义类, - * 以便抛出的事件对象的 target 属性可以指向自定义类自身。请勿在直接继承 EventDispatcher 的情况下使用此参数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(target?: IEventDispatcher); - /** - * @private - */ - $EventDispatcher: Object; - /** - * @private - * - * @param useCapture - */ - $getEventMap(useCapture?: boolean): any; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - once(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * @private - */ - $addListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number, dispatchOnce?: boolean): void; - $insertEventBin(list: any[], type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number, dispatchOnce?: boolean): boolean; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - removeEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean): void; - $removeEventBin(list: any[], listener: Function, thisObject: any): boolean; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - hasEventListener(type: string): boolean; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - willTrigger(type: string): boolean; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - dispatchEvent(event: Event): boolean; - /** - * @private - */ - $notifyListener(event: Event, capturePhase: boolean): boolean; - /** - * Distribute a specified event parameters. - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param data {any} data - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 派发一个指定参数的事件。 - * @param type {string} 事件类型 - * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param data {any} 事件data - * @param cancelable {boolean} 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dispatchEventWith(type: string, bubbles?: boolean, data?: any, cancelable?: boolean): boolean; - } -} -declare namespace egret.sys { - /** - * @private - * 事件信息对象 - */ - interface EventBin { - type: string; - /** - * @private - */ - listener: Function; - /** - * @private - */ - thisObject: any; - /** - * @private - */ - priority: number; - /** - * @private - */ - target: IEventDispatcher; - /** - * @private - */ - useCapture: boolean; - /** - * @private - */ - dispatchOnce: boolean; - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - class Filter extends HashObject { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - type: string; - /** - * @private - */ - $id: number; - /** - * @private - */ - $uniforms: any; - /** - * @private - */ - protected paddingTop: number; - /** - * @private - */ - protected paddingBottom: number; - /** - * @private - */ - protected paddingLeft: number; - /** - * @private - */ - protected paddingRight: number; - /** - * @private - * @native Render - */ - $obj: any; - constructor(); - /** - * @private - */ - $toJson(): string; - protected updatePadding(): void; - onPropertyChange(): void; - } -} -declare namespace egret { - /** - * @private - */ - const enum RenderMode { - NONE = 1, - FILTER = 2, - CLIP = 3, - SCROLLRECT = 4, - } - /** - * The DisplayObject class is the base class for all objects that can be placed on the display list. The display list - * manages all objects displayed in the runtime. Use the DisplayObjectContainer class to arrange the display - * objects in the display list. DisplayObjectContainer objects can have child display objects, while other display objects, - * such as Shape and TextField objects, are "leaf" nodes that have only parents and siblings, no children. - * The DisplayObject class supports basic functionality like the x and y position of an object, as well as more advanced - * properties of the object such as its transformation matrix.
- * The DisplayObject class contains several broadcast events.Normally, the target of any particular event is a specific - * DisplayObject instance. For example, the target of an added event is the specific DisplayObject instance that was added - * to the display list. Having a single target restricts the placement of event listeners to that target and in some cases - * the target's ancestors on the display list. With broadcast events, however, the target is not a specific DisplayObject - * instance, but rather all DisplayObject instances, including those that are not on the display list. This means that you - * can add a listener to any DisplayObject instance to listen for broadcast events. - * - * @event egret.Event.ADDED Dispatched when a display object is added to the display list. - * @event egret.Event.ADDED_TO_STAGE Dispatched when a display object is added to the on stage display list, either directly or through the addition of a sub tree in which the display object is contained. - * @event egret.Event.REMOVED Dispatched when a display object is about to be removed from the display list. - * @event egret.Event.REMOVED_FROM_STAGE Dispatched when a display object is about to be removed from the display list, either directly or through the removal of a sub tree in which the display object is contained. - * @event egret.Event.ENTER_FRAME [broadcast event] Dispatched when the playhead is entering a new frame. - * @event egret.Event.RENDER [broadcast event] Dispatched when the display list is about to be updated and rendered. - * @event egret.TouchEvent.TOUCH_MOVE Dispatched when the user touches the device, and is continuously dispatched until the point of contact is removed. - * @event egret.TouchEvent.TOUCH_BEGIN Dispatched when the user first contacts a touch-enabled device (such as touches a finger to a mobile phone or tablet with a touch screen). - * @event egret.TouchEvent.TOUCH_END Dispatched when the user removes contact with a touch-enabled device (such as lifts a finger off a mobile phone or tablet with a touch screen). - * @event egret.TouchEvent.TOUCH_TAP Dispatched when the user lifts the point of contact over the same DisplayObject instance on which the contact was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display object on a mobile phone or tablet with a touch screen). - * @event egret.TouchEvent.TOUCH_RELEASE_OUTSIDE Dispatched when the user lifts the point of contact over the different DisplayObject instance on which the contact was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display object on a mobile phone or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObject.ts - * @language en_US - */ - /** - * DisplayObject 类是可放在显示列表中的所有对象的基类。该显示列表管理运行时中显示的所有对象。使用 DisplayObjectContainer 类排列 - * 显示列表中的显示对象。DisplayObjectContainer 对象可以有子显示对象,而其他显示对象(如 Shape 和 TextField 对象)是“叶”节点,没有子项,只有父级和 - * 同级。DisplayObject 类有一些基本的属性(如确定坐标位置的 x 和 y 属性),也有一些高级的对象属性(如 Matrix 矩阵变换)。
- * DisplayObject 类包含若干广播事件。通常,任何特定事件的目标均为一个特定的 DisplayObject 实例。例如,added 事件的目标是已添加到显示列表 - * 的目标 DisplayObject 实例。若只有一个目标,则会将事件侦听器限制为只能监听在该目标上(在某些情况下,可监听在显示列表中该目标的祖代上)。 - * 但是对于广播事件,目标不是特定的 DisplayObject 实例,而是所有 DisplayObject 实例(包括那些不在显示列表中的实例)。这意味着您可以向任何 - * DisplayObject 实例添加侦听器来侦听广播事件。 - * - * @event egret.Event.ADDED 将显示对象添加到显示列表中时调度。 - * @event egret.Event.ADDED_TO_STAGE 在将显示对象直接添加到舞台显示列表或将包含显示对象的子树添加至舞台显示列表中时调度。 - * @event egret.Event.REMOVED 将要从显示列表中删除显示对象时调度。 - * @event egret.Event.REMOVED_FROM_STAGE 在从显示列表中直接删除显示对象或删除包含显示对象的子树时调度。 - * @event egret.Event.ENTER_FRAME [广播事件] 播放头进入新帧时调度。 - * @event egret.Event.RENDER [广播事件] 将要更新和呈现显示列表时调度。 - * @event egret.TouchEvent.TOUCH_MOVE 当用户触碰设备时进行调度,而且会连续调度,直到接触点被删除。 - * @event egret.TouchEvent.TOUCH_BEGIN 当用户第一次触摸启用触摸的设备时(例如,用手指触摸手机屏幕)调度。 - * @event egret.TouchEvent.TOUCH_END 当用户移除与启用触摸的设备的接触时(例如,将手指从屏幕上抬起)调度。 - * @event egret.TouchEvent.TOUCH_TAP 当用户在启用触摸设备上的已启动接触的同一 DisplayObject 实例上抬起接触点时(例如,手机点击屏幕后抬起)调度。 - * @event egret.TouchEvent.TOUCH_RELEASE_OUTSIDE 当用户在启用触摸设备上的已启动接触的不同 DisplayObject 实例上抬起接触点时(例如,按住屏幕上的某个对象,然后从它上面挪开后再松开手指)调度。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObject.ts - * @language zh_CN - */ - class DisplayObject extends EventDispatcher { - /** - * Initializes a DisplayObject object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个显示对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - $nativeDisplayObject: egret_native.NativeDisplayObject; - protected createNativeDisplayObject(): void; - /** - * @private - * 是否添加到舞台上,防止重复发送 removed_from_stage 消息 - */ - $hasAddToStage: boolean; - /** - * @private - * 能够含有子项的类将子项列表存储在这个属性里。 - */ - $children: DisplayObject[]; - private $name; - /** - * Indicates the instance name of the DisplayObject. The object can be identified in the child list of its parent - * display object container by calling the getChildByName() method of the display object container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 的实例名称。 - * 通过调用父显示对象容器的 getChildByName() 方法,可以在父显示对象容器的子列表中标识该对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - name: string; - /** - * @private - */ - $parent: DisplayObjectContainer; - /** - * Indicates the DisplayObjectContainer object that contains this display object. Use the parent property to specify - * a relative path to display objects that are above the current display object in the display list hierarchy. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示包含此显示对象的 DisplayObjectContainer 对象。 - * 使用 parent 属性可以指定高于显示列表层次结构中当前显示对象的显示对象的相对路径。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly parent: DisplayObjectContainer; - /** - * @private - * 设置父级显示对象 - */ - $setParent(parent: DisplayObjectContainer): void; - /** - * @private - * 显示对象添加到舞台 - */ - $onAddToStage(stage: Stage, nestLevel: number): void; - /** - * @private - * 显示对象从舞台移除 - */ - $onRemoveFromStage(): void; - /** - * @private - */ - $stage: Stage; - /** - * @private - * 这个对象在显示列表中的嵌套深度,舞台为1,它的子项为2,子项的子项为3,以此类推。当对象不在显示列表中时此属性值为0. - */ - $nestLevel: number; - $useTranslate: boolean; - protected $updateUseTransform(): void; - /** - * The Stage of the display object. you can create and load multiple display objects into the display list, and - * the stage property of each display object refers to the same Stage object.
- * If a display object is not added to the display list, its stage property is set to null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 显示对象的舞台。 - * 例如,您可以创建多个显示对象并加载到显示列表中,每个显示对象的 stage 属性是指向相同的 Stage 对象。
- * 如果显示对象未添加到显示列表,则其 stage 属性会设置为 null。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stage: Stage; - /** - * A Matrix object containing values that alter the scaling, rotation, and translation of the display object.
- * Note: to change the value of a display object's matrix, you must make a copy of the entire matrix object, then copy - * the new object into the matrix property of the display object. - * @example the following code increases the tx value of a display object's matrix - *
-         *     let myMatrix:Matrix = myDisplayObject.matrix;
-         *     myMatrix.tx += 10;
-         *     myDisplayObject.matrix = myMatrix;
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个 Matrix 对象,其中包含更改显示对象的缩放、旋转和平移的值。
- * 注意:要改变一个显示对象矩阵的值,您必引用整个矩阵对象,然后将它重新赋值给显示对象的 matrix 属性。 - * @example 以下代码改变了显示对象矩阵的tx属性值: - *
-         *     let myMatrix:Matrix = myDisplayObject.matrix;
-         *     myMatrix.tx += 10;
-         *     myDisplayObject.matrix = myMatrix;
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - matrix: Matrix; - private $matrix; - private $matrixDirty; - /** - * @private - * 获取矩阵 - */ - $getMatrix(): Matrix; - /** - * @private - * 设置矩阵 - */ - $setMatrix(matrix: Matrix, needUpdateProperties?: boolean): void; - private $concatenatedMatrix; - /** - * @private - * 获得这个显示对象以及它所有父级对象的连接矩阵。 - */ - $getConcatenatedMatrix(): Matrix; - private $invertedConcatenatedMatrix; - /** - * @private - * 获取链接矩阵 - */ - $getInvertedConcatenatedMatrix(): Matrix; - $x: number; - /** - * Indicates the x coordinate of the DisplayObject instance relative to the local coordinates of the parent - * DisplayObjectContainer.
- * If the object is inside a DisplayObjectContainer that has transformations, it is in - * the local coordinate system of the enclosing DisplayObjectContainer. Thus, for a DisplayObjectContainer - * rotated 90° counterclockwise, the DisplayObjectContainer's children inherit a coordinate system that is - * rotated 90° counterclockwise. The object's coordinates refer to the registration point position. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 实例相对于父级 DisplayObjectContainer 本地坐标的 x 坐标。
- * 如果该对象位于具有变形的 DisplayObjectContainer 内,则它也位于包含 DisplayObjectContainer 的本地坐标系中。 - * 因此,对于逆时针旋转 90 度的 DisplayObjectContainer,该 DisplayObjectContainer 的子级将继承逆时针旋转 90 度的坐标系。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - x: number; - /** - * @private - * 获取x坐标 - */ - $getX(): number; - /** - * @private - * 设置x坐标 - */ - $setX(value: number): boolean; - $y: number; - /** - * Indicates the y coordinate of the DisplayObject instance relative to the local coordinates of the parent - * DisplayObjectContainer.
- * If the object is inside a DisplayObjectContainer that has transformations, it is in - * the local coordinate system of the enclosing DisplayObjectContainer. Thus, for a DisplayObjectContainer rotated - * 90° counterclockwise, the DisplayObjectContainer's children inherit a coordinate system that is rotated 90° - * counterclockwise. The object's coordinates refer to the registration point position. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 实例相对于父级 DisplayObjectContainer 本地坐标的 y 坐标。
- * 如果该对象位于具有变形的 DisplayObjectContainer 内,则它也位于包含 DisplayObjectContainer 的本地坐标系中。 - * 因此,对于逆时针旋转 90 度的 DisplayObjectContainer,该 DisplayObjectContainer 的子级将继承逆时针旋转 90 度的坐标系。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - y: number; - /** - * @private - * 获取y坐标 - */ - $getY(): number; - /** - * @private - * 设置y坐标 - */ - $setY(value: number): boolean; - private $scaleX; - /** - * Indicates the horizontal scale (percentage) of the object as applied from the registration point.
- * The default 1.0 equals 100% scale. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从注册点开始应用的对象的水平缩放比例(百分比)。
- * 1.0 等于 100% 缩放。 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scaleX: number; - /** - * @private - * - * @returns - */ - $getScaleX(): number; - /** - * @private - * 设置水平缩放值 - */ - $setScaleX(value: number): void; - private $scaleY; - /** - * Indicates the vertical scale (percentage) of an object as applied from the registration point of the object. - * 1.0 is 100% scale. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从对象注册点开始应用的对象的垂直缩放比例(百分比)。1.0 是 100% 缩放。 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scaleY: number; - /** - * @private - * - * @returns - */ - $getScaleY(): number; - /** - * @private - * 设置垂直缩放值 - */ - $setScaleY(value: number): void; - private $rotation; - /** - * Indicates the rotation of the DisplayObject instance, in degrees, from its original orientation. Values from - * 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values outside - * this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement - * myDisplayObject.rotation = 450 is the same as myDisplayObject.rotation = 90. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 实例距其原始方向的旋转程度,以度为单位。 - * 从 0 到 180 的值表示顺时针方向旋转;从 0 到 -180 的值表示逆时针方向旋转。对于此范围之外的值,可以通过加上或 - * 减去 360 获得该范围内的值。例如,myDisplayObject.rotation = 450语句与 myDisplayObject.rotation = 90 是相同的。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - rotation: number; - /** - * @private - */ - $getRotation(): number; - $setRotation(value: number): void; - private $skewX; - private $skewXdeg; - /** - * 表示DisplayObject的x方向斜切 - * @member {number} egret.DisplayObject#skewX - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - */ - skewX: number; - /** - * @private - * - * @param value - */ - $setSkewX(value: number): void; - private $skewY; - private $skewYdeg; - /** - * 表示DisplayObject的y方向斜切 - * @member {number} egret.DisplayObject#skewY - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - */ - skewY: number; - /** - * @private - * - * @param value - */ - $setSkewY(value: number): void; - /** - * Indicates the width of the display object, in pixels. The width is calculated based on the bounds of the content - * of the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示显示对象的宽度,以像素为单位。宽度是根据显示对象内容的范围来计算的。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - width: number; - /** - * @private - * 获取显示宽度 - */ - $getWidth(): number; - $explicitWidth: number; - /** - * @private - * 设置显示宽度 - */ - $setWidth(value: number): void; - /** - * Indicates the height of the display object, in pixels. The height is calculated based on the bounds of the - * content of the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示显示对象的高度,以像素为单位。高度是根据显示对象内容的范围来计算的。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - height: number; - $explicitHeight: number; - /** - * @private - * 获取显示高度 - */ - $getHeight(): number; - /** - * @private - * 设置显示高度 - */ - $setHeight(value: number): void; - /** - * 测量宽度 - * @returns {number} - * @member {egret.Rectangle} egret.DisplayObject#measuredWidth - * @version Egret 2.4 - * @platform Web,Native - */ - readonly measuredWidth: number; - /** - * 测量高度 - * @returns {number} - * @member {egret.Rectangle} egret.DisplayObject#measuredWidth - * @version Egret 2.4 - * @platform Web,Native - */ - readonly measuredHeight: number; - $anchorOffsetX: number; - /** - * X represents the object of which is the anchor. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从对象绝对锚点X。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - anchorOffsetX: number; - /** - * @private - * - * @param value - * @returns - */ - $setAnchorOffsetX(value: number): void; - $anchorOffsetY: number; - /** - * Y represents the object of which is the anchor. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从对象绝对锚点Y。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - anchorOffsetY: number; - /** - * @private - * - * @param value - * @returns - */ - $setAnchorOffsetY(value: number): void; - /** - * @private - */ - $visible: boolean; - /** - * Whether or not the display object is visible. Display objects that are not visible are disabled. For example, - * if visible=false for an DisplayObject instance, it cannot receive touch or other user input. - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 显示对象是否可见。不可见的显示对象将被禁用。例如,如果实例的 visible 为 false,则无法接受触摸或用户交互操作。 - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - visible: boolean; - $setVisible(value: boolean): void; - /** - * @private - * cacheAsBitmap创建的缓存位图节点。 - */ - $displayList: egret.sys.DisplayList; - private $cacheAsBitmap; - /** - * If set to true, Egret runtime caches an internal bitmap representation of the display object. This caching can - * increase performance for display objects that contain complex vector content. After you set the cacheAsBitmap - * property to true, the rendering does not change, however the display object performs pixel snapping automatically. - * The execution speed can be significantly faster depending on the complexity of the content.The cacheAsBitmap - * property is best used with display objects that have mostly static content and that do not scale and rotate frequently.
- * Note: The display object will not create the bitmap caching when the memory exceeds the upper limit,even if you set it to true. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果设置为 true,则 Egret 运行时将缓存显示对象的内部位图表示形式。此缓存可以提高包含复杂矢量内容的显示对象的性能。 - * 将 cacheAsBitmap 属性设置为 true 后,呈现并不更改,但是,显示对象将自动执行像素贴紧。执行速度可能会大大加快, - * 具体取决于显示对象内容的复杂性。最好将 cacheAsBitmap 属性与主要具有静态内容且不频繁缩放或旋转的显示对象一起使用。
- * 注意:在内存超过上限的情况下,即使将 cacheAsBitmap 属性设置为 true,显示对象也不使用位图缓存。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - cacheAsBitmap: boolean; - $setHasDisplayList(value: boolean): void; - $cacheDirty: boolean; - $cacheDirtyUp(): void; - /** - * @private - */ - $alpha: number; - /** - * Indicates the alpha transparency value of the object specified. Valid values are 0 (fully transparent) to 1 (fully opaque). - * The default value is 1. Display objects with alpha set to 0 are active, even though they are invisible. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示指定对象的 Alpha 透明度值。 - * 有效值为 0(完全透明)到 1(完全不透明)。alpha 设置为 0 的显示对象是可触摸的,即使它们不可见。 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - alpha: number; - /** - * @private - * - * @param value - */ - $setAlpha(value: number): void; - /** - * @private - * The default touchEnabled property of DisplayObject - * @default false - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * @private - * 显示对象默认的 touchEnabled 属性 - * @default false - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - static defaultTouchEnabled: boolean; - $touchEnabled: boolean; - /** - * Specifies whether this object receives touch or other user input. The default value is false, which means that - * by default any DisplayObject instance that is on the display list cannot receive touch events. If touchEnabled is - * set to false, the instance does not receive any touch events (or other user input events). Any children of - * this instance on the display list are not affected. To change the touchEnabled behavior for all children of - * an object on the display list, use DisplayObjectContainer.touchChildren. - * @see egret.DisplayObjectContainer#touchChildren - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定此对象是否接收触摸或其他用户输入。默认值为 false,这表示默认情况下,显示列表上的任何 DisplayObject 实例都不会接收触摸事件或 - * 其他用户输入事件。如果将 touchEnabled 设置为 false,则实例将不接收任何触摸事件(或其他用户输入事件)。显示列表上的该实例的任 - * 何子级都不会受到影响。要更改显示列表上对象的所有子级的 touchEnabled 行为,请使用 DisplayObjectContainer.touchChildren。 - * @see egret.DisplayObjectContainer#touchChildren - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - touchEnabled: boolean; - /** - * @private - */ - $getTouchEnabled(): boolean; - /** - * @private - */ - $setTouchEnabled(value: boolean): void; - /** - * @private - */ - $scrollRect: Rectangle; - /** - * The scroll rectangle bounds of the display object. The display object is cropped to the size defined by the rectangle, - * and it scrolls within the rectangle when you change the x and y properties of the scrollRect object. A scrolled display - * object always scrolls in whole pixel increments.You can scroll an object left and right by setting the x property of - * the scrollRect Rectangle object. You can scroll an object up and down by setting the y property of the scrollRect - * Rectangle object. If the display object is rotated 90° and you scroll it left and right, the display object actually - * scrolls up and down.
- * - * Note: to change the value of a display object's scrollRect, you must make a copy of the entire scrollRect object, then copy - * the new object into the scrollRect property of the display object. - * @example the following code increases the x value of a display object's scrollRect - *
-         *     let myRectangle:Rectangle = myDisplayObject.scrollRect;
-         *     myRectangle.x += 10;
-         *     myDisplayObject.scrollRect = myRectangle;
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 显示对象的滚动矩形范围。显示对象被裁切为矩形定义的大小,当您更改 scrollRect 对象的 x 和 y 属性时,它会在矩形内滚动。 - * 滚动的显示对象始终以整像素为增量进行滚动。您可以通过设置 scrollRect Rectangle 对象的 x 属性来左右滚动对象, 还可以通过设置 - * scrollRect 对象的 y 属性来上下滚动对象。如果显示对象旋转了 90 度,并且您左右滚动它,则实际上显示对象会上下滚动。
- * - * 注意:要改变一个显示对象 scrollRect 属性的值,您必引用整个 scrollRect 对象,然后将它重新赋值给显示对象的 scrollRect 属性。 - * @example 以下代码改变了显示对象 scrollRect 的 x 属性值: - *
-         *     let myRectangle:Rectangle = myDisplayObject.scrollRect;
-         *     myRectangle.x += 10;
-         *     myDisplayObject.scrollRect = myRectangle;//设置完scrollRect的x、y、width、height值之后,一定要对myDisplayObject重新赋值scrollRect,不然会出问题。
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scrollRect: Rectangle; - /** - * @private - * - * @param value - */ - private $setScrollRect(value); - /** - * @private - */ - $blendMode: number; - /** - * A value from the BlendMode class that specifies which blend mode to use. Determine how a source image (new one) - * is drawn on the target image (old one).
- * If you attempt to set this property to an invalid value, Egret runtime set the value to BlendMode.NORMAL. - * @default egret.BlendMode.NORMAL - * @see egret.BlendMode - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * BlendMode 枚举中的一个值,用于指定要使用的混合模式,确定如何将一个源(新的)图像绘制到目标(已有)的图像上
- * 如果尝试将此属性设置为无效值,则运行时会将此值设置为 BlendMode.NORMAL。 - * @default egret.BlendMode.NORMAL - * @see egret.BlendMode - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - blendMode: string; - /** - * @private - * 被遮罩的对象 - */ - $maskedObject: DisplayObject; - /** - * @private - */ - $mask: DisplayObject; - /** - * @private - */ - $maskRect: Rectangle; - /** - * The calling display object is masked by the specified mask object. To ensure that masking works when the Stage - * is scaled, the mask display object must be in an active part of the display list. The mask object itself is not drawn. - * Set mask to null to remove the mask. To be able to scale a mask object, it must be on the display list. To be - * able to drag a mask object , it must be on the display list.
- * Note: A single mask object cannot be used to mask more than one calling display object. When the mask is assigned - * to a second display object, it is removed as the mask of the first object, and that object's mask property becomes null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 调用显示对象被指定的 mask 对象遮罩。要确保当舞台缩放时蒙版仍然有效,mask 显示对象必须处于显示列表的活动部分。 - * 但不绘制 mask 对象本身。将 mask 设置为 null 可删除蒙版。要能够缩放遮罩对象,它必须在显示列表中。要能够拖动蒙版 - * 对象,它必须在显示列表中。
- * 注意:单个 mask 对象不能用于遮罩多个执行调用的显示对象。在将 mask 分配给第二个显示对象时,会撤消其作为第一个对象的遮罩, - * 该对象的 mask 属性将变为 null。 - * - * 下面例子为 mask 为 Rectangle 类型对象,这种情况下,修改 mask 的值后,一定要对 myDisplayObject 重新赋值 mask,不然会出问题。 - * @example 以下代码改变了显示对象 mask 的 x 属性值: - *
-         *     let myMask:Rectangle = myDisplayObject.mask;
-         *     myMask.x += 10;
-         *     myDisplayObject.mask = myMask;//设置完 mask 的x、y、width、height值之后,一定要对myDisplayObject重新赋值 mask,不然会出问题。
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - mask: DisplayObject | Rectangle; - private $setMaskRect(value); - $filters: Array; - /** - * An indexed array that contains each filter object currently associated with the display object. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 包含当前与显示对象关联的每个滤镜对象的索引数组。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - filters: Array; - /** - * Returns a rectangle that defines the area of the display object relative to the coordinate system of the targetCoordinateSpace object. - * @param targetCoordinateSpace The display object that defines the coordinate system to use. - * @param resultRect A reusable instance of Rectangle for saving the results. Passing this parameter can reduce the number of reallocate objects - *, which allows you to get better code execution performance.. - * @returns The rectangle that defines the area of the display object relative to the targetCoordinateSpace object's coordinate system. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回一个矩形,该矩形定义相对于 targetCoordinateSpace 对象坐标系的显示对象区域。 - * @param targetCoordinateSpace 定义要使用的坐标系的显示对象。 - * @param resultRect 一个用于存储结果的可复用Rectangle实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。 - * @returns 定义与 targetCoordinateSpace 对象坐标系统相关的显示对象面积的矩形。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getTransformedBounds(targetCoordinateSpace: DisplayObject, resultRect?: Rectangle): Rectangle; - /** - * Obtain measurement boundary of display object - * @param resultRect {Rectangle} Optional. It is used to import Rectangle object for saving results, preventing duplicate object creation. - * @param calculateAnchor {boolean} Optional. It is used to determine whether to calculate anchor point. - * @returns {Rectangle} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取显示对象的测量边界 - * @param resultRect {Rectangle} 可选参数,传入用于保存结果的Rectangle对象,避免重复创建对象。 - * @param calculateAnchor {boolean} 可选参数,是否会计算锚点。 - * @returns {Rectangle} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getBounds(resultRect?: Rectangle, calculateAnchor?: boolean): egret.Rectangle; - /** - * @private - */ - $getTransformedBounds(targetCoordinateSpace: DisplayObject, resultRect?: Rectangle): Rectangle; - /** - * Converts the point object from the Stage (global) coordinates to the display object's (local) coordinates. - * @param stageX the x value in the global coordinates - * @param stageY the y value in the global coordinates - * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the - * number of reallocate objects, which allows you to get better code execution performance. - * @returns A Point object with coordinates relative to the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将从舞台(全局)坐标转换为显示对象的(本地)坐标。 - * @param stageX 舞台坐标x - * @param stageY 舞台坐标y - * @param resultPoint 一个用于存储结果的可复用 Point 实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。 - * @returns 具有相对于显示对象的坐标的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - globalToLocal(stageX?: number, stageY?: number, resultPoint?: Point): Point; - /** - * Converts the point object from the display object's (local) coordinates to the Stage (global) coordinates. - * @param localX the x value in the local coordinates - * @param localY the x value in the local coordinates - * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the - * number of reallocate objects, which allows you to get better code execution performance. - * @returns A Point object with coordinates relative to the Stage. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将显示对象的(本地)坐标转换为舞台(全局)坐标。 - * @param localX 本地坐标 x - * @param localY 本地坐标 y - * @param resultPoint 一个用于存储结果的可复用 Point 实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。 - * @returns 一个具有相对于舞台坐标的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - localToGlobal(localX?: number, localY?: number, resultPoint?: Point): Point; - /** - * @private - * 获取显示对象占用的矩形区域集合,通常包括自身绘制的测量区域,如果是容器,还包括所有子项占据的区域。 - */ - $getOriginalBounds(): Rectangle; - /** - * @private - * 测量子项占用的矩形区域 - * @param bounds 测量结果存储在这个矩形对象内 - */ - $measureChildBounds(bounds: Rectangle): void; - /** - * @private - */ - $getContentBounds(): Rectangle; - /** - * @private - * 测量自身占用的矩形区域,注意:此测量结果并不包括子项占据的区域。 - * @param bounds 测量结果存储在这个矩形对象内 - */ - $measureContentBounds(bounds: Rectangle): void; - /** - * @private - */ - $parentDisplayList: egret.sys.DisplayList; - /** - * @private - * 渲染节点,不为空表示自身有绘制到屏幕的内容 - */ - $renderNode: sys.RenderNode; - $renderDirty: boolean; - /** - * @private - * 获取渲染节点 - */ - $getRenderNode(): sys.RenderNode; - $updateRenderMode(): void; - $renderMode: RenderMode; - /** - * @private - */ - private $measureFiltersOffset(fromParent); - /** - * @private - * 获取相对于指定根节点的连接矩阵。 - * @param root 根节点显示对象 - * @param matrix 目标显示对象相对于舞台的完整连接矩阵。 - */ - $getConcatenatedMatrixAt(root: DisplayObject, matrix: Matrix): void; - /** - * @private - * 更新renderNode - */ - $updateRenderNode(): void; - /** - * @private - */ - $hitTest(stageX: number, stageY: number): DisplayObject; - /** - * Calculate the display object to determine whether it overlaps or crosses with the points specified by the x and y parameters. The x and y parameters specify the points in the coordinates of the stage, rather than the points in the display object container that contains display objects (except the situation where the display object container is a stage). - * Note: Don't use accurate pixel collision detection on a large number of objects. Otherwise, this will cause serious performance deterioration. - * @param x {number} x coordinate of the object to be tested. - * @param y {number} y coordinate of the object to be tested. - * @param shapeFlag {boolean} Whether to check the actual pixel of object (true) or check that of border (false).Write realized. - * @returns {boolean} If display object overlaps or crosses with the specified point, it is true; otherwise, it is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计算显示对象,以确定它是否与 x 和 y 参数指定的点重叠或相交。x 和 y 参数指定舞台的坐标空间中的点,而不是包含显示对象的显示对象容器中的点(除非显示对象容器是舞台)。 - * 注意,不要在大量物体中使用精确碰撞像素检测,这回带来巨大的性能开销 - * @param x {number} 要测试的此对象的 x 坐标。 - * @param y {number} 要测试的此对象的 y 坐标。 - * @param shapeFlag {boolean} 是检查对象 (true) 的实际像素,还是检查边框 (false) 的实际像素。 - * @returns {boolean} 如果显示对象与指定的点重叠或相交,则为 true;否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - hitTestPoint(x: number, y: number, shapeFlag?: boolean): boolean; - /** - * @private - */ - static $enterFrameCallBackList: DisplayObject[]; - /** - * @private - */ - static $renderCallBackList: DisplayObject[]; - /** - * @private - */ - $addListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number, dispatchOnce?: boolean): void; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - removeEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean): void; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - dispatchEvent(event: Event): boolean; - /** - * @private - * 获取事件流列表。注意:Egret框架的事件流与Flash实现并不一致。 - * - * 事件流有三个阶段:捕获,目标,冒泡。 - * Flash里默认的的事件监听若不开启useCapture将监听目标和冒泡阶段。若开始capture将只能监听捕获当不包括目标的事件。 - * 可以在Flash中写一个简单的测试:实例化一个非容器显示对象,例如TextField。分别监听useCapture为true和false时的鼠标事件。 - * 点击后将只有useCapture为false的回调函数输出信息。也就带来一个问题「Flash的捕获阶段不能监听到最内层对象本身,只在父级列表有效」。 - * - * 而HTML里的事件流设置useCapture为true时是能监听到目标阶段的,也就是目标阶段会被触发两次,在捕获和冒泡过程各触发一次。这样可以避免 - * 前面提到的监听捕获无法监听目标本身的问题。 - * - * Egret最终采用了HTML里目标节点触发两次的事件流方式。 - */ - $getPropagationList(target: DisplayObject): DisplayObject[]; - /** - * @private - */ - $dispatchPropagationEvent(event: Event, list: DisplayObject[], targetIndex: number): void; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - willTrigger(type: string): boolean; - } -} -declare namespace egret { - let $TextureScaleFactor: number; - /** - * The Texture class encapsulates different image resources on different platforms. - * In HTML5, resource is an HTMLElement object - * In OpenGL / WebGL, resource is a texture ID obtained after the GPU is submitted - * The Texture class encapsulates the details implemented on the underlayer. Developers just need to focus on interfaces - * @see http://edn.egret.com/cn/docs/page/135 The use of texture packs - * @see http://edn.egret.com/cn/docs/page/123 Several ways of access to resources - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Texture.ts - * @language en_US - */ - /** - * 纹理类是对不同平台不同的图片资源的封装 - * 在HTML5中,资源是一个HTMLElement对象 - * 在OpenGL / WebGL中,资源是一个提交GPU后获取的纹理id - * Texture类封装了这些底层实现的细节,开发者只需要关心接口即可 - * @see http://edn.egret.com/cn/docs/page/135 纹理集的使用 - * @see http://edn.egret.com/cn/docs/page/123 获取资源的几种方式 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Texture.ts - * @language zh_CN - */ - class Texture extends HashObject { - /** - * Create an egret.Texture object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.Texture 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @private - * 纹理id - */ - $textureId: number; - /** - * Whether to destroy the corresponding BitmapData when the texture is destroyed - * @version Egret 5.0.8 - * @platform Web,Native - * @language en_US - */ - /** - * 销毁纹理时是否销毁对应BitmapData - * @version Egret 5.0.8 - * @platform Web,Native - * @language zh_CN - */ - disposeBitmapData: boolean; - /** - * @private - * 表示这个纹理在 bitmapData 上的 x 起始位置 - */ - $bitmapX: number; - /** - * @private - * 表示这个纹理在 bitmapData 上的 y 起始位置 - */ - $bitmapY: number; - /** - * @private - * 表示这个纹理在 bitmapData 上的宽度 - */ - $bitmapWidth: number; - /** - * @private - * 表示这个纹理在 bitmapData 上的高度 - */ - $bitmapHeight: number; - /** - * @private - * 表示这个纹理显示了之后在 x 方向的渲染偏移量 - */ - $offsetX: number; - /** - * @private - * 表示这个纹理显示了之后在 y 方向的渲染偏移量 - */ - $offsetY: number; - /** - * @private - * 纹理宽度 - */ - private $textureWidth; - /** - * Texture width, read only - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 纹理宽度,只读属性,不可以设置 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textureWidth: number; - $getTextureWidth(): number; - /** - * @private - * 纹理高度 - */ - private $textureHeight; - /** - * Texture height, read only - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 纹理高度,只读属性,不可以设置 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textureHeight: number; - $getTextureHeight(): number; - $getScaleBitmapWidth(): number; - $getScaleBitmapHeight(): number; - /** - * @private - * 表示bitmapData.width - */ - $sourceWidth: number; - /** - * @private - * 表示bitmapData.height - */ - $sourceHeight: number; - /** - * @private - */ - $bitmapData: BitmapData; - /** - * @private - */ - $rotated: boolean; - /** - * The BitmapData object being referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的 BitmapData 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bitmapData: BitmapData; - /** - * Set the BitmapData object. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 设置 BitmapData 对象。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - _setBitmapData(value: BitmapData): void; - /** - * @private - * 设置Texture数据 - * @param bitmapX - * @param bitmapY - * @param bitmapWidth - * @param bitmapHeight - * @param offsetX - * @param offsetY - * @param textureWidth - * @param textureHeight - * @param sourceWidth - * @param sourceHeight - */ - $initData(bitmapX: number, bitmapY: number, bitmapWidth: number, bitmapHeight: number, offsetX: number, offsetY: number, textureWidth: number, textureHeight: number, sourceWidth: number, sourceHeight: number, rotated?: boolean): void; - /** - * @deprecated - */ - getPixel32(x: number, y: number): number[]; - /** - * Obtain the color value for the specified pixel region - * @param x The x coordinate of the pixel region - * @param y The y coordinate of the pixel region - * @param width The width of the pixel region - * @param height The height of the pixel region - * @returns Specifies the color value for the pixel region - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 获取指定像素区域的颜色值 - * @param x 像素区域的X轴坐标 - * @param y 像素区域的Y轴坐标 - * @param width 像素点的Y轴坐标 - * @param height 像素点的Y轴坐标 - * @returns 指定像素区域的颜色值 - * @version Egret 3.2.1 - * @platform Web - * @language zh_CN - */ - getPixels(x: number, y: number, width?: number, height?: number): number[]; - /** - * Convert base64 string, if the picture (or pictures included) cross-border or null - * @param type Type conversions, such as "image / png" - * @param rect The need to convert the area - * @param smoothing Whether to convert data to the smoothing process - * @returns {any} base64 string - * @version Egret 2.4 - * @language en_US - */ - /** - * 转换成base64字符串,如果图片(或者包含的图片)跨域,则返回null - * @param type 转换的类型,如 "image/png" - * @param rect 需要转换的区域 - * @param {any} encoderOptions 编码用的参数 - * @returns {any} base64字符串 - * @version Egret 2.4 - * @language zh_CN - */ - toDataURL(type: string, rect?: egret.Rectangle, encoderOptions?: any): string; - /** - * Crop designated area and save it as image. - * native support only "image / png" and "image / jpeg"; Web browser because of the various implementations are not the same, it is recommended to use only these two kinds. - * @param type Type conversions, such as "image / png" - * @param filePath The path name of the image (the home directory for the game's private space, the path can not have "../",Web supports only pass names.) - * @param rect The need to convert the area - * @version Egret 2.4 - * @platform Native - * @language en_US - */ - /** - * 裁剪指定区域并保存成图片。 - * native只支持 "image/png" 和 "image/jpeg";Web中由于各个浏览器的实现不一样,因此建议也只用这2种。 - * @param type 转换的类型,如 "image/png" - * @param filePath 图片的名称的路径(主目录为游戏的私有空间,路径中不能有 "../",Web只支持传名称。) - * @param rect 需要转换的区域 - * @version Egret 2.4 - * @platform Native - * @language zh_CN - */ - saveToFile(type: string, filePath: string, rect?: egret.Rectangle): void; - /** - * dispose texture - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放纹理 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dispose(): void; - } -} -declare namespace egret { - /** - * The Event class is used as the base class for the creation of Event objects, which are passed as parameters to event - * listeners when an event occurs.The properties of the Event class carry basic information about an event, such as - * the event's type or whether the event's default behavior can be canceled. For many events, such as the events represented - * by the Event class constants, this basic information is sufficient. Other events, however, may require more detailed - * information. Events associated with a touch tap, for example, need to include additional information about the - * location of the touch event. You can pass such additional information to event listeners by extending the Event class, - * which is what the TouchEvent class does. Egret API defines several Event subclasses for common events that require - * additional information. Events associated with each of the Event subclasses are described in the documentation for - * each class.The methods of the Event class can be used in event listener functions to affect the behavior of the event - * object. Some events have an associated default behavior. Your event listener can cancel this behavior by calling the - * preventDefault() method. You can also make the current event listener the last one to process an event by calling - * the stopPropagation() or stopImmediatePropagation() method. - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/Event.ts - * @see http://edn.egret.com/cn/docs/page/798 取消触摸事件 - * @language en_US - */ - /** - * Event 类作为创建事件实例的基类,当发生事件时,Event 实例将作为参数传递给事件侦听器。Event 类的属性包含有关事件的基本信息,例如事件 - * 的类型或者是否可以取消事件的默认行为。对于许多事件(如由 Event 类常量表示的事件),此基本信息就足够了。但其他事件可能需要更详细的信息。 - * 例如,与触摸关联的事件需要包括有关触摸事件的位置信息。您可以通过扩展 Event 类(TouchEvent 类执行的操作)将此类其他信息传递给事件侦听器。 - * Egret API 为需要其他信息的常见事件定义多个 Event 子类。与每个 Event 子类关联的事件将在每个类的文档中加以介绍。Event 类的方法可以在 - * 事件侦听器函数中使用以影响事件对象的行为。某些事件有关联的默认行为,通过调用 preventDefault() 方法,您的事件侦听器可以取消此行为。 - * 可以通过调用 stopPropagation() 或 stopImmediatePropagation() 方法,将当前事件侦听器作为处理事件的最后一个事件侦听器。 - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/Event.ts - * @see http://edn.egret.com/cn/docs/page/798 取消触摸事件 - * @language zh_CN - */ - class Event extends HashObject { - /** - * Dispatched when a display object is added to the on stage display list, either directly or through the addition - * of a sub tree in which the display object is contained. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在将显示对象直接添加到舞台显示列表或将包含显示对象的子树添加至舞台显示列表中时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ADDED_TO_STAGE: string; - /** - * Dispatched when a display object is about to be removed from the display list, either directly or through the removal - * of a sub tree in which the display object is contained. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在从显示列表中直接删除显示对象或删除包含显示对象的子树时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static REMOVED_FROM_STAGE: string; - /** - * Dispatched when a display object is added to the display list. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将显示对象添加到显示列表中时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ADDED: string; - /** - * Dispatched when a display object is about to be removed from the display list. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将要从显示列表中删除显示对象时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static REMOVED: string; - /** - * [broadcast event] Dispatched when the playhead is entering a new frame. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * [广播事件] 进入新的一帧,监听此事件将会在下一帧开始时触发一次回调。这是一个广播事件,可以在任何一个显示对象上监听,无论它是否在显示列表中。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ENTER_FRAME: string; - /** - * Dispatched when the display list is about to be updated and rendered. - * Note: Every time you want to receive a render event,you must call the stage.invalidate() method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 渲染事件,监听此事件将会在本帧末即将开始渲染的前一刻触发回调,这是一个广播事件,可以在任何一个显示对象上监听,无论它是否在显示列表中。 - * 注意:每次您希望 Egret 发送 Event.RENDER 事件时,都必须调用 stage.invalidate() 方法,由于每帧只会触发一次屏幕刷新, - * 若在 Event.RENDER 回调函数执行期间再次调用stage.invalidate(),将会被忽略。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static RENDER: string; - /** - * Dispatched when the size of stage or UIComponent is changed. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 舞台尺寸或UI组件尺寸发生改变 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static RESIZE: string; - /** - * Dispatched when the value or selection of a property is chaned. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 属性值或状态发生改变。通常是按钮的选中状态,或者列表的选中项索引改变。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CHANGE: string; - /** - * Dispatched when the value or selection of a property is going to change.you can cancel this by calling the - * preventDefault() method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 属性值或状态即将发生改变,通常是按钮的选中状态,或者列表的选中项索引改变。可以通过调用 preventDefault() 方法阻止索引发生更改。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CHANGING: string; - /** - * Dispatched when the net request is complete. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 网络请求加载完成 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static COMPLETE: string; - /** - * Dispatched when loop completed. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 循环完成。循环最后一次只派发 COMPLETE 事件,不派发 LOOP_COMPLETE 事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LOOP_COMPLETE: string; - /** - * Dispatched when the TextInput instance gets focus. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * TextInput实例获得焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static FOCUS_IN: string; - /** - * Dispatched when the TextInput instance loses focus. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * TextInput实例失去焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static FOCUS_OUT: string; - /** - * Dispatched when the playback is ended. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 动画声音等播放完成 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ENDED: string; - /** - * 游戏激活 - * @version Egret 2.4 - * @platform Web,Native - */ - static ACTIVATE: string; - /** - * 取消激活 - * @version Egret 2.4 - * @platform Web,Native - */ - static DEACTIVATE: string; - /** - * Event.CLOSE 常量定义 close 事件对象的 type 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - */ - static CLOSE: string; - /** - * Event.CONNECT 常量定义 connect 事件对象的 type 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - */ - static CONNECT: string; - /** - * Event.LEAVE_STAGE 常量定义 leaveStage 事件对象的 type 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - */ - static LEAVE_STAGE: string; - /** - * Event.SOUND_COMPLETE 常量定义 在声音完成播放后调度。 - * @version Egret 2.4 - * @platform Web,Native - */ - static SOUND_COMPLETE: string; - /** - * Creates an Event object to pass as a parameter to event listeners. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param data the optional data associated with this event - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个作为参数传递给事件侦听器的 Event 对象。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param data 与此事件对象关联的可选数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, data?: any); - /** - * the optional data associated with this event - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 与此事件对象关联的可选数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - data: any; - /** - * @private - */ - $type: string; - /** - * The type of event. The type is case-sensitive. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件的类型。类型区分大小写。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly type: string; - /** - * @private - */ - $bubbles: boolean; - /** - * Indicates whether an event is a bubbling event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示事件是否为冒泡事件。如果事件可以冒泡,则此值为 true;否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly bubbles: boolean; - /** - * @private - */ - $cancelable: boolean; - /** - * Indicates whether the behavior associated with the event can be prevented. If the behavior can be - * canceled, this value is true; otherwise it is false. - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示是否可以阻止与事件相关联的行为。如果可以取消该行为,则此值为 true;否则为 false。 - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly cancelable: boolean; - /** - * @private - */ - $eventPhase: number; - /** - * The current phase in the event flow. This property can contain the following numeric values: - * The capture phase (EventPhase.CAPTURING_PHASE). - * The target phase (EventPhase.AT_TARGET) - * The bubbling phase (EventPhase.BUBBLING_PHASE). - * @see egret.EventPhase - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件流中的当前阶段。此属性可以包含以下数值: - * 捕获阶段 (EventPhase.CAPTURING_PHASE)。 - * 目标阶段 (EventPhase.AT_TARGET)。 - * 冒泡阶段 (EventPhase.BUBBLING_PHASE)。 - * @see egret.EventPhase - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly eventPhase: number; - /** - * @private - */ - $currentTarget: any; - /** - * The object that is actively processing the Event object with an event listener. For example, if a - * user clicks an OK button, the current target could be the node containing that button or one of its ancestors - * that has registered an event listener for that event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前正在使用某个事件侦听器处理 Event 对象的对象。例如,如果用户单击“确定”按钮, - * 则当前目标可以是包含该按钮的节点,也可以是它的已为该事件注册了事件侦听器的始祖之一。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly currentTarget: any; - /** - * @private - */ - $target: any; - /** - * The event target. This property contains the target node. For example, if a user clicks an OK button, - * the target node is the display list node containing that button. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件目标。此属性包含目标节点。例如,如果用户单击“确定”按钮,则目标节点就是包含该按钮的显示列表节点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly target: any; - $setTarget(target: any): boolean; - /** - * @private - */ - $isDefaultPrevented: boolean; - /** - * Checks whether the preventDefault() method has been called on the event. If the preventDefault() method has been - * called, returns true; otherwise, returns false. - * @returns If preventDefault() has been called, returns true; otherwise, returns false. - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查是否已对事件调用 preventDefault() 方法。 - * @returns 如果已调用 preventDefault() 方法,则返回 true;否则返回 false。 - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - isDefaultPrevented(): boolean; - /** - * Cancels an event's default behavior if that behavior can be canceled.Many events have associated behaviors that - * are carried out by default. For example, if a user types a character into a text input, the default behavior - * is that the character is displayed in the text input. Because the TextEvent.TEXT_INPUT event's default behavior - * can be canceled, you can use the preventDefault() method to prevent the character from appearing. - * You can use the Event.cancelable property to check whether you can prevent the default behavior associated with - * a particular event. If the value of Event.cancelable is true, then preventDefault() can be used to cancel the event; - * otherwise, preventDefault() has no effect. - * @see #cancelable - * @see #isDefaultPrevented - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果可以取消事件的默认行为,则取消该行为。 - * 许多事件都有默认执行的关联行为。例如,如果用户在文本字段中键入一个字符,则默认行为就是在文本字段中显示该字符。 - * 由于可以取消 TextEvent.TEXT_INPUT 事件的默认行为,因此您可以使用 preventDefault() 方法来防止显示该字符。 - * 您可以使用 Event.cancelable 属性来检查是否可以防止与特定事件关联的默认行为。如果 Event.cancelable 的值为 true, - * 则可以使用 preventDefault() 来取消事件;否则,preventDefault() 无效。 - * @see #cancelable - * @see #isDefaultPrevented - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - preventDefault(): void; - /** - * @private - */ - $isPropagationStopped: boolean; - /** - * Prevents processing of any event listeners in nodes subsequent to the current node in the event flow. This method - * does not affect any event listeners in the current node (currentTarget). In contrast, the stopImmediatePropagation() - * method prevents processing of event listeners in both the current node and subsequent nodes. Additional calls to this - * method have no effect. This method can be called in any phase of the event flow.
- * Note: This method does not cancel the behavior associated with this event; see preventDefault() for that functionality. - * @see #stopImmediatePropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 防止对事件流中当前节点的后续节点中的所有事件侦听器进行处理。此方法不会影响当前节点 currentTarget 中的任何事件侦听器。 - * 相比之下,stopImmediatePropagation() 方法可以防止对当前节点中和后续节点中的事件侦听器进行处理。 - * 对此方法的其它调用没有任何效果。可以在事件流的任何阶段中调用此方法。
- * 注意:此方法不会取消与此事件相关联的行为;有关此功能的信息,请参阅 preventDefault()。 - * @see #stopImmediatePropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stopPropagation(): void; - /** - * @private - */ - $isPropagationImmediateStopped: boolean; - /** - * Prevents processing of any event listeners in the current node and any subsequent nodes in the event flow. - * This method takes effect immediately, and it affects event listeners in the current node. In contrast, the - * stopPropagation() method doesn't take effect until all the event listeners in the current node finish processing.
- * Note: This method does not cancel the behavior associated with this event; see preventDefault() for that functionality. - * @see #stopPropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 防止对事件流中当前节点中和所有后续节点中的事件侦听器进行处理。此方法会立即生效,并且会影响当前节点中的事件侦听器。 - * 相比之下,在当前节点中的所有事件侦听器都完成处理之前,stopPropagation() 方法不会生效。
- * 注意:此方法不会取消与此事件相关联的行为;有关此功能的信息,请参阅 preventDefault()。 - * @see #stopPropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stopImmediatePropagation(): void; - /** - * This method will be called automatically when you pass the event object as the parameters to the Event.release() method. - * If your custom event is designed for reusable,you should override this method to make sure all the references to external - * objects are cleaned. if not,it may cause memory leaking. - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当事件实例传递给Event.release()静态方法时,实例上的clean()方法将会被自动调用。 - * 若此自定义事件的实例设计为可以循环复用的,为了避免引起内存泄露,自定义事件需要覆盖此方法来确保实例被缓存前断开对外部对象的一切引用。 - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - protected clean(): void; - /** - * EventDispatcher object using the specified event object thrown Event. Objects thrown objects will be cached in the pool for the next round robin. - * @param target the event target - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param data {any} data - * @method egret.Event.dispatchEvent - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的 EventDispatcher 对象来抛出 Event 事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param type {string} 事件类型 - * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param data {any} 事件data - * @method egret.Event.dispatchEvent - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchEvent(target: IEventDispatcher, type: string, bubbles?: boolean, data?: any): boolean; - /** - * @private - * - * @param EventClass - * @returns - */ - static _getPropertyData(EventClass: any): any; - /** - * Gets one event instance from the object pool or create a new one. We highly recommend using the Event.create() - * and Event.release() methods to create and release an event object,it can reduce the number of reallocate objects, - * which allows you to get better code execution performance.
- * Note: If you want to use this method to initialize your custom event object,you must make sure the constructor - * of your custom event is the same as the constructor of egret.Event. - * @param EventClass Event Class。 - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @example - *
-         *    let event = Event.create(Event,type, bubbles);
-         *    event.data = data;    //optional,initializes custom data here
-         *    this.dispatchEvent(event);
-         *    Event.release(event);
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的事件实例。我们建议您尽可能使用Event.create()和Event.release() 这一对方法来创建和释放事件对象, - * 这一对方法会将事件实例在内部缓存下来供下次循环使用,减少对象的创建次数,从而获得更高的代码运行性能。
- * 注意:若使用此方法来创建自定义事件的实例,自定义的构造函数参数列表必须跟Event类一致。 - * @param EventClass Event类名。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @example - *
-         *    let event = Event.create(Event,type, bubbles);
-         *    event.data = data;  //可选,若指定义事件上需要附加其他参数,可以在获取实例后在此处设置。
-         *    this.dispatchEvent(event);
-         *    Event.release(event);
-         * 
- * @see #clean() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static create(EventClass: { - new (type: string, bubbles?: boolean, cancelable?: boolean): T; - eventPool?: Event[]; - }, type: string, bubbles?: boolean, cancelable?: boolean): T; - /** - * Releases an event object and cache it into the object pool.We highly recommend using the Event.create() - * and Event.release() methods to create and release an event object,it can reduce the number of reallocate objects, - * which allows you to get better code execution performance.
- * Note: The parameters of this method only accepts an instance created by the Event.create() method. - * if not,it may throw an error. - * @example - *
-         *    let event = Event.create(Event,type, bubbles);
-         *    event.data = data; //optional,initializes custom data here
-         *    this.dispatchEvent(event);
-         *    Event.release(event);
-         * 
- * @see #clean() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个事件对象,并缓存到对象池。我们建议您尽可能使用Event.create()和Event.release() 这一对方法来创建和释放事件对象, - * 这一对方法会将事件实例在内部缓存下来供下次循环使用,减少对象的创建次数,从而获得更高的代码运行性能。
- * 注意:此方法只能传入由Event.create()创建的事件实例,传入非法对象实例可能会导致报错。 - * @example - *
-         *    let event = Event.create(Event,type, bubbles);
-         *    event.data = data;   //可选,若指定义事件上需要附加其他参数,可以在获取实例后在此处设置。
-         *    this.dispatchEvent(event);
-         *    Event.release(event);
-         * 
- * @see #clean() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static release(event: Event): void; - } -} -/** - * Is debug mode. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ -/** - * 是否为 debug 模式。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ -declare let DEBUG: boolean; -/** - * Is release mode. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ -/** - * 是否为 release 模式。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ -declare let RELEASE: boolean; -declare namespace egret { - /** - * @private - */ - function $error(code: number, ...params: any[]): void; - /** - * @private - */ - function $warn(code: number, ...params: any[]): void; - /** - * @private - */ - function getString(code: number, ...params: any[]): string; - /** - * @private - */ - function $markCannotUse(instance: any, property: string, defaultVale: any): void; -} -declare namespace egret { - /** - * The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal - * axis and y represents the vertical axis. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Point.ts - * @language en_US - */ - /** - * Point 对象表示二维坐标系统中的某个位置,其中 x 表示水平轴,y 表示垂直轴。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Point.ts - * @language zh_CN - */ - class Point extends HashObject { - /** - * Releases a point instance to the object pool - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个Point实例到对象池 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static release(point: Point): void; - /** - * get a point instance from the object pool or create a new one. - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的Point对象。 - * @param x 该对象的x属性值,默认为0 - * @param y 该对象的y属性值,默认为0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static create(x: number, y: number): Point; - /** - * Creates a new point. If you pass no parameters to this method, a point is created at (0,0). - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。 - * @param x 该对象的x属性值,默认为0 - * @param y 该对象的y属性值,默认为0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(x?: number, y?: number); - /** - * The horizontal coordinate. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该点的水平坐标。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - x: number; - /** - * The vertical coordinate. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该点的垂直坐标。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - y: number; - /** - * The length of the line segment from (0,0) to this point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 (0,0) 到此点的线段长度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly length: number; - /** - * Sets the members of Point to the specified values - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Point 的成员设置为指定值 - * @param x 该对象的x属性值 - * @param y 该对象的y属性值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setTo(x: number, y: number): Point; - /** - * Creates a copy of this Point object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 克隆点对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clone(): Point; - /** - * Determines whether two points are equal. Two points are equal if they have the same x and y values. - * @param toCompare The point to be compared. - * @returns A value of true if the object is equal to this Point object; false if it is not equal. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定两个点是否相同。如果两个点具有相同的 x 和 y 值,则它们是相同的点。 - * @param toCompare 要比较的点。 - * @returns 如果该对象与此 Point 对象相同,则为 true 值,如果不相同,则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - equals(toCompare: Point): boolean; - /** - * Returns the distance between pt1 and pt2. - * @param p1 The first point. - * @param p2 The second point. - * @returns The distance between the first and second points. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回 pt1 和 pt2 之间的距离。 - * @param p1 第一个点 - * @param p2 第二个点 - * @returns 第一个点和第二个点之间的距离。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static distance(p1: Point, p2: Point): number; - /** - * Copies all of the point data from the source Point object into the calling Point object. - * @param sourcePoint The Point object from which to copy the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将源 Point 对象中的所有点数据复制到调用方 Point 对象中。 - * @param sourcePoint 要从中复制数据的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - copyFrom(sourcePoint: Point): void; - /** - * Adds the coordinates of another point to the coordinates of this point to create a new point. - * @param v The point to be added. - * @returns The new point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将另一个点的坐标添加到此点的坐标以创建一个新点。 - * @param v 要添加的点。 - * @returns 新点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - add(v: Point): Point; - /** - * Determines a point between two specified points. - * The parameter f determines where the new interpolated point is located relative to the two end points specified by parameters pt1 and pt2. The closer the value of the parameter f is to 1.0, the closer the interpolated point is to the first point (parameter pt1). The closer the value of the parameter f is to 0, the closer the interpolated point is to the second point (parameter pt2). - * @param pt1 The first point. - * @param pt2 The second point. - * @param f The level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned. - * @returns The new interpolated point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定两个指定点之间的点。 - * 参数 f 确定新的内插点相对于参数 pt1 和 pt2 指定的两个端点所处的位置。参数 f 的值越接近 1.0,则内插点就越接近第一个点(参数 pt1)。参数 f 的值越接近 0,则内插点就越接近第二个点(参数 pt2)。 - * @param pt1 第一个点。 - * @param pt2 第二个点。 - * @param f 两个点之间的内插级别。表示新点将位于 pt1 和 pt2 连成的直线上的什么位置。如果 f=1,则返回 pt1;如果 f=0,则返回 pt2。 - * @returns 新的内插点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static interpolate(pt1: Point, pt2: Point, f: number): Point; - /** - * Scales the line segment between (0,0) and the current point to a set length. - * @param thickness The scaling value. For example, if the current point is (0,5), and you normalize it to 1, the point returned is at (0,1). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 (0,0) 和当前点之间的线段缩放为设定的长度。 - * @param thickness 缩放值。例如,如果当前点为 (0,5) 并且您将它规范化为 1,则返回的点位于 (0,1) 处。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - normalize(thickness: number): void; - /** - * Offsets the Point object by the specified amount. The value of dx is added to the original value of x to create the new x value. The value of dy is added to the original value of y to create the new y value. - * @param dx The amount by which to offset the horizontal coordinate, x. - * @param dy The amount by which to offset the vertical coordinate, y. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 按指定量偏移 Point 对象。dx 的值将添加到 x 的原始值中以创建新的 x 值。dy 的值将添加到 y 的原始值中以创建新的 y 值。 - * @param dx 水平坐标 x 的偏移量。 - * @param dy 水平坐标 y 的偏移量。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - offset(dx: number, dy: number): void; - /** - * Converts a pair of polar coordinates to a Cartesian point coordinate. - * @param len The length coordinate of the polar pair. - * @param angle The angle, in radians, of the polar pair. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将一对极坐标转换为笛卡尔点坐标。 - * @param len 极坐标对的长度。 - * @param angle 极坐标对的角度(以弧度表示)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static polar(len: number, angle: number): Point; - /** - * Subtracts the coordinates of another point from the coordinates of this point to create a new point. - * @param v The point to be subtracted. - * @returns The new point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从此点的坐标中减去另一个点的坐标以创建一个新点。 - * @param v 要减去的点。 - * @returns 新点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - subtract(v: Point): Point; - /** - * Returns a string that contains the values of the x and y coordinates. The string has the form "(x=x, y=y)", so calling the toString() method for a point at 23,17 would return "(x=23, y=17)". - * @returns The string representation of the coordinates. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回包含 x 和 y 坐标的值的字符串。该字符串的格式为 "(x=x, y=y)",因此为点 23,17 调用 toString() 方法将返回 "(x=23, y=17)"。 - * @returns 坐标的字符串表示形式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - toString(): string; - } - /** - * @private - * 仅供框架内复用,要防止暴露引用到外部。 - */ - let $TempPoint: Point; -} -declare namespace egret { - /** - * The DisplayObjectContainer class is a basic display list building block: a display list node that can contain children. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObjectContainer.ts - * @language en_US - */ - /** - * DisplayObjectContainer 类是基本显示列表构造块:一个可包含子项的显示列表节点。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObjectContainer.ts - * @language zh_CN - */ - class DisplayObjectContainer extends DisplayObject { - /** - * @private - */ - static $EVENT_ADD_TO_STAGE_LIST: DisplayObject[]; - /** - * @private - */ - static $EVENT_REMOVE_FROM_STAGE_LIST: DisplayObject[]; - /** - * Creates a new DisplayObjectContainer instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 实例化一个容器 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * Returns the number of children of this object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回此对象的子项数目。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly numChildren: number; - /** - * Adds a child DisplayObject instance to this DisplayObjectContainer instance. The child is added to the front - * (top) of all other children in this DisplayObjectContainer instance. (To add a child to a specific index position, - * use the addChildAt() method.)If you add a child object that already has a different display object container - * as a parent, the object is removed from the child list of the other display object container. - * @param child The DisplayObject instance to add as a child of this DisplayObjectContainer instance. - * @returns 在 child The DisplayObject instance that you pass in the child parameter. - * @see #addChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将一个 DisplayObject 子实例添加到该 DisplayObjectContainer 实例中。子项将被添加到该 DisplayObjectContainer 实例中其他 - * 所有子项的前(上)面。(要将某子项添加到特定索引位置,请使用 addChildAt() 方法。) - * @param child 要作为该 DisplayObjectContainer 实例的子项添加的 DisplayObject 实例。 - * @returns 在 child 参数中传递的 DisplayObject 实例。 - * @see #addChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - addChild(child: DisplayObject): DisplayObject; - /** - * Adds a child DisplayObject instance to this DisplayObjectContainer instance. The child is added at the index position - * specified. An index of 0 represents the back (bottom) of the display list for this DisplayObjectContainer object. - * If you add a child object that already has a different display object container as a parent, the object is removed - * from the child list of the other display object container. - * @param child The DisplayObject instance to add as a child of this DisplayObjectContainer instance. - * @param index The index position to which the child is added. If you specify a currently occupied index position, - * the child object that exists at that position and all higher positions are moved up one position in the child list. - * @returns The DisplayObject instance that you pass in the child parameter. - * @see #addChild() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将一个 DisplayObject 子实例添加到该 DisplayObjectContainer 实例中。该子项将被添加到指定的索引位置。索引为 0 表示该 - * DisplayObjectContainer 对象的显示列表的后(底)部。如果添加一个已将其它显示对象容器作为父项的子对象,则会从其它显示对象容器的子列表中删除该对象。 - * @param child 要作为该 DisplayObjectContainer 实例的子项添加的 DisplayObject 实例。 - * @param index 添加该子项的索引位置。 如果指定当前占用的索引位置,则该位置以及所有更高位置上的子对象会在子级列表中上移一个位置。 - * @returns 在 child 参数中传递的 DisplayObject 实例。 - * @see #addChild() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - addChildAt(child: DisplayObject, index: number): DisplayObject; - /** - * @private - */ - $doAddChild(child: DisplayObject, index: number, notifyListeners?: boolean): DisplayObject; - /** - * Determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance - * itself. The search includes the entire display list including this DisplayObjectContainer instance. Grandchildren, - * great-grandchildren, and so on each return true. - * @param child The child object to test. - * @returns true if the child object is a child of the DisplayObjectContainer or the container itself; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定指定显示对象是 DisplayObjectContainer 实例的子项或该实例本身。搜索包括整个显示列表(其中包括此 DisplayObjectContainer 实例)。 - * 孙项、曾孙项等,每项都返回 true。 - * @param child 要测试的子对象。 - * @returns 如果 child 对象是 DisplayObjectContainer 的子项或容器本身,则为 true;否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - contains(child: DisplayObject): boolean; - /** - * Returns the child display object instance that exists at the specified index. - * @param index The index position of the child object. - * @returns The child display object at the specified index position. - * @see #getChildByName() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回位于指定索引处的子显示对象实例。 - * @param index 子对象的索引位置。 - * @returns 位于指定索引位置处的子显示对象。 - * @see #getChildByName() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getChildAt(index: number): DisplayObject; - /** - * Returns the index position of a child DisplayObject instance. - * @param child The DisplayObject instance to identify. - * @returns The index position of the child display object to identify. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回 DisplayObject 的 child 实例的索引位置。 - * @param child 要测试的子对象。 - * @returns 要查找的子显示对象的索引位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getChildIndex(child: egret.DisplayObject): number; - /** - * Returns the child display object that exists with the specified name. If more that one child display object has - * the specified name, the method returns the first object in the child list.The getChildAt() method is faster than - * the getChildByName() method. The getChildAt() method accesses a child from a cached array, whereas the getChildByName() - * method has to traverse a linked list to access a child. - * @param name The name of the child to return. - * @returns The child display object with the specified name. - * @see #getChildAt() - * @see egret.DisplayObject#name - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回具有指定名称的子显示对象。如果多个子显示对象具有指定名称,则该方法会返回子级列表中的第一个对象。 - * getChildAt() 方法比 getChildByName() 方法快。getChildAt() 方法从缓存数组中访问子项,而 getChildByName() 方法则必须遍历链接的列表来访问子项。 - * @param name 要返回的子项的名称。 - * @returns 具有指定名称的子显示对象。 - * @see #getChildAt() - * @see egret.DisplayObject#name - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getChildByName(name: string): DisplayObject; - /** - * Removes the specified child DisplayObject instance from the child list of the DisplayObjectContainer instance. - * The parent property of the removed child is set to null , and the object is garbage collected if no other references - * to the child exist. The index positions of any display objects above the child in the DisplayObjectContainer are - * decreased by 1. - * @param child The DisplayObject instance to remove. - * @returns The DisplayObject instance that you pass in the child parameter. - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 DisplayObjectContainer 实例的子列表中删除指定的 child DisplayObject 实例。将已删除子项的 parent 属性设置为 null; - * 如果不存在对该子项的任何其它引用,则将该对象作为垃圾回收。DisplayObjectContainer 中该子项之上的任何显示对象的索引位置都减去 1。 - * @param child 要删除的 DisplayObject 实例。 - * @returns 在 child 参数中传递的 DisplayObject 实例。 - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - removeChild(child: DisplayObject): DisplayObject; - /** - * Removes a child DisplayObject from the specified index position in the child list of the DisplayObjectContainer. - * The parent property of the removed child is set to null, and the object is garbage collected if no other references - * to the child exist. The index positions of any display objects above the child in the DisplayObjectContainer are decreased by 1. - * @param index The child index of the DisplayObject to remove. - * @returns The DisplayObject instance that was removed. - * @see #removeChild() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 DisplayObjectContainer 的子列表中指定的 index 位置删除子 DisplayObject。将已删除子项的 parent 属性设置为 null; - * 如果没有对该子项的任何其他引用,则将该对象作为垃圾回收。DisplayObjectContainer 中该子项之上的任何显示对象的索引位置都减去 1。 - * @param index 要删除的 DisplayObject 的子索引。 - * @returns 已删除的 DisplayObject 实例。 - * @see #removeChild() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - removeChildAt(index: number): DisplayObject; - /** - * @private - */ - $doRemoveChild(index: number, notifyListeners?: boolean): DisplayObject; - /** - * Changes the position of an existing child in the display object container. This affects the layering of child objects. - * @param child The child DisplayObject instance for which you want to change the index number. - * @param index The resulting index number for the child display object. - * @see #addChildAt() - * @see #getChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 更改现有子项在显示对象容器中的位置。这会影响子对象的分层。 - * @param child 要为其更改索引编号的 DisplayObject 子实例。 - * @param index 生成的 child 显示对象的索引编号。当新的索引编号小于0或大于已有子元件数量时,新加入的DisplayObject对象将会放置于最上层。 - * @see #addChildAt() - * @see #getChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setChildIndex(child: DisplayObject, index: number): void; - /** - * @private - */ - private doSetChildIndex(child, index); - /** - * Swaps the z-order (front-to-back order) of the child objects at the two specified index positions in the child - * list. All other child objects in the display object container remain in the same index positions. - * @param index1 The index position of the first child object. - * @param index2 The index position of the second child object. - * @see #swapChildren() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在子级列表中两个指定的索引位置,交换子对象的 Z 轴顺序(前后顺序)。显示对象容器中所有其他子对象的索引位置保持不变。 - * @param index1 第一个子对象的索引位置。 - * @param index2 第二个子对象的索引位置。 - * @see #swapChildren() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - swapChildrenAt(index1: number, index2: number): void; - /** - * Swaps the z-order (front-to-back order) of the two specified child objects. All other child objects in the - * display object container remain in the same index positions. - * @param child1 The first child object. - * @param child2 The second child object. - * @see #swapChildrenAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 交换两个指定子对象的 Z 轴顺序(从前到后顺序)。显示对象容器中所有其他子对象的索引位置保持不变。 - * @param child1 第一个子对象。 - * @param child2 第二个子对象。 - * @see #swapChildrenAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - swapChildren(child1: DisplayObject, child2: DisplayObject): void; - /** - * @private - */ - private doSwapChildrenAt(index1, index2); - /** - * Removes all child DisplayObject instances from the child list of the DisplayObjectContainer instance. The parent - * property of the removed children is set to null , and the objects are garbage collected if no other references to the children exist. - * @see #removeChild() - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 DisplayObjectContainer 实例的子级列表中删除所有 child DisplayObject 实例。 - * @see #removeChild() - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - removeChildren(): void; - /** - * @private - * 一个子项被添加到容器内,此方法不仅在操作addChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 - * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 - */ - $childAdded(child: DisplayObject, index: number): void; - /** - * @private - * 一个子项从容器内移除,此方法不仅在操作removeChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 - * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 - */ - $childRemoved(child: DisplayObject, index: number): void; - /** - * @private - */ - $onAddToStage(stage: Stage, nestLevel: number): void; - /** - * @private - * - */ - $onRemoveFromStage(): void; - /** - * @private - */ - $measureChildBounds(bounds: Rectangle): void; - $touchChildren: boolean; - /** - * Determines whether or not the children of the object are touch, or user input device, enabled. If an object is - * enabled, a user can interact with it by using a touch or user input device. - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定对象的子级是否支持触摸或用户输入设备。如果对象支持触摸或用户输入设备,用户可以通过使用触摸或用户输入设备与之交互。 - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - touchChildren: boolean; - /** - * @private - * - * @returns - */ - $getTouchChildren(): boolean; - /** - * @private - */ - $setTouchChildren(value: boolean): boolean; - /** - * @private - */ - $hitTest(stageX: number, stageY: number): DisplayObject; - } -} -declare namespace egret { - /** - * SpriteSheet is a mosaic of multiple sub-bitmaps, comprising a plurality of Texture objects. - * Each Texture object shares the set bitmap of SpriteSheet, but it points to its different areas. - * On WebGL / OpenGL, this operation can significantly improve performance. - * At the same time, SpriteSheet can carry out material integration easily to reduce the number of HTTP requests - * For specification of the SpriteSheet format, see the document https://github.com/egret-labs/egret-core/wiki/Egret-SpriteSheet-Specification - * @see http://edn.egret.com/cn/docs/page/135 The use of texture packs - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/SpriteSheet.ts - * @language en_US - */ - /** - * SpriteSheet 是一张由多个子位图拼接而成的集合位图,它包含多个 Texture 对象。 - * 每一个 Texture 都共享 SpriteSheet 的集合位图,但是指向它的不同的区域。 - * 在WebGL / OpenGL上,这种做法可以显著提升性能 - * 同时,SpriteSheet可以很方便的进行素材整合,降低HTTP请求数量 - * SpriteSheet 格式的具体规范可以参见此文档 https://github.com/egret-labs/egret-core/wiki/Egret-SpriteSheet-Specification - * @see http://edn.egret.com/cn/docs/page/135 纹理集的使用 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/SpriteSheet.ts - * @language zh_CN - */ - class SpriteSheet extends HashObject { - /** - * Create an egret.SpriteSheet object - * @param texture {Texture} Texture - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.SpriteSheet 对象 - * @param texture {Texture} 纹理 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(texture: Texture); - /** - * @private - * 表示这个SpriteSheet的位图区域在bitmapData上的起始位置x。 - */ - private _bitmapX; - /** - * @private - * 表示这个SpriteSheet的位图区域在bitmapData上的起始位置y。 - */ - private _bitmapY; - /** - * @private - * 共享的位图数据 - */ - $texture: Texture; - /** - * @private - * 纹理缓存字典 - */ - _textureMap: MapLike; - /** - * Obtain a cached Texture object according to the specified texture name - * @param name {string} Cache the name of this Texture object - * @returns {egret.Texture} The Texture object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 根据指定纹理名称获取一个缓存的 Texture 对象 - * @param name {string} 缓存这个 Texture 对象所使用的名称 - * @returns {egret.Texture} Texture 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getTexture(name: string): Texture; - /** - * Create a new Texture object for the specified area on SpriteSheet and cache it - * @param name {string} Cache the name of this Texture object. If the name already exists, the previous Texture object will be overwrited. - * @param bitmapX {number} Starting coordinate x of texture area on bitmapData - * @param bitmapY {number} Starting coordinate y of texture area on bitmapData - * @param bitmapWidth {number} Width of texture area on bitmapData - * @param bitmapHeight {number} Height of texture area on bitmapData - * @param offsetX {number} Starting point x for a non-transparent area of the original bitmap - * @param offsetY {number} Starting point y for a non-transparent area of the original bitmap - * @param textureWidth {number} Width of the original bitmap. If it is not passed, use the bitmapWidth value. - * @param textureHeight {number} Height of the original bitmap. If it is not passed, use the bitmapHeight value. - * @returns {egret.Texture} The created Texture object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 为 SpriteSheet 上的指定区域创建一个新的 Texture 对象并缓存它 - * @param name {string} 缓存这个 Texture 对象所使用的名称,如果名称已存在,将会覆盖之前的 Texture 对象 - * @param bitmapX {number} 纹理区域在 bitmapData 上的起始坐标x - * @param bitmapY {number} 纹理区域在 bitmapData 上的起始坐标y - * @param bitmapWidth {number} 纹理区域在 bitmapData 上的宽度 - * @param bitmapHeight {number} 纹理区域在 bitmapData 上的高度 - * @param offsetX {number} 原始位图的非透明区域 x 起始点 - * @param offsetY {number} 原始位图的非透明区域 y 起始点 - * @param textureWidth {number} 原始位图的高度,若不传入,则使用 bitmapWidth 的值。 - * @param textureHeight {number} 原始位图的宽度,若不传入,则使用 bitmapHeight 的值。 - * @returns {egret.Texture} 创建的 Texture 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - createTexture(name: string, bitmapX: number, bitmapY: number, bitmapWidth: number, bitmapHeight: number, offsetX?: number, offsetY?: number, textureWidth?: number, textureHeight?: number): Texture; - /** - * dispose texture - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放纹理 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dispose(): void; - } -} -declare namespace egret { - /** - * @private - */ - let $locale_strings: any; - /** - * @private - */ - let $language: string; -} -declare namespace egret.sys { - /** - * @private - * 全局多语言翻译函数 - * @param code 要查询的字符串代码 - * @param args 替换字符串中{0}标志的参数列表 - * @returns 返回拼接后的字符串 - */ - function tr(code: number, ...args: any[]): string; -} -declare namespace egret { - /** - * The Bitmap class represents display objects that represent bitmap images. - * The Bitmap() constructor allows you to create a Bitmap object that contains a reference to a BitmapData object. - * After you create a Bitmap object, use the addChild() or addChildAt() method of the parent DisplayObjectContainer - * instance to place the bitmap on the display list.A Bitmap object can share its texture reference among several - * Bitmap objects, independent of translation or rotation properties. Because you can create multiple Bitmap objects - * that reference the same texture object, multiple display objects can use the same complex texture object - * without incurring the memory overhead of a texture object for each display object instance. - * - * @see egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Bitmap.ts - * @language en_US - */ - /** - * Bitmap 类表示用于显示位图图片的显示对象。 - * 利用 Bitmap() 构造函数,可以创建包含对 BitmapData 对象引用的 Bitmap 对象。创建了 Bitmap 对象后, - * 使用父级 DisplayObjectContainer 实例的 addChild() 或 addChildAt() 方法可以将位图放在显示列表中。 - * 一个 Bitmap 对象可在若干 Bitmap 对象之中共享其 texture 引用,与缩放或旋转属性无关。 - * 由于能够创建引用相同 texture 对象的多个 Bitmap 对象,因此,多个显示对象可以使用相同的 texture 对象, - * 而不会因为每个显示对象实例使用一个 texture 对象而产生额外内存开销。 - * - * @see egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Bitmap.ts - * @language zh_CN - */ - class Bitmap extends DisplayObject { - /** - * Initializes a Bitmap object to refer to the specified Texture object. - * @param value The Texture object being referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个引用指定 Texture 实例的 Bitmap 对象 - * @param value 被引用的 Texture 实例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(value?: Texture); - protected $texture: Texture; - $bitmapData: BitmapData; - protected $bitmapX: number; - protected $bitmapY: number; - protected $bitmapWidth: number; - protected $bitmapHeight: number; - protected $offsetX: number; - protected $offsetY: number; - protected $textureWidth: number; - protected $textureHeight: number; - protected $sourceWidth: number; - protected $sourceHeight: number; - protected $smoothing: boolean; - protected $explicitBitmapWidth: number; - protected $explicitBitmapHeight: number; - protected createNativeDisplayObject(): void; - /** - * @private - * 显示对象添加到舞台 - */ - $onAddToStage(stage: Stage, nestLevel: number): void; - /** - * @private - * 显示对象从舞台移除 - */ - $onRemoveFromStage(): void; - /** - * The Texture object being referenced. - * If you pass the constructor of type BitmapData or last set for bitmapData, this value returns null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的 Texture 对象。 - * 如果传入构造函数的类型为 BitmapData 或者最后设置的为 bitmapData,则此值返回 null。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - texture: Texture; - /** - * @private - */ - $setTexture(value: Texture): boolean; - $setBitmapData(value: any): void; - /** - * @private - */ - protected setBitmapDataToWasm(data?: Texture): void; - /** - * @private - */ - $refreshImageData(): void; - /** - * @private - */ - private setImageData(bitmapData, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, sourceWidth, sourceHeight); - /** - * @private - */ - $scale9Grid: egret.Rectangle; - /** - * Represent a Rectangle Area that the 9 scale area of Image. - * Notice: This property is valid only when fillMode - * is BitmapFillMode.SCALE. - * - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形区域,它定义素材对象的九个缩放区域。 - * 注意:此属性仅在fillModeBitmapFillMode.SCALE时有效。 - * - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scale9Grid: egret.Rectangle; - protected $setScale9Grid(value: egret.Rectangle): void; - /** - * @private - */ - $fillMode: string; - /** - * Determines how the bitmap fills in the dimensions. - *

When set to BitmapFillMode.REPEAT, the bitmap - * repeats to fill the region.

- *

When set to BitmapFillMode.SCALE, the bitmap - * stretches to fill the region.

- * - * @default BitmapFillMode.SCALE - * - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 确定位图填充尺寸的方式。 - *

设置为 BitmapFillMode.REPEAT时,位图将重复以填充区域。

- *

设置为 BitmapFillMode.SCALE时,位图将拉伸以填充区域。

- * - * @default BitmapFillMode.SCALE - * - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - fillMode: string; - $setFillMode(value: string): boolean; - /** - * The default value of whether or not is smoothed when scaled. - * When object such as Bitmap is created,smoothing property will be set to this value. - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否进行平滑处理的默认值。 - * 在 Bitmap 等对象创建时,smoothing 属性会被设置为该值。 - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language zh_CN - */ - static defaultSmoothing: boolean; - /** - * Whether or not the bitmap is smoothed when scaled. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否对位图进行平滑处理。 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - smoothing: boolean; - /** - * @private - * - * @param value - */ - $setWidth(value: number): boolean; - /** - * @private - * - * @param value - */ - $setHeight(value: number): boolean; - /** - * @private - * 获取显示宽度 - */ - $getWidth(): number; - /** - * @private - * 获取显示宽度 - */ - $getHeight(): number; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - /** - * @private - */ - $updateRenderNode(): void; - private _pixelHitTest; - /** - * Specifies whether this object use precise hit testing by checking the alpha value of each pixel.If pixelHitTest - * is set to true,the transparent area of the bitmap will be touched through.
- * Note:If the image is loaded from cross origin,that we can't access to the pixel data,so it might cause - * the pixelHitTest property invalid. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否开启精确像素碰撞。设置为true显示对象本身的透明区域将能够被穿透。
- * 注意:若图片资源是以跨域方式从外部服务器加载的,将无法访问图片的像素数据,而导致此属性失效。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - pixelHitTest: boolean; - $hitTest(stageX: number, stageY: number): DisplayObject; - } -} -declare namespace egret.sys { - /** - * @private - * 渲染节点类型 - */ - const enum RenderNodeType { - /** - * 位图渲染节点 - */ - BitmapNode = 1, - /** - * 文本渲染节点 - */ - TextNode = 2, - /** - * 矢量渲染节点 - */ - GraphicsNode = 3, - /** - * 组渲染节点 - */ - GroupNode = 4, - /** - * Mesh 节点 - */ - MeshNode = 5, - /** - * 普通位图渲染节点 - */ - NormalBitmapNode = 6, - } - /** - * @private - * 渲染节点基类 - */ - class RenderNode { - /** - * 节点类型.. - */ - type: number; - /** - * 绘制数据 - */ - drawData: any[]; - /** - * 绘制次数 - */ - protected renderCount: number; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - $getRenderCount(): number; - } -} -declare namespace egret.sys { - /** - * @private - * 路径类型 - */ - const enum PathType { - /** - * 纯色填充路径 - */ - Fill = 1, - /** - * 渐变填充路径 - */ - GradientFill = 2, - /** - * 线条路径 - */ - Stroke = 3, - } - /** - * @private - * 2D路径命令 - */ - const enum PathCommand { - MoveTo = 1, - LineTo = 2, - CurveTo = 3, - CubicCurveTo = 4, - } - /** - * @private - * 2D路径 - */ - class Path2D { - /** - * 路径类型 - */ - type: number; - $commands: number[]; - $data: number | number[][]; - protected commandPosition: number; - protected dataPosition: number; - /** - * 当前移动到的坐标X - * 注意:目前只有drawArc之前会被赋值 - */ - $lastX: number; - /** - * 当前移动到的坐标Y - * 注意:目前只有drawArc之前会被赋值 - */ - $lastY: number; - /** - * 将当前绘图位置移动到 (x, y)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - */ - moveTo(x: number, y: number): void; - /** - * 使用当前线条样式绘制一条从当前绘图位置开始到 (x, y) 结束的直线;当前绘图位置随后会设置为 (x, y)。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - */ - lineTo(x: number, y: number): void; - /** - * 使用当前线条样式和由 (controlX, controlY) 指定的控制点绘制一条从当前绘图位置开始到 (anchorX, anchorY) 结束的二次贝塞尔曲线。当前绘图位置随后设置为 (anchorX, anchorY)。 - * 如果在调用 moveTo() 方法之前调用了 curveTo() 方法,则当前绘图位置的默认值为 (0, 0)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * 绘制的曲线是二次贝塞尔曲线。二次贝塞尔曲线包含两个锚点和一个控制点。该曲线内插这两个锚点,并向控制点弯曲。 - * @param controlX 一个数字,指定控制点相对于父显示对象注册点的水平位置。 - * @param controlY 一个数字,指定控制点相对于父显示对象注册点的垂直位置。 - * @param anchorX 一个数字,指定下一个锚点相对于父显示对象注册点的水平位置。 - * @param anchorY 一个数字,指定下一个锚点相对于父显示对象注册点的垂直位置。 - */ - curveTo(controlX: number, controlY: number, anchorX: number, anchorY: number): void; - /** - * 从当前绘图位置到指定的锚点绘制一条三次贝塞尔曲线。三次贝塞尔曲线由两个锚点和两个控制点组成。该曲线内插这两个锚点,并向两个控制点弯曲。 - * @param controlX1 指定首个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY1 指定首个控制点相对于父显示对象的注册点的垂直位置。 - * @param controlX2 指定第二个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY2 指定第二个控制点相对于父显示对象的注册点的垂直位置。 - * @param anchorX 指定锚点相对于父显示对象的注册点的水平位置。 - * @param anchorY 指定锚点相对于父显示对象的注册点的垂直位置。 - */ - cubicCurveTo(controlX1: number, controlY1: number, controlX2: number, controlY2: number, anchorX: number, anchorY: number): void; - /** - * 绘制一个矩形 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - */ - drawRect(x: number, y: number, width: number, height: number): void; - /** - * 绘制一个圆角矩形。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @param ellipseWidth 用于绘制圆角的椭圆的宽度(以像素为单位)。 - * @param ellipseHeight 用于绘制圆角的椭圆的高度(以像素为单位)。 (可选)如果未指定值,则默认值与为 ellipseWidth 参数提供的值相匹配。 - */ - drawRoundRect(x: number, y: number, width: number, height: number, ellipseWidth: number, ellipseHeight?: number): void; - /** - * 绘制一个圆。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param radius 圆的半径(以像素为单位)。 - */ - drawCircle(x: number, y: number, radius: number): void; - /** - * 绘制一个椭圆。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - */ - drawEllipse(x: number, y: number, width: number, height: number): void; - /** - * 绘制一段圆弧路径。圆弧路径的圆心在 (x, y) 位置,半径为 r ,根据anticlockwise (默认为顺时针)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radius 圆弧的半径。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * 注意,必须在0~2π之间。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * 注意,必须在0~2π之间。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - */ - drawArc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise: boolean): void; - /** - * 绘制一段圆弧路径 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radiusX 圆弧的半径 x。 - * @param radiusY 圆弧的半径 y。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * 注意:必须为正数。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * 注意:与startAngle差值必须在0~2π之间。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - * 注意:如果为true,endAngle必须小于startAngle,反之必须大于。 - */ - private arcToBezier(x, y, radiusX, radiusY, startAngle, endAngle, anticlockwise?); - } -} -declare namespace egret { - /** - * Writes an error message to the console if the assertion is false. If the assertion is true, nothing will happen. - * @param assertion Any boolean expression. If the assertion is false, the message will get written to the console. - * @param message the message written to the console - * @param optionalParams the extra messages written to the console - * @language en_US - */ - /** - * 判断参数assertion是否为true,若为false则抛出异常并且在console输出相应信息,反之什么也不做。 - * @param assertion 一个 boolean 表达式,若结果为false,则抛出错误并输出信息。 - * @param message 要输出到控制台的信息 - * @param optionalParams 要输出到控制台的额外可选信息 - * @language zh_CN - */ - function assert(assertion?: boolean, message?: string, ...optionalParams: any[]): void; - /** - * Writes a warning message to the console. - * @param message the message written to the console - * @param optionalParams the extra messages written to the console - * @language en_US - */ - /** - * 输出一个警告信息到控制台。 - * @param message 要输出到控制台的信息 - * @param optionalParams 要输出到控制台的额外信息 - * @language zh_CN - */ - function warn(message?: any, ...optionalParams: any[]): void; - /** - * Writes an error message to the console. - * @param message the message written to the console - * @param optionalParams the extra messages written to the console - * @language en_US - */ - /** - * 输出一个错误信息到控制台。 - * @param message 要输出到控制台的信息 - * @param optionalParams 要输出到控制台的额外信息 - * @language zh_CN - */ - function error(message?: any, ...optionalParams: any[]): void; - /** - * Writes an message to the console. - * @param message the message written to the console - * @param optionalParams the extra messages written to the console - * @language en_US - */ - /** - * 输出一个日志信息到控制台。 - * @param message 要输出到控制台的信息 - * @param optionalParams 要输出到控制台的额外信息 - * @language zh_CN - */ - function log(message?: any, ...optionalParams: any[]): void; -} -/** - * @private - */ -declare namespace egret { - /** - * @private - */ - let fontMapping: {}; -} -/** - * @private - */ -declare namespace egret_native { - function readUpdateFileSync(filePath: any): any; - function readResourceFileSync(filePath: any): any; - function sendInfoToPlugin(info: string): void; - function receivedPluginInfo(info: string): void; - function nrInit(): void; - function nrDownloadBuffers(callback: (displayCmdBuffer: Float32Array) => void): void; - function nrSetRenderMode(mode: number): void; - function nrRenderDisplayObject(id: number, scale: number, useClip: boolean, clipX: number, clipY: number, clipW: number, clipH: number): void; - function nrRenderDisplayObject2(id: number, offsetX: number, offsetY: number, forHitTest: boolean): void; - function nrLocalToGlobal(id: number, localX: number, localY: number): string; - function nrGlobalToLocal(id: number, globalX: number, globalY: number): string; - function nrGetTextFieldWidth(id: number): number; - function nrGetTextFieldHeight(id: number): number; - function nrGetTextWidth(id: number): number; - function nrGetTextHeight(id: number): number; - function nrResize(width: number, height: number): void; - function nrSetCanvasScaleFactor(factor: number, scalex: number, scaley: number): void; - function nrUpdate(): void; - function nrRender(): void; - function nrSendTextFieldData(textFieldId: number, strData: string): void; - function nrUpdateCallbackList(dt: number): void; - function nrActiveBuffer(id: number, width: number, height: number): void; - function nrGetPixels(x: number, y: number, width: number, height: number, pixels: Uint8Array): void; - class NrNode { - constructor(id: number, type: number); - } -} -/** - * @private - */ -declare namespace egret_native { - let rootWebGLBuffer: egret.sys.RenderBuffer; - let forHitTest: boolean; - let addModuleCallback: (callback: Function, thisObj: any) => void; - let initNativeRender: () => void; - let updateNativeRender: () => void; - let activateBuffer: (buffer: egret.sys.RenderBuffer) => void; - let getJsCustomFilterVertexSrc: (key: any) => any; - let getJsCustomFilterFragSrc: (key: any) => any; - let getJsCustomFilterUniforms: (key: any) => any; - let nrABIVersion: number; - let nrMinEgretVersion: string; -} -declare namespace egret_native { - /** - * @private - */ - class NativeRenderSurface { - width: number; - height: number; - constructor(currRenderBuffer: any, w?: number, h?: number, root?: boolean); - resize(w: number, h: number): void; - } - /** - * @private - */ - class NativeDisplayObject { - id: number; - constructor(type: number); - addChildAt(childId: number, index: number): void; - removeChild(childId: number): void; - swapChild(index1: number, index2: number): void; - setX(value: number): void; - setY(value: number): void; - setRotation(value: number): void; - setScaleX(value: number): void; - setScaleY(value: number): void; - setSkewX(value: number): void; - setSkewY(value: number): void; - setAlpha(value: number): void; - setAnchorOffsetX(value: number): void; - setAnchorOffsetY(value: number): void; - setVisible(value: boolean): void; - setBlendMode(value: number): void; - setMaskRect(x: number, y: number, w: number, h: number): void; - setScrollRect(x: number, y: number, w: number, h: number): void; - setFilters(filters: Array): void; - static createFilter(filter: egret.Filter): void; - static setFilterPadding(filterId: number, paddingTop: number, paddingBottom: number, paddingLeft: number, paddingRight: number): void; - setMask(value: number): void; - setBitmapData(value: egret.Texture): void; - setBitmapDataToMesh(value: egret.Texture): void; - setBitmapDataToParticle(value: egret.Texture): void; - setStopToParticle(value: boolean): void; - setCustomData(config: any): void; - setWidth(value: number): void; - setHeight(value: number): void; - setCacheAsBitmap(value: boolean): void; - setBitmapFillMode(fillMode: string): void; - setScale9Grid(x: number, y: number, w: number, h: number): void; - setMatrix(a: number, b: number, c: number, d: number, tx: number, ty: number): void; - setIsTyping(value: boolean): void; - setDataToBitmapNode(id: number, texture: egret.Texture, arr: number[]): void; - setDataToMesh(vertexArr: number[], indiceArr: number[], uvArr: number[]): void; - static setDataToFilter(currFilter: egret.Filter): void; - static disposeTexture(texture: egret.Texture): void; - static disposeBitmapData(bitmapData: egret.BitmapData): void; - static disposeTextData(node: egret.TextField): void; - static disposeGraphicData(graphic: egret.Graphics): void; - setFontSize(value: number): void; - setLineSpacing(value: number): void; - setTextColor(value: number): void; - setTextFieldWidth(value: number): void; - setTextFieldHeight(value: number): void; - setFontFamily(value: string): void; - setTextFlow(textArr: Array): void; - setTextAlign(value: string): void; - setVerticalAlign(value: string): void; - setText(value: string): void; - setBold(value: boolean): void; - setItalic(value: boolean): void; - setWordWrap(value: boolean): void; - setMaxChars(value: number): void; - setType(value: string): void; - setStrokeColor(value: number): void; - setStroke(value: number): void; - setScrollV(value: number): void; - setMultiline(value: boolean): void; - setBorder(value: boolean): void; - setBorderColor(value: number): void; - setBackground(value: boolean): void; - setBackgroundColor(value: number): void; - setInputType(value: string): void; - setBeginFill(color: number, alpha?: number): void; - setBeginGradientFill(type: string, colors: number[], alphas: number[], ratios: number[], matrix: egret.Matrix): void; - setEndFill(): void; - setLineStyle(thickness?: number, color?: number, alpha?: number, pixelHinting?: boolean, scaleMode?: string, caps?: string, joints?: string, miterLimit?: number, lineDash?: number[]): void; - setDrawRect(x: number, y: number, width: number, height: number): void; - setDrawRoundRect(x: number, y: number, width: number, height: number, ellipseWidth: number, ellipseHeight?: number): void; - setDrawCircle(x: number, y: number, radius: number): void; - setDrawEllipse(x: number, y: number, width: number, height: number): void; - setMoveTo(x: number, y: number): void; - setLineTo(x: number, y: number): void; - setCurveTo(controlX: number, controlY: number, anchorX: number, anchorY: number): void; - setCubicCurveTo(controlX1: number, controlY1: number, controlX2: number, controlY2: number, anchorX: number, anchorY: number): void; - setDrawArc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; - setGraphicsClear(): void; - } -} -/** - * @private - */ -declare namespace egret_native { - /** - * @private - */ - const enum NativeObjectType { - /** - * 容器 - */ - CONTAINER = 0, - /** - * 位图 - */ - BITMAP = 1, - /** - * 位图数据 - */ - BITMAP_DATA = 2, - /** - * 滤镜 - */ - FILTER = 6, - /** - * 文本 - */ - TEXT = 7, - /** - * 矢量绘图 - */ - GRAPHICS = 8, - /** - * 含一个适量绘图的容器 - */ - SPRITE = 9, - /** - * 粒子系统 - */ - PARTICLE_SYSTEM = 10, - /** - * 位图文本 - */ - BITMAP_TEXT = 11, - /** - * 网格 - */ - MESH = 12, - /** - * 舞台(根容器) - */ - STAGE = 13, - } -} -declare namespace egret { - /** - * @private - */ - interface MapLike { - [key: string]: T; - [key: number]: T; - } - /** - * @private - */ - function createMap(): MapLike; -} -declare namespace egret { - /** - * @class egret.GlowFilter - * @classdesc - * 使用 GlowFilter 类可以对显示对象应用发光效果。在投影滤镜的 distance 和 angle 属性设置为 0 时,发光滤镜与投影滤镜极为相似。 - * @extends egret.Filter - * @version Egret 3.1.4 - * @platform Web,Native - */ - class GlowFilter extends Filter { - /** - * @private - */ - $red: number; - /** - * @private - */ - $green: number; - /** - * @private - */ - $blue: number; - /** - * Initializes a new GlowFilter instance. - * @method egret.GlowFilter#constructor - * @param color {number} The color of the glow. Valid values are in the hexadecimal format 0xRRGGBB. The default value is 0xFF0000. - * @param alpha {number} The alpha transparency value for the color. Valid values are 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1. - * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point). - * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point). - * @param strength {number} The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255. - * @param quality {number} The number of times to apply the filter. - * @param inner {boolean} Specifies whether the glow is an inner glow. The value true indicates an inner glow. The default is false, an outer glow (a glow around the outer edges of the object). - * @param knockout {number} Specifies whether the object has a knockout effect. A value of true makes the object's fill transparent and reveals the background color of the document. The default value is false (no knockout effect). - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 初始化 GlowFilter 对象 - * @method egret.GlowFilter#constructor - * @param color {number} 光晕颜色,采用十六进制格式 0xRRGGBB。默认值为 0xFF0000。 - * @param alpha {number} 颜色的 Alpha 透明度值。有效值为 0 到 1。例如,0.25 设置透明度值为 25%。 - * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。 - * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。 - * @param strength {number} 印记或跨页的强度。该值越高,压印的颜色越深,而且发光与背景之间的对比度也越强。有效值为 0 到 255。 - * @param quality {number} 应用滤镜的次数。暂未实现。 - * @param inner {boolean} 指定发光是否为内侧发光。值 true 指定发光是内侧发光。值 false 指定发光是外侧发光(对象外缘周围的发光)。 - * @param knockout {number} 指定对象是否具有挖空效果。值为 true 将使对象的填充变为透明,并显示文档的背景颜色。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - constructor(color?: number, alpha?: number, blurX?: number, blurY?: number, strength?: number, quality?: number, inner?: boolean, knockout?: boolean); - /** - * @private - */ - $color: number; - /** - * The color of the glow. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 光晕颜色。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - color: number; - /** - * @private - */ - $alpha: number; - /** - * The alpha transparency value for the color. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 颜色的 Alpha 透明度值。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - alpha: number; - /** - * @private - */ - $blurX: number; - /** - * The amount of horizontal blur. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 水平模糊量。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - blurX: number; - /** - * @private - */ - $blurY: number; - /** - * The amount of vertical blur. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 垂直模糊量。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - blurY: number; - /** - * @private - */ - $strength: number; - /** - * The strength of the imprint or spread. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 印记或跨页的强度。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - strength: number; - /** - * @private - */ - $quality: number; - /** - * The number of times to apply the filter. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 应用滤镜的次数。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - quality: number; - /** - * @private - */ - $inner: boolean; - /** - * Specifies whether the glow is an inner glow. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 指定发光是否为内侧发光。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - inner: boolean; - /** - * @private - */ - $knockout: boolean; - /** - * Specifies whether the object has a knockout effect. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 指定对象是否具有挖空效果。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - knockout: boolean; - /** - * @private - */ - $toJson(): string; - protected updatePadding(): void; - } -} -declare namespace egret { - /** - * A class that provides constant values for visual blend mode effects. These constants are used in the blendMode - * property of the DisplayObject class. - * @see egret.DisplayObject#blendMode - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BlendMode.ts - * @see http://edn.egret.com/cn/docs/page/108 显示容器的概念与实现 - * @language en_US - */ - /** - * 提供混合模式可视效果的常量值的类,通常用于 DisplayObject 的 blendMode 属性上。 - * @see egret.DisplayObject#blendMode - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BlendMode.ts - * @see http://edn.egret.com/cn/docs/page/108 显示容器的概念与实现 - * @language zh_CN - */ - class BlendMode { - /** - * The display object appears in front of the background. Pixel values of the display object override the pixel - * values of the background. Where the display object is transparent, the background is visible. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该显示对象出现在背景前面。显示对象的像素值会覆盖背景的像素值。在显示对象为透明的区域,背景是可见的。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static NORMAL: string; - /** - * Adds the values of the constituent colors of the display object to the colors of its background, applying a - * ceiling of 0xFF. This setting is commonly used for animating a lightening dissolve between two objects.
- * For example, if the display object has a pixel with an RGB value of 0xAAA633, and the background pixel has an - * RGB value of 0xDD2200, the resulting RGB value for the displayed pixel is 0xFFC833 (because 0xAA + 0xDD > 0xFF, - * 0xA6 + 0x22 = 0xC8, and 0x33 + 0x00 = 0x33). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将显示对象的原色值添加到它的背景颜色中,上限值为 0xFF。此设置通常用于使两个对象间的加亮溶解产生动画效果。
- * 例如,如果显示对象的某个像素的 RGB 值为 0xAAA633,背景像素的 RGB 值为 0xDD2200,则显示像素的结果 RGB 值为 0xFFC833 - * (因为 0xAA + 0xDD > 0xFF,0xA6 + 0x22 = 0xC8,且 0x33 + 0x00 = 0x33)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ADD: string; - /** - * Erases the background based on the alpha value of the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 根据显示对象的 Alpha 值擦除背景。Alpha 值不为0的区域将被擦除。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ERASE: string; - } -} -declare namespace egret.sys { - /** - * @private - * 转换 blendMode 字符串为数字。 - */ - function blendModeToNumber(blendMode: string): number; - /** - * @private - * 转换数字为 blendMode 字符串。 - */ - function numberToBlendMode(blendMode: number): string; -} -declare namespace egret { - /** - * The CapsStyle class is an enumeration of constant values that specify the caps style to use in drawing lines. - * The constants are provided for use as values in the caps parameter of the egret.Graphics.lineStyle() method. - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * CapsStyle 类是可指定在绘制线条中使用的端点样式的常量值枚举。常量可用作 egret.Graphics.lineStyle() 方法的 caps 参数中的值。 - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - const CapsStyle: { - NONE: string; - ROUND: string; - SQUARE: string; - }; -} -declare namespace egret { - /** - * @private - */ - class WebGLUtils { - static compileProgram(gl: WebGLRenderingContext, vertexSrc: string, fragmentSrc: string): WebGLProgram; - static compileFragmentShader(gl: WebGLRenderingContext, shaderSrc: string): WebGLShader; - static compileVertexShader(gl: WebGLRenderingContext, shaderSrc: string): WebGLShader; - private static _compileShader(gl, shaderSrc, shaderType); - private static canUseWebGL; - static checkCanUseWebGL(): boolean; - static deleteWebGLTexture(bitmapData: any): void; - } -} -declare namespace egret { - /** - * The EventPhase class provides values for the eventPhase property of the Event class. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventPhase.ts - * @language en_US - */ - /** - * EventPhase 可为 Event 类的 eventPhase 属性提供值。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventPhase.ts - * @language zh_CN - */ - const enum EventPhase { - /** - * The capturing phase, which is the first phase of the event flow. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 捕获阶段。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - CAPTURING_PHASE = 1, - /** - * The target phase, which is the second phase of the event flow. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 目标阶段,是事件流的第二个阶段。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - AT_TARGET = 2, - /** - * The bubbling phase, which is the third phase of the event flow. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 冒泡阶段。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - BUBBLING_PHASE = 3, - } -} -declare namespace egret { - /** - * When the user changes the focus from one object in the display list to another object, the object dispatches a FocusEvent object. Currently only supports input text. - * Focus events: FocusEvent.FOCUS_IN FocusEvent.FOCUS_OUT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用户将焦点从显示列表中的一个对象更改到另一个对象时,对象将调度 FocusEvent 对象。目前只支持输入文本。 - * 焦点事件:FocusEvent.FOCUS_IN FocusEvent.FOCUS_OUT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class FocusEvent extends egret.Event { - /** - * Gets focus - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获得焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static FOCUS_IN: "focusIn"; - /** - * Loses focus - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 失去焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static FOCUS_OUT: "focusOut"; - /** - * Create a egret.FocusEvent objects - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.FocusEvent 对象 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - } -} -declare namespace egret { - interface Geolocation { - addEventListener(type: "ioError", listener: (this: Z, e: GeolocationEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * The GeolocationEvent represents the position and altitude of the device on Earth, - * and show errors occurred while getting the location of the device. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Geolocation.ts - * @see http://edn.egret.com/cn/docs/page/662 获取位置信息 - * @language en_US - */ - /** - * GeolocationEvent 提供设备的地理位置信息和获取位置时发生的错误信息 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Geolocation.ts - * @see http://edn.egret.com/cn/docs/page/662 获取位置信息 - * @language zh_CN - */ - class GeolocationEvent extends Event { - /** - * The acquisition of the location information failed because of app don't have permission. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由于用户拒绝访问位置信息,获取位置信息失败 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static PERMISSION_DENIED: string; - /** - * The acquisition of the location failed because at least one internal source of position returned an internal error. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设备位置服务不可用或者超时等原因没有得到位置信息 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static UNAVAILABLE: string; - /** - * The position's longitude in decimal degrees. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前位置的经度信息 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - longitude: number; - /** - * The position's latitude in decimal degrees. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前位置的纬度信息 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - latitude: number; - /** - * The velocity of the device in meters per second. This value can be null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前设备的速度 单位是 米/秒,这个值可能为 null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - speed: number; - /** - * The direction in which the device is traveling. This value, specified in degrees, - * indicates how far off from heading due north the device is. 0 degrees represents - * true true north, and the direction is determined clockwise (which means that east - * is 90 degrees and west is 270 degrees). If speed is 0, heading is NaN. If the - * device is unable to provide heading information, this value is null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示设备正在前进的方向,单位是度。heading 表示从正北开始顺时针旋转到当前方向的角度, - * 比如正东是 90 度,正西是 270 度,如果 speed 是 0,heading 为 NaN。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - heading: number; - /** - * The position's altitude in metres, relative to sea level. - * This value can be null if the implementation cannot provide the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该位置的海拔信息,如果设备没有实现这个属性时,这个值有可能为 null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - altitude: number; - /** - * The accuracy of the latitude and longitude properties, expressed in meters. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 经纬度的准确性,单位是米 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - accuracy: number; - /** - * The accuracy of the altitude expressed in meters. This value can be null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该位置海拔信息的准确性,单位是米,这个值有可能为 null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - altitudeAccuracy: number; - /** - * The type of error occurred while get the location of the device. The value could be: - * @see egret.GeolocationEvent.PERMISSION_DENIED - * @see egret.GeolocationEvent.UNAVAILABLE - * - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位置信息错误时的错误类型。值可能为: - * @see egret.GeolocationEvent.PERMISSION_DENIED - * @see egret.GeolocationEvent.UNAVAILABLE - * - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - errorType: string; - /** - * The error message occurred while get the location of the device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位置信息错误的错误信息 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - errorMessage: string; - } -} -declare namespace egret { - /** - * When a network request returns an HTTP status code, the application dispatches HTTPStatusEvent objects. - * Before error or completion events will always send HTTPStatusEvent object. HTTPStatusEvent object does not necessarily indicate an error condition; it simply reflects the HTTP status code provided by the network stack (if any). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在网络请求返回 HTTP 状态代码时,应用程序将调度 HTTPStatusEvent 对象。 - * 在错误或完成事件之前,将始终发送 HTTPStatusEvent 对象。HTTPStatusEvent 对象不一定表示错误条件;它仅反映网络堆栈提供的 HTTP 状态代码(如果有的话)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class HTTPStatusEvent extends Event { - /** - * HTTPStatusEvent.HTTP_STATUS constant defines the value of the type property httpStatus event object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HTTPStatusEvent.HTTP_STATUS 常量定义 httpStatus 事件对象的 type 属性值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static HTTP_STATUS: "httpStatus"; - /** - * Create a egret.HTTPStatusEvent objects - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.HTTPStatusEvent 对象 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * @private - */ - private _status; - /** - * he server returns the HTTP status code. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由服务器返回的 HTTP 状态代码。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly status: number; - /** - * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin. - * @param target {egret.IEventDispatcher} Distribute event target - * @param status {number} The server returns the HTTP status code - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param status {number} 由服务器返回的 HTTP 状态代码 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchHTTPStatusEvent(target: IEventDispatcher, status: number): boolean; - } -} -declare namespace egret { - /** - * The IEventDispatcher interface defines methods for adding or removing event listeners, checks whether specific types - * of event listeners are registered, and dispatches events. Event targets are an important part of the Egret event model. - * The event target serves as the focal point for how events flow through the display list hierarchy. When an event - * such as a touch tap occurs, an event object is dispatched into the event flow from the root of the display list. - * The event object makes a round-trip journey to the event target, which is conceptually divided into three phases:
- * the capture phase includes the journey from the root to the last node before the event target's node; the target - * phase includes only the event target node; and the bubbling phase includes any subsequent nodes encountered on the - * return trip to the root of the display list.In general, the easiest way for a user-defined class to gain event - * dispatching capabilities is to extend EventDispatcher. If this is impossible (that is, if the class is already - * extending another class), you can instead implement the IEventDispatcher interface, create an EventDispatcher member, - * and write simple hooks to route calls into the aggregated EventDispatcher. - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IEventDispatcher.ts - * @language en_US - */ - /** - * IEventDispatcher 接口定义用于添加或删除事件侦听器的方法,检查是否已注册特定类型的事件侦听器,并调度事件。 - * 事件目标是 Egret 事件模型的重要组成部分。事件目标是事件如何通过显示列表层次结构这一问题的焦点。当发生触摸轻拍事件时, - * 会将事件对象调度到从显示列表根开始的事件流中。事件对象进行到事件目标的往返行程,在概念上,此往返行程被划分为三个阶段:
- * 捕获阶段包括从根到事件目标节点之前的最后一个节点的行程,目标阶段仅包括事件目标节点,冒泡阶段包括到显示列表的根的回程上遇到的任何后续节点。 - * 通常,使用户定义的类能够调度事件的最简单方法是扩展 EventDispatcher。如果无法扩展(即,如果该类已经扩展了另一个类), - * 则可以实现 IEventDispatcher 接口,创建 EventDispatcher 成员,并编写一些简单的挂钩,将调用连接到聚合的 EventDispatcher 中。 - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IEventDispatcher.ts - * @language zh_CN - */ - interface IEventDispatcher extends HashObject { - /** - * Registers an event listener object with an EventDispatcher object so that the listener receives notification of an - * event. You can register event listeners on all nodes in the display list for a specific type of event, phase, - * and priority.After you successfully register an event listener, you cannot change its priority through additional - * calls to on(). To change a listener's priority, you must first call removeEventListener(). Then you can register the - * listener again with the new priority level.After the listener is registered, subsequent calls to on() with a - * different value for either type or useCapture result in the creation of a separate listener registration.
- * When you no longer need an event listener, remove it by calling EventDispatcher.removeEventListener(); otherwise, memory - * problems might result. Objects with registered event listeners are not automatically removed from memory because - * the garbage collector does not remove objects that still have references.Copying an EventDispatcher instance does - * not copy the event listeners attached to it. (If your newly created node needs an event listener, you must attach - * the listener after creating the node.) However, if you move an EventDispatcher instance, the event listeners attached - * to it move along with it.If the event listener is being registered on a node while an event is also being processed - * on this node, the event listener is not triggered during the current phase but may be triggered during a later phase - * in the event flow, such as the bubbling phase.If an event listener is removed from a node while an event is being - * processed on the node, it is still triggered by the current actions. After it is removed, the event listener is - * never invoked again (unless it is registered again for future processing). - * @param type The type of event. - * @param listener The listener function that processes the event. This function must accept an event object as - * its only parameter and must return nothing, as this example shows: function(evt:Event):void The function can - * have any name. - * @param thisObject the listener function's "this" - * @param useCapture Determines whether the listener works in the capture phase or the bubbling phases. If useCapture - * is set to true, the listener processes the event only during the capture phase and not in the bubbling phase. - * If useCapture is false, the listener processes the event only during the bubbling phase. To listen for the event - * in all three phases, call on() twice, once with useCapture set to true, then again with useCapture set to false. - * @param priority The priority level of the event listener. Priorities are designated by a integer. The higher - * the number, the higher the priority. All listeners with priority n are processed before listeners of priority n-1. - * If two or more listeners share the same priority, they are processed in the order in which they were added. - * The default priority is - * @see #once() - * @see #removeEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用 EventDispatcher 对象注册事件侦听器对象,以使侦听器能够接收事件通知。可以为特定类型的事件、阶段和优先级在显示列表的所有节 - * 点上注册事件侦听器。成功注册一个事件侦听器后,无法通过额外调用 on() 来更改其优先级。要更改侦听器的优先级,必须 - * 先调用 removeEventListener()。然后,可以使用新的优先级再次注册该侦听器。注册该侦听器后,如果继续调用具有不同 type 或 useCapture - * 值的 on(),则会创建单独的侦听器注册。
- * 如果不再需要某个事件侦听器,可调用 EventDispatcher.removeEventListener() - * 删除它;否则会产生内存问题。由于垃圾回收器不会删除仍包含引用的对象,因此不会从内存中自动删除使用已注册事件侦听器的对象。复制 - * EventDispatcher 实例时并不复制其中附加的事件侦听器。(如果新近创建的节点需要一个事件侦听器,必须在创建该节点后附加该侦听器。) - * 但是,如果移动 EventDispatcher 实例,则其中附加的事件侦听器也会随之移动。如果在正在处理事件的节点上注册事件侦听器,则不会在当 - * 前阶段触发事件侦听器,但会在事件流的稍后阶段触发,如冒泡阶段。如果从正在处理事件的节点中删除事件侦听器,则该事件侦听器仍由当前操 - * 作触发。删除事件侦听器后,决不会再次调用该事件侦听器(除非再次注册以备将来处理)。 - * @param type 事件的类型。 - * @param listener 处理事件的侦听器函数。此函数必须接受 Event 对象作为其唯一的参数,并且不能返回任何结果, - * 如下面的示例所示: function(evt:Event):void 函数可以有任何名称。 - * @param thisObject 侦听函数绑定的this对象 - * @param useCapture 确定侦听器是运行于捕获阶段还是运行于冒泡阶段。如果将 useCapture 设置为 true, - * 则侦听器只在捕获阶段处理事件,而不在冒泡阶段处理事件。如果 useCapture 为 false,则侦听器只在冒泡阶段处理事件。 - * 要在两个阶段都侦听事件,请调用 on() 两次:一次将 useCapture 设置为 true,一次将 useCapture 设置为 false。 - * @param priority 事件侦听器的优先级。优先级由一个带符号的整数指定。数字越大,优先级越高。优先级为 n 的所有侦听器会在 - * 优先级为 n -1 的侦听器之前得到处理。如果两个或更多个侦听器共享相同的优先级,则按照它们的添加顺序进行处理。默认优先级为 0。 - * @see #once() - * @see #removeEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * Registers an event listener object with an EventDispatcher object so that the listener receives notification of an - * event. Different from the on() method,the listener receives notification only once,and then it will be removed - * automatically. - * @param type The type of event. - * @param listener The listener function that processes the event. This function must accept an event object as - * its only parameter and must return nothing, as this example shows: function(evt:Event):void The function can - * have any name. - * @param thisObject the listener function's "this" - * @param useCapture Determines whether the listener works in the capture phase or the bubbling phases. If useCapture - * is set to true, the listener processes the event only during the capture phase and not in the bubbling phase. - * If useCapture is false, the listener processes the event only during the bubbling phase. To listen for the event - * in all three phases, call on() twice, once with useCapture set to true, then again with useCapture set to false. - * @param priority The priority level of the event listener. Priorities are designated by a integer. The higher - * the number, the higher the priority. All listeners with priority n are processed before listeners of priority n-1. - * If two or more listeners share the same priority, they are processed in the order in which they were added. - * The default priority is - * @see #on() - * @see #removeEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 添加仅回调一次的事件侦听器,此方法与on()方法不同,on()方法会持续产生回调,而此方法在第一次回调时就会自动移除监听。 - * @param type 事件的类型。 - * @param listener 处理事件的侦听器函数。此函数必须接受 Event 对象作为其唯一的参数,并且不能返回任何结果, - * 如下面的示例所示: function(evt:Event):void 函数可以有任何名称。 - * @param thisObject 侦听函数绑定的this对象 - * @param useCapture 确定侦听器是运行于捕获阶段还是运行于冒泡阶段。如果将 useCapture 设置为 true, - * 则侦听器只在捕获阶段处理事件,而不在冒泡阶段处理事件。如果 useCapture 为 false,则侦听器只在冒泡阶段处理事件。 - * 要在两个阶段都侦听事件,请调用 once() 两次:一次将 useCapture 设置为 true,一次将 useCapture 设置为 false。 - * @param priority 事件侦听器的优先级。优先级由一个带符号整数指定。数字越大,优先级越高。优先级为 n 的所有侦听器会在 - * 优先级为 n -1 的侦听器之前得到处理。如果两个或更多个侦听器共享相同的优先级,则按照它们的添加顺序进行处理。默认优先级为 0。 - * @see #on() - * @see #removeEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - once(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * Removes a listener from the EventDispatcher object. If there is no matching listener registered with the - * EventDispatcher object, a call to this method has no effect. - * @param type The type of event. - * @param listener The listener object to remove. - * @param thisObject the listener function's "this" - * @param useCapture Specifies whether the listener was registered for the capture phase or the bubbling phases. - * If the listener was registered for both the capture phase and the bubbling phases, two calls to removeEventListener() - * are required to remove both: one call with useCapture set to true, and another call with useCapture set to false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 EventDispatcher 对象中删除侦听器。如果没有向 EventDispatcher 对象注册任何匹配的侦听器,则对此方法的调用没有任何效果。 - * @param type 事件的类型。 - * @param listener 要删除的侦听器对象 - * @param thisObject 侦听函数绑定的this对象 - * @param useCapture 指出是为捕获阶段还是为冒泡阶段注册了侦听器。如果为捕获阶段以及冒泡阶段注册了侦听器,则需要对 - * removeEventListener() 进行两次调用才能将这两个侦听器删除:一次调用将 useCapture 设置为 true,另一次调用将 useCapture 设置为 false。。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - removeEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean): void; - /** - * Checks whether the EventDispatcher object has any listeners registered for a specific type of event. This allows - * you to determine where an EventDispatcher object has altered handling of an event type in the event flow hierarchy. - * To determine whether a specific event type will actually trigger an event listener, use IEventDispatcher.willTrigger(). - * The difference between hasEventListener() and willTrigger() is that hasEventListener() examines only the object to - * which it belongs, whereas willTrigger() examines the entire event flow for the event specified by the type parameter. - * @param type The type of event. - * @returns A value of true if a listener of the specified type is registered; false otherwise. - * @see #willTrigger() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查 EventDispatcher 对象是否为特定事件类型注册了任何侦听器。这样,您就可以确定 EventDispatcher 对象在事件流层次结构中的哪个 - * 位置改变了对事件类型的处理。要确定特定事件类型是否确实会触发事件侦听器,请使用 IEventDispatcher.willTrigger()。hasEventListener() - * 与 willTrigger() 的区别是:hasEventListener() 只检查它所属的对象,而 willTrigger() 检查整个事件流以查找由 type 参数指定的事件。 - * @param type 事件的类型。 - * @returns 如果指定类型的侦听器已注册,则值为 true;否则,值为 false。 - * @see #willTrigger() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - hasEventListener(type: string): boolean; - /** - * Dispatches an event into the event flow. The event target is the EventDispatcher object upon which dispatchEvent() is called. - * @param event The event object dispatched into the event flow. - * @returns A value of true unless preventDefault() is called on the event, in which case it returns false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将事件分派到事件流中。事件目标是对其调用 dispatchEvent() 方法的 EventDispatcher 对象。 - * @param event 调度到事件流中的 Event 对象。 - * @returns 如果成功调度了事件,则值为 true。值 false 表示失败或对事件调用了 preventDefault()。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dispatchEvent(event: Event): boolean; - /** - * Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the - * specified event type. This method returns true if an event listener is triggered during any phase of the event - * flow when an event of the specified type is dispatched to this EventDispatcher object or any of its descendants. - * @param type The type of event. - * @returns A value of true if a listener of the specified type will be triggered; false otherwise. - * @see #hasEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查是否用此 EventDispatcher 对象或其任何始祖为指定事件类型注册了事件侦听器。将指定类型的事件调度给此 - * EventDispatcher 对象或其任一后代时,如果在事件流的任何阶段触发了事件侦听器,则此方法返回 true。 - * hasEventListener() 与 willTrigger() 方法的区别是:hasEventListener() 只检查它所属的对象, - * 而 willTrigger() 方法检查整个事件流以查找由 type 参数指定的事件。 - * @param type 事件类型 - * @returns 是否注册过监听器,如果注册过返回true,反之返回false - * @see #hasEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - willTrigger(type: string): boolean; - } -} -declare namespace egret { - interface HttpRequest { - addEventListener(type: "ioError", listener: (this: Z, e: IOErrorEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * @classdesc IO流事件,当错误导致输入或输出操作失败时调度 IOErrorEvent 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IOErrorEvent.ts - * @language en_US - */ - /** - * @classdesc IO流事件,当错误导致输入或输出操作失败时调度 IOErrorEvent 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IOErrorEvent.ts - * @language zh_CN - */ - class IOErrorEvent extends Event { - /** - * io error - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * io发生错误 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static IO_ERROR: "ioError"; - /** - * Create a egret.IOErrorEvent objects - * @param type {string} Type of event, accessible as Event.type. - * @param bubbles {boolean} Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable {boolean} Determine whether the Event object can be canceled. The default value is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.IOErrorEvent 对象 - * @param type {string} 事件的类型,可以作为 Event.type 访问。 - * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable {boolean} 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin. - * @param target {egret.IEventDispatcher} Distribute event target - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchIOErrorEvent(target: IEventDispatcher): boolean; - } -} -declare namespace egret { - /** - * MotionEvent represents the device's movement - * Acceleration and accelerationIncludingGravity to represents the device's acceleration - * RotationRate to represents the device's rotation - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Motion.ts - * @language en_US - */ - /** - * MotionEvent 类呈现设备运动的具体信息 - * Acceleration 和 accelerationIncludingGravity 呈现设备三个维度的加速度信息 - * RotationRate 呈现设备的旋转状态信息 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Motion.ts - * @language zh_CN - */ - class MotionEvent extends Event { - /** - * An object giving the acceleration of the device on the three axis X, Y and Z. Acceleration is expressed in m/s2. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * acceleration 表示设备在 X Y Z 轴方将的加速度信息,单位是 m/s2,不包含重力 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - acceleration: DeviceAcceleration; - /** - * An object giving the acceleration of the device on the three axis X, Y and Z with the effect of gravity. Acceleration is expressed in m/s2. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * acceleration 表示设备在 X Y Z 轴方将的加速度信息,单位是 m/s2,包含重力 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - accelerationIncludingGravity: DeviceAcceleration; - /** - * An object giving the rate of change of the device's orientation on the three orientation axis alpha, beta and gamma. Rotation rate is express in degrees per seconds. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * rotationRate 表示设备在 alpha、 beta 和 gamma 三个轴向的角速度信息,单位是 角度每秒 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - rotationRate: DeviceRotationRate; - } -} -declare namespace egret { - /** - * The OrientationEvent provides information from the physical orientation of the device. - * Note: Currently, Browsers on the iOS and Android does not handle the coordinates the same way. - * Take care about this while using them. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/DeviceOrientation.ts - * @language en_US - */ - /** - * OrientationEvent 提供设备的方向信息 - * 注意: 目前各个浏览器和操作系统处理方向的方式不完全相同,请根据使用场景做相应的校正, - * 比如使用两次方向数据的变化而不是直接使用方向的值 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/DeviceOrientation.ts - * @language zh_CN - */ - class OrientationEvent extends Event { - /** - * A number representing the motion of the device around the z axis, - * express in degrees with values ranging from 0 to 360 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示设备绕 Z 轴的角度,单位是 角度 范围是 0 到 360 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - alpha: number; - /** - * A number representing the motion of the device around the x axis, - * express in degrees with values ranging from -180 to 180. - * This represents a front to back motion of the device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示设备绕 X 轴的角度,单位是 角度 范围是 -180 到 180. - * 这个值表示设备从前向后的旋转状态 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - beta: number; - /** - * A number representing the motion of the device around the y axis, - * express in degrees with values ranging from -90 to 90. - * This represents a left to right motion of the device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示设备绕 Y 轴的角度,单位是 角度 范围是 -90 到 90. - * 这个值表示设备从前向后的旋转状态 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - gamma: number; - } -} -declare namespace egret { - interface HttpRequest { - addEventListener(type: "progress", listener: (this: Z, e: ProgressEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * When a load operation has begun or a socket has received data, ProgressEvent object is dispatched. - * There are two types of progress events: ProgressEvent.PROGRESS and ProgressEvent.SOCKET_DATA. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当加载操作已开始或套接字已接收到数据时,将调度 ProgressEvent 对象。 - * 有两种类型的进程事件:ProgressEvent.PROGRESS 和 ProgressEvent.SOCKET_DATA。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class ProgressEvent extends egret.Event { - /** - * Changes in the loading progress - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 加载进度发生变化 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static PROGRESS: "progress"; - /** - * Get the data - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取到数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static SOCKET_DATA: "socketData"; - /** - * Number of items or bytes when the listener processes the event。 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在侦听器处理事件时加载的项数或字节数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bytesLoaded: number; - /** - * If the loading process succeeds, the total number or the total number of bytes that will be loaded term. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果加载过程成功,将加载的总项数或总字节数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bytesTotal: number; - /** - * 创建一个 egret.ProgressEvent 对象 - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param bytesLoaded {number} Number of items or bytes loaded - * @param bytesTotal {number} The total number of items or bytes loaded - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.ProgressEvent 对象 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param bytesLoaded {number} 加载的项数或字节数 - * @param bytesTotal {number} 加载的总项数或总字节数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, bytesLoaded?: number, bytesTotal?: number); - /** - * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin. - * @param target {egret.IEventDispatcher} Distribute event target - * @param type The type of the event, accessible as Event.type. - * @param bytesLoaded {number} Number of items or bytes loaded - * @param bytesTotal {number} The total number of items or bytes loaded - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param type {string} 事件类型 - * @param bytesLoaded {number} 加载的项数或字节数 - * @param bytesTotal {number} 加载的总项数或总字节数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchProgressEvent(target: IEventDispatcher, type: string, bytesLoaded?: number, bytesTotal?: number): boolean; - } -} -declare namespace egret { - interface Stage { - addEventListener(type: "orientationChange", listener: (this: Z, e: StageOrientationEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * When the direction of the stage of change, Stage object dispatches StageOrientationEvent object. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/StageOrientationEvent.ts - * @language en_US - */ - /** - * 当舞台的方向更改时,Stage 对象将调度 StageOrientationEvent 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/StageOrientationEvent.ts - * @language zh_CN - */ - class StageOrientationEvent extends Event { - /** - * After screen rotation distribute events. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 屏幕旋转后派发的事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ORIENTATION_CHANGE: "orientationChange"; - /** - * Creating contains specific information related to the event and the stage direction of StageOrientationEvent object. - * @param type Event types:StageOrientationEvent.ORIENTATION_CHANGE - * @param bubbles It indicates whether the Event object participates in the bubbling stage of the event flow. - * @param cancelable It indicates whether the Event object can be canceled. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建包含与舞台方向事件相关的特定信息的 StageOrientationEvent 对象。 - * @param type 事件的类型:StageOrientationEvent.ORIENTATION_CHANGE - * @param bubbles 表示 Event 对象是否参与事件流的冒泡阶段。 - * @param cancelable 表示是否可以取消 Event 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * 派发一个屏幕旋转的事件。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param type {egret.IEventDispatcher} 派发事件类型 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 派发一个屏幕旋转的事件。 - * @param target {egret.IEventDispatcher} Distribute event target - * @param type {egret.IEventDispatcher} Distribute event type - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchStageOrientationEvent(target: IEventDispatcher, type: string): boolean; - } -} -declare namespace egret { - /** - * When a user clicks a hyperlink rich text object dispatches TextEvent object. Text Event Type: TextEvent.LINK. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TextEvent.ts - * @language en_US - */ - /** - * 用户在富文本中单击超链接时,对象将调度 TextEvent 对象。文本事件类型:TextEvent.LINK。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TextEvent.ts - * @language zh_CN - */ - class TextEvent extends Event { - /** - * TextEvent create an object that contains information about text events. - * @param type Type of event, you can access the TextEvent.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determine whether the Event object can be canceled. The default value is false. - * @param text One or more characters of text entered by the user. Event listeners can access this information through the text property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 TextEvent 对象,其中包含有关文本事件的信息。 - * @param type 事件的类型,可以作为 TextEvent.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param text 用户输入的一个或多个文本字符。事件侦听器可以通过 text 属性访问此信息。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, text?: string); - /** - * It defines the value of the type property of a link event object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 定义 link 事件对象的 type 属性值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LINK: "link"; - /** - * In TextEvent.LINK event, event corresponding string. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在 TextEvent.LINK 事件中,event对应的字符串。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - text: string; - /** - * EventDispatcher object using the specified event object thrown TextEvent. The objects will be thrown in the object cache pool for the next round robin. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param text Text TextEvent object assignment - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出TextEvent事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 派发事件目标 - * @param type 事件类型 - * @param text TextEvent对象的text赋值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchTextEvent(target: IEventDispatcher, type: string, text: string): boolean; - } -} -declare namespace egret { - interface Timer { - addEventListener(type: "timer" | "timerComplete", listener: (this: Z, e: TimerEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * A Timer object dispatches a TimerEvent objects whenever the Timer object reaches the interval specified by the Timer.delay property. - * @see egret.Timer - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TimerEvent.ts - * @language en_US - */ - /** - * 每当 Timer 对象达到由 Timer.delay 属性指定的间隔时,Timer 对象即会调度 TimerEvent 对象。 - * @see egret.Timer - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TimerEvent.ts - * @language zh_CN - */ - class TimerEvent extends Event { - /** - * Dispatched whenever a Timer object reaches an interval specified according to the Timer.delay property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 每当 Timer 对象达到根据 Timer.delay 属性指定的间隔时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TIMER: "timer"; - /** - * Dispatched whenever it has completed the number of requests set by Timer.repeatCount. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 每当它完成 Timer.repeatCount 设置的请求数后调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TIMER_COMPLETE: "timerComplete"; - /** - * Creates an Event object with specific information relevant to timer events. - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param cancelable Determines whether the Event object can be canceled. Event listeners can access this information - * through the inherited cancelable property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Event 对象,其中包含有关 timer 事件的特定信息。 - * @param type 事件的类型。事件侦听器可以通过继承的 type 属性访问此信息。 - * @param bubbles 确定 Event 对象是否冒泡。事件侦听器可以通过继承的 bubbles 属性访问此信息。 - * @param cancelable 确定是否可以取消 Event 对象。事件侦听器可以通过继承的 cancelable 属性访问此信息。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * Instructs Egret runtime to render after processing of this event completes, if the display list has been modified. - * @example - *
-         *    function onTimer(event:TimerEvent):void {
-         *        if (40 < mySp.x && mySp.x < 375) {
-         *            mySp.x-= 50;
-         *        } else {
-         *            mySp.x=374;
-         *        }
-         *        event.updateAfterEvent();
-         *    }
-         *
-         *    let moveTimer:Timer=new Timer(50,250);
-         *    moveTimer.addEventListener(TimerEvent.TIMER,onTimer);
-         *    moveTimer.start();
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果已修改显示列表,调用此方法将会忽略帧频限制,在此事件处理完成后立即重绘屏幕。 - * @example - *
-         *    function onTimer(event:TimerEvent):void {
-         *        if (40 < mySp.x && mySp.x < 375) {
-         *            mySp.x-= 50;
-         *        } else {
-         *            mySp.x=374;
-         *        }
-         *        event.updateAfterEvent();
-         *    }
-         *
-         *    let moveTimer:Timer=new Timer(50,250);
-         *    moveTimer.addEventListener(TimerEvent.TIMER,onTimer);
-         *    moveTimer.start();
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - updateAfterEvent(): void; - /** - * uses a specified target to dispatchEvent an event. Using this method can reduce the number of - * reallocate event objects, which allows you to get better code execution performance. - * @param target the event target - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param cancelable Determines whether the Event object can be canceled. Event listeners can access this information - * through the inherited cancelable property. - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 事件派发目标 - * @param type 事件的类型。事件侦听器可以通过继承的 type 属性访问此信息。 - * @param bubbles 确定 Event 对象是否冒泡。事件侦听器可以通过继承的 bubbles 属性访问此信息。 - * @param cancelable 确定是否可以取消 Event 对象。事件侦听器可以通过继承的 cancelable 属性访问此信息。 - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchTimerEvent(target: IEventDispatcher, type: string, bubbles?: boolean, cancelable?: boolean): boolean; - } -} -declare namespace egret { - /** - * A BitmapData object contains an array of pixel data. This data can represent either a fully opaque bitmap or a - * transparent bitmap that contains alpha channel data. Either type of BitmapData object is stored as a buffer of 32-bit - * integers. Each 32-bit integer determines the properties of a single pixel in the bitmap.
- * Each 32-bit integer is a combination of four 8-bit channel values (from 0 to 255) that describe the alpha transparency - * and the red, green, and blue (ARGB) values of the pixel. (For ARGB values, the most significant byte represents the - * alpha channel value, followed by red, green, and blue.) - * @see egret.Bitmap - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * BitmapData 对象是一个包含像素数据的数组。此数据可以表示完全不透明的位图,或表示包含 Alpha 通道数据的透明位图。 - * 以上任一类型的 BitmapData 对象都作为 32 位整数的缓冲区进行存储。每个 32 位整数确定位图中单个像素的属性。
- * 每个 32 位整数都是四个 8 位通道值(从 0 到 255)的组合,这些值描述像素的 Alpha 透明度以及红色、绿色、蓝色 (ARGB) 值。 - * (对于 ARGB 值,最高有效字节代表 Alpha 通道值,其后的有效字节分别代表红色、绿色和蓝色通道值。) - * @see egret.Bitmap - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class BitmapData extends HashObject { - /** - * The width of the bitmap image in pixels. - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 位图图像的宽度,以像素为单位。 - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - width: number; - /** - * The height of the bitmap image in pixels. - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 位图图像的高度,以像素为单位。 - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - height: number; - /** - * Original bitmap image. - * HTMLImageElement|HTMLCanvasElement|HTMLVideoElement - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language en_US - */ - /** - * 原始位图图像。 - * HTMLImageElement|HTMLCanvasElement|HTMLVideoElement - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language zh_CN - */ - source: any; - /** - * WebGL texture. - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language en_US - */ - /** - * WebGL纹理。 - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language zh_CN - */ - webGLTexture: any; - /** - * Texture format. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 纹理格式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - format: string; - /** - * @private - * webgl纹理生成后,是否删掉原始图像数据 - */ - $deleteSource: boolean; - /** - * @private - * id - */ - $bitmapDataId: number; - /** - * Initializes a BitmapData object to refer to the specified source object. - * @param source The source object being referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个引用指定 source 实例的 BitmapData 对象 - * @param source 被引用的 source 实例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(source: any); - static create(type: "arraybuffer", data: ArrayBuffer, callback?: (bitmapData: BitmapData) => void): BitmapData; - static create(type: "base64", data: string, callback?: (bitmapData: BitmapData) => void): BitmapData; - $dispose(): void; - private static _displayList; - static $addDisplayObject(displayObject: DisplayObject, bitmapData: BitmapData): void; - static $removeDisplayObject(displayObject: DisplayObject, bitmapData: BitmapData): void; - static $invalidate(bitmapData: BitmapData): void; - static $dispose(bitmapData: BitmapData): void; - } -} -declare namespace egret { - interface DisplayObject { - addEventListener(type: "touchMove" | "touchBegin" | "touchEnd" | "touchCancel" | "touchTap" | "touchReleaseOutside" | "touchRollOut" | "touchRollOver", listener: (this: Z, e: TouchEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * The TouchEvent class lets you handle events on devices that detect user contact with the device (such as a finger - * on a touch screen).When a user interacts with a device such as a mobile phone or tablet with a touch screen, the - * user typically touches the screen with his or her fingers or a pointing device. You can develop applications that - * respond to basic touch events (such as a single finger tap) with the TouchEvent class. Create event listeners using - * the event types defined in this class. - * Note: When objects are nested on the display list, touch events target the deepest possible nested object that is - * visible in the display list. This object is called the target node. To have a target node's ancestor (an object - * containing the target node in the display list) receive notification of a touch event, use EventDispatcher.addEventListener() - * on the ancestor node with the type parameter set to the specific touch event you want to detect. - * - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TouchEvent.ts - * @language en_US - */ - /** - * 使用 TouchEvent 类,您可以处理设备上那些检测用户与设备之间的接触的事件。 - * 当用户与带有触摸屏的移动电话或平板电脑等设备交互时,用户通常使用手指或指针设备接触屏幕。可使用 TouchEvent - * 类开发响应基本触摸事件(如单个手指点击)的应用程序。使用此类中定义的事件类型创建事件侦听器。 - * 注意:当对象嵌套在显示列表中时,触摸事件的目标将是显示列表中可见的最深的可能嵌套对象。 - * 此对象称为目标节点。要使目标节点的祖代(祖代是一个包含显示列表中所有目标节点的对象,从舞台到目标节点的父节点均包括在内) - * 接收触摸事件的通知,请对祖代节点使用 EventDispatcher.on() 并将 type 参数设置为要检测的特定触摸事件。 - * - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TouchEvent.ts - * @language zh_CN - */ - class TouchEvent extends Event { - /** - * Dispatched when the user touches the device, and is continuously dispatched until the point of contact is removed. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户触碰设备时进行调度,而且会连续调度,直到接触点被删除。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_MOVE: "touchMove"; - /** - * Dispatched when the user first contacts a touch-enabled device (such as touches a finger to a mobile phone or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户第一次触摸启用触摸的设备时(例如,用手指触摸配有触摸屏的移动电话或平板电脑)调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_BEGIN: "touchBegin"; - /** - * Dispatched when the user removes contact with a touch-enabled device (such as lifts a finger off a mobile phone - * or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户移除与启用触摸的设备的接触时(例如,将手指从配有触摸屏的移动电话或平板电脑上抬起)调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_END: "touchEnd"; - /** - * Dispatched when an event of some kind occurred that canceled the touch. - * Such as the eui.Scroller will dispatch 'TOUCH_CANCEL' when it start move, the 'TOUCH_END' and 'TOUCH_TAP' will not be triggered. - * @version Egret 3.0.1 - * @platform Web,Native - * @language en_US - */ - /** - * 由于某个事件取消了触摸时触发。比如 eui.Scroller 在开始滚动后会触发 'TOUCH_CANCEL' 事件,不再触发后续的 'TOUCH_END' 和 'TOUCH_TAP' 事件 - * @version Egret 3.0.1 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_CANCEL: "touchCancel"; - /** - * Dispatched when the user lifts the point of contact over the same DisplayObject instance on which the contact - * was initiated on a touch-enabled device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户在触摸设备上与开始触摸的同一 DisplayObject 实例上抬起接触点时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_TAP: "touchTap"; - /** - * Dispatched when the user lifts the point of contact over the different DisplayObject instance on which the contact - * was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display - * object on a mobile phone or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户在触摸设备上与开始触摸的不同 DisplayObject 实例上抬起接触点时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_RELEASE_OUTSIDE: "touchReleaseOutside"; - /** - * Creates an Event object that contains information about touch events. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param stageX The horizontal coordinate at which the event occurred in global Stage coordinates. - * @param stageY The vertical coordinate at which the event occurred in global Stage coordinates. - * @param touchPointID A unique identification number assigned to the touch point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 TouchEvent 对象,其中包含有关Touch事件的信息 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param stageX 事件发生点在全局舞台坐标系中的水平坐标 - * @param stageY 事件发生点在全局舞台坐标系中的垂直坐标 - * @param touchPointID 分配给触摸点的唯一标识号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, stageX?: number, stageY?: number, touchPointID?: number); - /** - * @private - */ - $initTo(stageX: number, stageY: number, touchPointID: number): void; - /** - * @private - */ - $stageX: number; - /** - * The horizontal coordinate at which the event occurred in global Stage coordinates. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点在全局舞台坐标中的水平坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stageX: number; - /** - * @private - */ - $stageY: number; - /** - * The vertical coordinate at which the event occurred in global Stage coordinates. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点在全局舞台坐标中的垂直坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stageY: number; - private _localX; - /** - * The horizontal coordinate at which the event occurred relative to the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点相对于所属显示对象的水平坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly localX: number; - private _localY; - /** - * The vertical coordinate at which the event occurred relative to the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点相对于所属显示对象的垂直坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly localY: number; - private targetChanged; - /** - * @private - */ - private getLocalXY(); - $setTarget(target: any): boolean; - /** - * A unique identification number assigned to the touch point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 分配给触摸点的唯一标识号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - touchPointID: number; - /** - * Instructs Egret runtime to render after processing of this event completes, if the display list has been modified. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果已修改显示列表,调用此方法将会忽略帧频限制,在此事件处理完成后立即重绘屏幕。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - updateAfterEvent(): void; - /** - * Whether the touch is pressed (true) or not pressed (false). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示触摸已按下 (true) 还是未按下 (false)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - touchDown: boolean; - /** - * uses a specified target to dispatchEvent an event. Using this method can reduce the number of - * reallocate event objects, which allows you to get better code execution performance. - * @param target the event target - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param stageX The horizontal coordinate at which the event occurred in global Stage coordinates. - * @param stageY The vertical coordinate at which the event occurred in global Stage coordinates. - * @param touchPointID A unique identification number (as an int) assigned to the touch point. - * - * @see egret.Event.create() - * @see egret.Event.release() - * - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 派发事件目标 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param stageX 事件发生点在全局舞台坐标系中的水平坐标 - * @param stageY 事件发生点在全局舞台坐标系中的垂直坐标 - * @param touchPointID 分配给触摸点的唯一标识号 - * - * @see egret.Event.create() - * @see egret.Event.release() - * - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchTouchEvent(target: IEventDispatcher, type: string, bubbles?: boolean, cancelable?: boolean, stageX?: number, stageY?: number, touchPointID?: number, touchDown?: boolean): boolean; - } -} -declare namespace egret { - /** - * h5 and native interaction. - * @see http://edn.egret.com/cn/article/index/id/714 Egret basic skills to communicate with Native - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/external/ExternalInterface.ts - * @language en_US - */ - /** - * h5与native交互。 - * @see http://edn.egret.com/cn/article/index/id/714 Egret 与 Native 通信基本技巧 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/external/ExternalInterface.ts - * @language zh_CN - */ - interface ExternalInterface { - } - let ExternalInterface: { - /** - * Call functionName, and the value passed to the native. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 调用 functionName,并将value传入到native中。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - call(functionName: string, value: string): void; - /** - * FunctionName callback listener, you need to have to call functionName this field in native rather than such a call. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 监听 functionName 回调,需要在native中有调用 functionName 这个字段,而不是 此类的call。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - addCallback(functionName: string, listener: (value: string) => void): void; - }; -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - const enum BitmapFilterQuality { - /** - * 定义低品质滤镜设置 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - LOW = 1, - /** - * 定义中等品质滤镜设置 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - MEDIUM = 2, - /** - * 定义高品质滤镜设置 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - HIGH = 3, - } -} -declare namespace egret { - /** - * The BlurFilter class lets you apply a blur visual effect to display objects. A blur effect softens the details of an image. - * You can produce blurs that range from a softly unfocused look to a Gaussian blur, a hazy appearance like viewing an image through semi-opaque glass. - * @version Egret 3.0.1 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947#模糊滤镜 模糊滤镜 - * @language en_US - */ - /** - * 可使用 BlurFilter 类将模糊视觉效果应用于显示对象。模糊效果可以柔化图像的细节。 - * 您可以生成一些模糊效果,范围从创建一个柔化的、未聚焦的外观到高斯模糊(就像通过半透明玻璃查看图像一样的朦胧的外观)。 - * @version Egret 3.1.0 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947#模糊滤镜 模糊滤镜 - * @language zh_CN - */ - class BlurFilter extends Filter { - /** - * Initializes a BlurFilter object. - * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point). - * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point). - * @param quality {number} The number of times to apply the filter. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 创建一个 BlurFilter 对象。 - * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。 - * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。 - * @param quality {number} 应用滤镜的次数。暂未实现。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - constructor(blurX?: number, blurY?: number, quality?: number); - /** - * @private - */ - blurXFilter: IBlurXFilter; - /** - * @private - */ - blurYFilter: IBlurYFilter; - /** - * @private - */ - $quality: number; - /** - * The amount of horizontal blur. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 水平模糊量。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - blurX: number; - /** - * @private - */ - $blurX: number; - /** - * The amount of vertical blur. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 垂直模糊量。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - blurY: number; - /** - * @private - */ - $blurY: number; - /** - * @private - */ - $toJson(): string; - protected updatePadding(): void; - onPropertyChange(): void; - } - /** - * @private - */ - interface IBlurXFilter extends Filter { - type: string; - $uniforms: any; - blurX: number; - } - /** - * @private - */ - interface IBlurYFilter extends Filter { - type: string; - $uniforms: any; - blurY: number; - } -} -declare namespace egret { - /** - * The ColorMatrixFilter class lets you apply a 4 x 5 matrix transformation on the RGBA color and alpha values of every pixel in the input image to produce a result with a new set of RGBA color and alpha values. - * It allows saturation changes, hue rotation, luminance to alpha, and various other effects. - * @version Egret 3.1.0 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947 颜色矩阵滤镜 - * @language en_US - */ - /** - * 使用 ColorMatrixFilter 类可以将 4 x 5 矩阵转换应用于输入图像上的每个像素的 RGBA 颜色和 Alpha 值,以生成具有一组新的 RGBA 颜色和 Alpha 值的结果。 - * 该类允许饱和度更改、色相旋转、亮度为 Alpha 以及各种其他效果。 - * @version Egret 3.1.0 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947 颜色矩阵滤镜 - * @language zh_CN - */ - class ColorMatrixFilter extends Filter { - /** - * @private - */ - $matrix: number[]; - /** - * @private - */ - private matrix2; - /** - * Initializes a ColorMatrixFilter object. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 创建一个 ColorMatrixFilter 对象。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - constructor(matrix?: number[]); - /** - * A comma delimited list of 20 doubles that comprise a 4x5 matrix applied to the rendered element. - * The matrix is in row major order -- that is, the first five elements are multipled by the vector [srcR,srcG,srcB,srcA,1] to determine the output red value, the second five determine the output green value, etc. - * The value must either be an array or comma delimited string of 20 numbers. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 构成应用于所呈示的元素的一个 4x5 矩阵的、以逗号分隔的 20 个双精度数的列表。 - * 矩阵以行作为主要顺序,即用第一行五个元素乘以矢量 [srcR,srcG,srcB,srcA,1] 以确定输出的红色值,用第二行的五个元素确定输出的绿色值,等等。 - * 该值必须为 20 个数字组成的数组或以逗号分隔的字符串。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - matrix: number[]; - /** - * @private - */ - private setMatrix(value); - /** - * @private - */ - $toJson(): string; - } -} -declare namespace egret { - /** - * custom filter, now support WebGL mode only. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 自定义滤镜,目前仅支持WebGL模式 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - class CustomFilter extends Filter { - /** - * @private - */ - $vertexSrc: string; - /** - * @private - */ - $fragmentSrc: string; - /** - * @private - */ - $shaderKey: string; - /** - * @private - */ - type: string; - private $padding; - /** - * The inner margin of the filter. - * If the desired area of the custom filter is larger than the original area (stroke, etc.), you need to set it manually. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 滤镜的内边距 - * 如果自定义滤镜所需区域比原区域大(描边等),需要手动设置 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - padding: number; - /** - * The initial value of the uniform in the shader (key, value one-to-one correspondence), currently only supports numbers and arrays. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 着色器中uniform的初始值(key,value一一对应),目前仅支持数字和数组。 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - readonly uniforms: any; - /** - * Initialize the CustomFilter object. - * @param vertexSrc Custom vertex shader program. - * @param fragmentSrc Custom fragment shader program. - * @param uniforms The initial value of the uniform in the shader (key, value one-to-one correspondence), currently only supports numbers and arrays. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 初始化 CustomFilter 对象 - * @param vertexSrc 自定义的顶点着色器程序。 - * @param fragmentSrc 自定义的片段着色器程序。 - * @param uniforms 着色器中uniform的初始值(key,value一一对应),目前仅支持数字和数组。 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - constructor(vertexSrc: string, fragmentSrc: string, uniforms?: any); - onPropertyChange(): void; - } -} -declare namespace egret { - /** - * @class egret.DropShadowFilter - * @classdesc - * 可使用 DropShadowFilter 类向显示对象添加投影。 - * @extends egret.GlowFilter - * @version Egret 3.1.4 - * @platform Web,Native - */ - class DropShadowFilter extends GlowFilter { - /** - * Initializes a new DropShadowFilter instance. - * @method egret.DropShadowFilter#constructor - * @param distance {number} The offset distance of the bevel. Valid values are in pixels (floating point). - * @param angle {number} The angle of the bevel. Valid values are from 0 to 360°. - * @param color {number} The color of the glow. Valid values are in the hexadecimal format 0xRRGGBB. The default value is 0xFF0000. - * @param alpha {number} The alpha transparency value for the color. Valid values are 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1. - * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point). - * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point). - * @param strength {number} The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255. - * @param quality {number} The number of times to apply the filter. - * @param inner {boolean} Specifies whether the glow is an inner glow. The value true indicates an inner glow. The default is false, an outer glow (a glow around the outer edges of the object). - * @param knockout {number} Specifies whether the object has a knockout effect. A value of true makes the object's fill transparent and reveals the background color of the document. The default value is false (no knockout effect). - * @param hideObject {number} Indicates whether or not the object is hidden. The value true indicates that the object itself is not drawn; only the shadow is visible. The default is false, meaning that the object is shown. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 初始化 DropShadowFilter 对象 - * @method egret.DropShadowFilter#constructor - * @param distance {number} 阴影的偏移距离,以像素为单位。 - * @param angle {number} 阴影的角度,0 到 360 度(浮点)。 - * @param color {number} 光晕颜色,采用十六进制格式 0xRRGGBB。默认值为 0xFF0000。 - * @param alpha {number} 颜色的 Alpha 透明度值。有效值为 0 到 1。例如,0.25 设置透明度值为 25%。 - * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。 - * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。 - * @param strength {number} 印记或跨页的强度。该值越高,压印的颜色越深,而且发光与背景之间的对比度也越强。有效值为 0 到 255。 - * @param quality {number} 应用滤镜的次数。暂未实现。 - * @param inner {boolean} 指定发光是否为内侧发光。值 true 指定发光是内侧发光。值 false 指定发光是外侧发光(对象外缘周围的发光)。 - * @param knockout {number} 指定对象是否具有挖空效果。值为 true 将使对象的填充变为透明,并显示文档的背景颜色。 - * @param hideObject {number} 表示是否隐藏对象。如果值为 true,则表示没有绘制对象本身,只有阴影是可见的。默认值为 false(显示对象)。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - constructor(distance?: number, angle?: number, color?: number, alpha?: number, blurX?: number, blurY?: number, strength?: number, quality?: number, inner?: boolean, knockout?: boolean, hideObject?: boolean); - /** - * @private - */ - $distance: number; - /** - * The offset distance of the bevel. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 阴影的偏移距离,以像素为单位。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - distance: number; - /** - * @private - */ - $angle: number; - /** - * The angle of the bevel. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 阴影的角度。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - angle: number; - /** - * @private - */ - $hideObject: boolean; - /** - * Indicates whether or not the object is hidden. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 表示是否隐藏对象。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - hideObject: boolean; - /** - * @private - */ - $toJson(): string; - protected updatePadding(): void; - } -} -declare namespace egret { - /** - * The GradientType class provides values for the type parameter in the beginGradientFill() methods of the egret.Graphics class. - * - * @see egret.Graphics#beginGradientFill() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * GradientType 类为 egret.Graphics 类的 beginGradientFill() 方法中的 type 参数提供值。 - * - * @see egret.Graphics#beginGradientFill() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class GradientType { - /** - * Value used to specify a linear gradient fill. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定线性渐变填充的值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LINEAR: string; - /** - * Value used to specify a radial gradient fill. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定放射状渐变填充的值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static RADIAL: string; - } -} -declare namespace egret { - /** - * The Graphics class contains a set of methods for creating vector shape. Display objects that support drawing include Sprite and Shape objects. Each class in these classes includes the graphics attribute that is a Graphics object. - * The following auxiliary functions are provided for ease of use: drawRect(), drawRoundRect(), drawCircle(), and drawEllipse(). - * @see http://edn.egret.com/cn/docs/page/136 Draw Rectangle - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Graphics.ts - * @language en_US - */ - /** - * Graphics 类包含一组可用来创建矢量形状的方法。支持绘制的显示对象包括 Sprite 和 Shape 对象。这些类中的每一个类都包括 graphics 属性,该属性是一个 Graphics 对象。 - * 以下是为便于使用而提供的一些辅助函数:drawRect()、drawRoundRect()、drawCircle() 和 drawEllipse()。 - * @see http://edn.egret.com/cn/docs/page/136 绘制矩形 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Graphics.ts - * @language zh_CN - */ - class Graphics extends HashObject { - /** - * Initializes a Graphics object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Graphics 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @private - */ - $renderNode: sys.GraphicsNode; - /** - * 绑定到的目标显示对象 - */ - $targetDisplay: DisplayObject; - $targetIsSprite: boolean; - /** - * @private - * 设置绑定到的目标显示对象 - */ - $setTarget(target: DisplayObject): void; - /** - * 当前移动到的坐标X - */ - private lastX; - /** - * 当前移动到的坐标Y - */ - private lastY; - /** - * 当前正在绘制的填充 - */ - private fillPath; - /** - * 当前正在绘制的线条 - */ - private strokePath; - /** - * 线条的左上方宽度 - */ - private topLeftStrokeWidth; - /** - * 线条的右下方宽度 - */ - private bottomRightStrokeWidth; - /** - * 对1像素和3像素特殊处理,向右下角偏移0.5像素,以显示清晰锐利的线条。 - */ - private setStrokeWidth(width); - /** - * Specify a simple single color fill that will be used for subsequent calls to other Graphics methods (for example, lineTo() and drawCircle()) when drawing. - * Calling the clear() method will clear the fill. - * @param color Filled color - * @param alpha Filled Alpha value - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * 调用 clear() 方法会清除填充。 - * @param color 填充的颜色 - * @param alpha 填充的 Alpha 值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - beginFill(color: number, alpha?: number): void; - /** - * Specifies a gradient fill used by subsequent calls to other Graphics methods (such as lineTo() or drawCircle()) for the object. - * Calling the clear() method clears the fill. - * @param type A value from the GradientType class that specifies which gradient type to use: GradientType.LINEAR or GradientType.RADIAL. - * @param colors An array of RGB hexadecimal color values used in the gradient; for example, red is 0xFF0000, blue is 0x0000FF, and so on. You can specify up to 15 colors. For each color, specify a corresponding value in the alphas and ratios parameters. - * @param alphas An array of alpha values for the corresponding colors in the colors array; - * @param ratios An array of color distribution ratios; valid values are 0-255. - * @param matrix A transformation matrix as defined by the egret.Matrix class. The egret.Matrix class includes a createGradientBox() method, which lets you conveniently set up the matrix for use with the beginGradientFill() method. - * @platform Web,Native - * @version Egret 2.4 - * @language en_US - */ - /** - * 指定一种渐变填充,用于随后调用对象的其他 Graphics 方法(如 lineTo() 或 drawCircle())。 - * 调用 clear() 方法会清除填充。 - * @param type 用于指定要使用哪种渐变类型的 GradientType 类的值:GradientType.LINEAR 或 GradientType.RADIAL。 - * @param colors 渐变中使用的 RGB 十六进制颜色值的数组(例如,红色为 0xFF0000,蓝色为 0x0000FF,等等)。对于每种颜色,请在 alphas 和 ratios 参数中指定对应值。 - * @param alphas colors 数组中对应颜色的 alpha 值数组。 - * @param ratios 颜色分布比率的数组。有效值为 0 到 255。 - * @param matrix 一个由 egret.Matrix 类定义的转换矩阵。egret.Matrix 类包括 createGradientBox() 方法,通过该方法可以方便地设置矩阵,以便与 beginGradientFill() 方法一起使用 - * @platform Web,Native - * @version Egret 2.4 - * @language zh_CN - */ - beginGradientFill(type: string, colors: number[], alphas: number[], ratios: number[], matrix?: egret.Matrix): void; - /** - * Apply fill to the lines and curves added after the previous calling to the beginFill() method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 对从上一次调用 beginFill()方法之后添加的直线和曲线应用填充。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - endFill(): void; - /** - * Specify a line style that will be used for subsequent calls to Graphics methods such as lineTo() and drawCircle(). - * @param thickness An integer, indicating the thickness of the line in points. Valid values are 0 to 255. If a number is not specified, or if the parameter is undefined, a line is not drawn. If a value less than 0 is passed, the default value is 0. Value 0 indicates hairline thickness; the maximum thickness is 255. If a value greater than 255 is passed, the default value is 255. - * @param color A hexadecimal color value of the line (for example, red is 0xFF0000, and blue is 0x0000FF, etc.). If no value is specified, the default value is 0x000000 (black). Optional. - * @param alpha Indicates Alpha value of the line's color. Valid values are 0 to 1. If no value is specified, the default value is 1 (solid). If the value is less than 0, the default value is 0. If the value is greater than 1, the default value is 1. - * @param pixelHinting A boolean value that specifies whether to hint strokes to full pixels. This affects both the position of anchors of a curve and the line stroke size itself. With pixelHinting set to true, the line width is adjusted to full pixel width. With pixelHinting set to false, disjoints can appear for curves and straight lines. - * @param scaleMode Specifies the scale mode to be used - * @param caps Specifies the value of the CapsStyle class of the endpoint type at the end of the line. (default = CapsStyle.ROUND) - * @param joints Specifies the type of joint appearance of corner. (default = JointStyle.ROUND) - * @param miterLimit Indicates the limit number of cut miter. - * @param lineDash set the line dash. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。 - * @param thickness 一个整数,以点为单位表示线条的粗细,有效值为 0 到 255。如果未指定数字,或者未定义该参数,则不绘制线条。如果传递的值小于 0,则默认值为 0。值 0 表示极细的粗细;最大粗细为 255。如果传递的值大于 255,则默认值为 255。 - * @param color 线条的十六进制颜色值(例如,红色为 0xFF0000,蓝色为 0x0000FF 等)。如果未指明值,则默认值为 0x000000(黑色)。可选。 - * @param alpha 表示线条颜色的 Alpha 值的数字;有效值为 0 到 1。如果未指明值,则默认值为 1(纯色)。如果值小于 0,则默认值为 0。如果值大于 1,则默认值为 1。 - * @param pixelHinting 布尔型值,指定是否提示笔触采用完整像素。它同时影响曲线锚点的位置以及线条笔触大小本身。在 pixelHinting 设置为 true 的情况下,线条宽度会调整到完整像素宽度。在 pixelHinting 设置为 false 的情况下,对于曲线和直线可能会出现脱节。 - * @param scaleMode 用于指定要使用的比例模式 - * @param caps 用于指定线条末端处端点类型的 CapsStyle 类的值。默认值:CapsStyle.ROUND - * @param joints 指定用于拐角的连接外观的类型。默认值:JointStyle.ROUND - * @param miterLimit 用于表示剪切斜接的极限值的数字。 - * @param lineDash 设置虚线样式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - lineStyle(thickness?: number, color?: number, alpha?: number, pixelHinting?: boolean, scaleMode?: string, caps?: string, joints?: string, miterLimit?: number, lineDash?: number[]): void; - /** - * Draw a rectangle - * @param x x position of the center, relative to the registration point of the parent display object (in pixels). - * @param y y position of the center, relative to the registration point of the parent display object (in pixels). - * @param width Width of the rectangle (in pixels). - * @param height Height of the rectangle (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个矩形 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawRect(x: number, y: number, width: number, height: number): void; - /** - * Draw a rectangle with rounded corners. - * @param x x position of the center, relative to the registration point of the parent display object (in pixels). - * @param y y position of the center, relative to the registration point of the parent display object (in pixels). - * @param width Width of the rectangle (in pixels). - * @param height Height of the rectangle (in pixels). - * @param ellipseWidth Width used to draw an ellipse with rounded corners (in pixels). - * @param ellipseHeight Height used to draw an ellipse with rounded corners (in pixels). (Optional) If no value is specified, the default value matches the value of the ellipseWidth parameter. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个圆角矩形。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @param ellipseWidth 用于绘制圆角的椭圆的宽度(以像素为单位)。 - * @param ellipseHeight 用于绘制圆角的椭圆的高度(以像素为单位)。 (可选)如果未指定值,则默认值与为 ellipseWidth 参数提供的值相匹配。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawRoundRect(x: number, y: number, width: number, height: number, ellipseWidth: number, ellipseHeight?: number): void; - /** - * Draw a circle. - * @param x x position of the center, relative to the registration point of the parent display object (in pixels). - * @param y y position of the center, relative to the registration point of the parent display object (in pixels). - * @param r Radius of the circle (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个圆。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param radius 圆的半径(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawCircle(x: number, y: number, radius: number): void; - /** - * Draw an ellipse. - * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels). - * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels). - * @param width Width of the rectangle (in pixels). - * @param height Height of the rectangle (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个椭圆。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawEllipse(x: number, y: number, width: number, height: number): void; - /** - * Move the current drawing position to (x, y). If any of these parameters is missed, calling this method will fail and the current drawing position keeps unchanged. - * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels). - * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将当前绘图位置移动到 (x, y)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - moveTo(x: number, y: number): void; - /** - * Draw a straight line from the current drawing position to (x, y) using the current line style; the current drawing position is then set to (x, y). - * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels). - * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用当前线条样式绘制一条从当前绘图位置开始到 (x, y) 结束的直线;当前绘图位置随后会设置为 (x, y)。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - lineTo(x: number, y: number): void; - /** - * Draw a quadratic Bezier curve from the current drawing position to (anchorX, anchorY) using the current line style according to the control points specified by (controlX, controlY). The current drawing position is then set to (anchorX, anchorY). - * If the curveTo() method is called before the moveTo() method, the default value of the current drawing position is (0, 0). If any of these parameters is missed, calling this method will fail and the current drawing position keeps unchanged. - * The drawn curve is a quadratic Bezier curve. A quadratic Bezier curve contains two anchor points and one control point. The curve interpolates the two anchor points and bends to the control point. - * @param controlX A number indicating the horizontal position of the control point, relative to the registration point of the parent display object. - * @param controlY A number indicating the vertical position of the control point, relative to the registration point of the parent display object. - * @param anchorX A number indicating the horizontal position of the next anchor point, relative to the registration point of the parent display object. - * @param anchorY A number indicating the vertical position of the next anchor point, relative to the registration point of the parent display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用当前线条样式和由 (controlX, controlY) 指定的控制点绘制一条从当前绘图位置开始到 (anchorX, anchorY) 结束的二次贝塞尔曲线。当前绘图位置随后设置为 (anchorX, anchorY)。 - * 如果在调用 moveTo() 方法之前调用了 curveTo() 方法,则当前绘图位置的默认值为 (0, 0)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * 绘制的曲线是二次贝塞尔曲线。二次贝塞尔曲线包含两个锚点和一个控制点。该曲线内插这两个锚点,并向控制点弯曲。 - * @param controlX 一个数字,指定控制点相对于父显示对象注册点的水平位置。 - * @param controlY 一个数字,指定控制点相对于父显示对象注册点的垂直位置。 - * @param anchorX 一个数字,指定下一个锚点相对于父显示对象注册点的水平位置。 - * @param anchorY 一个数字,指定下一个锚点相对于父显示对象注册点的垂直位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - curveTo(controlX: number, controlY: number, anchorX: number, anchorY: number): void; - /** - * Draws a cubic Bezier curve from the current drawing position to the specified anchor. Cubic Bezier curves consist of two anchor points and two control points. The curve interpolates the two anchor points and two control points to the curve. - * @param controlX1 Specifies the first control point relative to the registration point of the parent display the horizontal position of the object. - * @param controlY1 Specifies the first control point relative to the registration point of the parent display the vertical position of the object. - * @param controlX2 Specify the second control point relative to the registration point of the parent display the horizontal position of the object. - * @param controlY2 Specify the second control point relative to the registration point of the parent display the vertical position of the object. - * @param anchorX Specifies the anchor point relative to the registration point of the parent display the horizontal position of the object. - * @param anchorY Specifies the anchor point relative to the registration point of the parent display the vertical position of the object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从当前绘图位置到指定的锚点绘制一条三次贝塞尔曲线。三次贝塞尔曲线由两个锚点和两个控制点组成。该曲线内插这两个锚点,并向两个控制点弯曲。 - * @param controlX1 指定首个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY1 指定首个控制点相对于父显示对象的注册点的垂直位置。 - * @param controlX2 指定第二个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY2 指定第二个控制点相对于父显示对象的注册点的垂直位置。 - * @param anchorX 指定锚点相对于父显示对象的注册点的水平位置。 - * @param anchorY 指定锚点相对于父显示对象的注册点的垂直位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - cubicCurveTo(controlX1: number, controlY1: number, controlX2: number, controlY2: number, anchorX: number, anchorY: number): void; - /** - * adds an arc to the path which is centered at (x, y) position with radius r starting at startAngle and ending - * at endAngle going in the given direction by anticlockwise (defaulting to clockwise). - * @param x The x coordinate of the arc's center. - * @param y The y coordinate of the arc's center. - * @param radius The arc's radius. - * @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians. - * @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians. - * @param anticlockwise if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一段圆弧路径。圆弧路径的圆心在 (x, y) 位置,半径为 r ,根据anticlockwise (默认为顺时针)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radius 圆弧的半径。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawArc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; - private dirty(); - /** - * @private - * 测量圆弧的矩形大小 - */ - private arcBounds(x, y, radius, startAngle, endAngle); - /** - * Clear graphics that are drawn to this Graphics object, and reset fill and line style settings. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 清除绘制到此 Graphics 对象的图形,并重置填充和线条样式设置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clear(): void; - /** - * @private - */ - private minX; - /** - * @private - */ - private minY; - /** - * @private - */ - private maxX; - /** - * @private - */ - private maxY; - /** - * @private - */ - private extendBoundsByPoint(x, y); - /** - * @private - */ - private extendBoundsByX(x); - /** - * @private - */ - private extendBoundsByY(y); - /** - * @private - */ - private updateNodeBounds(); - /** - * 是否已经包含上一次moveTo的坐标点 - */ - private includeLastPosition; - /** - * 更新当前的lineX和lineY值,并标记尺寸失效。 - * @private - */ - private updatePosition(x, y); - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - /** - * @private - * - */ - $hitTest(stageX: number, stageY: number): DisplayObject; - /** - * @private - */ - $onRemoveFromStage(): void; - } -} -declare namespace egret { - /** - * The Matrix class represents a transformation matrix that determines how to map points from one coordinate space to - * another. You can perform various graphical transformations on a display object by setting the properties of a Matrix - * object, applying that Matrix object to the matrix property of a display object, These transformation functions include - * translation (x and y repositioning), rotation, scaling, and skewing. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Matrix.ts - * @language en_US - */ - /** - * Matrix 类表示一个转换矩阵,它确定如何将点从一个坐标空间映射到另一个坐标空间。 - * 您可以对一个显示对象执行不同的图形转换,方法是设置 Matrix 对象的属性,将该 Matrix - * 对象应用于显示对象的 matrix 属性。这些转换函数包括平移(x 和 y 重新定位)、旋转、缩放和倾斜。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Matrix.ts - * @language zh_CN - */ - class Matrix extends HashObject { - /** - * Releases a matrix instance to the object pool - * @param matrix matrix that Needs to be recycled - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个Matrix实例到对象池 - * @param matrix 需要回收的 matrix - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static release(matrix: Matrix): void; - /** - * get a matrix instance from the object pool or create a new one. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的Matrix对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static create(): Matrix; - /** - * Creates a new Matrix object with the specified parameters. - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定参数创建一个 Matrix 对象 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值。 - * @param b 旋转或倾斜图像时影响像素沿 y 轴定位的值。 - * @param c 旋转或倾斜图像时影响像素沿 x 轴定位的值。 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值。 - * @param tx 沿 x 轴平移每个点的距离。 - * @param ty 沿 y 轴平移每个点的距离。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); - /** - * The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - a: number; - /** - * The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 旋转或倾斜图像时影响像素沿 y 轴定位的值 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - b: number; - /** - * The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 旋转或倾斜图像时影响像素沿 x 轴定位的值 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - c: number; - /** - * The value that affects the positioning of pixels along the y axis when scaling or rotating an image. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - d: number; - /** - * The distance by which to translate each point along the x axis. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 沿 x 轴平移每个点的距离 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - tx: number; - /** - * The distance by which to translate each point along the y axis. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 沿 y 轴平移每个点的距离 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ty: number; - /** - * Returns a new Matrix object that is a clone of this matrix, with an exact copy of the contained object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回一个新的 Matrix 对象,它是此矩阵的克隆,带有与所含对象完全相同的副本。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clone(): Matrix; - /** - * Concatenates a matrix with the current matrix, effectively combining the geometric effects of the two. In mathematical - * terms, concatenating two matrixes is the same as combining them using matrix multiplication. - * @param other The matrix to be concatenated to the source matrix. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将某个矩阵与当前矩阵连接,从而将这两个矩阵的几何效果有效地结合在一起。在数学术语中,将两个矩阵连接起来与使用矩阵乘法将它们结合起来是相同的。 - * @param other 要连接到源矩阵的矩阵。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - concat(other: Matrix): void; - /** - * Copies all of the matrix data from the source Point object into the calling Matrix object. - * @param other The Matrix object from which to copy the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将源 Matrix 对象中的所有矩阵数据复制到调用方 Matrix 对象中。 - * @param other 要拷贝的目标矩阵 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - copyFrom(other: Matrix): Matrix; - /** - * Sets each matrix property to a value that causes a null transformation. An object transformed by applying an - * identity matrix will be identical to the original. After calling the identity() method, the resulting matrix - * has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 为每个矩阵属性设置一个值,该值将导致矩阵无转换。通过应用恒等矩阵转换的对象将与原始对象完全相同。 - * 调用 identity() 方法后,生成的矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0 和 ty=0。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - identity(): void; - /** - * Performs the opposite transformation of the original matrix. You can apply an inverted matrix to an object to - * undo the transformation performed when applying the original matrix. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 执行原始矩阵的逆转换。 - * 您可以将一个逆矩阵应用于对象来撤消在应用原始矩阵时执行的转换。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - invert(): void; - /** - * @private - */ - $invertInto(target: Matrix): void; - /** - * Applies a rotation transformation to the Matrix object. - * The rotate() method alters the a, b, c, and d properties of the Matrix object. - * @param angle The rotation angle in radians. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 对 Matrix 对象应用旋转转换。 - * rotate() 方法将更改 Matrix 对象的 a、b、c 和 d 属性。 - * @param angle 以弧度为单位的旋转角度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - rotate(angle: number): void; - /** - * Applies a scaling transformation to the matrix. The x axis is multiplied by sx, and the y axis it is multiplied by sy. - * The scale() method alters the a and d properties of the Matrix object. - * @param sx A multiplier used to scale the object along the x axis. - * @param sy A multiplier used to scale the object along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 对矩阵应用缩放转换。x 轴乘以 sx,y 轴乘以 sy。 - * scale() 方法将更改 Matrix 对象的 a 和 d 属性。 - * @param sx 用于沿 x 轴缩放对象的乘数。 - * @param sy 用于沿 y 轴缩放对象的乘数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scale(sx: number, sy: number): void; - /** - * Sets the members of Matrix to the specified values - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Matrix 的成员设置为指定值 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值。 - * @param b 旋转或倾斜图像时影响像素沿 y 轴定位的值。 - * @param c 旋转或倾斜图像时影响像素沿 x 轴定位的值。 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值。 - * @param tx 沿 x 轴平移每个点的距离。 - * @param ty 沿 y 轴平移每个点的距离。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setTo(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix; - /** - * Returns the result of applying the geometric transformation represented by the Matrix object to the specified point. - * @param pointX The x coordinate for which you want to get the result of the Matrix transformation. - * @param pointY The y coordinate for which you want to get the result of the Matrix transformation. - * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the - * number of reallocate objects, which allows you to get better code execution performance. - * @returns The point resulting from applying the Matrix transformation. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回将 Matrix 对象表示的几何转换应用于指定点所产生的结果。 - * @param pointX 想要获得其矩阵转换结果的点的x坐标。 - * @param pointY 想要获得其矩阵转换结果的点的y坐标。 - * @param resultPoint 框架建议尽可能减少创建对象次数来优化性能,可以从外部传入一个复用的Point对象来存储结果,若不传入将创建一个新的Point对象返回。 - * @returns 由应用矩阵转换所产生的点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - transformPoint(pointX: number, pointY: number, resultPoint?: Point): Point; - /** - * Translates the matrix along the x and y axes, as specified by the dx and dy parameters. - * @param dx The amount of movement along the x axis to the right, in pixels. - * @param dy The amount of movement down along the y axis, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 沿 x 和 y 轴平移矩阵,由 dx 和 dy 参数指定。 - * @param dx 沿 x 轴向右移动的量(以像素为单位)。 - * @param dy 沿 y 轴向下移动的量(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - translate(dx: number, dy: number): void; - /** - * Determines whether two matrixes are equal. - * @param other The matrix to be compared. - * @returns A value of true if the object is equal to this Matrix object; false if it is not equal. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否与另一个矩阵数据相等 - * @param other 要比较的另一个矩阵对象。 - * @returns 是否相等,ture表示相等。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - equals(other: Matrix): boolean; - /** - * prepend matrix - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @returns matrix - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 前置矩阵 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param b 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param c 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param tx 沿 x 轴平移每个点的距离 - * @param ty 沿 y 轴平移每个点的距离 - * @returns 矩阵自身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - prepend(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix; - /** - * append matrix - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @returns matrix - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 后置矩阵 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param b 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param c 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param tx 沿 x 轴平移每个点的距离 - * @param ty 沿 y 轴平移每个点的距离 - * @returns 矩阵自身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - append(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix; - /** - * Given a point in the pretransform coordinate space, returns the coordinates of that point after the transformation occurs. - * Unlike the standard transformation applied using the transformPoint() method, the deltaTransformPoint() method's transformation does not consider the translation parameters tx and ty. - * @param point The point for which you want to get the result of the matrix transformation. - * @returns The point resulting from applying the matrix transformation. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果给定预转换坐标空间中的点,则此方法返回发生转换后该点的坐标。 - * 与使用 transformPoint() 方法应用的标准转换不同,deltaTransformPoint() 方法的转换不考虑转换参数 tx 和 ty。 - * @param point 想要获得其矩阵转换结果的点 - * @returns 由应用矩阵转换所产生的点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - deltaTransformPoint(point: Point): Point; - /** - * Returns a text value listing the properties of the Matrix object. - * @returns A string containing the values of the properties of the Matrix object: a, b, c, d, tx, and ty. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回将 Matrix 对象表示的几何转换应用于指定点所产生的结果。 - * @returns 一个字符串,它包含 Matrix 对象的属性值:a、b、c、d、tx 和 ty。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - toString(): string; - /** - * Includes parameters for scaling, rotation, and translation. When applied to a matrix it sets the matrix's values based on those parameters. - * @param scaleX The factor by which to scale horizontally. - * @param scaleY The factor by which scale vertically. - * @param rotation The amount to rotate, in radians. - * @param tx The number of pixels to translate (move) to the right along the x axis. - * @param ty The number of pixels to translate (move) down along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 包括用于缩放、旋转和转换的参数。当应用于矩阵时,该方法会基于这些参数设置矩阵的值。 - * @param scaleX 水平缩放所用的系数 - * @param scaleY 垂直缩放所用的系数 - * @param rotation 旋转量(以弧度为单位) - * @param tx 沿 x 轴向右平移(移动)的像素数 - * @param ty 沿 y 轴向下平移(移动)的像素数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - createBox(scaleX: number, scaleY: number, rotation?: number, tx?: number, ty?: number): void; - /** - * Creates the specific style of matrix expected by the beginGradientFill() and lineGradientStyle() methods of the Graphics class. - * Width and height are scaled to a scaleX/scaleY pair and the tx/ty values are offset by half the width and height. - * @param width The width of the gradient box. - * @param height The height of the gradient box. - * @param rotation The amount to rotate, in radians. - * @param tx The distance, in pixels, to translate to the right along the x axis. This value is offset by half of the width parameter. - * @param ty The distance, in pixels, to translate down along the y axis. This value is offset by half of the height parameter. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建 Graphics 类的 beginGradientFill() 和 lineGradientStyle() 方法所需的矩阵的特定样式。 - * 宽度和高度被缩放为 scaleX/scaleY 对,而 tx/ty 值偏移了宽度和高度的一半。 - * @param width 渐变框的宽度 - * @param height 渐变框的高度 - * @param rotation 旋转量(以弧度为单位) - * @param tx 沿 x 轴向右平移的距离(以像素为单位)。此值将偏移 width 参数的一半 - * @param ty 沿 y 轴向下平移的距离(以像素为单位)。此值将偏移 height 参数的一半 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - createGradientBox(width: number, height: number, rotation?: number, tx?: number, ty?: number): void; - /** - * @private - */ - $transformBounds(bounds: Rectangle): void; - /** - * @private - */ - private getDeterminant(); - /** - * @private - */ - $getScaleX(): number; - /** - * @private - */ - $getScaleY(): number; - /** - * @private - */ - $getSkewX(): number; - /** - * @private - */ - $getSkewY(): number; - /** - * @private - */ - $updateScaleAndRotation(scaleX: number, scaleY: number, skewX: number, skewY: number): void; - /** - * @private - * target = other * this - */ - $preMultiplyInto(other: Matrix, target: Matrix): void; - } - /** - * @private - * 仅供框架内复用,要防止暴露引用到外部。 - */ - let $TempMatrix: Matrix; -} -declare namespace egret { - /** - * A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its - * width and its height.
- * The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of - * one property has no effect on the others. However, the right and bottom properties are integrally related to those - * four properties. For example, if you change the value of the right property, the value of the width property changes; - * if you change the bottom property, the value of the height property changes. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Rectangle.ts - * @language en_US - */ - /** - * Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。
- * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 - * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width - * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Rectangle.ts - * @language zh_CN - */ - class Rectangle extends HashObject { - /** - * Releases a rectangle instance to the object pool. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个Rectangle实例到对象池 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static release(rect: Rectangle): void; - /** - * get a rectangle instance from the object pool or create a new one. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的Rectangle对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static create(): Rectangle; - /** - * Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified - * width and height parameters. - * @param x The x coordinate of the top-left corner of the rectangle. - * @param y The y coordinate of the top-left corner of the rectangle. - * @param width The width of the rectangle, in pixels. - * @param height The height of the rectangle, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个新 Rectangle 对象,其左上角由 x 和 y 参数指定,并具有指定的 width 和 height 参数。 - * @param x 矩形左上角的 x 坐标。 - * @param y 矩形左上角的 y 坐标。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(x?: number, y?: number, width?: number, height?: number); - /** - * The x coordinate of the top-left corner of the rectangle. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 x 坐标。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - x: number; - /** - * The y coordinate of the top-left corner of the rectangle. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 y 坐标。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - y: number; - /** - * The width of the rectangle, in pixels. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形的宽度(以像素为单位)。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - width: number; - /** - * 矩形的高度(以像素为单位)。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * The height of the rectangle, in pixels. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - height: number; - /** - * The sum of the x and width properties. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * x 和 width 属性的和。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - right: number; - /** - * The sum of the y and height properties. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * y 和 height 属性的和。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bottom: number; - /** - * The x coordinate of the top-left corner of the rectangle. Changing the left property of a Rectangle object has - * no effect on the y and height properties. However it does affect the width property, whereas changing the x value - * does not affect the width property. - * The value of the left property is equal to the value of the x property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 x 坐标。更改 Rectangle 对象的 left 属性对 y 和 height 属性没有影响。但是,它会影响 width 属性,而更改 x 值不会影响 width 属性。 - * left 属性的值等于 x 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - left: number; - /** - * The y coordinate of the top-left corner of the rectangle. Changing the top property of a Rectangle object has - * no effect on the x and width properties. However it does affect the height property, whereas changing the y - * value does not affect the height property.
- * The value of the top property is equal to the value of the y property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 y 坐标。更改 Rectangle 对象的 top 属性对 x 和 width 属性没有影响。但是,它会影响 height 属性,而更改 y 值不会影响 height 属性。
- * top 属性的值等于 y 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - top: number; - /** - * The location of the Rectangle object's top-left corner, determined by the x and y coordinates of the point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由该点的 x 和 y 坐标确定的 Rectangle 对象左上角的位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - topLeft: Point; - /** - * The location of the Rectangle object's bottom-right corner, determined by the values of the right and bottom properties. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由 right 和 bottom 属性的值确定的 Rectangle 对象的右下角的位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bottomRight: Point; - /** - * Copies all of rectangle data from the source Rectangle object into the calling Rectangle object. - * @param sourceRect The Rectangle object from which to copy the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将源 Rectangle 对象中的所有矩形数据复制到调用方 Rectangle 对象中。 - * @param sourceRect 要从中复制数据的 Rectangle 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - copyFrom(sourceRect: Rectangle): Rectangle; - /** - * Sets the members of Rectangle to the specified values - * @param x The x coordinate of the top-left corner of the rectangle. - * @param y The y coordinate of the top-left corner of the rectangle. - * @param width The width of the rectangle, in pixels. - * @param height The height of the rectangle, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Rectangle 的成员设置为指定值 - * @param x 矩形左上角的 x 坐标。 - * @param y 矩形左上角的 y 坐标。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setTo(x: number, y: number, width: number, height: number): Rectangle; - /** - * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. - * @param x The x coordinate (horizontal position) of the point. - * @param y The y coordinate (vertical position) of the point. - * @returns A value of true if the Rectangle object contains the specified point; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定由此 Rectangle 对象定义的矩形区域内是否包含指定的点。 - * @param x 检测点的x轴 - * @param y 检测点的y轴 - * @returns 如果检测点位于矩形内,返回true,否则,返回false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - contains(x: number, y: number): boolean; - /** - * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns - * the area of intersection as a Rectangle object. If the rectangles do not intersect, this method returns an empty - * Rectangle object with its properties set to 0. - * @param toIntersect The Rectangle object to compare against to see if it intersects with this Rectangle object. - * @returns A Rectangle object that equals the area of intersection. If the rectangles do not intersect, this method - * returns an empty Rectangle object; that is, a rectangle with its x, y, width, and height properties set to 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果在 toIntersect 参数中指定的 Rectangle 对象与此 Rectangle 对象相交,则返回交集区域作为 Rectangle 对象。如果矩形不相交, - * 则此方法返回一个空的 Rectangle 对象,其属性设置为 0。 - * @param toIntersect 要对照比较以查看其是否与此 Rectangle 对象相交的 Rectangle 对象。 - * @returns 等于交集区域的 Rectangle 对象。如果该矩形不相交,则此方法返回一个空的 Rectangle 对象;即,其 x、y、width 和 - * height 属性均设置为 0 的矩形。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - intersection(toIntersect: Rectangle): Rectangle; - /** - * Increases the size of the Rectangle object by the specified amounts, in pixels. - * The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value. - * @param dx The value to be added to the left and the right of the Rectangle object. - * @param dy The value to be added to the top and the bottom of the Rectangle. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 按指定量增加 Rectangle 对象的大小(以像素为单位) - * 保持 Rectangle 对象的中心点不变,使用 dx 值横向增加它的大小,使用 dy 值纵向增加它的大小。 - * @param dx Rectangle 对象横向增加的值。 - * @param dy Rectangle 对象纵向增加的值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - inflate(dx: number, dy: number): void; - /** - * @private - */ - $intersectInPlace(clipRect: Rectangle): Rectangle; - /** - * Determines whether the object specified in the toIntersect parameter intersects with this Rectangle object. - * This method checks the x, y, width, and height properties of the specified Rectangle object to see if it - * intersects with this Rectangle object. - * @param toIntersect The Rectangle object to compare against this Rectangle object. - * @returns A value of true if the specified object intersects with this Rectangle object; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定在 toIntersect 参数中指定的对象是否与此 Rectangle 对象相交。此方法检查指定的 Rectangle - * 对象的 x、y、width 和 height 属性,以查看它是否与此 Rectangle 对象相交。 - * @param toIntersect 要与此 Rectangle 对象比较的 Rectangle 对象。 - * @returns 如果两个矩形相交,返回true,否则返回false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - intersects(toIntersect: Rectangle): boolean; - /** - * Determines whether or not this Rectangle object is empty. - * @returns A value of true if the Rectangle object's width or height is less than or equal to 0; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定此 Rectangle 对象是否为空。 - * @returns 如果 Rectangle 对象的宽度或高度小于等于 0,则返回 true 值,否则返回 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - isEmpty(): boolean; - /** - * Sets all of the Rectangle object's properties to 0. A Rectangle object is empty if its width or height is less than or equal to 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Rectangle 对象的所有属性设置为 0。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setEmpty(): void; - /** - * Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. - * @returns A new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回一个新的 Rectangle 对象,其 x、y、width 和 height 属性的值与原始 Rectangle 对象的对应值相同。 - * @returns 新的 Rectangle 对象,其 x、y、width 和 height 属性的值与原始 Rectangle 对象的对应值相同。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clone(): Rectangle; - /** - * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. - * This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter. - * @param point The point, as represented by its x and y coordinates. - * @returns A value of true if the Rectangle object contains the specified point; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定由此 Rectangle 对象定义的矩形区域内是否包含指定的点。 - * 此方法与 Rectangle.contains() 方法类似,只不过它采用 Point 对象作为参数。 - * @param point 包含点对象 - * @returns 如果包含,返回true,否则返回false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - containsPoint(point: Point): boolean; - /** - * Determines whether the Rectangle object specified by the rect parameter is contained within this Rectangle object. - * A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first. - * @param rect The Rectangle object being checked. - * @returns A value of true if the Rectangle object that you specify is contained by this Rectangle object; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定此 Rectangle 对象内是否包含由 rect 参数指定的 Rectangle 对象。 - * 如果一个 Rectangle 对象完全在另一个 Rectangle 的边界内,我们说第二个 Rectangle 包含第一个 Rectangle。 - * @param rect 所检查的 Rectangle 对象 - * @returns 如果此 Rectangle 对象包含您指定的 Rectangle 对象,则返回 true 值,否则返回 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - containsRect(rect: egret.Rectangle): boolean; - /** - * Determines whether the object specified in the toCompare parameter is equal to this Rectangle object. - * This method compares the x, y, width, and height properties of an object against the same properties of this Rectangle object. - * @param The rectangle to compare to this Rectangle object. - * @returns A value of true if the object has exactly the same values for the x, y, width, and height properties as this Rectangle object; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定在 toCompare 参数中指定的对象是否等于此 Rectangle 对象。 - * 此方法将某个对象的 x、y、width 和 height 属性与此 Rectangle 对象所对应的相同属性进行比较。 - * @param toCompare 要与此 Rectangle 对象进行比较的矩形。 - * @returns 如果对象具有与此 Rectangle 对象完全相同的 x、y、width 和 height 属性值,则返回 true 值,否则返回 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - equals(toCompare: Rectangle): boolean; - /** - * Increases the size of the Rectangle object. This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter. - * @param point 此 Point 对象的 x 属性用于增加 Rectangle 对象的水平尺寸。y 属性用于增加 Rectangle 对象的垂直尺寸。 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 增加 Rectangle 对象的大小。此方法与 Rectangle.inflate() 方法类似,只不过它采用 Point 对象作为参数。 - * @param point The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object. - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - inflatePoint(point: Point): void; - /** - * Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts. - * @param dx Moves the x value of the Rectangle object by this amount. - * @param dy Moves the y value of the Rectangle object by this amount. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 按指定量调整 Rectangle 对象的位置(由其左上角确定)。 - * @param dx 将 Rectangle 对象的 x 值移动此数量。 - * @param dy 将 Rectangle 对象的 t 值移动此数量。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - offset(dx: number, dy: number): void; - /** - * Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter. - * @param point A Point object to use to offset this Rectangle object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Point 对象用作参数来调整 Rectangle 对象的位置。此方法与 Rectangle.offset() 方法类似,只不过它采用 Point 对象作为参数。 - * @param point 要用于偏移此 Rectangle 对象的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - offsetPoint(point: Point): void; - /** - * Builds and returns a string that lists the horizontal and vertical positions and the width and height of the Rectangle object. - * @returns A string listing the value of each of the following properties of the Rectangle object: x, y, width, and height. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 生成并返回一个字符串,该字符串列出 Rectangle 对象的水平位置和垂直位置以及高度和宽度。 - * @returns 一个字符串,它列出了 Rectangle 对象的下列各个属性的值:x、y、width 和 height。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - toString(): string; - /** - * Adds two rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two rectangles. - * @param toUnion A Rectangle object to add to this Rectangle object. - * @returns A new Rectangle object that is the union of the two rectangles. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 通过填充两个矩形之间的水平和垂直空间,将这两个矩形组合在一起以创建一个新的 Rectangle 对象。 - * @param toUnion 要添加到此 Rectangle 对象的 Rectangle 对象。 - * @returns 充当两个矩形的联合的新 Rectangle 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - union(toUnion: Rectangle): Rectangle; - /** - * @private - */ - $getBaseWidth(angle: number): number; - /** - * @private - */ - $getBaseHeight(angle: number): number; - } - /** - * @private - * 仅供框架内复用,要防止暴露引用到外部。 - */ - let $TempRectangle: Rectangle; -} -declare namespace egret { -} -declare namespace egret { - /** - * The JointStyle class is an enumeration of constant values that specify the joint style to use in drawing lines. - * These constants are provided for use as values in the joints parameter of the egret.Graphics.lineStyle() method. - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * JointStyle 类是指定要在绘制线条中使用的联接点样式的常量值枚举。提供的这些常量用作 egret.Graphics.lineStyle() 方法的 joints 参数中的值。 - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - const JointStyle: { - BEVEL: string; - MITER: string; - ROUND: string; - }; -} -declare namespace egret { -} -/** - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/localStorage/localStorage.ts - */ -declare namespace egret.localStorage { - /** - * Read data - * @param key {string} Name of the key to be read - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 读取数据 - * @param key {string} 要读取的键名称 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let getItem: (key: string) => string; - /** - * Save data - * @param key {string} Name of the key to be saved - * @param value {string} Value to be saved - * @returns {boolean} Whether data is saved successfully - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 保存数据 - * @param key {string} 要保存的键名称 - * @param value {string} 要保存的值 - * @returns {boolean} 数据保存是否成功 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let setItem: (key: string, value: string) => boolean; - /** - * Delete data - * @param key {string} Name of the key to be deleted - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 删除数据 - * @param key {string} 要删除的键名称 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let removeItem: (key: string) => void; - /** - * Clear all data - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将所有数据清空 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let clear: () => void; -} -declare namespace egret.sys { - /** - * @private - * @param channel - */ - function $pushSoundChannel(channel: SoundChannel): void; - /** - * @private - * @param channel - */ - function $popSoundChannel(channel: SoundChannel): boolean; -} -declare namespace egret { - /** - * The Sound class lets you work with sound in an application. - * The Sound class lets you create a Sound object, load and play an external audio file into that object. - * More detailed control of the sound is performed through the SoundChannel - * - * @event egret.Event.COMPLETE Dispatch when the audio resource is loaded and ready to play - * @event egret.IOErrorEvent.IO_ERROR Dispatch when the audio resource is failed to load - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/media/Sound.ts - * @language en_US - */ - /** - * Sound 允许您在应用程序中使用声音。使用 Sound 类可以创建 Sound 对象、将外部音频文件加载到该对象并播放该文件。 - * 可通过 SoundChannel 对声音执行更精细的控制,如控制音量和监控播放进度。 - * @see http://edn.egret.com/cn/docs/page/156 音频系统 - * - * @event egret.Event.COMPLETE 音频加载完成时抛出 - * @event egret.IOErrorEvent.IO_ERROR 音频加载失败时抛出 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/media/Sound.ts - * @language zh_CN - */ - interface Sound extends EventDispatcher { - /** - * Initiates loading of an external audio file from the specified URL. - * @param url Audio file URL - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 启动从指定 URL 加载外部音频文件的过程。 - * @param url 需要加载的音频文件URL - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - load(url: string): void; - /** - * Generates a new SoundChannel object to play back the sound. - * @param startTime The initial position in seconds at which playback should start, (default = 0) - * @param loops Plays, the default value is 0. Greater than 0 to the number of plays, such as 1 to play 1, less than or equal to 0, to loop. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 生成一个新的 SoundChannel 对象来播放该声音。此方法返回 SoundChannel 对象,访问该对象可停止声音调整音量。 - * @param startTime 应开始播放的初始位置(以秒为单位),默认值是 0 - * @param loops 播放次数,默认值是 0,循环播放。 大于 0 为播放次数,如 1 为播放 1 次;小于等于 0,为循环播放。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - play(startTime?: number, loops?: number): SoundChannel; - /** - * Closes the stream, causing any download of data to cease - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 关闭该流,从而停止所有数据的下载。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - close(): void; - /** - * Type, default is egret.Sound.EFFECT. - * In the native and runtime environment, while only play a background music, sound length so as not to be too long. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 类型,默认为 egret.Sound.EFFECT。 - * 在 native 和 runtime 环境下,背景音乐同时只能播放一个,音效长度尽量不要太长。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - type: string; - /** - * Length of the current sound (in seconds). - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 当前声音的长度(以秒为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - length: number; - } - /** - * @copy egret.Sound - */ - let Sound: { - /** - * Create Sound object, load an external audio file and play - * @param url Audio file URL, Sound will start to load the media if url is not empty - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建 Sound 对象、将外部音频文件加载到该对象并播放该文件 - * @param url 需要加载的音频文件URL,如果指定了 url, Sound会立即开始加载指定的媒体文件 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - new (): Sound; - /** - * Background music - * @default "music" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 背景音乐 - * @default "music" - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - MUSIC: string; - /** - * EFFECT - * @default "effect" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 音效 - * @default "effect" - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - EFFECT: string; - }; -} -declare namespace egret { - /** - * The SoundChannel class controls a sound in an application. - * Every sound is assigned to a sound channel, and the application - * can have multiple sound channels that are mixed together. - * The SoundChannel class contains a stop() method, properties for - * set the volume of the channel - * - * @event egret.Event.SOUND_COMPLETE Dispatch when a sound has finished playing at last time - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/media/Sound.ts - * @language en_US - */ - /** - * SoundChannel 类控制应用程序中的声音。每个声音均分配给一个声道,而且应用程序可以具有混合在一起的多个声道。 - * SoundChannel 类包含 stop() 方法、用于设置音量和监视播放进度的属性。 - * - * @event egret.Event.SOUND_COMPLETE 音频最后一次播放完成时抛出 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/media/Sound.ts - * @language zh_CN - */ - interface SoundChannel extends IEventDispatcher { - /** - * The volume, ranging from 0 (silent) to 1 (full volume). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 音量范围从 0(静音)至 1(最大音量)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - volume: number; - /** - * When the sound is playing, the position property indicates - * in seconds the current point that is being played in the sound file. - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 当播放声音时,position 属性表示声音文件中当前播放的位置(以秒为单位) - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - position: number; - /** - * Stops the sound playing in the channel. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 停止在该声道中播放声音。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stop(): void; - } -} -declare namespace egret { - /** - * The Video class lets you work with video in an application. - * The Video class lets you create a Video object, load and play an external video file into that object. - * Note: On most mobile device, the video is playback in the full screen mode.
- * - * @param url URL of the media to play, Video will start to load if the url is not empty - * - * @event egret.Event.COMPLETE Dispatch when the video resource is loaded and ready to play - * @event egret.Event.ENDED Dispatch when the video playback ended - * @event egret.IOErrorEvent.IO_ERROR when the video is failed to load - * @version Egret 2.4 - * @platform Web - * @includeExample egret/media/Video.ts - * @language en_US - */ - /** - * Video 允许您在应用程序中使用视频。使用 Video 类可以创建 Video 对象、将外部视频文件加载到该对象并播放该文件。
- * 注意: 在大多数移动设备中,视频是强制全屏播放的,所以你可以直接调用 play() 方法全屏播放视频,不用将它绘制在Stage中。 - * @see http://edn.egret.com/cn/docs/page/657 视频系统 - * - * @param url 要播放的视频的URL,如果url不为空,Video会立即加载这个视频 - * - * @event egret.Event.COMPLETE 视频加载完成时抛出 - * @event egret.Event.ENDED 视频播放完成时抛出 - * @event egret.IOErrorEvent.IO_ERROR 视频加载失败时触发 - * @version Egret 2.4 - * @platform Web - * @includeExample egret/media/Video.ts - * @language zh_CN - */ - interface Video extends DisplayObject { - /** - * Initiates loading of an external video file from the specified URL. - * @param url Audio file URL - * * @param cache Should cache the video,only used in Native - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 启动从指定 URL 加载外部视频文件的过程。 - * @param url 需要加载的视频文件URL - * @param cache 是否需要缓存到本地,只在 Native 上使用 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - load(url: string, cache?: boolean): void; - /** - * Play back the video. - * @param startTime The initial position in seconds at which playback should start, (default = 0) - * @param loop Defines should play the video again when the video is ended. (default = false) - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 播放该视频 - * @param startTime 应开始播放的初始位置(以秒为单位),默认值是视频上次结束的位置 - * @param loop 是否需要循环播放,默认值是 false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - play(startTime?: number, loop?: boolean): any; - /** - * Closes the stream, causing any download of data to cease - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 关闭该流,从而停止所有数据的下载。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - close(): void; - /** - * The URL of the video you want to play. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 想要播放的视频的URL - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - src: string; - /** - * The URL of an image you want to display before the video is loaded or video cannot been draw on the canvas on some mobile device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 视频加载前,或者在不支持将 video 画在 canvas 的设备上,想要显示的视频截图地址。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - poster: string; - /** - * Should play the video in fullscreen mode (default = true). - * Currently only supports full-screen mobile terminal web. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否全屏播放这个视频(默认值是 true)。 - * 目前移动端 web 只支持全屏。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - fullscreen: boolean; - /** - * The volume, ranging from 0 (silent) to 1 (full volume). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 音量范围从 0(静音)至 1(最大音量)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - volume: number; - /** - * When the video is playing, the position property indicates - * in seconds the current point that is being played in the video file. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当播放视频时,position 属性表示视频文件中当前播放的位置(以秒为单位) - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - position: number; - /** - * Pause the video playing. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停播放。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - pause(): void; - /** - * Get bitmapData of the video file, you can use the video as bitmapData on the stage. - * Note: On most mobile device, the video is playback in the full screen mode. - * So you can just use the play() method instead of draw it on the Stage - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 获取视频的 bitmapData, 你可以将视频绘制到舞台上。 - * 注意: 在大多数移动设备中,视频是全屏播放的,所以你可以直接调用 play() 方法全屏播放视频,不用将它绘制在Stage中。 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - bitmapData?: BitmapData; - /** - * Whether current video is paused. - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 当前视频是否在暂停状态。 - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - paused: boolean; - /** - * Length of the current video (in seconds). - * @version Egret 3.0.8 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 当前视频的长度(以秒为单位)。 - * @version Egret 3.0.8 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - length: number; - } - /** - * @copy egret.Video - */ - let Video: { - new (url?: string, cache?: boolean): Video; - }; -} -declare namespace egret { - /** - * The HttpMethod class provides values that specify whether the HttpRequest object should use the POST method - * or the GET method when sending data to a server. - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HttpRequestMethod 类提供了一些值,这些值可指定在将数据发送到服务器时, - * HttpRequest 对象应使用 POST 方法还是 GET 方法。 - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - namespace HttpMethod { - /** - * Specifies that the HttpRequest object is a GET. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 HttpRequest 对象是一个 GET。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const GET = "GET"; - /** - * Specifies that the HttpRequest object is a POST. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 HttpRequest 对象是一个 POST。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const POST = "POST"; - } -} -declare namespace egret { - /** - * The HttpRequest class downloads data from a URL as text or binary data. It is useful for downloading text files, - * XML, or other information to be used in a dynamic, data-driven application. A HttpRequest object downloads all - * of the data from a URL before making it available to code in the applications. It sends out notifications about - * the progress of the download, which you can monitor through the bytesLoaded and bytesTotal properties, - * as well as through dispatched events. - * @event egret.Event.COMPLETE Dispatched when the net request is complete. - * @event egret.Event.IO_ERROR Dispatched when the net request is failed. - * @event egret.ProgressEvent.PROGRESS Dispatched when data is received as the download operation progresses. - * @see egret.HttpMethod - * @see egret.HttpResponseType - * @includeExample egret/net/HttpRequestExample.ts - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HttpRequest 类以文本或二进制数据的形式从 URL 下载数据。 - * HttpRequest 对象会先从 URL 中下载所有数据,然后才将数据用于应用程序中的代码。它会发出有关下载进度的通知, - * 通过 bytesLoaded 和 bytesTotal 属性以及已调度的事件,可以监视下载进度。 - * @event egret.Event.COMPLETE 加载完成 - * @event egret.Event.IO_ERROR 加载失败 - * @event egret.ProgressEvent.PROGRESS 加载进度,可通过event.bytesLoaded和event.bytesTotal统计进度信息。 - * @see egret.HttpMethod - * @see egret.HttpResponseType - * @includeExample egret/net/HttpRequestExample.ts - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface HttpRequest extends EventDispatcher { - /** - * The data received from the load operation. The format of the data depends on the setting of the responseType property. - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 本次请求返回的数据,数据类型根据 responseType 设置的值确定。 - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - response: any; - /** - * Controls whether the downloaded data is received as text (HttpResponseType.TEXT) or raw binary data (HttpResponseType.ArrayBuffer)
- * Note:If you attempt to set this property to an invalid value, Egret runtime set the value to HttpResponseType.TEXT. - * @default egret.HttpResponseType.TEXT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置返回的数据格式为文本(HttpResponseType.TEXT)还是二进制数据(HttpResponseType.ArrayBuffer)
- * 注意:若尝试设置此属性为一个非法的值,运行时将使用HttpResponseType.TEXT。 - * @default egret.HttpResponseType.TEXT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - responseType: string; - /** - * indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies - * or authorization headers. (This never affects same-site requests.) - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表明在进行跨站(cross-site)的访问控制(Access-Control)请求时,是否使用认证信息(例如cookie或授权的header)。(这个标志不会影响同站的请求) - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - withCredentials: boolean; - /** - * Initializes a request.
- * Note: Calling this method for an already active request (one for which open() or openRequest() has already been - * called) is the equivalent of calling abort(). - * @param url The URL to send the request to. - * @param method The HTTP method to use, please use the const value in the HttpMethod class. - * @see egret.HttpMethod - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 初始化一个请求.
- * 注意: 若在已经发出请求的对象上调用此方法,相当于立即调用abort(). - * @param url 该请求所要访问的URL该请求所要访问的URL - * @param method 请求所使用的HTTP方法, 请使用 HttpMethod 定义的枚举值. - * @see egret.HttpMethod - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - open(url: string, method?: string): void; - /** - * Sends the request. - * @param data the data to send. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 发送请求. - * @param data 需要发送的数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - send(data?: any): void; - /** - * Aborts the request if it has already been sent. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果请求已经被发送,则立刻中止请求. - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - abort(): void; - /** - * Returns all the response headers as a string, or null if no response has been received. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回所有响应头信息(响应头名和值), 如果响应头还没接受,则返回"". - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getAllResponseHeaders(): string; - /** - * Sets the value of an HTTP request header. You must call setRequestHeader() after open(). - * @param header The name of the header whose value is to be set. - * @param value The value to set as the body of the header. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 给指定的HTTP请求头赋值.在这之前,您必须确认已经调用 open() 方法打开了一个url. - * @param header 将要被赋值的请求头名称. - * @param value 给指定的请求头赋的值. - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setRequestHeader(header: string, value: string): void; - /** - * Returns the string containing the text of the specified header, or null if either the response has not yet been - * received or the header doesn't exist in the response. - * @param header The name of the header whose value is to be get. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回指定的响应头的值, 如果响应头还没被接受,或该响应头不存在,则返回"". - * @param header 要返回的响应头名称 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getResponseHeader(header: string): string; - } - /** - * Creates a HttpRequest object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 HttpRequest 实例。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let HttpRequest: { - new (): HttpRequest; - }; -} -declare namespace egret { - /** - * The HttpResponseType class provides values that specify how downloaded data is received. - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * URLLoaderDataFormat 类提供了一些用于指定如何接收已下载数据的值。 - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class HttpResponseType { - /** - * Specifies that downloaded data is received as text. This is the default value of HttpRequest.responseType - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回字符串。HttpRequest.responseType属性的默认值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TEXT: string; - /** - * Specifies that downloaded data is received as raw binary data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回二进制的ArrayBuffer对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ARRAY_BUFFER: string; - } -} -declare namespace egret { - /** - * The Loader class is used to load image (JPG, PNG, or GIF) files. Use the load() method to initiate loading. - * The loaded image data is in the data property of ImageLoader. - * @event egret.Event.COMPLETE Dispatched when the net request is complete. - * @event egret.IOErrorEvent.IO_ERROR Dispatched when the net request is failed. - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/net/ImageLoaderExample.ts - * @see http://edn.egret.com/cn/docs/page/590 加载位图文件 - * @language en_US - */ - /** - * ImageLoader 类可用于加载图像(JPG、PNG 或 GIF)文件。使用 load() 方法来启动加载。被加载的图像对象数据将存储在 ImageLoader.data 属性上 。 - * @event egret.Event.COMPLETE 加载完成 - * @event egret.IOErrorEvent.IO_ERROR 加载失败 - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/net/ImageLoaderExample.ts - * @see http://edn.egret.com/cn/docs/page/590 加载位图文件 - * @language zh_CN - */ - interface ImageLoader extends EventDispatcher { - /** - * The data received from the load operation. - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用 load() 方法加载成功的 BitmapData 图像数据。 - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - data: BitmapData; - /** - * Specifies whether or not cross-site Access-Control requests should be made when loading a image from foreign origins.
- * possible values are:"anonymous","use-credentials" or null. - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当从其他站点加载一个图片时,指定是否启用跨域资源共享(CORS),默认值为null。
- * 可以设置为"anonymous","use-credentials"或null,设置为其他值将等同于"anonymous"。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - crossOrigin: string; - /** - * start a load operation。
- * Note: Calling this method for an already active request (one for which load() has already been - * called) will abort the last load operation immediately. - * @param url 要加载的图像文件的地址。 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 启动一次图像加载。
- * 注意:若之前已经调用过加载请求,重新调用 load() 将终止先前的请求,并开始新的加载。 - * @param url 要加载的图像文件的地址。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - load(url: string): void; - } - /** - * Creates a ImageLoader object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 ImageLoader 实例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let ImageLoader: { - /** - * constructor - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - new (): ImageLoader; - /** - * Specifies whether to enable cross-origin resource sharing, If ImageLoader instance has been set crossOrigin property will be used to set the property. - * @version Egret 2.5.7 - * @platform Web,Native - * @language en_US - */ - /** - * 指定是否启用跨域资源共享,如果ImageLoader实例有设置过crossOrigin属性将使用设置的属性 - * @version Egret 2.5.7 - * @platform Web,Native - * @language zh_CN - */ - crossOrigin: string; - }; -} -declare namespace egret.sys { - /** - * @private - * 显示列表 - */ - class DisplayList extends HashObject { - /** - * 创建一个DisplayList对象,若内存不足或无法创建RenderBuffer,将会返回null。 - */ - static create(target: DisplayObject): DisplayList; - /** - * @private - * 创建一个DisplayList对象 - */ - constructor(root: DisplayObject); - private isStage; - /** - * 位图渲染节点 - */ - $renderNode: RenderNode; - /** - * @private - * 获取渲染节点 - */ - $getRenderNode(): sys.RenderNode; - /** - * @private - */ - renderBuffer: RenderBuffer; - /** - * @private - */ - offsetX: number; - /** - * @private - */ - offsetY: number; - /** - * @private - */ - private offsetMatrix; - /** - * @private - * 显示列表根节点 - */ - root: DisplayObject; - /** - * @private - * 设置剪裁边界,不再绘制完整目标对象,画布尺寸由外部决定,超过边界的节点将跳过绘制。 - */ - setClipRect(width: number, height: number): void; - $canvasScaleX: number; - $canvasScaleY: number; - /** - * @private - * 绘制根节点显示对象到目标画布,返回draw的次数。 - */ - drawToSurface(): number; - private bitmapData; - /** - * @private - * 改变画布的尺寸,由于画布尺寸修改会清空原始画布。所以这里将原始画布绘制到一个新画布上,再与原始画布交换。 - */ - changeSurfaceSize(): void; - static $canvasScaleFactor: number; - /** - * @private - */ - static $canvasScaleX: number; - static $canvasScaleY: number; - /** - * @private - */ - static $setCanvasScale(x: number, y: number): void; - } -} -declare namespace egret { - type runEgretOptions = { - renderMode?: string; - audioType?: number; - screenAdapter?: sys.IScreenAdapter; - antialias?: boolean; - canvasScaleFactor?: number; - calculateCanvasScaleFactor?: (context: CanvasRenderingContext2D) => number; - entryClassName?: string; - scaleMode?: string; - frameRate?: number; - contentWidth?: number; - contentHeight?: number; - orientation?: string; - }; - /** - * egret project entry function - * @param options An object containing the initialization properties for egret engine. - * @language en_US - */ - /** - * egret工程入口函数 - * @param options 一个可选对象,包含初始化Egret引擎需要的参数。 - * @language zh_CN - */ - function runEgret(options?: runEgretOptions): void; - /** - * Refresh the screen display - * @language en_US - */ - /** - * 刷新屏幕显示 - * @language zh_CN - */ - function updateAllScreens(): void; -} -declare namespace egret { - /** - * @private - */ - interface FPSDisplay { - /** - * 更新FPS信息 - */ - update(datas: FPSData): void; - /** - * 插入一条log信息 - */ - updateInfo(info: string): void; - /** - * 插入一条warn信息 - */ - updateWarn(info: string): void; - /** - * 插入一条error信息 - */ - updateError(info: string): void; - } - /** - * @private - */ - let FPSDisplay: { - new (stage: Stage, showFPS: boolean, showLog: boolean, logFilter: string, styles: Object): FPSDisplay; - }; -} -/** - * @private - */ -interface FPSData extends Object { - fps: number; - draw: number; - costTicker: number; - costRender: number; -} -declare namespace egret.sys { - let $TempStage: egret.Stage; - /** - * @private - * Egret播放器 - */ - class Player extends HashObject { - /** - * @private - * 实例化一个播放器对象。 - */ - constructor(buffer: RenderBuffer, stage: Stage, entryClassName: string); - /** - * @private - */ - private createDisplayList(stage, buffer); - /** - * @private - */ - private screenDisplayList; - /** - * @private - * 入口类的完整类名 - */ - private entryClassName; - /** - * @private - * 舞台引用 - */ - stage: Stage; - /** - * @private - * 入口类实例 - */ - private root; - /** - * @private - */ - private isPlaying; - /** - * @private - * 启动播放器 - */ - start(): void; - /** - * @private - */ - private initialize(); - /** - * @private - * 停止播放器,停止后将不能重新启动。 - */ - stop(): void; - /** - * @private - * 暂停播放器,后续可以通过调用start()重新启动播放器。 - */ - pause(): void; - /** - * @private - * 渲染屏幕 - */ - $render(triggerByFrame: boolean, costTicker: number): void; - /** - * @private - * 更新舞台尺寸 - * @param stageWidth 舞台宽度(以像素为单位) - * @param stageHeight 舞台高度(以像素为单位) - */ - updateStageSize(stageWidth: number, stageHeight: number): void; - /** - * @private - * 显示FPS。 - */ - displayFPS(showFPS: boolean, showLog: boolean, logFilter: string, styles: Object): void; - /** - * @private - */ - private showFPS; - /** - * @private - */ - private showLog; - /** - * @private - */ - private stageDisplayList; - } - /** - * @private - */ - let $logToFPS: (info: string) => void; - /** - * @private - */ - let $warnToFPS: (info: string) => void; - /** - * @private - */ - let $errorToFPS: (info: string) => void; -} -/** - * @private - */ -declare module egret { - /** - * @private - */ - var nativeRender: boolean; -} -/** - * @private - */ -interface PlayerOption { - /** - * 入口类完整类名 - */ - entryClassName?: string; - /** - * 默认帧率 - */ - frameRate?: number; - /** - * 屏幕适配模式 - */ - scaleMode?: string; - /** - * 初始内容宽度 - */ - contentWidth?: number; - /** - * 初始内容高度 - */ - contentHeight?: number; - /** - * 屏幕方向 - */ - orientation?: string; - /** - * 显示FPS - */ - showFPS?: boolean; - /** - * - */ - fpsStyles?: Object; - /** - * 显示日志 - */ - showLog?: boolean; - /** - * 过滤日志的正则表达式 - */ - logFilter?: string; - /** - * - */ - maxTouches?: number; - /** - * - */ - textureScaleFactor?: number; -} -declare namespace egret { - /** - * @private - */ - class Mesh extends Bitmap { - constructor(value?: Texture); - protected createNativeDisplayObject(): void; - /** - * @private - */ - protected setBitmapDataToWasm(data?: Texture): void; - /** - * @private - */ - $updateRenderNode(): void; - /** - * @private - */ - private _verticesDirty; - private _bounds; - /** - * @private - */ - $updateVertices(): void; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - } -} -declare namespace egret.sys { - /** - * @private - * 设备屏幕 - */ - interface Screen { - /** - * @private - * 更新屏幕视口尺寸 - */ - updateScreenSize(): any; - /** - * @private - * 更新触摸数量 - */ - updateMaxTouches(): any; - /** - * @private - * 设置分辨率尺寸 - */ - setContentSize(width: number, height: number): any; - } -} -declare namespace egret.sys { - /** - * @private - * 屏幕适配器接口,当播放器视口尺寸改变时,屏幕适配器将被用于计算当前对应的舞台显示尺寸。 - */ - interface IScreenAdapter { - /** - * @private - * 计算舞台显示尺寸 - * @param scaleMode 当前的缩放模式 - * @param screenWidth 播放器视口宽度 - * @param screenHeight 播放器视口高度 - * @param contentWidth 初始化内容宽度 - * @param contentHeight 初始化内容高度 - */ - calculateStageSize(scaleMode: string, screenWidth: number, screenHeight: number, contentWidth: number, contentHeight: number): StageDisplaySize; - } - /** - * @private - * 舞台显示尺寸数据 - */ - interface StageDisplaySize { - /** - * @private - * 舞台宽度 - */ - stageWidth: number; - /** - * @private - * 舞台高度 - */ - stageHeight: number; - /** - * @private - * 显示宽度,若跟舞台宽度不同,将会产生缩放。 - */ - displayWidth: number; - /** - * @private - * 显示高度,若跟舞台高度不同,将会产生缩放。 - */ - displayHeight: number; - } - /** - * @private - * 屏幕适配器实例,开发者可以通过给这个变量赋值实现了IScreenAdapter接口的实例,从而注入自定义的屏幕适配器。 - */ - let screenAdapter: IScreenAdapter; - /** - * @private - * 屏幕适配器默认实现,开发者可以实现自定义规则的屏幕适配器。并在初始化加载时将适配器的实例赋值给egret.sys.screenAdapter上,从而替换掉默认适配器。 - */ - class DefaultScreenAdapter extends HashObject implements IScreenAdapter { - /** - * @private - */ - constructor(); - /** - * @private - * 计算舞台显示尺寸 - * @param scaleMode 当前的缩放模式 - * @param screenWidth 播放器视口宽度 - * @param screenHeight 播放器视口高度 - * @param contentWidth 初始化内容宽度 - * @param contentHeight 初始化内容高度 - */ - calculateStageSize(scaleMode: string, screenWidth: number, screenHeight: number, contentWidth: number, contentHeight: number): StageDisplaySize; - } -} -declare namespace egret { - /** - * StageScaleMode class provides values for the stage zoom mode. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/player/StageScaleMode.ts - * @language en_US - */ - /** - * StageScaleMode 类为舞台缩放模式提供值。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/player/StageScaleMode.ts - * @language zh_CN - */ - class StageScaleMode { - /** - * Do not scale application content. Even when you change the player viewport size, it remains unchanged. If the player is smaller than the viewport content, possibly with some cropping.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) always with the player viewport size consistent. - * @language en_US - */ - /** - * 不缩放应用程序内容。即使在更改播放器视口大小时,它仍然保持不变。如果播放器视口比内容小,则可能进行一些裁切。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终跟播放器视口大小保持一致。 - * @language zh_CN - */ - static NO_SCALE: string; - /** - * Keep the original aspect ratio scaling application content, after scaling a wide directions application content to fill the viewport players on both sides in the other direction may not be wide enough and left black bars.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较宽方向填满播放器视口,另一个方向的两侧可能会不够宽而留有黑边。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - * @language zh_CN - */ - static SHOW_ALL: string; - /** - * Keep the original aspect ratio scaling application content, after scaling a narrow direction of application content to fill the viewport players on both sides in the other direction may exceed the viewport and the player is cut.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较窄方向填满播放器视口,另一个方向的两侧可能会超出播放器视口而被裁切。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - * @language zh_CN - */ - static NO_BORDER: string; - /** - * Do not keep the original aspect ratio scaling application content, after scaling application content just fill the player viewport.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - * @language en_US - */ - /** - * 不保持原始宽高比缩放应用程序内容,缩放后应用程序内容正好填满播放器视口。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - * @language zh_CN - */ - static EXACT_FIT: string; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant width, height may change.
- * In this mode, the stage width (Stage.stageWidth) is always equal to initialize external incoming application content width. Stage height (Stage.stageHeight) by the current scale with the player viewport height decision. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始宽度不变,高度可能会改变。
- * 在此模式下,舞台宽度(Stage.stageWidth)始终等于初始化时外部传入的应用程序内容宽度。舞台高度(Stage.stageHeight)由当前的缩放比例与播放器视口高度决定。 - * @language zh_CN - */ - static FIXED_WIDTH: string; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant height, width may change.
- * In this mode, the stage height (Stage.stageHeight) is always equal to initialize external incoming application content height. Stage width (Stage.stageWidth) by the current scale with the player viewport width decision. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始高度不变,宽度可能会改变。
- * 在此模式下,舞台高度(Stage.stageHeight)始终等于初始化时外部传入的应用程序内容高度。舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽度决定。 - * @language zh_CN - */ - static FIXED_HEIGHT: string; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player,a narrow direction may not be wide enough and fill.
- * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较窄方向可能会不够宽而填充。
- * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 - * @language zh_CN - */ - static FIXED_NARROW: string; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, a wide direction may exceed the viewport and the player is cut.
- * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较宽方向的两侧可能会超出播放器视口而被裁切。
- * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 - * @language zh_CN - */ - static FIXED_WIDE: string; - } -} -declare namespace egret.sys { - /** - * @private - */ - let systemRenderer: SystemRenderer; - /** - * @private - * 用于碰撞检测绘制 - */ - let canvasRenderer: SystemRenderer; - /** - * @private - * 显示渲染器接口 - */ - interface SystemRenderer { - /** - * 渲染一个显示对象 - * @param displayObject 要渲染的显示对象 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - * @param forRenderTexture 绘制目标是RenderTexture的标志 - * @returns drawCall触发绘制的次数 - */ - render(displayObject: DisplayObject, buffer: RenderBuffer, matrix: Matrix, forRenderTexture?: boolean): number; - /** - * 将一个RenderNode对象绘制到渲染缓冲 - * @param node 要绘制的节点 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - * @param forHitTest 绘制结果是用于碰撞检测。若为true,当渲染GraphicsNode时,会忽略透明度样式设置,全都绘制为不透明的。 - */ - drawNodeToBuffer(node: sys.RenderNode, buffer: RenderBuffer, matrix: Matrix, forHitTest?: boolean): void; - } -} -declare namespace egret.sys { - /** - * @private - */ - let $START_TIME: number; - /** - * @private - * 是否要广播Event.RENDER事件的标志。 - */ - let $invalidateRenderFlag: boolean; - /** - * @private - * 需要立即刷新屏幕的标志 - */ - let $requestRenderingFlag: boolean; - /** - * Egret心跳计时器 - */ - class SystemTicker { - /** - * @private - */ - constructor(); - /** - * @private - */ - private playerList; - /** - * @private - * 注册一个播放器实例并运行 - */ - $addPlayer(player: Player): void; - /** - * @private - * 停止一个播放器实例的运行。 - */ - $removePlayer(player: Player): void; - /** - * @private - */ - private callBackList; - /** - * @private - */ - private thisObjectList; - /** - * @private - */ - $startTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; - /** - * @private - */ - $stopTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; - /** - * @private - */ - private getTickIndex(callBack, thisObject); - /** - * @private - * - */ - private concatTick(); - /** - * @private - * 全局帧率 - */ - $frameRate: number; - /** - * @private - */ - private frameInterval; - /** - * @private - */ - private frameDeltaTime; - /** - * @private - */ - private lastTimeStamp; - /** - * @private - * 设置全局帧率 - */ - $setFrameRate(value: number): boolean; - /** - * @private - */ - private lastCount; - /** - * @private - * ticker 花销的时间 - */ - private costEnterFrame; - /** - * @private - * 是否被暂停 - */ - private isPaused; - /** - * Pause the ticker. - * @version Egret 5.0.2 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停心跳 - * @version Egret 5.0.2 - * @platform Web,Native - * @language zh_CN - */ - pause(): void; - /** - * Resume the ticker. - * @version Egret 5.0.2 - * @platform Web,Native - * @language en_US - */ - /** - * 恢复心跳 - * @version Egret 5.0.2 - * @platform Web,Native - * @language zh_CN - */ - resume(): void; - /** - * @private - * 执行一次刷新 - */ - update(): void; - /** - * @private - * 执行一次屏幕渲染 - */ - private render(triggerByFrame, costTicker); - /** - * @private - * 广播EnterFrame事件。 - */ - private broadcastEnterFrame(); - /** - * @private - * 广播Render事件。 - */ - private broadcastRender(); - /** - * @private - */ - private callLaters(); - /** - * @private - */ - private callLaterAsyncs(); - } -} -declare module egret { - namespace lifecycle { - type LifecyclePlugin = (context: LifecycleContext) => void; - /** - * @private - */ - let stage: egret.Stage; - /** - * @private - */ - let contexts: LifecycleContext[]; - class LifecycleContext { - pause(): void; - resume(): void; - onUpdate?: () => void; - } - let onResume: () => void; - let onPause: () => void; - function addLifecycleListener(plugin: LifecyclePlugin): void; - } - /** - * 心跳计时器单例 - */ - let ticker: sys.SystemTicker; -} -/** - * @private - */ -declare let egret_stages: egret.Stage[]; -declare namespace egret.sys { - /** - * @private - * 用户交互操作管理器 - */ - class TouchHandler extends HashObject { - private maxTouches; - private useTouchesCount; - /** - * @private - */ - constructor(stage: Stage); - /** - * @private - * 设置同时触摸数量 - */ - $initMaxTouches(): void; - /** - * @private - */ - private stage; - /** - * @private - */ - private touchDownTarget; - /** - * @private - * 触摸开始(按下) - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - onTouchBegin(x: number, y: number, touchPointID: number): void; - /** - * @private - */ - private lastTouchX; - /** - * @private - */ - private lastTouchY; - /** - * @private - * 触摸移动 - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - onTouchMove(x: number, y: number, touchPointID: number): void; - /** - * @private - * 触摸结束(弹起) - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - onTouchEnd(x: number, y: number, touchPointID: number): void; - /** - * @private - * 获取舞台坐标下的触摸对象 - */ - private findTarget(stageX, stageY); - } -} -declare namespace egret.sys { - /** - * @private - * 位图渲染节点 - */ - class BitmapNode extends RenderNode { - constructor(); - /** - * 要绘制的位图 - */ - image: BitmapData; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - smoothing: boolean; - /** - * 相对偏移矩阵。 - */ - matrix: egret.Matrix; - /** - * 图片宽度。WebGL渲染使用 - */ - imageWidth: number; - /** - * 图片高度。WebGL渲染使用 - */ - imageHeight: number; - /** - * 使用的混合模式 - */ - blendMode: number; - /** - * 相对透明度 - */ - alpha: number; - /** - * 颜色变换滤镜 - */ - filter: ColorMatrixFilter; - /** - * 翻转 - */ - rotated: boolean; - /** - * 绘制一次位图 - */ - drawImage(sourceX: number, sourceY: number, sourceW: number, sourceH: number, drawX: number, drawY: number, drawW: number, drawH: number): void; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - static $updateTextureData(node: sys.NormalBitmapNode, image: BitmapData, bitmapX: number, bitmapY: number, bitmapWidth: number, bitmapHeight: number, offsetX: number, offsetY: number, textureWidth: number, textureHeight: number, destW: number, destH: number, sourceWidth: number, sourceHeight: number, fillMode: string, smoothing: boolean): void; - /** - * @private - * 绘制九宫格位图 - */ - static $updateTextureDataWithScale9Grid(node: sys.NormalBitmapNode, image: BitmapData, scale9Grid: egret.Rectangle, bitmapX: number, bitmapY: number, bitmapWidth: number, bitmapHeight: number, offsetX: number, offsetY: number, textureWidth: number, textureHeight: number, destW: number, destH: number, sourceWidth: number, sourceHeight: number, smoothing: boolean): void; - /** - * @private - */ - private static drawClipImage(node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, destW, destH, startX?, startY?); - } -} -declare namespace egret.sys { - /** - * @private - * 矢量渲染节点 - */ - class GraphicsNode extends RenderNode { - constructor(); - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * @param color 填充的颜色 - * @param alpha 填充的 Alpha 值 - * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 - */ - beginFill(color: number, alpha?: number, beforePath?: Path2D): Path2D; - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * 调用 clear() 方法会清除填充。 - * @param type 用于指定要使用哪种渐变类型的 GradientType 类的值:GradientType.LINEAR 或 GradientType.RADIAL。 - * @param colors 渐变中使用的 RGB 十六进制颜色值的数组(例如,红色为 0xFF0000,蓝色为 0x0000FF,等等)。对于每种颜色,请在 alphas 和 ratios 参数中指定对应值。 - * @param alphas colors 数组中对应颜色的 alpha 值数组。 - * @param ratios 颜色分布比率的数组。有效值为 0 到 255。 - * @param matrix 一个由 egret.Matrix 类定义的转换矩阵。egret.Matrix 类包括 createGradientBox() 方法,通过该方法可以方便地设置矩阵,以便与 beginGradientFill() 方法一起使用 - * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 - */ - beginGradientFill(type: string, colors: number[], alphas: number[], ratios: number[], matrix?: egret.Matrix, beforePath?: Path2D): Path2D; - /** - * 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。 - * @param thickness 一个整数,以点为单位表示线条的粗细,有效值为 0 到 255。如果未指定数字,或者未定义该参数,则不绘制线条。如果传递的值小于 0,则默认值为 0。值 0 表示极细的粗细;最大粗细为 255。如果传递的值大于 255,则默认值为 255。 - * @param color 线条的十六进制颜色值(例如,红色为 0xFF0000,蓝色为 0x0000FF 等)。如果未指明值,则默认值为 0x000000(黑色)。可选。 - * @param alpha 表示线条颜色的 Alpha 值的数字;有效值为 0 到 1。如果未指明值,则默认值为 1(纯色)。如果值小于 0,则默认值为 0。如果值大于 1,则默认值为 1。 - * @param caps 用于指定线条末端处端点类型的 CapsStyle 类的值。默认值:CapsStyle.ROUND - * @param joints 指定用于拐角的连接外观的类型。默认值:JointStyle.ROUND - * @param miterLimit 用于表示剪切斜接的极限值的数字。 - */ - lineStyle(thickness?: number, color?: number, alpha?: number, caps?: string, joints?: string, miterLimit?: number, lineDash?: number[]): StrokePath; - /** - * 清空所有缓存的绘制数据 - */ - clear(): void; - /** - * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 - */ - cleanBeforeRender(): void; - /** - * 绘制x偏移 - */ - x: number; - /** - * 绘制y偏移 - */ - y: number; - /** - * 绘制宽度 - */ - width: number; - /** - * 绘制高度 - */ - height: number; - /** - * 脏渲染标记 - * 暂时调用lineStyle,beginFill,beginGradientFill标记,实际应该draw时候标记在Path2D - */ - dirtyRender: boolean; - $texture: WebGLTexture; - $textureWidth: number; - $textureHeight: number; - $canvasScaleX: number; - $canvasScaleY: number; - /** - * 清除非绘制的缓存数据 - */ - clean(): void; - } -} -declare namespace egret.sys { - /** - * @private - * 组渲染节点,用于组合多个渲染节点 - */ - class GroupNode extends RenderNode { - /** - * 相对偏移矩阵。 - */ - matrix: egret.Matrix; - constructor(); - addNode(node: RenderNode): void; - /** - * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 - * 这里只是想清空绘制命令,因此不调用super - */ - cleanBeforeRender(): void; - $getRenderCount(): number; - } -} -declare namespace egret.sys { - /** - * @private - * Mesh 渲染节点 - */ - class MeshNode extends RenderNode { - constructor(); - /** - * 要绘制的位图 - */ - image: BitmapData; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - smoothing: boolean; - /** - * 图片宽度。WebGL渲染使用 - */ - imageWidth: number; - /** - * 图片高度。WebGL渲染使用 - */ - imageHeight: number; - /** - * 相对偏移矩阵。 - */ - matrix: egret.Matrix; - /** - * UV 坐标。 - */ - uvs: number[]; - /** - * 顶点坐标。 - */ - vertices: number[]; - /** - * 顶点索引。 - */ - indices: number[]; - /** - * 顶点索引。 - */ - bounds: Rectangle; - /** - * 使用的混合模式 - */ - blendMode: number; - /** - * 相对透明度 - */ - alpha: number; - /** - * 颜色变换滤镜 - */ - filter: ColorMatrixFilter; - /** - * 翻转 - */ - rotated: boolean; - /** - * 绘制一次位图 - */ - drawMesh(sourceX: number, sourceY: number, sourceW: number, sourceH: number, drawX: number, drawY: number, drawW: number, drawH: number): void; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - } -} -declare namespace egret.sys { - /** - * @private - * 位图渲染节点 - */ - class NormalBitmapNode extends RenderNode { - constructor(); - /** - * 要绘制的位图 - */ - image: BitmapData; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - smoothing: boolean; - /** - * 图片宽度。WebGL渲染使用 - */ - imageWidth: number; - /** - * 图片高度。WebGL渲染使用 - */ - imageHeight: number; - /** - * 翻转 - */ - rotated: boolean; - sourceX: number; - sourceY: number; - sourceW: number; - sourceH: number; - drawX: number; - drawY: number; - drawW: number; - drawH: number; - /** - * 绘制一次位图 - */ - drawImage(sourceX: number, sourceY: number, sourceW: number, sourceH: number, drawX: number, drawY: number, drawW: number, drawH: number): void; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - } -} -declare namespace egret { - /** - * OrientationMode 类为舞台初始旋转模式提供值。 - */ - const OrientationMode: { - AUTO: string; - PORTRAIT: string; - LANDSCAPE: string; - LANDSCAPE_FLIPPED: string; - }; -} -declare namespace egret.sys { - /** - * @private - * 文本格式 - */ - interface TextFormat { - /** - * 颜色值 - */ - textColor?: number; - /** - * 描边颜色值 - */ - strokeColor?: number; - /** - * 字号 - */ - size?: number; - /** - * 描边大小 - */ - stroke?: number; - /** - * 是否加粗 - */ - bold?: boolean; - /** - * 是否倾斜 - */ - italic?: boolean; - /** - * 字体名称 - */ - fontFamily?: string; - } -} -declare namespace egret.sys { - /** - * @private - * 文本渲染节点 - */ - class TextNode extends RenderNode { - constructor(); - /** - * 颜色值 - */ - textColor: number; - /** - * 描边颜色值 - */ - strokeColor: number; - /** - * 字号 - */ - size: number; - /** - * 描边大小 - */ - stroke: number; - /** - * 是否加粗 - */ - bold: boolean; - /** - * 是否倾斜 - */ - italic: boolean; - /** - * 字体名称 - */ - fontFamily: string; - /** - * 绘制一行文本 - */ - drawText(x: number, y: number, text: string, format: TextFormat): void; - /** - * 绘制x偏移 - */ - x: number; - /** - * 绘制y偏移 - */ - y: number; - /** - * 绘制宽度 - */ - width: number; - /** - * 绘制高度 - */ - height: number; - /** - * 脏渲染标记 - */ - dirtyRender: boolean; - $texture: WebGLTexture; - $textureWidth: number; - $textureHeight: number; - $canvasScaleX: number; - $canvasScaleY: number; - /** - * 清除非绘制的缓存数据 - */ - clean(): void; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - } -} -declare namespace egret.sys { - /** - * @private - * 填充路径 - */ - class FillPath extends Path2D { - constructor(); - /** - * 填充颜色 - */ - fillColor: number; - /** - * 填充透明度 - */ - fillAlpha: number; - } -} -declare namespace egret.sys { - /** - * @private - * 渐变填充路径 - */ - class GradientFillPath extends Path2D { - constructor(); - gradientType: string; - colors: number[]; - alphas: number[]; - ratios: number[]; - matrix: Matrix; - } -} -declare namespace egret { - /** - * RenderTexture is a dynamic texture - * @extends egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/RenderTexture.ts - * @language en_US - */ - /** - * RenderTexture 是动态纹理类,他实现了将显示对象及其子对象绘制成为一个纹理的功能 - * @extends egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/RenderTexture.ts - * @language zh_CN - */ - class RenderTexture extends egret.Texture { - constructor(); - $renderBuffer: sys.RenderBuffer; - /** - * The specified display object is drawn as a texture - * @param displayObject {egret.DisplayObject} the display to draw - * @param clipBounds {egret.Rectangle} clip rect - * @param scale {number} scale factor - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定显示对象绘制为一个纹理 - * @param displayObject {egret.DisplayObject} 需要绘制的显示对象 - * @param clipBounds {egret.Rectangle} 绘制矩形区域 - * @param scale {number} 缩放比例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawToTexture(displayObject: egret.DisplayObject, clipBounds?: Rectangle, scale?: number): boolean; - /** - * @inheritDoc - */ - getPixel32(x: number, y: number): number[]; - /** - * @inheritDoc - */ - dispose(): void; - } -} -declare namespace egret.sys { - /** - * @private - * 线条路径。 - * 注意:当线条宽度(lineWidth)为1或3像素时,需要特殊处理,往右下角偏移0.5像素,以显示清晰锐利的线条。 - */ - class StrokePath extends Path2D { - constructor(); - /** - * 线条宽度。 - * 注意:绘制时对1像素和3像素要特殊处理,整体向右下角偏移0.5像素,以显示清晰锐利的线条。 - */ - lineWidth: number; - /** - * 线条颜色 - */ - lineColor: number; - /** - * 线条透明度 - */ - lineAlpha: number; - /** - * 端点样式,"none":无端点,"round":圆头端点,"square":方头端点 - */ - caps: string; - /** - * 联接点样式,"bevel":斜角连接,"miter":尖角连接,"round":圆角连接 - */ - joints: string; - /** - * 用于表示剪切斜接的极限值的数字。 - */ - miterLimit: number; - /** - * 描述交替绘制线段和间距(坐标空间单位)长度的数字。 - */ - lineDash: number[]; - } -} -/** - * @private - */ -interface CanvasRenderingContext2D { - imageSmoothingEnabled: boolean; - $imageSmoothingEnabled: boolean; - $offsetX: number; - $offsetY: number; -} -declare namespace egret { - class CanvasRenderer { - private nestLevel; - render(displayObject: DisplayObject, buffer: sys.RenderBuffer, matrix: Matrix, forRenderTexture?: boolean): number; - /** - * @private - * 绘制一个显示对象 - */ - private drawDisplayObject(displayObject, context, offsetX, offsetY, isStage?); - private drawWithFilter(displayObject, context, offsetX, offsetY); - private drawWithClip(displayObject, context, offsetX, offsetY); - private drawWithScrollRect(displayObject, context, offsetX, offsetY); - drawNodeToBuffer(node: sys.RenderNode, buffer: sys.RenderBuffer, matrix: Matrix, forHitTest?: boolean): void; - /** - * 将一个DisplayObject绘制到渲染缓冲,用于RenderTexture绘制 - * @param displayObject 要绘制的显示对象 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - */ - drawDisplayToBuffer(displayObject: DisplayObject, buffer: sys.RenderBuffer, matrix: Matrix): number; - private renderNode(node, context, forHitTest?); - private renderNormalBitmap(node, context); - private renderBitmap(node, context); - private renderMesh(node, context); - renderText(node: sys.TextNode, context: CanvasRenderingContext2D): void; - private renderingMask; - /** - * @private - */ - renderGraphics(node: sys.GraphicsNode, context: CanvasRenderingContext2D, forHitTest?: boolean): number; - private renderPath(path, context); - private renderGroup(groupNode, context); - private createRenderBuffer(width, height, useForFilters?); - } - /** - * @private - * 获取字体字符串 - */ - function getFontString(node: sys.TextNode, format: sys.TextFormat): string; - /** - * @private - * 获取RGBA字符串 - */ - function getRGBAString(color: number, alpha: number): string; -} -declare namespace egret { - /** - * Orientation monitor the orientation of the device, send CHANGE event when the orientation is changed - * - * @event egret.Event.CHANGE device's orientation is changed - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/DeviceOrientation.ts - * @see http://edn.egret.com/cn/docs/page/661 获取设备旋转角度 - * @language en_US - */ - /** - * Orientation 监听设备方向的变化,当方向变化时派发 CHANGE 事件 - * @event egret.Event.CHANGE 设备方向改变时派发 - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/DeviceOrientation.ts - * @see http://edn.egret.com/cn/docs/page/661 获取设备旋转角度 - * @language zh_CN - */ - interface DeviceOrientation extends EventDispatcher { - /** - * Start to monitor the device's orientation - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 开始监听设备方向变化 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - start(): void; - /** - * Stop monitor the device's orientation - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 停止监听设备方向变化 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - stop(): void; - } - /** - * @copy egret.Orientation - */ - let DeviceOrientation: { - new (): DeviceOrientation; - }; -} -declare namespace egret { - /** - * The Geolocation able to obtain the position of the device. - * Geolocation will emit CHANGE event when the device's location is changed. - * It will emit IO_ERROR event if the location request is denied - * or there is no location service on the device. - * - * @event egret.Event.CHANGE The device's location is changed - * @event egret.Event.IO_ERROR Error occurred while getting the location - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/Geolocation.ts - * @language en_US - */ - /** - * Geolocation 能够从设备的定位服务获取设备的当前位置。 - * 当设备的位置发生改变时 Geolocation 会派发 CHANGE 事件。 - * 当定位请求被拒绝或该设备没有定位服务时 Geolocation 会派发 IO_ERROR 事件。 - * - * @event egret.Event.CHANGE 设备位置发生改变 - * @event egret.Event.IO_ERROR 获取设备位置时发生错误 - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/Geolocation.ts - * @language zh_CN - */ - interface Geolocation extends EventDispatcher { - /** - * Start to monitor the device's location - * @returns - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 开始监听设备位置信息 - * @returns - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - start(): void; - /** - * Stop monitor the device's location - * @returns - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 停止监听设备位置信息 - * @returns - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - stop(): void; - } - /** - * @copy egret.Geolocation - */ - let Geolocation: { - /** - * constructor - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 构造函数 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - new (): Geolocation; - }; -} -declare namespace egret { - /** - * @copy egret.Motion - */ - let Motion: { - new (): Motion; - }; - /** - * The Motion class emits events based on activity detected by the device's motion sensor. - * This data represents the device's movement along a 3-dimensional axis. When the device moves, - * the sensor detects this movement and emit the CHANGE event. @see egret.MotionEvent - * - * @event egret.Event.CHANGE device is moved - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/Motion.ts - * @language en_US - */ - /** - * Motion 类从用户设备读取运动状态信息并派发 CHANGE 事件。 - * 当设备移动时,传感器会检测到此移动并返回设备加速度,重力和旋转数据。@see egret.MotionEvent - * Motion 类提供了 start 和 stop 方法,来启动和停止运动信息检查 - * - * @event egret.Event.CHANGE 运动状态发生改变 - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/Motion.ts - * @language zh_CN - */ - interface Motion extends EventDispatcher { - /** - * Start to monitor device movement - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 开始监听设备运动状态 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - start(): void; - /** - * Stop monitor device movement - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 停止监听设备运动状态 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - stop(): void; - } - /** - * A DeviceRotationRate object provides information about the rate at which - * the device is rotating around all three axes. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * DeviceRotationRate 提供设备围绕三个轴旋转的角速度信息,单位是 角度/秒 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - interface DeviceRotationRate { - /** - * The amount of rotation around the Z axis, in degrees per second. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 设备绕 Z 轴旋转的角速度信息,单位是 度/秒 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - alpha: number; - /** - * The amount of rotation around the X axis, in degrees per second. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 设备绕 X 轴旋转的角速度信息,单位是 度/秒 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - beta: number; - /** - * The amount of rotation around the Y axis, in degrees per second. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 设备绕 Y 轴旋转的角速度信息,单位是 度/秒 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - gamma: number; - } - /** - * A DeviceAcceleration object provides information about the amount - * of acceleration the device is experiencing along all three axes. - * Acceleration is expressed in m/s2. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * DeviceAcceleration 提供设备在三个维度的加速度信息,加速度值的单位是 m/s2 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - interface DeviceAcceleration { - /** - * The amount of acceleration along the X axis - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * X 轴方向的加速度值 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - x: number; - /** - * The amount of acceleration along the Y axis - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * Y 轴方向的加速度值 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - y: number; - /** - * The amount of acceleration along the Z axis - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * Z 轴方向的加速度值 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - z: number; - } -} -declare namespace egret { - /** - * Type of operation. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 运行类型的类型。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - namespace RuntimeType { - /** - * Running on Web - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 运行在Web上 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const WEB = "web"; - /** - * Running on NATIVE - * @version Egret 2.4 - * @deprecated - * @platform Web,Native - * @language en_US - */ - /** - * 运行在NATIVE上 - * @version Egret 2.4 - * @deprecated - * @platform Web,Native - * @language zh_CN - */ - const NATIVE = "native"; - /** - * Running on Runtime2.0 - * @version Egret 5.1.5 - * @platform Web,Native - * @language en_US - */ - /** - * 运行在Runtime2.0上 - * @version Egret 5.1.5 - * @platform Web,Native - * @language zh_CN - */ - const RUNTIME2 = "runtime2"; - /** - * Running on WeChat mini game - * @version Egret 5.1.5 - * @platform All - * @language en_US - */ - /** - * 运行在微信小游戏上 - * @version Egret 5.1.5 - * @platform All - * @language zh_CN - */ - const WXGAME = "wxgame"; - } - /** - * The Capabilities class provides properties that describe the system and runtime that are hosting the application. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/system/Capabilities.ts - * @language en_US - */ - /** - * Capabilities 类提供一些属性,这些属性描述了承载应用程序的系统和运行时。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/system/Capabilities.ts - * @language zh_CN - */ - class Capabilities { - /** - * Specifies the language code of the system on which the content is running. The language is specified as a lowercase - * two-letter language code from ISO 639-1. For Chinese, an additional uppercase two-letter country code from ISO 3166 - * distinguishes between Simplified and Traditional Chinese.
- * The following table lists the possible values,but not limited to them: - *
    - *
  • Simplified Chinese zh-CN
  • - *
  • Traditional Chinese zh-TW
  • - *
  • English en
  • - *
  • Japanese ja
  • - *
  • Korean ko
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示运行内容的系统的语言代码。语言指定为 ISO 639-1 中的小写双字母语言代码。 - * 对于中文,另外使用 ISO 3166 中的大写双字母国家/地区代码,以区分简体中文和繁体中文。
- * 以下是可能但不限于的语言和值: - *
    - *
  • 简体中文 zh-CN
  • - *
  • 繁体中文 zh-TW
  • - *
  • 英语 en
  • - *
  • 日语 ja
  • - *
  • 韩语 ko
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static readonly language: string; - /** - * Specifies whether the system is running in a mobile device.(such as a mobile phone or tablet) - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示程序内容是否运行在移动设备中(例如移动电话或平板电脑)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static readonly isMobile: boolean; - /** - * Specifies the current operating system. The os property can return the following strings: - *
    - *
  • iPhone "iOS"
  • - *
  • Android Phone "Android"
  • - *
  • Windows Phone "Windows Phone"
  • - *
  • Windows Desktop "Windows PC"
  • - *
  • Mac Desktop "Mac OS"
  • - *
  • Unknown OS "Unknown"
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指示当前的操作系统。os 属性返回下列字符串: - *
    - *
  • 苹果手机操作系统 "iOS"
  • - *
  • 安卓手机操作系统 "Android"
  • - *
  • 微软手机操作系统 "Windows Phone"
  • - *
  • 微软桌面操作系统 "Windows PC"
  • - *
  • 苹果桌面操作系统 "Mac OS"
  • - *
  • 未知操作系统 "Unknown"
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static readonly os: string; - /** - * It indicates the current type of operation. runtimeType property returns the following string: - *
    - *
  • Run on Web egret.RuntimeType.WEB
  • - *
  • Run on Runtime2.0 egret.RuntimeType.RUNTIME2
  • - *
  • Run on WeChat mini game egret.RuntimeType.WXGAME
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指示当前的运行类型。runtimeType 属性返回下列字符串: - *
    - *
  • 运行在Web上 egret.RuntimeType.WEB
  • - *
  • 运行在Runtime2.0上 egret.RuntimeType.RUNTIME2
  • - *
  • 运行在微信小游戏上 egret.RuntimeType.WXGAME
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static readonly runtimeType: string; - /*** - * version of Egret. - * @type {string} - * @version Egret 3.2.0 - * @platform Web,Native - * @language en_US - */ - /*** - * Egret 的版本号。 - * @type {string} - * @version Egret 3.2.0 - * @platform Web,Native - * @language zh_CN - */ - static readonly engineVersion: string; - /*** - * current render mode. - * @type {string} - * @version Egret 3.0.7 - * @platform Web,Native - * @language en_US - */ - /*** - * 当前渲染模式。 - * @type {string} - * @version Egret 3.0.7 - * @platform Web,Native - * @language zh_CN - */ - static readonly renderMode: string; - /*** - * Clients border width. - * The value before the document class initialization is always 0. - * This value will change after the distribution Event.RESIZE and StageOrientationEvent.ORIENTATION_CHANGE. - * @version Egret 3.1.3 - * @platform Web,Native - * @language en_US - */ - /*** - * 客户端边界宽度。 - * 该值在文档类初始化之前始终是0。 - * 该值在派发 Event.RESIZE 以及 StageOrientationEvent.ORIENTATION_CHANGE 之后会发生改变。 - * @version Egret 3.1.3 - * @platform Web,Native - * @language zh_CN - */ - static readonly boundingClientWidth: number; - /*** - * Clients border height. - * The value before the document class initialization is always 0. - * This value will change after the distribution Event.RESIZE and StageOrientationEvent.ORIENTATION_CHANGE. - * @version Egret 3.1.3 - * @platform Web,Native - * @language en_US - */ - /*** - * 客户端边界高度。 - * 该值在文档类初始化之前始终是0。 - * 该值在派发 Event.RESIZE 以及 StageOrientationEvent.ORIENTATION_CHANGE 之后会发生改变。 - * @version Egret 3.1.3 - * @platform Web,Native - * @language zh_CN - */ - static readonly boundingClientHeight: number; - } -} -declare namespace egret { - /** - * This class is used to create lightweight shapes using the drawing application program interface (API). The Shape - * class includes a graphics property, which lets you access methods from the Graphics class. - * @see egret.Graphics - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Shape.ts - * @language en_US - */ - /** - * 此类用于使用绘图应用程序编程接口 (API) 创建简单形状。Shape 类含有 graphics 属性,通过该属性您可以访问各种矢量绘图方法。 - * @see egret.Graphics - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Shape.ts - * @language zh_CN - */ - class Shape extends DisplayObject { - /** - * Creates a new Shape object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Shape 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - protected createNativeDisplayObject(): void; - /** - * @private - */ - $graphics: Graphics; - /** - * Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取 Shape 中的 Graphics 对象。可通过此对象执行矢量绘图命令。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly graphics: Graphics; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - $hitTest(stageX: number, stageY: number): DisplayObject; - /** - * @private - */ - $onRemoveFromStage(): void; - } -} -declare namespace egret { - /** - * Adds an interface-name-to-implementation-class mapping to the registry. - * @param interfaceName the interface name to register. For example:"eui.IAssetAdapter","eui.Theme" - * @param instance the instance to register. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 注册一个接口实现。 - * @param interfaceName 注入的接口名称。例如:"eui.IAssetAdapter","eui.Theme" - * @param instance 实现此接口的实例。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - function registerImplementation(interfaceName: string, instance: any): void; - /** - * Returns the singleton instance of the implementation class that was registered for the specified interface. - * This method is usually called by egret framework. - * @param interfaceName The interface name to identify. For example:"eui.IAssetAdapter","eui.Theme" - * @returns the singleton instance of the implementation class - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 获取一个接口实现。此方法通常由框架内部调用。获取项目注入的自定义实现实例。 - * @param interfaceName 要获取的接口名称。例如:"eui.IAssetAdapter","eui.Theme" - * @returns 返回实现此接口的实例。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - function getImplementation(interfaceName: string): any; -} -declare namespace egret { - /** - * The Sprite class is a basic display list building block: a display list node that can contain children. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Sprite.ts - * @language en_US - */ - /** - * Sprite 类是基本显示列表构造块:一个可包含子项的显示列表节点。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Sprite.ts - * @language zh_CN - */ - class Sprite extends DisplayObjectContainer { - /** - * Creates a new Sprite instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 实例化一个容器 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - protected createNativeDisplayObject(): void; - /** - * @private - */ - $graphics: Graphics; - /** - * Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取 Shape 中的 Graphics 对象。可通过此对象执行矢量绘图命令。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly graphics: Graphics; - $hitTest(stageX: number, stageY: number): DisplayObject; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - /** - * @private - */ - $onRemoveFromStage(): void; - } -} -declare namespace egret { - /** - * Bitmap font, texture set of a font. It is generally used as the value of the BitmapText.font attribute. - * @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger - * @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 Text(Containing the specific usage of the bitmap font ) - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapFont.ts - * @language en_US - */ - /** - * 位图字体,是一个字体的纹理集,通常作为BitmapText.font属性的值。 - * @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger - * @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 文本(含位图字体具体用法) - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapFont.ts - * @language zh_CN - */ - class BitmapFont extends SpriteSheet { - /** - * Create an egret.BitmapFont object - * @param texture {egret.Texture} Texture set that use TextureMerger create - * @param config {any} Configure data that use TextureMerger create - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.BitmapFont 对象 - * @param texture {egret.Texture} 使用TextureMerger生成的纹理集 - * @param config {any} 使用TextureMerger生成的配置数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(texture: Texture, config: any); - /** - * @private - */ - private charList; - /** - * Obtain corresponding texture through the name attribute - * @param name {string} name Attribute - * @returns {egret.Texture} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 通过 name 属性获取对应纹理 - * @param name {string} name属性 - * @returns {egret.Texture} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getTexture(name: string): Texture; - /** - * @private - */ - getConfig(name: string, key: string): number; - /** - * @private - */ - private firstCharHeight; - /** - * @private - * - * @returns - */ - _getFirstCharHeight(): number; - /** - * @private - * - * @param fntText - * @returns - */ - private parseConfig(fntText); - /** - * @private - * - * @param configText - * @param key - * @returns - */ - private getConfigByKey(configText, key); - } -} -declare namespace egret { - /** - * Bitmap font adopts the Bitmap+SpriteSheet mode to render text. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapText.ts - * @language en_US - */ - /** - * 位图字体采用了Bitmap+SpriteSheet的方式来渲染文字。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapText.ts - * @language zh_CN - */ - class BitmapText extends DisplayObject { - /** - * Create an egret.BitmapText object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.BitmapText 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - protected createNativeDisplayObject(): void; - private $smoothing; - /** - * Whether or not is smoothed when scaled. - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否进行平滑处理。 - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language zh_CN - */ - smoothing: boolean; - private $text; - /** - * A string to display in the text field. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要显示的文本内容 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - text: string; - /** - * @private - */ - $setText(value: string): boolean; - protected $textFieldWidth: number; - /** - * @private - */ - $getWidth(): number; - /** - * @private - */ - $setWidth(value: number): boolean; - private $textLinesChanged; - /** - * @private - */ - $invalidateContentBounds(): void; - protected $textFieldHeight: number; - /** - * @private - */ - $getHeight(): number; - /** - * @private - */ - $setHeight(value: number): boolean; - protected $font: BitmapFont; - protected $fontStringChanged: boolean; - /** - * The name of the font to use, or a comma-separated list of font names, the type of value must be BitmapFont. - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要使用的字体的名称或用逗号分隔的字体名称列表,类型必须是 BitmapFont。 - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - font: Object; - $setFont(value: any): boolean; - private $lineSpacing; - /** - /** - * An integer representing the amount of vertical space between lines. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个整数,表示行与行之间的垂直间距量 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - lineSpacing: number; - $setLineSpacing(value: number): boolean; - private $letterSpacing; - /** - * An integer representing the amount of distance between characters. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个整数,表示字符之间的距离。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - letterSpacing: number; - $setLetterSpacing(value: number): boolean; - private $textAlign; - /** - * Horizontal alignment of text. - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.5.6 - * @platform Web,Native - * @language en_US - */ - /** - * 文本的水平对齐方式。 - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.5.6 - * @platform Web,Native - * @language zh_CN - */ - textAlign: string; - $setTextAlign(value: string): boolean; - private $verticalAlign; - /** - * Vertical alignment of text. - * @default:egret.VerticalAlign.TOP - * @version Egret 2.5.6 - * @platform Web,Native - * @language en_US - */ - /** - * 文字的垂直对齐方式。 - * @default:egret.VerticalAlign.TOP - * @version Egret 2.5.6 - * @platform Web,Native - * @language zh_CN - */ - verticalAlign: string; - $setVerticalAlign(value: string): boolean; - /** - * A ratio of the width of the space character. This value is multiplied by the height of the first character is the space character width. - * @default 0.33 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个空格字符的宽度比例。这个数值乘以第一个字符的高度即为空格字符的宽。 - * @default 0.33 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static EMPTY_FACTOR: number; - /** - * @private - */ - $updateRenderNode(): void; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - private $textWidth; - /** - * Get the BitmapText measured width - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位图文本测量宽度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textWidth: number; - private $textHeight; - /** - * Get Text BitmapText height - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位图文本测量高度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textHeight: number; - /** - * @private - */ - private $textOffsetX; - /** - * @private - */ - private $textOffsetY; - /** - * @private - */ - private $textStartX; - /** - * @private - */ - private $textStartY; - /** - * @private - */ - private textLines; - /** - * @private 每一行文字的宽度 - */ - private $textLinesWidth; - /** - * @private - */ - $lineHeights: number[]; - /** - * @private - * - * @returns - */ - $getTextLines(): string[]; - } -} -declare namespace egret { - /** - * The HorizontalAlign class defines the possible values for the horizontal alignment. - * @see egret.TextField#textAlign - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HorizontalAlign 类为水平对齐方式定义可能的值。 - * @see egret.TextField#textAlign - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class HorizontalAlign { - /** - * Horizontally align content to the left of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的左侧对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LEFT: string; - /** - * Horizontally align content to the right of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的右侧对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static RIGHT: string; - /** - * Horizontally align content in the center of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在容器的水平中心对齐内容。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CENTER: string; - /** - * Horizontal alignment with both edges. - * Note: TextFiled does not support this alignment method. - * @constant egret.HorizontalAlign.JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 水平两端对齐。 - * 注意:TextFiled不支持此对齐方式。 - * @constant egret.HorizontalAlign.JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static JUSTIFY: string; - /** - * Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Width \" of the container \". - * The Content Width \" of the container \" is the size of the max. child item. If the size of all child items are less than the width of the container, they will be adjusted to the width of the container. - * Note: TextFiled does not support this alignment method. - * @constant egret.HorizontalAlign.CONTENT_JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的"内容宽度"。 - * 容器的"内容宽度"是最大子项的大小,如果所有子项都小于容器的宽度,则会将所有子项的大小调整为容器的宽度。 - * 注意:TextFiled不支持此对齐方式。 - * @constant egret.HorizontalAlign.CONTENT_JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CONTENT_JUSTIFY: string; - } -} -declare namespace egret { - /** - * Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property - * @see http://edn.egret.com/cn/docs/page/146 Text mixed in a variety of style - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/HtmlTextParser.ts - * @language en_US - */ - /** - * 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象 - * @see http://edn.egret.com/cn/docs/page/146 多种样式文本混合 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/HtmlTextParser.ts - * @language zh_CN - */ - class HtmlTextParser { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - private replaceArr; - private initReplaceArr(); - /** - * @private - * - * @param value - * @returns - */ - private replaceSpecial(value); - /** - * @private - */ - private resutlArr; - /** - * Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property - * @param htmltext {string} Text in html - * @returns {Array} 可赋值给 egret.TextField#textFlow Object that can be assigned to the egret.TextField#textFlow property - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象 - * @param htmltext {string} html文本 - * @returns {Array} 可赋值给 egret.TextField#textFlow 属性的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - parse(htmltext: string): egret.ITextElement[]; - parser(htmltext: string): Array; - /** - * @private - * - * @param value - */ - private addToResultArr(value); - private changeStringToObject(str); - /** - * @private - * - * @returns - */ - private getHeadReg(); - /** - * @private - * - * @param info - * @param head - * @param value - */ - private addProperty(info, head, value); - /** - * @private - */ - private stackArray; - /** - * @private - * - * @param infoStr - */ - private addToArray(infoStr); - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - interface IHitTextElement { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - lineIndex: number; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - textElementIndex: number; - } - /** - * Text Style - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本样式 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface ITextStyle { - /** - * text color - * @version Egret 2.4 - * @platform Web,Native - * @see http://edn.egret.com/cn/docs/page/146 多种样式混合文本的基本结构 - * @language en_US - */ - /** - * 颜色值 - * @version Egret 2.4 - * @platform Web,Native - * @see http://edn.egret.com/cn/docs/page/146 多种样式混合文本的基本结构 - * @language zh_CN - */ - textColor?: number; - /** - * stroke color - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 描边颜色值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - strokeColor?: number; - /** - * size - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 字号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - size?: number; - /** - * stroke width - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 描边大小 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stroke?: number; - /** - * whether bold - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否加粗 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bold?: boolean; - /** - * whether italic - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否倾斜 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - italic?: boolean; - /** - * fontFamily - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 字体名称 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - fontFamily?: string; - /** - * Link events or address - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 链接事件或者地址 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - href?: string; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - target?: string; - /** - * Is underlined - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否加下划线 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - underline?: boolean; - } - /** - * Used to build the basic structure of text with a variety of mixed styles, mainly for setting textFlow property - * @see http://edn.egret.com/cn/docs/page/146 Text mixed in a variety of style - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于建立多种样式混合文本的基本结构,主要用于设置 textFlow 属性 - * @see http://edn.egret.com/cn/docs/page/146 多种样式文本混合 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface ITextElement { - /** - * String Content - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 字符串内容 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - text: string; - /** - * Text Style - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本样式 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - style?: ITextStyle; - } - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - interface IWTextElement extends ITextElement { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - width: number; - } - /** - * 文本最终解析的一行数据格式 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - interface ILineElement { - /** - * 文本占用宽度 - * @version Egret 2.4 - * @platform Web,Native - */ - width: number; - /** - * 文本占用高度 - * @version Egret 2.4 - * @platform Web,Native - */ - height: number; - /** - * 当前文本字符总数量(包括换行符) - * @version Egret 2.4 - * @platform Web,Native - */ - charNum: number; - /** - * 是否含有换行符 - * @version Egret 2.4 - * @platform Web,Native - */ - hasNextLine: boolean; - /** - * 本行文本内容 - * @version Egret 2.4 - * @platform Web,Native - */ - elements: Array; - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - class InputController extends HashObject { - /** - * @private - */ - private stageText; - /** - * @private - */ - private stageTextAdded; - /** - * @private - */ - private _text; - /** - * @private - */ - private _isFocus; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - /** - * - * @param text - * @version Egret 2.4 - * @platform Web,Native - */ - init(text: TextField): void; - /** - * @private - * - */ - _addStageText(): void; - /** - * @private - * - */ - _removeStageText(): void; - /** - * @private - * - * @returns - */ - _getText(): string; - /** - * @private - * - * @param value - */ - _setText(value: string): void; - /** - * @private - */ - _setColor(value: number): void; - /** - * @private - * - * @param event - */ - private focusHandler(event); - /** - * @private - * - * @param event - */ - private blurHandler(event); - private tempStage; - private onMouseDownHandler(event); - $onFocus(): void; - private onStageDownHandler(event); - /** - * @private - * - * @param event - */ - private updateTextHandler(event); - /** - * @private - * - */ - private resetText(); - /** - * @private - * - */ - _hideInput(): void; - /** - * @private - * - */ - private updateInput(); - /** - * @private - * - */ - _updateProperties(): void; - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - interface StageText extends EventDispatcher { - /** - * @private - */ - $textfield: egret.TextField; - /** - * @private - * - * @param textfield - */ - $setTextField(textfield: egret.TextField): boolean; - /** - * @private - * - */ - $resetStageText(): void; - /** - * @private - * - * @returns - */ - $getText(): string; - /** - * @private - * - * @param value - */ - $setText(value: string): boolean; - /** - * @private - * - * @param value - */ - $setColor(value: number): boolean; - /** - * @private - * - */ - $show(): void; - /** - * @private - * - */ - $hide(): void; - /** - * @private - * - */ - $addToStage(): void; - /** - * @private - * - */ - $removeFromStage(): void; - /** - * @private - * - */ - $onBlur(): void; - } - /** - * @version Egret 2.4 - * @platform Web,Native - */ - let StageText: { - new (): StageText; - }; -} -declare namespace egret.sys { - /** - * @private - */ - const enum TextKeys { - /** - * @private - */ - fontSize = 0, - /** - * @private - */ - lineSpacing = 1, - /** - * @private - */ - textColor = 2, - /** - * @private - */ - textFieldWidth = 3, - /** - * @private - */ - textFieldHeight = 4, - /** - * @private - */ - textWidth = 5, - /** - * @private - */ - textHeight = 6, - /** - * @private - */ - textDrawWidth = 7, - /** - * @private - */ - fontFamily = 8, - /** - * @private - */ - textAlign = 9, - /** - * @private - */ - verticalAlign = 10, - /** - * @private - */ - textColorString = 11, - /** - * @private - */ - fontString = 12, - /** - * @private - */ - text = 13, - /** - * @private - */ - measuredWidths = 14, - /** - * @private - */ - bold = 15, - /** - * @private - */ - italic = 16, - /** - * @private - */ - fontStringChanged = 17, - /** - * @private - */ - textLinesChanged = 18, - /** - * @private - */ - wordWrap = 19, - /** - * @private - */ - displayAsPassword = 20, - /** - * @private - */ - maxChars = 21, - /** - * @private - */ - selectionActivePosition = 22, - /** - * @private - */ - selectionAnchorPosition = 23, - /** - * @private - */ - type = 24, - /** - * @private - */ - strokeColor = 25, - /** - * @private - */ - strokeColorString = 26, - /** - * @private - */ - stroke = 27, - /** - * @private - */ - scrollV = 28, - /** - * @private - */ - numLines = 29, - /** - * @private - */ - multiline = 30, - /** - * @private - */ - border = 31, - /** - * @private - */ - borderColor = 32, - /** - * @private - */ - background = 33, - /** - * @private - */ - backgroundColor = 34, - /** - * @private - */ - restrictAnd = 35, - /** - * @private - */ - restrictNot = 36, - /** - * @private - */ - inputType = 37, - /** - * @private - */ - textLinesChangedForNativeRender = 38, - } -} -declare namespace egret { - /** - * TextField is the text rendering class of egret. It conducts rendering by using the browser / device API. Due to different ways of font rendering in different browsers / devices, there may be differences in the rendering - * If developers expect no differences among all platforms, please use BitmapText - * @see http://edn.egret.com/cn/docs/page/141 Create Text - * - * @event egret.Event.CHANGE Dispatched when entering text user input。 - * @event egret.FocusEvent.FOCUS_IN Dispatched after the focus to enter text. - * @event egret.FocusEvent.FOCUS_OUT Enter the text loses focus after dispatch. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/TextField.ts - * @language en_US - */ - /** - * TextField是egret的文本渲染类,采用浏览器/设备的API进行渲染,在不同的浏览器/设备中由于字体渲染方式不一,可能会有渲染差异 - * 如果开发者希望所有平台完全无差异,请使用BitmapText - * @see http://edn.egret.com/cn/docs/page/141 创建文本 - * - * @event egret.Event.CHANGE 输入文本有用户输入时调度。 - * @event egret.FocusEvent.FOCUS_IN 聚焦输入文本后调度。 - * @event egret.FocusEvent.FOCUS_OUT 输入文本失去焦点后调度。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/TextField.ts - * @language zh_CN - */ - class TextField extends DisplayObject { - /** - * default fontFamily - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本字体 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static default_fontFamily: string; - /** - * default size in pixels of text - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本字号大小 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - static default_size: number; - /** - * default color of the text. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本颜色 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - static default_textColor: number; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - protected createNativeDisplayObject(): void; - /** - * @private - */ - $TextField: Object; - /** - * @private - */ - private isInput(); - $inputEnabled: boolean; - $setTouchEnabled(value: boolean): void; - /** - * The name of the font to use, or a comma-separated list of font names. - * @default "Arial" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要使用的字体的名称或用逗号分隔的字体名称列表。 - * @default "Arial" - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - fontFamily: string; - $setFontFamily(value: string): boolean; - /** - * The size in pixels of text - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本的字号大小。 - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - size: number; - $setSize(value: number): boolean; - /** - * Specifies whether the text is boldface. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否显示为粗体。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bold: boolean; - $setBold(value: boolean): boolean; - /** - * Determines whether the text is italic font. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否显示为斜体。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - italic: boolean; - $setItalic(value: boolean): boolean; - /** - * @private - * - */ - private invalidateFontString(); - /** - * Horizontal alignment of text. - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本的水平对齐方式。 - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - textAlign: string; - $setTextAlign(value: string): boolean; - /** - * Vertical alignment of text. - * @default:egret.VerticalAlign.TOP - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文字的垂直对齐方式。 - * @default:egret.VerticalAlign.TOP - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - verticalAlign: string; - $setVerticalAlign(value: string): boolean; - /** - * An integer representing the amount of vertical space between lines. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个整数,表示行与行之间的垂直间距量 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - lineSpacing: number; - $setLineSpacing(value: number): boolean; - /** - * Color of the text. - * @default 0x000000 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本颜色 - * @default 0x000000 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - textColor: number; - $setTextColor(value: number): boolean; - /** - * A Boolean value that indicates whether the text field word wrap. If the value is true, then the text field by word wrap; - * if the value is false, the text field by newline characters. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个布尔值,表示文本字段是否按单词换行。如果值为 true,则该文本字段按单词换行; - * 如果值为 false,则该文本字段按字符换行。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - wordWrap: boolean; - $setWordWrap(value: boolean): void; - /** - * @private - */ - private inputUtils; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Type of the text field. - * Any one of the following TextFieldType constants: TextFieldType.DYNAMIC (specifies the dynamic text field that users can not edit), or TextFieldType.INPUT (specifies the dynamic text field that users can edit). - * @default egret.TextFieldType.DYNAMIC - * @language en_US - */ - /** - * 文本字段的类型。 - * 以下 TextFieldType 常量中的任一个:TextFieldType.DYNAMIC(指定用户无法编辑的动态文本字段),或 TextFieldType.INPUT(指定用户可以编辑的输入文本字段)。 - * @default egret.TextFieldType.DYNAMIC - * @language zh_CN - */ - type: string; - /** - * @private - * - * @param value - */ - $setType(value: string): boolean; - /** - * @version Egret 3.1.2 - * @platform Web,Native - */ - /** - * Pop-up keyboard type. - * Any of a TextFieldInputType constants. - * @language en_US - */ - /** - * 弹出键盘的类型。 - * TextFieldInputType 常量中的任一个。 - * @language zh_CN - */ - inputType: string; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Serve as a string of the current text field in the text - * @language en_US - */ - /** - * 作为文本字段中当前文本的字符串 - * @language zh_CN - */ - text: string; - /** - * @private - * - * @returns - */ - $getText(): string; - /** - * @private - * - * @param value - */ - $setBaseText(value: string): boolean; - /** - * @private - * - * @param value - */ - $setText(value: string): boolean; - /** - * Specify whether the text field is a password text field. - * If the value of this property is true, the text field is treated as a password text field and hides the input characters using asterisks instead of the actual characters. If false, the text field is not treated as a password text field. - * @default false - * @language en_US - */ - /** - * 指定文本字段是否是密码文本字段。 - * 如果此属性的值为 true,则文本字段被视为密码文本字段,并使用星号而不是实际字符来隐藏输入的字符。如果为 false,则不会将文本字段视为密码文本字段。 - * @default false - * @language zh_CN - */ - displayAsPassword: boolean; - /** - * @private - * - * @param value - */ - $setDisplayAsPassword(value: boolean): boolean; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Represent the stroke color of the text. - * Contain three 8-bit numbers with RGB color components; for example, 0xFF0000 is red, 0x00FF00 is green. - * @default 0x000000 - * @language en_US - */ - /** - * 表示文本的描边颜色。 - * 包含三个 8 位 RGB 颜色成分的数字;例如,0xFF0000 为红色,0x00FF00 为绿色。 - * @default 0x000000 - * @language zh_CN - */ - strokeColor: number; - /** - * @private - * - * @param value - */ - $setStrokeColor(value: number): boolean; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Indicate the stroke width. - * 0 means no stroke. - * @default 0 - * @language en_US - */ - /** - * 表示描边宽度。 - * 0为没有描边。 - * @default 0 - * @language zh_CN - */ - stroke: number; - /** - * @private - * - * @param value - */ - $setStroke(value: number): boolean; - /** - * The maximum number of characters that the text field can contain, as entered by a user. \n A script can insert more text than maxChars allows; the maxChars property indicates only how much text a user can enter. If the value of this property is 0, a user can enter an unlimited amount of text. - * The default value is 0. - * @default 0 - * @language en_US - */ - /** - * 文本字段中最多可包含的字符数(即用户输入的字符数)。 - * 脚本可以插入比 maxChars 允许的字符数更多的文本;maxChars 属性仅表示用户可以输入多少文本。如果此属性的值为 0,则用户可以输入无限数量的文本。 - * @default 0 - * @language zh_CN - */ - maxChars: number; - /** - * @private - * - * @param value - */ - $setMaxChars(value: number): boolean; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Vertical position of text in a text field. scrollV property helps users locate specific passages in a long article, and create scrolling text fields. - * Vertically scrolling units are lines, and horizontal scrolling unit is pixels. - * If the first displayed line is the first line in the text field, scrollV is set to 1 (instead of 0). - * @language en_US - */ - /** - * 文本在文本字段中的垂直位置。scrollV 属性可帮助用户定位到长篇文章的特定段落,还可用于创建滚动文本字段。 - * 垂直滚动的单位是行,而水平滚动的单位是像素。 - * 如果显示的第一行是文本字段中的第一行,则 scrollV 设置为 1(而非 0)。 - * @language zh_CN - */ - scrollV: number; - /** - * The maximum value of scrollV - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * scrollV 的最大值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly maxScrollV: number; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - readonly selectionBeginIndex: number; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - readonly selectionEndIndex: number; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - readonly caretIndex: number; - /** - * @private - * - * @param beginIndex - * @param endIndex - */ - $setSelection(beginIndex: number, endIndex: number): boolean; - /** - * @private - * - * @returns - */ - $getLineHeight(): number; - /** - * Number of lines of text. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本行数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly numLines: number; - /** - * Indicate whether field is a multiline text field. Note that this property is valid only when the type is TextFieldType.INPUT. - * If the value is true, the text field is multiline; if the value is false, the text field is a single-line text field. In a field of type TextFieldType.INPUT, the multiline value determines whether the Enter key creates a new line (a value of false, and the Enter key is ignored). - * @default false - * @language en_US - */ - /** - * 表示字段是否为多行文本字段。注意,此属性仅在type为TextFieldType.INPUT时才有效。 - * 如果值为 true,则文本字段为多行文本字段;如果值为 false,则文本字段为单行文本字段。在类型为 TextFieldType.INPUT 的字段中,multiline 值将确定 Enter 键是否创建新行(如果值为 false,则将忽略 Enter 键)。 - * @default false - * @language zh_CN - */ - multiline: boolean; - /** - * @private - * - * @param value - */ - $setMultiline(value: boolean): boolean; - /** - * Indicates a user can enter into the text field character set. If you restrict property is null, you can enter any character. If you restrict property is an empty string, you can not enter any character. If you restrict property is a string of characters, you can enter only characters in the string in the text field. The string is scanned from left to right. You can use a hyphen (-) to specify a range. Only restricts user interaction; a script may put any text into the text field.
- * If the string of characters caret (^) at the beginning, all characters are initially accepted, then the string are excluded from receiving ^ character. If the string does not begin with a caret (^) to, any characters are initially accepted and then a string of characters included in the set of accepted characters.
- * The following example allows only uppercase characters, spaces, and numbers in the text field:
- * My_txt.restrict = "A-Z 0-9";
- * The following example includes all characters except lowercase letters:
- * My_txt.restrict = "^ a-z";
- * If you need to enter characters \ ^, use two backslash "\\ -" "\\ ^":
- * Can be used anywhere in the string ^ to rule out including characters and switch between characters, but can only be used to exclude a ^. The following code includes only uppercase letters except uppercase Q:
- * My_txt.restrict = "A-Z ^ Q";
- * @version Egret 2.4 - * @platform Web,Native - * @default null - * @language en_US - */ - /** - * 表示用户可输入到文本字段中的字符集。如果 restrict 属性的值为 null,则可以输入任何字符。如果 restrict 属性的值为空字符串,则不能输入任何字符。如果 restrict 属性的值为一串字符,则只能在文本字段中输入该字符串中的字符。从左向右扫描该字符串。可以使用连字符 (-) 指定一个范围。只限制用户交互;脚本可将任何文本放入文本字段中。
- * 如果字符串以尖号 (^) 开头,则先接受所有字符,然后从接受字符集中排除字符串中 ^ 之后的字符。如果字符串不以尖号 (^) 开头,则最初不接受任何字符,然后将字符串中的字符包括在接受字符集中。
- * 下例仅允许在文本字段中输入大写字符、空格和数字:
- * my_txt.restrict = "A-Z 0-9";
- * 下例包含除小写字母之外的所有字符:
- * my_txt.restrict = "^a-z";
- * 如果需要输入字符 \ ^,请使用2个反斜杠 "\\-" "\\^" :
- * 可在字符串中的任何位置使用 ^,以在包含字符与排除字符之间进行切换,但是最多只能有一个 ^ 用来排除。下面的代码只包含除大写字母 Q 之外的大写字母:
- * my_txt.restrict = "A-Z^Q";
- * @version Egret 2.4 - * @platform Web,Native - * @default null - * @language zh_CN - */ - restrict: string; - /** - * @private - * - * @param value - */ - $setWidth(value: number): boolean; - /** - * @private - * - * @param value - */ - $setHeight(value: number): boolean; - /** - * @private - * 获取显示宽度 - */ - $getWidth(): number; - /** - * @private - * 获取显示宽度 - */ - $getHeight(): number; - /** - * @private - */ - private textNode; - /** - * @private - */ - $graphicsNode: sys.GraphicsNode; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Specifies whether the text field has a border. - * If true, the text field has a border. If false, the text field has no border. - * Use borderColor property to set the border color. - * @default false - * @language en_US - */ - /** - * 指定文本字段是否具有边框。 - * 如果为 true,则文本字段具有边框。如果为 false,则文本字段没有边框。 - * 使用 borderColor 属性来设置边框颜色。 - * @default false - * @language zh_CN - */ - border: boolean; - /** - * @private - */ - $setBorder(value: boolean): void; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * The color of the text field border. - * Even currently is no border can be retrieved or set this property, but only if the text field has the border property is set to true, the color is visible. - * @default 0x000000 - * @language en_US - */ - /** - * 文本字段边框的颜色。 - * 即使当前没有边框,也可检索或设置此属性,但只有当文本字段已将 border 属性设置为 true 时,才可以看到颜色。 - * @default 0x000000 - * @language zh_CN - */ - borderColor: number; - /** - * @private - */ - $setBorderColor(value: number): void; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Specifies whether the text field has a background fill. - * If true, the text field has a background fill. If false, the text field has no background fill. - * Use the backgroundColor property to set the background color of the text field. - * @default false - * @language en_US - */ - /** - * 指定文本字段是否具有背景填充。 - * 如果为 true,则文本字段具有背景填充。如果为 false,则文本字段没有背景填充。 - * 使用 backgroundColor 属性来设置文本字段的背景颜色。 - * @default false - * @language zh_CN - */ - background: boolean; - /** - * @private - */ - $setBackground(value: boolean): void; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Color of the text field background. - * Even currently is no background, can be retrieved or set this property, but only if the text field has the background property set to true, the color is visible. - * @default 0xFFFFFF - * @language en_US - */ - /** - * 文本字段背景的颜色。 - * 即使当前没有背景,也可检索或设置此属性,但只有当文本字段已将 background 属性设置为 true 时,才可以看到颜色。 - * @default 0xFFFFFF - * @language zh_CN - */ - backgroundColor: number; - /** - * @private - */ - $setBackgroundColor(value: number): void; - /** - * @private - * - */ - private fillBackground(lines?); - /** - * Enter the text automatically entered into the input state, the input type is text only and may only be invoked in the user interaction. - * @version Egret 3.0.8 - * @platform Web,Native - * @language en_US - */ - /** - * 输入文本自动进入到输入状态,仅在类型是输入文本并且是在用户交互下才可以调用。 - * @version Egret 3.0.8 - * @platform Web,Native - * @language zh_CN - */ - setFocus(): void; - /** - * @private - * - */ - $onRemoveFromStage(): void; - /** - * @private - * - * @param stage - * @param nestLevel - */ - $onAddToStage(stage: Stage, nestLevel: number): void; - $invalidateTextField(): void; - $getRenderBounds(): Rectangle; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - $updateRenderNode(): void; - /** - * @private - */ - private isFlow; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Set rich text - * @language en_US - */ - /** - * 设置富文本 - * @see http://edn.egret.com/cn/index.php/article/index/id/146 - * @language zh_CN - */ - textFlow: Array; - /** - * @private - * - * @param text - * @returns - */ - private changeToPassText(text); - /** - * @private - */ - private textArr; - /** - * @private - * - * @param textArr - */ - private setMiddleStyle(textArr); - /** - * Get the text measured width - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取文本测量宽度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textWidth: number; - /** - * Get Text measuring height - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取文本测量高度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textHeight: number; - /** - * @private - * @param text - * @version Egret 2.4 - * @platform Web,Native - */ - appendText(text: string): void; - /** - * @private - * @param element - * @version Egret 2.4 - * @platform Web,Native - */ - appendElement(element: egret.ITextElement): void; - /** - * @private - */ - private linesArr; - $getLinesArr(): Array; - /** - * @private - * - * @returns - */ - $getLinesArr2(): Array; - /** - * @private - */ - $isTyping: boolean; - /** - * @private - */ - $setIsTyping(value: boolean): void; - /** - * @private - * 返回要绘制的下划线列表 - */ - private drawText(); - private addEvent(); - private removeEvent(); - private onTapHandler(e); - } - interface TextField { - addEventListener(type: "link", listener: (this: Z, e: TextEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: "focusIn" | "focusOut", listener: (this: Z, e: FocusEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } -} -declare namespace egret { - /** - * TextFieldInputType class is an enumeration of constant value used in setting the inputType property of the TextField class. - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * TextFieldInputType 类是在设置 TextField 类的 inputType 属性时使用的常数值的枚举。 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - class TextFieldInputType { - /** - * The default - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * 默认 input 类型 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - static TEXT: string; - /** - * Telephone Number Inputs - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * 电话号码 input 类型 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - static TEL: string; - /** - * Password Inputs - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * password 类型 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - static PASSWORD: string; - } -} -declare namespace egret { - /** - * TextFieldType class is an enumeration of constant value used in setting the type property of the TextField class. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * TextFieldType 类是在设置 TextField 类的 type 属性时使用的常数值的枚举。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class TextFieldType { - /** - * Used to specify dynamic text - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定动态文本 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static DYNAMIC: string; - /** - * Used to specify the input text - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定输入文本 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static INPUT: string; - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - class TextFieldUtils { - /** - * 获取第一个绘制的行数 - * @param textfield 文本 - * @returns {number} 行数,从0开始 - * @private - */ - static $getStartLine(textfield: egret.TextField): number; - /** - * 获取水平比例 - * @param textfield 文本 - * @returns {number} 水平比例 - * @private - */ - static $getHalign(textfield: egret.TextField): number; - /** - * @private - * - * @param textfield - * @returns - */ - static $getTextHeight(textfield: egret.TextField): number; - /** - * 获取垂直比例 - * @param textfield 文本 - * @returns {number} 垂直比例 - * @private - */ - static $getValign(textfield: egret.TextField): number; - /** - * 根据x、y获取文本项 - * @param textfield 文本 - * @param x x坐标值 - * @param y y坐标值 - * @returns 文本单项 - * @private - */ - static $getTextElement(textfield: egret.TextField, x: number, y: number): ITextElement; - /** - * 获取文本点击块 - * @param textfield 文本 - * @param x x坐标值 - * @param y y坐标值 - * @returns 文本点击块 - * @private - */ - static $getHit(textfield: egret.TextField, x: number, y: number): IHitTextElement; - /** - * 获取当前显示多少行 - * @param textfield 文本 - * @returns {number} 显示的行数 - * @private - */ - static $getScrollNum(textfield: egret.TextField): number; - } -} -/** - * @private - */ -declare namespace egret.sys { - /** - * 测量文本在指定样式下的宽度。 - * @param text 要测量的文本内容。 - * @param fontFamily 字体名称 - * @param fontSize 字体大小 - * @param bold 是否粗体 - * @param italic 是否斜体 - */ - let measureText: (text: string, fontFamily: string, fontSize: number, bold: boolean, italic: boolean) => number; -} -declare namespace egret { - /** - * The VerticalAlign class defines the possible values for the vertical alignment. - * @see egret.TextField#verticalAlign - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * VerticalAlign 类为垂直对齐方式定义可能的值。 - * @see egret.TextField#verticalAlign - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class VerticalAlign { - /** - * Vertically align content to the top of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的顶部对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOP: string; - /** - * Vertically align content to the bottom of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的底部对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static BOTTOM: string; - /** - * Vertically align content in the middle of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在容器的垂直中心对齐内容。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static MIDDLE: string; - /** - * Vertical alignment with both edges - * Note: TextFiled does not support this alignment method." - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 垂直两端对齐 - * 注意:TextFiled不支持此对齐方式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static JUSTIFY: string; - /** - * Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Height \" of the container \". - * The Content Height \" of the container \" is the size of the max. child item. If the size of all child items are less than the height of the container, they will be adjusted to the height of the container. - * Note: TextFiled does not support this alignment method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的"内容高度"。 - * 容器的"内容高度"是最大子项的大小,如果所有子项都小于容器的高度,则会将所有子项的大小调整为容器的高度。 - * 注意:TextFiled不支持此对齐方式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CONTENT_JUSTIFY: string; - } -} -declare namespace egret { - /** - * @language en_US - * The Base64Util class provides methods for encoding and decoding base64. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Base64Util.ts - */ - /** - * @language zh_CN - * Base64Util 类提供用于编解码base64的方法。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Base64Util.ts - */ - class Base64Util { - /** - * @language en_US - * encode base64. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 编码base64。 - * @version Egret 2.4 - * @platform Web,Native - */ - static encode(arraybuffer: ArrayBuffer): string; - /** - * @language en_US - * decode base64. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 解码base64。 - * @version Egret 2.4 - * @platform Web,Native - */ - static decode(base64: string): ArrayBuffer; - } -} -/** - * @private - */ -declare let chars: string; -/** - * @private - */ -declare let lookup: Uint8Array; -declare namespace egret { - /** - * The Endian class contains values that denote the byte order used to represent multibyte numbers. - * The byte order is either bigEndian (most significant byte first) or littleEndian (least significant byte first). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Endian 类中包含一些值,它们表示用于表示多字节数字的字节顺序。 - * 字节顺序为 bigEndian(最高有效字节位于最前)或 littleEndian(最低有效字节位于最前)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class Endian { - /** - * Indicates the least significant byte of the multibyte number appears first in the sequence of bytes. - * The hexadecimal number 0x12345678 has 4 bytes (2 hexadecimal digits per byte). The most significant byte is 0x12. The least significant byte is 0x78. (For the equivalent decimal number, 305419896, the most significant digit is 3, and the least significant digit is 6). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示多字节数字的最低有效字节位于字节序列的最前面。 - * 十六进制数字 0x12345678 包含 4 个字节(每个字节包含 2 个十六进制数字)。最高有效字节为 0x12。最低有效字节为 0x78。(对于等效的十进制数字 305419896,最高有效数字是 3,最低有效数字是 6)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LITTLE_ENDIAN: string; - /** - * Indicates the most significant byte of the multibyte number appears first in the sequence of bytes. - * The hexadecimal number 0x12345678 has 4 bytes (2 hexadecimal digits per byte). The most significant byte is 0x12. The least significant byte is 0x78. (For the equivalent decimal number, 305419896, the most significant digit is 3, and the least significant digit is 6). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示多字节数字的最高有效字节位于字节序列的最前面。 - * 十六进制数字 0x12345678 包含 4 个字节(每个字节包含 2 个十六进制数字)。最高有效字节为 0x12。最低有效字节为 0x78。(对于等效的十进制数字 305419896,最高有效数字是 3,最低有效数字是 6)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static BIG_ENDIAN: string; - } - const enum EndianConst { - LITTLE_ENDIAN = 0, - BIG_ENDIAN = 1, - } - /** - * The ByteArray class provides methods and attributes for optimized reading and writing as well as dealing with binary data. - * Note: The ByteArray class is applied to the advanced developers who need to access data at the byte layer. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/ByteArray.ts - * @language en_US - */ - /** - * ByteArray 类提供用于优化读取、写入以及处理二进制数据的方法和属性。 - * 注意:ByteArray 类适用于需要在字节层访问数据的高级开发人员。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/ByteArray.ts - * @language zh_CN - */ - class ByteArray { - /** - * @private - */ - protected bufferExtSize: number; - protected data: DataView; - protected _bytes: Uint8Array; - /** - * @private - */ - protected _position: number; - /** - * - * 已经使用的字节偏移量 - * @protected - * @type {number} - * @memberOf ByteArray - */ - protected write_position: number; - /** - * Changes or reads the byte order; egret.EndianConst.BIG_ENDIAN or egret.EndianConst.LITTLE_EndianConst. - * @default egret.EndianConst.BIG_ENDIAN - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 更改或读取数据的字节顺序;egret.EndianConst.BIG_ENDIAN 或 egret.EndianConst.LITTLE_ENDIAN。 - * @default egret.EndianConst.BIG_ENDIAN - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - endian: string; - protected $endian: EndianConst; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(buffer?: ArrayBuffer | Uint8Array, bufferExtSize?: number); - /** - * @deprecated - * @version Egret 2.4 - * @platform Web,Native - */ - setArrayBuffer(buffer: ArrayBuffer): void; - /** - * 可读的剩余字节数 - * - * @returns - * - * @memberOf ByteArray - */ - readonly readAvailable: number; - /** - * @private - */ - buffer: ArrayBuffer; - readonly rawBuffer: ArrayBuffer; - readonly bytes: Uint8Array; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @private - */ - dataView: DataView; - /** - * @private - */ - readonly bufferOffset: number; - /** - * The current position of the file pointer (in bytes) to move or return to the ByteArray object. The next time you start reading reading method call in this position, or will start writing in this position next time call a write method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将文件指针的当前位置(以字节为单位)移动或返回到 ByteArray 对象中。下一次调用读取方法时将在此位置开始读取,或者下一次调用写入方法时将在此位置开始写入。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - position: number; - /** - * The length of the ByteArray object (in bytes). - * If the length is set to be larger than the current length, the right-side zero padding byte array. - * If the length is set smaller than the current length, the byte array is truncated. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * ByteArray 对象的长度(以字节为单位)。 - * 如果将长度设置为大于当前长度的值,则用零填充字节数组的右侧。 - * 如果将长度设置为小于当前长度的值,将会截断该字节数组。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - length: number; - protected _validateBuffer(value: number): void; - /** - * The number of bytes that can be read from the current position of the byte array to the end of the array data. - * When you access a ByteArray object, the bytesAvailable property in conjunction with the read methods each use to make sure you are reading valid data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 可从字节数组的当前位置到数组末尾读取的数据的字节数。 - * 每次访问 ByteArray 对象时,将 bytesAvailable 属性与读取方法结合使用,以确保读取有效的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly bytesAvailable: number; - /** - * Clears the contents of the byte array and resets the length and position properties to 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 清除字节数组的内容,并将 length 和 position 属性重置为 0。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clear(): void; - /** - * Read a Boolean value from the byte stream. Read a simple byte. If the byte is non-zero, it returns true; otherwise, it returns false. - * @return If the byte is non-zero, it returns true; otherwise, it returns false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取布尔值。读取单个字节,如果字节非零,则返回 true,否则返回 false - * @return 如果字节不为零,则返回 true,否则返回 false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readBoolean(): boolean; - /** - * Read signed bytes from the byte stream. - * @return An integer ranging from -128 to 127 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取带符号的字节 - * @return 介于 -128 和 127 之间的整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readByte(): number; - /** - * Read data byte number specified by the length parameter from the byte stream. Starting from the position specified by offset, read bytes into the ByteArray object specified by the bytes parameter, and write bytes into the target ByteArray - * @param bytes ByteArray object that data is read into - * @param offset Offset (position) in bytes. Read data should be written from this position - * @param length Byte number to be read Default value 0 indicates reading all available data - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取 length 参数指定的数据字节数。从 offset 指定的位置开始,将字节读入 bytes 参数指定的 ByteArray 对象中,并将字节写入目标 ByteArray 中 - * @param bytes 要将数据读入的 ByteArray 对象 - * @param offset bytes 中的偏移(位置),应从该位置写入读取的数据 - * @param length 要读取的字节数。默认值 0 导致读取所有可用的数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readBytes(bytes: ByteArray, offset?: number, length?: number): void; - /** - * Read an IEEE 754 double-precision (64 bit) floating point number from the byte stream - * @return Double-precision (64 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个 IEEE 754 双精度(64 位)浮点数 - * @return 双精度(64 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readDouble(): number; - /** - * Read an IEEE 754 single-precision (32 bit) floating point number from the byte stream - * @return Single-precision (32 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个 IEEE 754 单精度(32 位)浮点数 - * @return 单精度(32 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readFloat(): number; - /** - * Read a 32-bit signed integer from the byte stream. - * @return A 32-bit signed integer ranging from -2147483648 to 2147483647 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个带符号的 32 位整数 - * @return 介于 -2147483648 和 2147483647 之间的 32 位带符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readInt(): number; - /** - * Read a 16-bit signed integer from the byte stream. - * @return A 16-bit signed integer ranging from -32768 to 32767 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个带符号的 16 位整数 - * @return 介于 -32768 和 32767 之间的 16 位带符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readShort(): number; - /** - * Read unsigned bytes from the byte stream. - * @return A unsigned integer ranging from 0 to 255 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取无符号的字节 - * @return 介于 0 和 255 之间的无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUnsignedByte(): number; - /** - * Read a 32-bit unsigned integer from the byte stream. - * @return A 32-bit unsigned integer ranging from 0 to 4294967295 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个无符号的 32 位整数 - * @return 介于 0 和 4294967295 之间的 32 位无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUnsignedInt(): number; - /** - * Read a 16-bit unsigned integer from the byte stream. - * @return A 16-bit unsigned integer ranging from 0 to 65535 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个无符号的 16 位整数 - * @return 介于 0 和 65535 之间的 16 位无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUnsignedShort(): number; - /** - * Read a UTF-8 character string from the byte stream Assume that the prefix of the character string is a short unsigned integer (use byte to express length) - * @return UTF-8 character string - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个 UTF-8 字符串。假定字符串的前缀是无符号的短整型(以字节表示长度) - * @return UTF-8 编码的字符串 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUTF(): string; - /** - * Read a UTF-8 byte sequence specified by the length parameter from the byte stream, and then return a character string - * @param Specify a short unsigned integer of the UTF-8 byte length - * @return A character string consists of UTF-8 bytes of the specified length - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个由 length 参数指定的 UTF-8 字节序列,并返回一个字符串 - * @param length 指明 UTF-8 字节长度的无符号短整型数 - * @return 由指定长度的 UTF-8 字节组成的字符串 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUTFBytes(length: number): string; - /** - * Write a Boolean value. A single byte is written according to the value parameter. If the value is true, write 1; if the value is false, write 0. - * @param value A Boolean value determining which byte is written. If the value is true, write 1; if the value is false, write 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 写入布尔值。根据 value 参数写入单个字节。如果为 true,则写入 1,如果为 false,则写入 0 - * @param value 确定写入哪个字节的布尔值。如果该参数为 true,则该方法写入 1;如果该参数为 false,则该方法写入 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeBoolean(value: boolean): void; - /** - * Write a byte into the byte stream - * The low 8 bits of the parameter are used. The high 24 bits are ignored. - * @param value A 32-bit integer. The low 8 bits will be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个字节 - * 使用参数的低 8 位。忽略高 24 位 - * @param value 一个 32 位整数。低 8 位将被写入字节流 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeByte(value: number): void; - /** - * Write the byte sequence that includes length bytes in the specified byte array, bytes, (starting at the byte specified by offset, using a zero-based index), into the byte stream - * If the length parameter is omitted, the default length value 0 is used and the entire buffer starting at offset is written. If the offset parameter is also omitted, the entire buffer is written - * If the offset or length parameter is out of range, they are clamped to the beginning and end of the bytes array. - * @param bytes ByteArray Object - * @param offset A zero-based index specifying the position into the array to begin writing - * @param length An unsigned integer specifying how far into the buffer to write - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定字节数组 bytes(起始偏移量为 offset,从零开始的索引)中包含 length 个字节的字节序列写入字节流 - * 如果省略 length 参数,则使用默认长度 0;该方法将从 offset 开始写入整个缓冲区。如果还省略了 offset 参数,则写入整个缓冲区 - * 如果 offset 或 length 超出范围,它们将被锁定到 bytes 数组的开头和结尾 - * @param bytes ByteArray 对象 - * @param offset 从 0 开始的索引,表示在数组中开始写入的位置 - * @param length 一个无符号整数,表示在缓冲区中的写入范围 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeBytes(bytes: ByteArray, offset?: number, length?: number): void; - /** - * Write an IEEE 754 double-precision (64 bit) floating point number into the byte stream - * @param value Double-precision (64 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个 IEEE 754 双精度(64 位)浮点数 - * @param value 双精度(64 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeDouble(value: number): void; - /** - * Write an IEEE 754 single-precision (32 bit) floating point number into the byte stream - * @param value Single-precision (32 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个 IEEE 754 单精度(32 位)浮点数 - * @param value 单精度(32 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeFloat(value: number): void; - /** - * Write a 32-bit signed integer into the byte stream - * @param value An integer to be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个带符号的 32 位整数 - * @param value 要写入字节流的整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeInt(value: number): void; - /** - * Write a 16-bit integer into the byte stream. The low 16 bits of the parameter are used. The high 16 bits are ignored. - * @param value A 32-bit integer. Its low 16 bits will be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个 16 位整数。使用参数的低 16 位。忽略高 16 位 - * @param value 32 位整数,该整数的低 16 位将被写入字节流 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeShort(value: number): void; - /** - * Write a 32-bit unsigned integer into the byte stream - * @param value An unsigned integer to be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个无符号的 32 位整数 - * @param value 要写入字节流的无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeUnsignedInt(value: number): void; - /** - * Write a 16-bit unsigned integer into the byte stream - * @param value An unsigned integer to be written into the byte stream - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个无符号的 16 位整数 - * @param value 要写入字节流的无符号整数 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - writeUnsignedShort(value: number): void; - /** - * Write a UTF-8 string into the byte stream. The length of the UTF-8 string in bytes is written first, as a 16-bit integer, followed by the bytes representing the characters of the string - * @param value Character string value to be written - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 UTF-8 字符串写入字节流。先写入以字节表示的 UTF-8 字符串长度(作为 16 位整数),然后写入表示字符串字符的字节 - * @param value 要写入的字符串值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeUTF(value: string): void; - /** - * Write a UTF-8 string into the byte stream. Similar to the writeUTF() method, but the writeUTFBytes() method does not prefix the string with a 16-bit length word - * @param value Character string value to be written - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 UTF-8 字符串写入字节流。类似于 writeUTF() 方法,但 writeUTFBytes() 不使用 16 位长度的词为字符串添加前缀 - * @param value 要写入的字符串值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeUTFBytes(value: string): void; - /** - * - * @returns - * @version Egret 2.4 - * @platform Web,Native - */ - toString(): string; - /** - * @private - * 将 Uint8Array 写入字节流 - * @param bytes 要写入的Uint8Array - * @param validateBuffer - */ - _writeUint8Array(bytes: Uint8Array | ArrayLike, validateBuffer?: boolean): void; - /** - * @param len - * @returns - * @version Egret 2.4 - * @platform Web,Native - * @private - */ - validate(len: number): boolean; - /**********************/ - /**********************/ - /** - * @private - * @param len - * @param needReplace - */ - protected validateBuffer(len: number): void; - /** - * @private - * UTF-8 Encoding/Decoding - */ - private encodeUTF8(str); - /** - * @private - * - * @param data - * @returns - */ - private decodeUTF8(data); - /** - * @private - * - * @param code_point - */ - private encoderError(code_point); - /** - * @private - * - * @param fatal - * @param opt_code_point - * @returns - */ - private decoderError(fatal, opt_code_point?); - /** - * @private - */ - private EOF_byte; - /** - * @private - */ - private EOF_code_point; - /** - * @private - * - * @param a - * @param min - * @param max - */ - private inRange(a, min, max); - /** - * @private - * - * @param n - * @param d - */ - private div(n, d); - /** - * @private - * - * @param string - */ - private stringToCodePoints(string); - } -} -declare namespace egret { - /** - * The BitmapFillMode class defines the image fill mode of Bitmap. - * The BitmapFillMode class defines a pattern enumeration for adjusting size. These patterns determine how Bitmap fill the size designated by the layout system. - * @see http://edn.egret.com/cn/docs/page/134 Texture filling way - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BitmapFillMode.ts - * @language en_US - */ - /** - * BitmapFillMode 类定义Bitmap的图像填充方式。 - * BitmapFillMode 类定义了调整大小模式的一个枚举,这些模式确定 Bitmap 如何填充由布局系统指定的尺寸。 - * @see http://edn.egret.com/cn/docs/page/134 纹理的填充方式 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BitmapFillMode.ts - * @language zh_CN - */ - const BitmapFillMode: { - REPEAT: string; - SCALE: string; - CLIP: string; - }; -} -declare namespace egret { - /** - * Registers the runtime class information for a class.This method adds some strings which represent the class name or - * some interface names to the class definition. After the registration,you can use egret.is() method to do the type checking - * for the instance of this class.
- * Note:If you use the TypeScript programming language, the egret command line tool will automatically generate the registration code line. - * You don't need to manually call this method. - * - * @example the following code shows how to register the runtime class information for the EventDispatcher class and do the type checking: - *
-     *      egret.registerClass(egret.EventDispatcher,"egret.EventDispatcher",["egret.IEventDispatcher"]);
-     *      let dispatcher = new egret.EventDispatcher();
-     *      egret.log(egret.is(dispatcher, "egret.IEventDispatcher"));  //true。
-     *      egret.log(egret.is(dispatcher, "egret.EventDispatcher"));   //true。
-     *      egret.log(egret.is(dispatcher, "egret.Bitmap"));   //false。
-     * 
- * @param classDefinition the class definition to be registered. - * @param className a unique identification string of the specific class - * @param interfaceNames a list of unique identification string of the specific interfaces. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 为一个类定义注册运行时类信息,用此方法往类定义上注册它自身以及所有接口对应的字符串。 - * 在运行时,这个类的实例将可以使用 egret.is() 方法传入一个字符串来判断实例类型。 - * @example 以下代码演示了如何为EventDispatcher类注册运行时类信息并判断类型: - *
-     *      //为egret.EventDispatcher类注册运行时类信息,由于它实现了IEventDispatcher接口,这里应同时传入接口名对应的字符串。
-     *      egret.registerClass(egret.EventDispatcher,"egret.EventDispatcher",["egret.IEventDispatcher"]);
-     *      let dispatcher = new egret.EventDispatcher();
-     *      egret.log(egret.is(dispatcher, "egret.IEventDispatcher"));  //true。
-     *      egret.log(egret.is(dispatcher, "egret.EventDispatcher"));   //true。
-     *      egret.log(egret.is(dispatcher, "egret.Bitmap"));   //false。
-     * 
- * 注意:若您使用 TypeScript 来编写程序,egret 命令行会自动帮您生成类信息注册代码行到最终的 Javascript 文件中。因此您不需要手动调用此方法。 - * - * @param classDefinition 要注册的类定义。 - * @param className 要注册的类名。 - * @param interfaceNames 要注册的类所实现的接口名列表。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function registerClass(classDefinition: any, className: string, interfaceNames?: string[]): void; -} -declare namespace egret { - /** - * The Stage class represents the main drawing area.The Stage object is not globally accessible. You need to access - * it through the stage property of a DisplayObject instance.
- * The Stage class has several ancestor classes — Sprite, DisplayObject, and EventDispatcher — from which it inherits - * properties and methods. Many of these properties and methods are inapplicable to Stage objects. - * @event egret.Event.RESIZE Dispatched when the stageWidth or stageHeight property of the Stage object is changed. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Stage.ts - * @language en_US - */ - /** - * Stage 类代表主绘图区。 - * 可以利用 DisplayObject 实例的 stage 属性进行访问。
- * Stage 类具有多个祖代类: Sprite、DisplayObject 和 EventDispatcher,属性和方法便是从这些类继承而来的。 - * 从这些继承的许多属性和方法不适用于 Stage 对象。 - * @event egret.Event.RESIZE 当stageWidth或stageHeight属性发生改变时调度 - * @event egret.Event.DEACTIVATE 当stage失去焦点后调度 - * @event egret.Event.ACTIVATE 当stage获得焦点后调度 - * - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Stage.ts - * @language zh_CN - */ - class Stage extends DisplayObjectContainer { - /** - * @private - * Stage不许允许自行实例化 - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - protected createNativeDisplayObject(): void; - /** - * Gets and sets the frame rate of the stage. The frame rate is defined as frames per second. Valid range for the - * frame rate is from 0.01 to 1000 frames per second.
- * Note: setting the frameRate property of one Stage object changes the frame rate for all Stage objects - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取并设置舞台的帧速率。帧速率是指每秒显示的帧数。帧速率的有效范围为每秒 0.01 到 60 个帧。
- * 注意: 修改任何一个Stage的frameRate属性都会同步修改其他Stage的帧率。 - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - frameRate: number; - /** - * @private - */ - $stageWidth: number; - /** - * Indicates the width of the stage, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 舞台的当前宽度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stageWidth: number; - /** - * @private - */ - $stageHeight: number; - /** - * Indicates the height of the stage, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 舞台的当前高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stageHeight: number; - /** - * After you call the invalidate() method, when the display list is next rendered, the Egret runtime sends a render - * event to each display object that has registered to listen for the render event. You must call the invalidate() - * method each time you want the Egret runtime to send render events. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 调用 invalidate() 方法后,在显示列表下次呈现时,Egret 会向每个已注册侦听 Event.RENDER 事件的显示对象发送一个 Event.RENDER 事件。 - * 每次您希望 Egret 发送 Event.RENDER 事件时,都必须调用 invalidate() 方法。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - invalidate(): void; - /** - * @deprecated - */ - registerImplementation(interfaceName: string, instance: any): void; - /** - * @deprecated - */ - getImplementation(interfaceName: string): any; - /** - * @private - * 设备屏幕引用 - */ - $screen: egret.sys.Screen; - $scaleMode: string; - /** - * A StageScaleMode class that specifies which scale mode to use. The following are valid values:
- *
    - *
  • StageScaleMode.EXACT_FIT -- The entire application be visible in the specified area without trying to preserve the original aspect ratio. Distortion can occur, the application may be stretched or compressed.
  • - *
  • StageScaleMode.SHOW_ALL -- The entire application is visible in the specified area without distortion while maintaining the application of the original aspect ratio. Applications may display border.
  • - *
  • StageScaleMode.NO_SCALE -- The size of the entire application is fixed, so that even if the size of the player window changes, it remains unchanged. If the player window is smaller than the content, it may do some trimming.
  • - *
  • StageScaleMode.NO_BORDER -- Keep the original aspect ratio scaling application content, after scaling a narrow direction of application content to fill the viewport players on both sides in the other direction may exceed the viewport and the player is cut.
  • - *
  • StageScaleMode.FIXED_WIDTH -- Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant width, height may change.
  • - *
  • StageScaleMode.FIXED_HEIGHT -- Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant height, width may change.
  • - *
- * @default egret.StageScaleMode.SHOW_ALL - * @language en_US - */ - /** - * 一个 StageScaleMode 类中指定要使用哪种缩放模式的值。以下是有效值:
- *
    - *
  • StageScaleMode.EXACT_FIT -- 整个应用程序在指定区域中可见,但不尝试保持原始高宽比。可能会发生扭曲,应用程序可能会拉伸或压缩显示。
  • - *
  • StageScaleMode.SHOW_ALL -- 整个应用程序在指定区域中可见,且不发生扭曲,同时保持应用程序的原始高宽比。应用程序的可能会显示边框。
  • - *
  • StageScaleMode.NO_SCALE -- 整个应用程序的大小固定,因此,即使播放器窗口的大小更改,它也会保持不变。如果播放器窗口比内容小,则可能进行一些裁切。
  • - *
  • StageScaleMode.NO_BORDER -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较窄方向填满播放器视口,另一个方向的两侧可能会超出播放器视口而被裁切。
  • - *
  • StageScaleMode.FIXED_WIDTH -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始宽度不变,高度可能会改变。
  • - *
  • StageScaleMode.FIXED_HEIGHT -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始高度不变,宽度可能会改变。
  • - *
- * @default egret.StageScaleMode.SHOW_ALL - * @language zh_CN - */ - scaleMode: string; - $orientation: string; - /** - * Horizontal and vertical screen display screen, can only be set under the current Native in the configuration file. A egret.OrientationMode class that specifies which display mode to use. The following are valid values:
- *
    - *
  • egret.OrientationMode.AUTO -- Always follow the direction of application display screen, always guaranteed by the look down.
  • - *
  • egret.OrientationMode.PORTRAIT -- Applications remain portrait mode, namely horizontal screen look, the screen from left to right.
  • - *
  • egret.OrientationMode.LANDSCAPE -- Applications remain horizontal screen mode, namely vertical screen, the screen from right to left.
  • - *
  • egret.OrientationMode.LANDSCAPE_FLIPPED -- Applications remain horizontal screen mode, namely vertical screen, the screen from left to right.
  • - *
- * @platform Web - * @version 2.4 - * @language en_US - */ - /** - * 屏幕横竖屏显示方式,目前 Native 下只能在配置文件里设置。一个 egret.OrientationMode 类中指定要使用哪种显示方式。以下是有效值:
- *
    - *
  • egret.OrientationMode.AUTO -- 应用始终跟随屏幕的方向显示,始终保证由上往下看。
  • - *
  • egret.OrientationMode.PORTRAIT -- 应用始终保持竖屏模式,即横屏看时,屏幕由左往右看。
  • - *
  • egret.OrientationMode.LANDSCAPE -- 应用始终保持横屏模式,即竖屏看时,屏幕显示由右往左。
  • - *
  • egret.OrientationMode.LANDSCAPE_FLIPPED -- 应用始终保持横屏模式,即竖屏看时,屏幕显示由左往右。
  • - *
- * @platform Web - * @version 2.4 - * @language zh_CN - */ - orientation: string; - /** - * Draw texture zoom ratio - * @default 1 - * @language en_US - */ - /** - * 绘制纹理的缩放比率,默认值为1 - * @default 1 - * @language zh_CN - */ - textureScaleFactor: number; - $maxTouches: number; - /** - * Set the number of screens can simultaneously touch. Above this amount will not be triggered in response. - * @default 99 - * @language en_US - */ - /** - * 设置屏幕同时可以触摸的数量。高于这个数量将不会被触发响应。 - * @default 99 - * @language zh_CN - */ - maxTouches: number; - /** - * Set resolution size - * @param width width - * @param height height - * @version Egret 2.5.5 - * @platform Web,Native - * @language en_US - */ - /** - * 设置分辨率尺寸 - * @param width 宽度 - * @param height 高度 - * @version Egret 2.5.5 - * @platform Web,Native - * @language zh_CN - */ - setContentSize(width: number, height: number): void; - } -} -declare namespace egret { - /** - * Logger is an entrance for the log processing namespace of the engine - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Logger是引擎的日志处理模块入口 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class Logger { - /** - * open all - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 全开 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ALL: string; - /** - * level: DEBUG - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 DEBUG - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static DEBUG: string; - /** - * level: INFO - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 INFO - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static INFO: string; - /** - * level: WARN - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 WARN - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static WARN: string; - /** - * level: ERROR - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 ERROR - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ERROR: string; - /** - * close all - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 全关 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static OFF: string; - /** - * Set the current need to open the log level. Grade level are: ALL - * This feature is only in DEBUG mode to take effect.
- *
    - *
  • Logger.ALL - all levels of log can be printed out. - *
  • Logger.DEBUG - print debug, info, log, warn, error. - *
  • Logger.INFO - print info, log, warn, error. - *
  • Logger.WARN - can print warn, error. - *
  • Logger.ERROR - You can print error. - *
  • Logger.OFF - all closed. - * - *param LogType from this level to start printing. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置当前需要开启的log级别。级别等级分别为:ALL < DEBUG < INFO < WARN < ERROR < OFF
    - * 此功能只在 DEBUG 模式下才生效。
    - *
      - *
    • Logger.ALL -- 所有等级的log都可以打印出来。
    • - *
    • Logger.DEBUG -- 可以打印debug、info、log、warn、error。
    • - *
    • Logger.INFO -- 可以打印info、log、warn、error。
    • - *
    • Logger.WARN -- 可以打印warn、error。
    • - *
    • Logger.ERROR -- 可以打印error。
    • - *
    • Logger.OFF -- 全部关闭。
    • - *
    - * @param logType 从这个等级开始打印。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static logLevel: string; - } -} -declare namespace egret { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - class NumberUtils { - /** - * Judge whether it is a numerical value - * @param value Parameter that needs to be judged - * @returns - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 判断是否是数值 - * @param value 需要判断的参数 - * @returns - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static isNumber(value: any): boolean; - /** - * Obtain the approximate sin value of the corresponding angle value - * @param value {number} Angle value - * @returns {number} sin value - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 得到对应角度值的sin近似值 - * @param value {number} 角度值 - * @returns {number} sin值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static sin(value: number): number; - /** - * @private - * - * @param value - * @returns - */ - private static sinInt(value); - /** - * Obtain the approximate cos value of the corresponding angle value - * @param value {number} Angle value - * @returns {number} cos value - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 得到对应角度值的cos近似值 - * @param value {number} 角度值 - * @returns {number} cos值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static cos(value: number): number; - /** - * @private - * - * @param value - * @returns - */ - private static cosInt(value); - } -} -/** - * @private - */ -declare let egret_sin_map: {}; -/** - * @private - */ -declare let egret_cos_map: {}; -/** - * @private - */ -declare let DEG_TO_RAD: number; -declare namespace egret { - /** - * The Timer class is the interface to timers, which let you run code on a specified time sequence. Use the start() - * method to start a timer. Add an event listener for the timer event to set up code to be run on the timer interval.
    - * You can create Timer objects to run once or repeat at specified intervals to execute code on a schedule. Depending - * on the framerate or the runtime environment (available memory and other factors), the runtime may dispatchEvent events at - * slightly offset intervals. - * @see egret.TimerEvent - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Timer.ts - * @language en_US - */ - /** - * Timer 类是计时器的接口,它使您能按指定的时间序列运行代码。 - * 使用 start() 方法来启动计时器。为 timer 事件添加事件侦听器,以便将代码设置为按计时器间隔运行。 - * 可以创建 Timer 对象以运行一次或按指定间隔重复运行,从而按计划执行代码。 - * 根据 Egret 的帧速率或运行时环境(可用内存和其他因素),运行时调度事件的间隔可能稍有不同。 - * @see egret.TimerEvent - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Timer.ts - * @language zh_CN - */ - class Timer extends EventDispatcher { - /** - * Constructs a new Timer object with the specified delay and repeatCount states. - * @param delay The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended. - * Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems. - * @param repeatCount Specifies the number of repetitions. If zero, the timer repeats indefinitely.If nonzero, - * the timer runs the specified number of times and then stops. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的 delay 和 repeatCount 状态构造新的 Timer 对象。 - * @param delay 计时器事件间的延迟(以毫秒为单位)。建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。 - * @param repeatCount 指定重复次数。如果为零,则计时器将持续不断重复运行。如果不为 0,则将运行计时器,运行次数为指定的次数,然后停止。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(delay: number, repeatCount?: number); - /** - * @private - */ - private _delay; - /** - * The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended.
    - * Note: Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计时器事件间的延迟(以毫秒为单位)。如果在计时器正在运行时设置延迟间隔,则计时器将按相同的 repeatCount 迭代重新启动。
    - * 注意:建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - delay: number; - /** - * The total number of times the timer is set to run. If the repeat count is set to 0, the timer continues indefinitely, - * until the stop() method is invoked or the program stops. If the repeat count is nonzero, the timer runs the specified - * number of times. If repeatCount is set to a total that is the same or less then currentCount the timer stops and will not fire again. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置的计时器运行总次数。如果重复计数设置为 0,则计时器将持续不断运行,或直至调用了 stop() 方法或节目停止。 - * 如果重复计数不为 0,则将运行计时器,运行次数为指定的次数。如果设置的 repeatCount 总数等于或小于 currentCount,则计时器将停止并且不会再次触发。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - repeatCount: number; - /** - * @private - */ - private _currentCount; - /** - * The total number of times the timer has fired since it started at zero. If the timer has been reset, only the fires since the reset are counted. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计时器从 0 开始后触发的总次数。如果已重置了计时器,则只会计入重置后的触发次数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly currentCount: number; - /** - * @private - */ - private _running; - /** - * The timer's current state; true if the timer is running, otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计时器的当前状态;如果计时器正在运行,则为 true,否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly running: boolean; - /** - * Stops the timer, if it is running, and sets the currentCount property back to 0, like the reset button of a stopwatch. - * Then, when start() is called, the timer instance runs for the specified number of repetitions, as set by the repeatCount value. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果计时器正在运行,则停止计时器,并将 currentCount 属性设回为 0,这类似于秒表的重置按钮。然后,在调用 start() 后,将运行计时器实例,运行次数为指定的重复次数(由 repeatCount 值设置)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - reset(): void; - /** - * Starts the timer, if it is not already running. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果计时器尚未运行,则启动计时器。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - start(): void; - /** - * Stops the timer. When start() is called after stop(), the timer instance runs for the remaining number of - * repetitions, as set by the repeatCount property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 停止计时器。如果在调用 stop() 后调用 start(),则将继续运行计时器实例,运行次数为剩余的 重复次数(由 repeatCount 属性设置)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stop(): void; - /** - * @private - */ - private updateInterval; - /** - * @private - */ - private lastCount; - /** - * @private - */ - private lastTimeStamp; - /** - * @private - * Ticker以60FPS频率刷新此方法 - */ - $update(timeStamp: number): boolean; - } -} -declare namespace egret { - /** - * The XMLNode class is the base class for all xml node. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * XML节点基类 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface XMLNode { - /** - * a integer representing the type of the node, 1:XML,2:XMLAttribute,3:XMLText - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 节点类型,1:XML,2:XMLAttribute,3:XMLText - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - nodeType: number; - /** - * the parent node of this xml node. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 节点所属的父级节点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - parent: XML; - } - /** - * The XML class contains properties for working with XML objects. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/XML.ts - * @language en_US - */ - /** - * XML 类包含用于处理 XML 对象的属性。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/XML.ts - * @language zh_CN - */ - interface XML extends XMLNode { - /** - * the attributes of this xml node. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前节点上的属性列表 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - attributes: any; - /** - * the children of the xml node. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前节点的子节点列表 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - children: XMLNode[]; - /** - * the full name of this xml node. For example,the name of is "s:Button". - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 节点完整名称。例如节点 的 name 为:"s:Button" - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - name: string; - /** - * thie namesapce prefix of this xml node.For example,the prefix of is "s". - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 节点的命名空间前缀。例如节点 的 prefix 为:s - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - prefix: string; - /** - * the local name of this xml node. For example,the local name of is "Button". - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 节点的本地名称。例如节点 的 localName 为:Button - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - localName: string; - /** - * the namesapce uri of this xml node.For example,the namespace uri of is "http://ns.egret.com/eui". - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 节点的命名空间地址。例如节点 的 namespace 为: http://ns.egret.com/eui - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - namespace: string; - } - /** - * The XMLText class represents a string node in the XML. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * XMLText 类表示在XML中的文本节点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface XMLText extends XMLNode { - /** - * the text content - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本内容 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - text: string; - } - /** - * The XML class contains properties for working with XML objects. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * XML 类包含用于处理 XML 对象的属性。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let XML: { - /** - * parses a text to XML instance. - * @param text the text to be parsed. - * @language en_US - */ - /** - * 解析字符串为XML对象 - * @param text 要解析的XML对象。 - * @language zh_CN - */ - parse(text: string): XML; - }; -} -declare namespace egret { - /** - * @private - */ - let $callLaterFunctionList: any[]; - /** - * @private - */ - let $callLaterThisList: any[]; - /** - * @private - */ - let $callLaterArgsList: any[]; - /** - * Delay the function to run unless screen is redrawn. - * @param method {Function} The function to be delayed to run - * @param thisObject {any} this reference of callback function - * @param ...args {any} Function parameter list - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/callLater.ts - * @language en_US - */ - /** - * 延迟函数到屏幕重绘前执行。 - * @param method {Function} 要延迟执行的函数 - * @param thisObject {any} 回调函数的this引用 - * @param ...args {any} 函数参数列表 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/callLater.ts - * @language zh_CN - */ - function callLater(method: Function, thisObject: any, ...args: any[]): void; - /** - * @private - */ - let $callAsyncFunctionList: any[]; - /** - * @private - */ - let $callAsyncThisList: any[]; - /** - * @private - */ - let $callAsyncArgsList: any[]; - /** - * 异步调用函数 - * @param method {Function} 要异步调用的函数 - * @param thisObject {any} 函数的this引用 - * @param ...args {any} 函数参数列表 - * @private - */ - function $callAsync(method: Function, thisObject: any, ...args: any[]): void; -} -declare namespace egret { - /** - * Call setter properties of the parent class, instead of the other writing languages, such as super.alpha = 1; - * @param currentClass The current class class name, non-string - * @param thisObj The current object. Always this - * @param type Setter property names need to call - * @param values Value passed to the parent class - * - * @exmaple egret.superSetter(egret.Sprite, this, "alpha", 1); - * @language en_US - */ - /** - * 调用父类的setter属性,代替其他语言的写法,如 super.alpha = 1; - * @param currentClass 当前 class 类名,非字符串 - * @param thisObj 当前对象。永远都this - * @param type 需要调用的setter属性名称 - * @param values 传给父类的值 - * - * @exmaple egret.superSetter(egret.Sprite, this, "alpha", 1); - * @language zh_CN - */ - function superSetter(currentClass: any, thisObj: any, type: string, ...values: any[]): any; - /** - * Get getter property value of the parent class. Instead of writing in other languages, such as super.alpha; - * @param currentClass The current class class name, non-string - * @param thisObj The current object. Always this - * @param type Setter property names need to call - * @returns {any} The value returned by the parent - * - * @exmaple egret.superGetter(egret.Sprite, this, "alpha"); - * @language en_US - */ - /** - * 获取父类的getter属性值。代替其他语言的写法,如 super.alpha; - * @param currentClass 当前 class 类名,非字符串 - * @param thisObj 当前对象。永远都this - * @param type 需要调用的getter属性名称 - * @returns {any} 父类返回的值 - * - * @exmaple egret.superGetter(egret.Sprite, this, "alpha"); - * @language zh_CN - */ - function superGetter(currentClass: any, thisObj: any, type: string): any; -} -declare namespace egret { - /** - * Returns a reference to the class object of the class specified by the name parameter. - * @param name The name of a class. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getDefinitionByName.ts - * @language en_US - */ - /** - * 返回 name 参数指定的类的类对象引用。 - * @param name 类的名称。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getDefinitionByName.ts - * @language zh_CN - */ - function getDefinitionByName(name: string): any; -} -declare namespace egret { - /** - * Get browser or Runtime parameters, returns an empty string if not set - * Get the url parameter corresponds to the browser, access to the corresponding parameter in the Runtime setOption - * @method egret.getOption - * @param key {string} Parameters key - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取浏览器或者Runtime参数,如果没有设置返回空字符串 - * 在浏览器中相当于获取url中参数,在Runtime获取对应setOption参数 - * @method egret.getOption - * @param key {string} 参数key - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let getOption: (key: string) => string; -} -declare namespace egret { - /** - * Return the fully qualified class name of an object - * @param value The object for which a fully qualified class name is desired. Any JavaScript value may be passed to - * this method including all available JavaScript types, object instances, primitive types such as number, and class objects. - * @returns A string containing the fully qualified class name. - * @example - *
    -     *  egret.getQualifiedClassName(egret.DisplayObject) //return "egret.DisplayObject"
    -     * 
    - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedClassName.ts - * @language en_US - */ - /** - * 返回对象的完全限定类名。 - * @param value 需要完全限定类名称的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型 - * (如number)和类对象 - * @returns 包含完全限定类名称的字符串。 - * @example - *
    -     *  egret.getQualifiedClassName(egret.DisplayObject) //返回 "egret.DisplayObject"
    -     * 
    - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedClassName.ts - * @language zh_CN - */ - function getQualifiedClassName(value: any): string; -} -declare namespace egret { - /** - * Returns the fully qualified class name of the base class of the object specified by the value parameter. - * @param value The object for which a parent class is desired. Any JavaScript value may be passed to this method including - * all available JavaScript types, object instances, primitive types such as number, and class objects. - * @returns A fully qualified base class name, or null if none exists. - * @example - *
    -     *  egret.getQualifiedSuperclassName(egret.Bitmap) //return "egret.DisplayObject"
    -     * 
    - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedSuperclassName.ts - * @language en_US - */ - /** - * 返回 value 参数指定的对象的基类的完全限定类名。 - * @param value 需要取得父类的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型(如number)和类对象 - * @returns 完全限定的基类名称,或 null(如果不存在基类名称)。 - * @example - *
    -     *  egret.getQualifiedSuperclassName(egret.Sprite) //返回 "egret.DisplayObject"
    -     * 
    - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedSuperclassName.ts - * @language zh_CN - */ - function getQualifiedSuperclassName(value: any): string; -} -declare namespace egret { - /** - * Used to compute relative time.this method returns the number of milliseconds since the Egret framework was initialized - * @returns The number of milliseconds since the Egret framework was initialized - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getTimer.ts - * @language en_US - */ - /** - * 用于计算相对时间。此方法返回自启动 Egret 框架以来经过的毫秒数。 - * @returns 启动 Egret 框架以来经过的毫秒数。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getTimer.ts - * @language zh_CN - */ - function getTimer(): number; -} -declare namespace egret { - /** - * Check whether a public definition exists in the specified application domain. The definition can be that of a class, a naming space or a function. - * @param name {string} Name of the definition. - * @returns {boolean} Whether the public definition exists - * @example - * egret.hasDefinition("egret.DisplayObject") //return true - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/hasDefinition.ts - * @language en_US - */ - /** - * 检查指定的应用程序域之内是否存在一个公共定义。该定义可以是一个类、一个命名空间或一个函数的定义。 - * @param name {string} 定义的名称。 - * @returns {boolean} 公共定义是否存在 - * @example - * egret.hasDefinition("egret.DisplayObject") //返回 true - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/hasDefinition.ts - * @language zh_CN - */ - function hasDefinition(name: string): boolean; -} -declare namespace egret { - /** - * Indicates whether an object is a instance of the class or interface specified as the parameter.This method has better performance - * compared width the instanceOf operator,and it can indicate whether an object is a instance of the specific interface. - * @param instance the instance to be checked. - * @param typeName the string value representing a specific class or interface. - * @returns A value of true if the object is a instance of the class or interface specified as the parameter. - * @example - *
    -     *     let instance = new egret.Sprite();
    -     *     egret.log(egret.is(instance,"egret.Sprite"))  //true
    -     *     egret.log(egret.is(instance,"egret.DisplayObjectContainer"))  //true
    -     *     egret.log(egret.is(instance,"egret.Bitmap"))  //false
    -     * 
    - * @see egret.registerClass() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查指定对象是否为 Egret 框架内指定接口或类或其子类的实例。此方法与使用 instanceOf 关键字相比具有更高的性能,并且能判断接口的实现。 - * @param instance 要判断的实例。 - * @param typeName 类或接口的完全名称. - * @returns 返回true表示当前对象是指定类或接口的实例。 - * @example - *
    -     *     let instance = new egret.Sprite();
    -     *     egret.log(egret.is(instance,"egret.Sprite"))  //true
    -     *     egret.log(egret.is(instance,"egret.DisplayObjectContainer"))  //true
    -     *     egret.log(egret.is(instance,"egret.Bitmap"))  //false
    -     * 
    - * @see egret.registerClass() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function is(instance: any, typeName: string): boolean; -} -declare namespace egret { - /** - * Register and start a timer,which will notify the callback method at a rate of 60 FPS ,and pass the current time stamp as parameters.
    - * Note: After the registration,it will notify the callback method continuously,you can call the stopTick () method to stop it. - * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds - * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime - * to render after processing of this method completes. - * @param thisObject the call back method's "this" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 注册并启动一个计时器,通常会以60FPS的速率触发回调方法,并传入当前时间戳。注意:注册后将会持续触发回调方法,若要停止回调,需要手动调用stopTick()方法。 - * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。 - * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。 - * @param thisObject 回调方法的this对象引用。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function startTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; -} -declare namespace egret { - /** - * Stops the timer started by the egret.startTick() method. - * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds - * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime - * to render after processing of this method completes. - * @param thisObject the call back method's "this" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 停止之前用 startTick() 方法启动的计时器。 - * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。 - * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。 - * @param thisObject 回调方法的this对象引用。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function stopTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; -} -declare namespace egret { - /** - * Transfer number to color character string - * @param value {number} color value ,such as 0xffffff - * @returns {string} Color character string, for example, #ffffff. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/toColorString.ts - * @language en_US - */ - /** - * 转换数字为颜色字符串 - * @param value {number} 颜色值,例如 0xffffff - * @returns {string} 颜色字符串,例如"#ffffff"。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/toColorString.ts - * @language zh_CN - */ - function toColorString(value: number): string; -} -declare namespace egret.sys { - /** - * @private - * 共享的用于碰撞检测的渲染缓冲 - */ - let customHitTestBuffer: sys.RenderBuffer; - /** - * @private - * 共享的用于canvas碰撞检测的渲染缓冲 - */ - let canvasHitTestBuffer: sys.RenderBuffer; - /** - * @private - * 渲染缓冲 - */ - interface RenderBuffer { - /** - * 呈现最终绘图结果的画布。 - * @readOnly - */ - surface: any; - /** - * 渲染上下文。 - * @readOnly - */ - context: any; - /** - * 渲染缓冲的宽度,以像素为单位。 - * @readOnly - */ - width: number; - /** - * 渲染缓冲的高度,以像素为单位。 - * @readOnly - */ - height: number; - /** - * 改变渲染缓冲的大小并清空缓冲区 - * @param width 改变后的宽 - * @param height 改变后的高 - * @param useMaxSize 若传入true,则将改变后的尺寸与已有尺寸对比,保留较大的尺寸。 - */ - resize(width: number, height: number, useMaxSize?: boolean): void; - /** - * 获取指定区域的像素 - */ - getPixels(x: number, y: number, width?: number, height?: number): number[]; - /** - * 转换成base64字符串,如果图片(或者包含的图片)跨域,则返回null - * @param type 转换的类型,如: "image/png","image/jpeg" - */ - toDataURL(type?: string, ...args: any[]): string; - /** - * 清空缓冲区数据 - */ - clear(): void; - /** - * 销毁渲染缓冲 - */ - destroy(): void; - } - /** - * @private - */ - let RenderBuffer: { - /** - * 创建一个RenderTarget。 - * 注意:若内存不足或创建缓冲区失败,将会抛出错误异常。 - * @param width 渲染缓冲的初始宽 - * @param height 渲染缓冲的初始高 - * @param root 是否为舞台buffer - */ - new (width?: number, height?: number, root?: boolean): RenderBuffer; - }; - /** - * @private - */ - let CanvasRenderBuffer: { - /** - * 创建一个CanvasRenderBuffer。 - * 注意:若内存不足或创建缓冲区失败,将会抛出错误异常。 - * @param width 渲染缓冲的初始宽 - * @param height 渲染缓冲的初始高 - */ - new (width?: number, height?: number): RenderBuffer; - }; -} diff --git a/helloworld/libs/modules/egret/egret.js b/helloworld/libs/modules/egret/egret.js deleted file mode 100644 index f30a780..0000000 --- a/helloworld/libs/modules/egret/egret.js +++ /dev/null @@ -1,24957 +0,0 @@ -var __reflect = (this && this.__reflect) || function (p, c, t) { - p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; -}; -var __extends = this && this.__extends || function __extends(t, e) { - function r() { - this.constructor = t; -} -for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]); -r.prototype = e.prototype, t.prototype = new r(); -}; -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/// -if (typeof global == 'undefined') { - var global = window; -} -if (typeof __global == 'undefined') { - var __global = global; -} -var __define = this && this.__define || function (o, p, g, s) { Object.defineProperty(o, p, { configurable: true, enumerable: true, get: g, set: s }); }; -var egret; -(function (egret) { - /** - * @private - * 哈希计数 - */ - egret.$hashCount = 1; - /** - * The HashObject class is the base class for all objects in the Egret framework.The HashObject - * class includes a hashCode property, which is a unique identification number of the instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Egret顶级对象。框架内所有对象的基类,为对象实例提供唯一的hashCode值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var HashObject = (function () { - /** - * Initializes a HashObject - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 HashObject 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function HashObject() { - this.$hashCode = egret.$hashCount++; - } - Object.defineProperty(HashObject.prototype, "hashCode", { - /** - * a unique identification number assigned to this instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回此对象唯一的哈希值,用于唯一确定一个对象。hashCode为大于等于1的整数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$hashCode; - }, - enumerable: true, - configurable: true - }); - return HashObject; - }()); - egret.HashObject = HashObject; - __reflect(HashObject.prototype, "egret.HashObject", ["egret.IHashObject"]); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var ONCE_EVENT_LIST = []; - /** - * The EventDispatcher class is the base class for all classes that dispatchEvent events. The EventDispatcher class implements - * the IEventDispatcher interface and is the base class for the DisplayObject class. The EventDispatcher class allows - * any object on the display list to be an event target and as such, to use the methods of the IEventDispatcher interface. - * Event targets are an important part of the Egret event model. The event target serves as the focal point for how events - * flow through the display list hierarchy. When an event such as a touch tap, Egret dispatches an event object into the - * event flow from the root of the display list. The event object then makes its way through the display list until it - * reaches the event target, at which point it begins its return trip through the display list. This round-trip journey - * to the event target is conceptually divided into three phases:
    - * the capture phase comprises the journey from the root to the last node before the event target's node, the target - * phase comprises only the event target node, and the bubbling phase comprises any subsequent nodes encountered on - * the return trip to the root of the display list. In general, the easiest way for a user-defined class to gain event - * dispatching capabilities is to extend EventDispatcher. If this is impossible (that is, if the class is already extending - * another class), you can instead implement the IEventDispatcher interface, create an EventDispatcher member, and write simple - * hooks to route calls into the aggregated EventDispatcher. - * @see egret.IEventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventDispatcher.ts - * @language en_US - */ - /** - * EventDispatcher 是 Egret 的事件派发器类,负责进行事件的发送和侦听。 - * 事件目标是事件如何通过显示列表层次结构这一问题的焦点。当发生鼠标单击、触摸或按键等事件时, - * 框架会将事件对象调度到从显示列表根开始的事件流中。然后该事件对象在显示列表中前进,直到到达事件目标, - * 然后从这一点开始其在显示列表中的回程。在概念上,到事件目标的此往返行程被划分为三个阶段: - * 捕获阶段包括从根到事件目标节点之前的最后一个节点的行程,目标阶段仅包括事件目标节点,冒泡阶段包括回程上遇到的任何后续节点到显示列表的根。 - * 通常,使用户定义的类能够调度事件的最简单方法是扩展 EventDispatcher。如果无法扩展(即,如果该类已经扩展了另一个类),则可以实现 - * IEventDispatcher 接口,创建 EventDispatcher 成员,并编写一些简单的映射,将调用连接到聚合的 EventDispatcher 中。 - * @see egret.IEventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventDispatcher.ts - * @language zh_CN - */ - var EventDispatcher = (function (_super) { - __extends(EventDispatcher, _super); - /** - * create an instance of the EventDispatcher class. - * @param target The target object for events dispatched to the EventDispatcher object. This parameter is used when - * the EventDispatcher instance is aggregated by a class that implements IEventDispatcher; it is necessary so that the - * containing object can be the target for events. Do not use this parameter in simple cases in which a class extends EventDispatcher. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 EventDispatcher 类的实例 - * @param target 此 EventDispatcher 所抛出事件对象的 target 指向。此参数主要用于一个实现了 IEventDispatcher 接口的自定义类, - * 以便抛出的事件对象的 target 属性可以指向自定义类自身。请勿在直接继承 EventDispatcher 的情况下使用此参数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function EventDispatcher(target) { - if (target === void 0) { target = null; } - var _this = _super.call(this) || this; - _this.$EventDispatcher = { - 0: target ? target : _this, - 1: {}, - 2: {}, - 3: 0 - }; - return _this; - } - /** - * @private - * - * @param useCapture - */ - EventDispatcher.prototype.$getEventMap = function (useCapture) { - var values = this.$EventDispatcher; - var eventMap = useCapture ? values[2 /* captureEventsMap */] : values[1 /* eventsMap */]; - return eventMap; - }; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - EventDispatcher.prototype.addEventListener = function (type, listener, thisObject, useCapture, priority) { - this.$addListener(type, listener, thisObject, useCapture, priority); - }; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - EventDispatcher.prototype.once = function (type, listener, thisObject, useCapture, priority) { - this.$addListener(type, listener, thisObject, useCapture, priority, true); - }; - /** - * @private - */ - EventDispatcher.prototype.$addListener = function (type, listener, thisObject, useCapture, priority, dispatchOnce) { - if (true && !listener) { - egret.$error(1003, "listener"); - } - var values = this.$EventDispatcher; - var eventMap = useCapture ? values[2 /* captureEventsMap */] : values[1 /* eventsMap */]; - var list = eventMap[type]; - if (!list) { - list = eventMap[type] = []; - } - else if (values[3 /* notifyLevel */] !== 0) { - eventMap[type] = list = list.concat(); - } - this.$insertEventBin(list, type, listener, thisObject, useCapture, priority, dispatchOnce); - }; - EventDispatcher.prototype.$insertEventBin = function (list, type, listener, thisObject, useCapture, priority, dispatchOnce) { - priority = +priority | 0; - var insertIndex = -1; - var length = list.length; - for (var i = 0; i < length; i++) { - var bin = list[i]; - if (bin.listener == listener && bin.thisObject == thisObject && bin.target == this) { - return false; - } - if (insertIndex == -1 && bin.priority < priority) { - insertIndex = i; - } - } - var eventBin = { - type: type, listener: listener, thisObject: thisObject, priority: priority, - target: this, useCapture: useCapture, dispatchOnce: !!dispatchOnce - }; - if (insertIndex !== -1) { - list.splice(insertIndex, 0, eventBin); - } - else { - list.push(eventBin); - } - return true; - }; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - EventDispatcher.prototype.removeEventListener = function (type, listener, thisObject, useCapture) { - var values = this.$EventDispatcher; - var eventMap = useCapture ? values[2 /* captureEventsMap */] : values[1 /* eventsMap */]; - var list = eventMap[type]; - if (!list) { - return; - } - if (values[3 /* notifyLevel */] !== 0) { - eventMap[type] = list = list.concat(); - } - this.$removeEventBin(list, listener, thisObject); - if (list.length == 0) { - eventMap[type] = null; - } - }; - EventDispatcher.prototype.$removeEventBin = function (list, listener, thisObject) { - var length = list.length; - for (var i = 0; i < length; i++) { - var bin = list[i]; - if (bin.listener == listener && bin.thisObject == thisObject && bin.target == this) { - list.splice(i, 1); - return true; - } - } - return false; - }; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - EventDispatcher.prototype.hasEventListener = function (type) { - var values = this.$EventDispatcher; - return !!(values[1 /* eventsMap */][type] || values[2 /* captureEventsMap */][type]); - }; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - EventDispatcher.prototype.willTrigger = function (type) { - return this.hasEventListener(type); - }; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - EventDispatcher.prototype.dispatchEvent = function (event) { - event.$currentTarget = this.$EventDispatcher[0 /* eventTarget */]; - event.$setTarget(event.$currentTarget); - return this.$notifyListener(event, false); - }; - /** - * @private - */ - EventDispatcher.prototype.$notifyListener = function (event, capturePhase) { - var values = this.$EventDispatcher; - var eventMap = capturePhase ? values[2 /* captureEventsMap */] : values[1 /* eventsMap */]; - var list = eventMap[event.$type]; - if (!list) { - return true; - } - var length = list.length; - if (length == 0) { - return true; - } - var onceList = ONCE_EVENT_LIST; - //做个标记,防止外部修改原始数组导致遍历错误。这里不直接调用list.concat()因为dispatch()方法调用通常比on()等方法频繁。 - values[3 /* notifyLevel */]++; - for (var i = 0; i < length; i++) { - var eventBin = list[i]; - eventBin.listener.call(eventBin.thisObject, event); - if (eventBin.dispatchOnce) { - onceList.push(eventBin); - } - if (event.$isPropagationImmediateStopped) { - break; - } - } - values[3 /* notifyLevel */]--; - while (onceList.length) { - var eventBin = onceList.pop(); - eventBin.target.removeEventListener(eventBin.type, eventBin.listener, eventBin.thisObject, eventBin.useCapture); - } - return !event.$isDefaultPrevented; - }; - /** - * Distribute a specified event parameters. - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param data {any} data - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 派发一个指定参数的事件。 - * @param type {string} 事件类型 - * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param data {any} 事件data - * @param cancelable {boolean} 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - EventDispatcher.prototype.dispatchEventWith = function (type, bubbles, data, cancelable) { - if (bubbles || this.hasEventListener(type)) { - var event_1 = egret.Event.create(egret.Event, type, bubbles, cancelable); - event_1.data = data; - var result = this.dispatchEvent(event_1); - egret.Event.release(event_1); - return result; - } - return true; - }; - return EventDispatcher; - }(egret.HashObject)); - egret.EventDispatcher = EventDispatcher; - __reflect(EventDispatcher.prototype, "egret.EventDispatcher", ["egret.IEventDispatcher"]); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - var Filter = (function (_super) { - __extends(Filter, _super); - function Filter() { - var _this = _super.call(this) || this; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - _this.type = null; - /** - * @private - */ - _this.$id = null; - /** - * @private - */ - _this.paddingTop = 0; - /** - * @private - */ - _this.paddingBottom = 0; - /** - * @private - */ - _this.paddingLeft = 0; - /** - * @private - */ - _this.paddingRight = 0; - _this.$uniforms = {}; - if (egret.nativeRender) { - egret_native.NativeDisplayObject.createFilter(_this); - } - return _this; - } - /** - * @private - */ - Filter.prototype.$toJson = function () { - return ''; - }; - Filter.prototype.updatePadding = function () { - }; - Filter.prototype.onPropertyChange = function () { - var self = this; - self.updatePadding(); - if (egret.nativeRender) { - egret_native.NativeDisplayObject.setFilterPadding(self.$id, self.paddingTop, self.paddingBottom, self.paddingLeft, self.paddingRight); - egret_native.NativeDisplayObject.setDataToFilter(self); - } - }; - return Filter; - }(egret.HashObject)); - egret.Filter = Filter; - __reflect(Filter.prototype, "egret.Filter"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - ; - /** - * @private - * 格式化旋转角度的值 - */ - function clampRotation(value) { - value %= 360; - if (value > 180) { - value -= 360; - } - else if (value < -180) { - value += 360; - } - return value; - } - /** - * The DisplayObject class is the base class for all objects that can be placed on the display list. The display list - * manages all objects displayed in the runtime. Use the DisplayObjectContainer class to arrange the display - * objects in the display list. DisplayObjectContainer objects can have child display objects, while other display objects, - * such as Shape and TextField objects, are "leaf" nodes that have only parents and siblings, no children. - * The DisplayObject class supports basic functionality like the x and y position of an object, as well as more advanced - * properties of the object such as its transformation matrix.
    - * The DisplayObject class contains several broadcast events.Normally, the target of any particular event is a specific - * DisplayObject instance. For example, the target of an added event is the specific DisplayObject instance that was added - * to the display list. Having a single target restricts the placement of event listeners to that target and in some cases - * the target's ancestors on the display list. With broadcast events, however, the target is not a specific DisplayObject - * instance, but rather all DisplayObject instances, including those that are not on the display list. This means that you - * can add a listener to any DisplayObject instance to listen for broadcast events. - * - * @event egret.Event.ADDED Dispatched when a display object is added to the display list. - * @event egret.Event.ADDED_TO_STAGE Dispatched when a display object is added to the on stage display list, either directly or through the addition of a sub tree in which the display object is contained. - * @event egret.Event.REMOVED Dispatched when a display object is about to be removed from the display list. - * @event egret.Event.REMOVED_FROM_STAGE Dispatched when a display object is about to be removed from the display list, either directly or through the removal of a sub tree in which the display object is contained. - * @event egret.Event.ENTER_FRAME [broadcast event] Dispatched when the playhead is entering a new frame. - * @event egret.Event.RENDER [broadcast event] Dispatched when the display list is about to be updated and rendered. - * @event egret.TouchEvent.TOUCH_MOVE Dispatched when the user touches the device, and is continuously dispatched until the point of contact is removed. - * @event egret.TouchEvent.TOUCH_BEGIN Dispatched when the user first contacts a touch-enabled device (such as touches a finger to a mobile phone or tablet with a touch screen). - * @event egret.TouchEvent.TOUCH_END Dispatched when the user removes contact with a touch-enabled device (such as lifts a finger off a mobile phone or tablet with a touch screen). - * @event egret.TouchEvent.TOUCH_TAP Dispatched when the user lifts the point of contact over the same DisplayObject instance on which the contact was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display object on a mobile phone or tablet with a touch screen). - * @event egret.TouchEvent.TOUCH_RELEASE_OUTSIDE Dispatched when the user lifts the point of contact over the different DisplayObject instance on which the contact was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display object on a mobile phone or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObject.ts - * @language en_US - */ - /** - * DisplayObject 类是可放在显示列表中的所有对象的基类。该显示列表管理运行时中显示的所有对象。使用 DisplayObjectContainer 类排列 - * 显示列表中的显示对象。DisplayObjectContainer 对象可以有子显示对象,而其他显示对象(如 Shape 和 TextField 对象)是“叶”节点,没有子项,只有父级和 - * 同级。DisplayObject 类有一些基本的属性(如确定坐标位置的 x 和 y 属性),也有一些高级的对象属性(如 Matrix 矩阵变换)。
    - * DisplayObject 类包含若干广播事件。通常,任何特定事件的目标均为一个特定的 DisplayObject 实例。例如,added 事件的目标是已添加到显示列表 - * 的目标 DisplayObject 实例。若只有一个目标,则会将事件侦听器限制为只能监听在该目标上(在某些情况下,可监听在显示列表中该目标的祖代上)。 - * 但是对于广播事件,目标不是特定的 DisplayObject 实例,而是所有 DisplayObject 实例(包括那些不在显示列表中的实例)。这意味着您可以向任何 - * DisplayObject 实例添加侦听器来侦听广播事件。 - * - * @event egret.Event.ADDED 将显示对象添加到显示列表中时调度。 - * @event egret.Event.ADDED_TO_STAGE 在将显示对象直接添加到舞台显示列表或将包含显示对象的子树添加至舞台显示列表中时调度。 - * @event egret.Event.REMOVED 将要从显示列表中删除显示对象时调度。 - * @event egret.Event.REMOVED_FROM_STAGE 在从显示列表中直接删除显示对象或删除包含显示对象的子树时调度。 - * @event egret.Event.ENTER_FRAME [广播事件] 播放头进入新帧时调度。 - * @event egret.Event.RENDER [广播事件] 将要更新和呈现显示列表时调度。 - * @event egret.TouchEvent.TOUCH_MOVE 当用户触碰设备时进行调度,而且会连续调度,直到接触点被删除。 - * @event egret.TouchEvent.TOUCH_BEGIN 当用户第一次触摸启用触摸的设备时(例如,用手指触摸手机屏幕)调度。 - * @event egret.TouchEvent.TOUCH_END 当用户移除与启用触摸的设备的接触时(例如,将手指从屏幕上抬起)调度。 - * @event egret.TouchEvent.TOUCH_TAP 当用户在启用触摸设备上的已启动接触的同一 DisplayObject 实例上抬起接触点时(例如,手机点击屏幕后抬起)调度。 - * @event egret.TouchEvent.TOUCH_RELEASE_OUTSIDE 当用户在启用触摸设备上的已启动接触的不同 DisplayObject 实例上抬起接触点时(例如,按住屏幕上的某个对象,然后从它上面挪开后再松开手指)调度。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObject.ts - * @language zh_CN - */ - var DisplayObject = (function (_super) { - __extends(DisplayObject, _super); - /** - * Initializes a DisplayObject object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个显示对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function DisplayObject() { - var _this = _super.call(this) || this; - /** - * @private - * 能够含有子项的类将子项列表存储在这个属性里。 - */ - _this.$children = null; - _this.$name = ""; - /** - * @private - */ - _this.$parent = null; - /** - * @private - */ - _this.$stage = null; - /** - * @private - * 这个对象在显示列表中的嵌套深度,舞台为1,它的子项为2,子项的子项为3,以此类推。当对象不在显示列表中时此属性值为0. - */ - _this.$nestLevel = 0; - _this.$useTranslate = false; - _this.$matrix = new egret.Matrix(); - _this.$matrixDirty = false; - _this.$x = 0; - _this.$y = 0; - _this.$scaleX = 1; - _this.$scaleY = 1; - _this.$rotation = 0; - _this.$skewX = 0; - _this.$skewXdeg = 0; - _this.$skewY = 0; - _this.$skewYdeg = 0; - _this.$explicitWidth = NaN; - _this.$explicitHeight = NaN; - _this.$anchorOffsetX = 0; - _this.$anchorOffsetY = 0; - /** - * @private - */ - _this.$visible = true; - /** - * @private - * cacheAsBitmap创建的缓存位图节点。 - */ - _this.$displayList = null; - _this.$cacheAsBitmap = false; - _this.$cacheDirty = false; - /** - * @private - */ - _this.$alpha = 1; - _this.$touchEnabled = DisplayObject.defaultTouchEnabled; - /** - * @private - */ - _this.$scrollRect = null; - /** - * @private - */ - _this.$blendMode = 0; - /** - * @private - * 被遮罩的对象 - */ - _this.$maskedObject = null; - /** - * @private - */ - _this.$mask = null; - /** - * @private - */ - _this.$maskRect = null; - /** - * @private - */ - _this.$parentDisplayList = null; - /** - * @private - * 渲染节点,不为空表示自身有绘制到屏幕的内容 - */ - _this.$renderNode = null; - _this.$renderDirty = false; - _this.$renderMode = null; - if (egret.nativeRender) { - _this.createNativeDisplayObject(); - } - return _this; - } - DisplayObject.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(0 /* CONTAINER */); - }; - Object.defineProperty(DisplayObject.prototype, "name", { - /** - * Indicates the instance name of the DisplayObject. The object can be identified in the child list of its parent - * display object container by calling the getChildByName() method of the display object container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 的实例名称。 - * 通过调用父显示对象容器的 getChildByName() 方法,可以在父显示对象容器的子列表中标识该对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$name; - }, - set: function (value) { - this.$name = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "parent", { - /** - * Indicates the DisplayObjectContainer object that contains this display object. Use the parent property to specify - * a relative path to display objects that are above the current display object in the display list hierarchy. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示包含此显示对象的 DisplayObjectContainer 对象。 - * 使用 parent 属性可以指定高于显示列表层次结构中当前显示对象的显示对象的相对路径。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$parent; - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 设置父级显示对象 - */ - DisplayObject.prototype.$setParent = function (parent) { - this.$parent = parent; - }; - /** - * @private - * 显示对象添加到舞台 - */ - DisplayObject.prototype.$onAddToStage = function (stage, nestLevel) { - var self = this; - self.$stage = stage; - self.$nestLevel = nestLevel; - self.$hasAddToStage = true; - egret.Sprite.$EVENT_ADD_TO_STAGE_LIST.push(self); - }; - /** - * @private - * 显示对象从舞台移除 - */ - DisplayObject.prototype.$onRemoveFromStage = function () { - var self = this; - self.$nestLevel = 0; - egret.Sprite.$EVENT_REMOVE_FROM_STAGE_LIST.push(self); - }; - DisplayObject.prototype.$updateUseTransform = function () { - var self = this; - if (self.$scaleX == 1 && self.$scaleY == 1 && self.$skewX == 0 && self.$skewY == 0) { - self.$useTranslate = false; - } - else { - self.$useTranslate = true; - } - }; - Object.defineProperty(DisplayObject.prototype, "stage", { - /** - * The Stage of the display object. you can create and load multiple display objects into the display list, and - * the stage property of each display object refers to the same Stage object.
    - * If a display object is not added to the display list, its stage property is set to null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 显示对象的舞台。 - * 例如,您可以创建多个显示对象并加载到显示列表中,每个显示对象的 stage 属性是指向相同的 Stage 对象。
    - * 如果显示对象未添加到显示列表,则其 stage 属性会设置为 null。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$stage; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "matrix", { - /** - * A Matrix object containing values that alter the scaling, rotation, and translation of the display object.
    - * Note: to change the value of a display object's matrix, you must make a copy of the entire matrix object, then copy - * the new object into the matrix property of the display object. - * @example the following code increases the tx value of a display object's matrix - *
    -             *     let myMatrix:Matrix = myDisplayObject.matrix;
    -             *     myMatrix.tx += 10;
    -             *     myDisplayObject.matrix = myMatrix;
    -             * 
    - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个 Matrix 对象,其中包含更改显示对象的缩放、旋转和平移的值。
    - * 注意:要改变一个显示对象矩阵的值,您必引用整个矩阵对象,然后将它重新赋值给显示对象的 matrix 属性。 - * @example 以下代码改变了显示对象矩阵的tx属性值: - *
    -             *     let myMatrix:Matrix = myDisplayObject.matrix;
    -             *     myMatrix.tx += 10;
    -             *     myDisplayObject.matrix = myMatrix;
    -             * 
    - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getMatrix().clone(); - }, - set: function (value) { - this.$setMatrix(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 获取矩阵 - */ - DisplayObject.prototype.$getMatrix = function () { - var self = this; - if (self.$matrixDirty) { - self.$matrixDirty = false; - self.$matrix.$updateScaleAndRotation(self.$scaleX, self.$scaleY, self.$skewX, self.$skewY); - } - self.$matrix.tx = self.$x; - self.$matrix.ty = self.$y; - return self.$matrix; - }; - /** - * @private - * 设置矩阵 - */ - DisplayObject.prototype.$setMatrix = function (matrix, needUpdateProperties) { - if (needUpdateProperties === void 0) { needUpdateProperties = true; } - var self = this; - var m = self.$matrix; - m.a = matrix.a; - m.b = matrix.b; - m.c = matrix.c; - m.d = matrix.d; - self.$x = matrix.tx; - self.$y = matrix.ty; - self.$matrixDirty = false; - if (m.a == 1 && m.b == 0 && m.c == 0 && m.d == 1) { - self.$useTranslate = false; - } - else { - self.$useTranslate = true; - } - if (needUpdateProperties) { - self.$scaleX = m.$getScaleX(); - self.$scaleY = m.$getScaleY(); - self.$skewX = matrix.$getSkewX(); - self.$skewY = matrix.$getSkewY(); - self.$skewXdeg = clampRotation(self.$skewX * 180 / Math.PI); - self.$skewYdeg = clampRotation(self.$skewY * 180 / Math.PI); - self.$rotation = clampRotation(self.$skewY * 180 / Math.PI); - } - if (egret.nativeRender) { - self.$nativeDisplayObject.setMatrix(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty); - } - }; - /** - * @private - * 获得这个显示对象以及它所有父级对象的连接矩阵。 - */ - DisplayObject.prototype.$getConcatenatedMatrix = function () { - var self = this; - var matrix = self.$concatenatedMatrix; - if (!matrix) { - matrix = self.$concatenatedMatrix = new egret.Matrix(); - } - if (self.$parent) { - self.$parent.$getConcatenatedMatrix().$preMultiplyInto(self.$getMatrix(), matrix); - } - else { - matrix.copyFrom(self.$getMatrix()); - } - var offsetX = self.$anchorOffsetX; - var offsetY = self.$anchorOffsetY; - var rect = self.$scrollRect; - if (rect) { - matrix.$preMultiplyInto(egret.$TempMatrix.setTo(1, 0, 0, 1, -rect.x - offsetX, -rect.y - offsetY), matrix); - } - else if (offsetX != 0 || offsetY != 0) { - matrix.$preMultiplyInto(egret.$TempMatrix.setTo(1, 0, 0, 1, -offsetX, -offsetY), matrix); - } - return self.$concatenatedMatrix; - }; - /** - * @private - * 获取链接矩阵 - */ - DisplayObject.prototype.$getInvertedConcatenatedMatrix = function () { - var self = this; - if (!self.$invertedConcatenatedMatrix) { - self.$invertedConcatenatedMatrix = new egret.Matrix(); - } - self.$getConcatenatedMatrix().$invertInto(self.$invertedConcatenatedMatrix); - return self.$invertedConcatenatedMatrix; - }; - Object.defineProperty(DisplayObject.prototype, "x", { - /** - * Indicates the x coordinate of the DisplayObject instance relative to the local coordinates of the parent - * DisplayObjectContainer.
    - * If the object is inside a DisplayObjectContainer that has transformations, it is in - * the local coordinate system of the enclosing DisplayObjectContainer. Thus, for a DisplayObjectContainer - * rotated 90° counterclockwise, the DisplayObjectContainer's children inherit a coordinate system that is - * rotated 90° counterclockwise. The object's coordinates refer to the registration point position. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 实例相对于父级 DisplayObjectContainer 本地坐标的 x 坐标。
    - * 如果该对象位于具有变形的 DisplayObjectContainer 内,则它也位于包含 DisplayObjectContainer 的本地坐标系中。 - * 因此,对于逆时针旋转 90 度的 DisplayObjectContainer,该 DisplayObjectContainer 的子级将继承逆时针旋转 90 度的坐标系。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getX(); - }, - set: function (value) { - this.$setX(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 获取x坐标 - */ - DisplayObject.prototype.$getX = function () { - return this.$x; - }; - /** - * @private - * 设置x坐标 - */ - DisplayObject.prototype.$setX = function (value) { - var self = this; - if (self.$x == value) { - return false; - } - self.$x = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setX(value); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - return true; - }; - Object.defineProperty(DisplayObject.prototype, "y", { - /** - * Indicates the y coordinate of the DisplayObject instance relative to the local coordinates of the parent - * DisplayObjectContainer.
    - * If the object is inside a DisplayObjectContainer that has transformations, it is in - * the local coordinate system of the enclosing DisplayObjectContainer. Thus, for a DisplayObjectContainer rotated - * 90° counterclockwise, the DisplayObjectContainer's children inherit a coordinate system that is rotated 90° - * counterclockwise. The object's coordinates refer to the registration point position. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 实例相对于父级 DisplayObjectContainer 本地坐标的 y 坐标。
    - * 如果该对象位于具有变形的 DisplayObjectContainer 内,则它也位于包含 DisplayObjectContainer 的本地坐标系中。 - * 因此,对于逆时针旋转 90 度的 DisplayObjectContainer,该 DisplayObjectContainer 的子级将继承逆时针旋转 90 度的坐标系。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getY(); - }, - set: function (value) { - this.$setY(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 获取y坐标 - */ - DisplayObject.prototype.$getY = function () { - return this.$y; - }; - /** - * @private - * 设置y坐标 - */ - DisplayObject.prototype.$setY = function (value) { - var self = this; - if (self.$y == value) { - return false; - } - self.$y = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setY(value); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - return true; - }; - Object.defineProperty(DisplayObject.prototype, "scaleX", { - /** - * Indicates the horizontal scale (percentage) of the object as applied from the registration point.
    - * The default 1.0 equals 100% scale. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从注册点开始应用的对象的水平缩放比例(百分比)。
    - * 1.0 等于 100% 缩放。 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getScaleX(); - }, - set: function (value) { - this.$setScaleX(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @returns - */ - DisplayObject.prototype.$getScaleX = function () { - return this.$scaleX; - }; - /** - * @private - * 设置水平缩放值 - */ - DisplayObject.prototype.$setScaleX = function (value) { - var self = this; - self.$scaleX = value; - self.$matrixDirty = true; - self.$updateUseTransform(); - if (egret.nativeRender) { - self.$nativeDisplayObject.setScaleX(value); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(DisplayObject.prototype, "scaleY", { - /** - * Indicates the vertical scale (percentage) of an object as applied from the registration point of the object. - * 1.0 is 100% scale. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从对象注册点开始应用的对象的垂直缩放比例(百分比)。1.0 是 100% 缩放。 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getScaleY(); - }, - set: function (value) { - this.$setScaleY(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @returns - */ - DisplayObject.prototype.$getScaleY = function () { - return this.$scaleY; - }; - /** - * @private - * 设置垂直缩放值 - */ - DisplayObject.prototype.$setScaleY = function (value) { - var self = this; - self.$scaleY = value; - self.$matrixDirty = true; - self.$updateUseTransform(); - if (egret.nativeRender) { - self.$nativeDisplayObject.setScaleY(value); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(DisplayObject.prototype, "rotation", { - /** - * Indicates the rotation of the DisplayObject instance, in degrees, from its original orientation. Values from - * 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values outside - * this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement - * myDisplayObject.rotation = 450 is the same as myDisplayObject.rotation = 90. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 实例距其原始方向的旋转程度,以度为单位。 - * 从 0 到 180 的值表示顺时针方向旋转;从 0 到 -180 的值表示逆时针方向旋转。对于此范围之外的值,可以通过加上或 - * 减去 360 获得该范围内的值。例如,myDisplayObject.rotation = 450语句与 myDisplayObject.rotation = 90 是相同的。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getRotation(); - }, - set: function (value) { - this.$setRotation(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - DisplayObject.prototype.$getRotation = function () { - return this.$rotation; - }; - DisplayObject.prototype.$setRotation = function (value) { - value = clampRotation(value); - var self = this; - if (value == self.$rotation) { - return; - } - var delta = value - self.$rotation; - var angle = delta / 180 * Math.PI; - self.$skewX += angle; - self.$skewY += angle; - self.$rotation = value; - self.$matrixDirty = true; - self.$updateUseTransform(); - if (egret.nativeRender) { - self.$nativeDisplayObject.setRotation(value); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(DisplayObject.prototype, "skewX", { - /** - * 表示DisplayObject的x方向斜切 - * @member {number} egret.DisplayObject#skewX - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$skewXdeg; - }, - set: function (value) { - this.$setSkewX(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - DisplayObject.prototype.$setSkewX = function (value) { - var self = this; - if (value == self.$skewXdeg) { - return; - } - self.$skewXdeg = value; - value = clampRotation(value); - value = value / 180 * Math.PI; - self.$skewX = value; - self.$matrixDirty = true; - self.$updateUseTransform(); - if (egret.nativeRender) { - self.$nativeDisplayObject.setSkewX(self.$skewXdeg); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(DisplayObject.prototype, "skewY", { - /** - * 表示DisplayObject的y方向斜切 - * @member {number} egret.DisplayObject#skewY - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$skewYdeg; - }, - set: function (value) { - this.$setSkewY(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - DisplayObject.prototype.$setSkewY = function (value) { - var self = this; - if (value == self.$skewYdeg) { - return; - } - self.$skewYdeg = value; - value = clampRotation(value); - value = value / 180 * Math.PI; - self.$skewY = value; - self.$matrixDirty = true; - self.$updateUseTransform(); - if (egret.nativeRender) { - self.$nativeDisplayObject.setSkewY(self.$skewYdeg); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(DisplayObject.prototype, "width", { - /** - * Indicates the width of the display object, in pixels. The width is calculated based on the bounds of the content - * of the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示显示对象的宽度,以像素为单位。宽度是根据显示对象内容的范围来计算的。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getWidth(); - }, - set: function (value) { - this.$setWidth(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 获取显示宽度 - */ - DisplayObject.prototype.$getWidth = function () { - var self = this; - return isNaN(self.$explicitWidth) ? self.$getOriginalBounds().width : self.$explicitWidth; - }; - /** - * @private - * 设置显示宽度 - */ - DisplayObject.prototype.$setWidth = function (value) { - this.$explicitWidth = isNaN(value) ? NaN : value; - }; - Object.defineProperty(DisplayObject.prototype, "height", { - /** - * Indicates the height of the display object, in pixels. The height is calculated based on the bounds of the - * content of the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示显示对象的高度,以像素为单位。高度是根据显示对象内容的范围来计算的。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getHeight(); - }, - set: function (value) { - this.$setHeight(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 获取显示高度 - */ - DisplayObject.prototype.$getHeight = function () { - var self = this; - return isNaN(self.$explicitHeight) ? self.$getOriginalBounds().height : self.$explicitHeight; - }; - /** - * @private - * 设置显示高度 - */ - DisplayObject.prototype.$setHeight = function (value) { - this.$explicitHeight = isNaN(value) ? NaN : value; - }; - Object.defineProperty(DisplayObject.prototype, "measuredWidth", { - /** - * 测量宽度 - * @returns {number} - * @member {egret.Rectangle} egret.DisplayObject#measuredWidth - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$getOriginalBounds().width; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "measuredHeight", { - /** - * 测量高度 - * @returns {number} - * @member {egret.Rectangle} egret.DisplayObject#measuredWidth - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$getOriginalBounds().height; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "anchorOffsetX", { - /** - * X represents the object of which is the anchor. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从对象绝对锚点X。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$anchorOffsetX; - }, - set: function (value) { - this.$setAnchorOffsetX(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - * @returns - */ - DisplayObject.prototype.$setAnchorOffsetX = function (value) { - var self = this; - self.$anchorOffsetX = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setAnchorOffsetX(value); - } - }; - Object.defineProperty(DisplayObject.prototype, "anchorOffsetY", { - /** - * Y represents the object of which is the anchor. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从对象绝对锚点Y。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$anchorOffsetY; - }, - set: function (value) { - this.$setAnchorOffsetY(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - * @returns - */ - DisplayObject.prototype.$setAnchorOffsetY = function (value) { - var self = this; - self.$anchorOffsetY = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setAnchorOffsetY(value); - } - }; - Object.defineProperty(DisplayObject.prototype, "visible", { - /** - * Whether or not the display object is visible. Display objects that are not visible are disabled. For example, - * if visible=false for an DisplayObject instance, it cannot receive touch or other user input. - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 显示对象是否可见。不可见的显示对象将被禁用。例如,如果实例的 visible 为 false,则无法接受触摸或用户交互操作。 - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$visible; - }, - set: function (value) { - this.$setVisible(value); - }, - enumerable: true, - configurable: true - }); - DisplayObject.prototype.$setVisible = function (value) { - var self = this; - self.$visible = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setVisible(value); - } - else { - self.$updateRenderMode(); - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(DisplayObject.prototype, "cacheAsBitmap", { - /** - * If set to true, Egret runtime caches an internal bitmap representation of the display object. This caching can - * increase performance for display objects that contain complex vector content. After you set the cacheAsBitmap - * property to true, the rendering does not change, however the display object performs pixel snapping automatically. - * The execution speed can be significantly faster depending on the complexity of the content.The cacheAsBitmap - * property is best used with display objects that have mostly static content and that do not scale and rotate frequently.
    - * Note: The display object will not create the bitmap caching when the memory exceeds the upper limit,even if you set it to true. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果设置为 true,则 Egret 运行时将缓存显示对象的内部位图表示形式。此缓存可以提高包含复杂矢量内容的显示对象的性能。 - * 将 cacheAsBitmap 属性设置为 true 后,呈现并不更改,但是,显示对象将自动执行像素贴紧。执行速度可能会大大加快, - * 具体取决于显示对象内容的复杂性。最好将 cacheAsBitmap 属性与主要具有静态内容且不频繁缩放或旋转的显示对象一起使用。
    - * 注意:在内存超过上限的情况下,即使将 cacheAsBitmap 属性设置为 true,显示对象也不使用位图缓存。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$cacheAsBitmap; - }, - set: function (value) { - var self = this; - self.$cacheAsBitmap = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setCacheAsBitmap(value); - } - else { - self.$setHasDisplayList(value); - } - }, - enumerable: true, - configurable: true - }); - DisplayObject.prototype.$setHasDisplayList = function (value) { - var self = this; - var hasDisplayList = !!self.$displayList; - if (hasDisplayList == value) { - return; - } - if (value) { - var displayList = egret.sys.DisplayList.create(self); - if (displayList) { - self.$displayList = displayList; - self.$cacheDirty = true; - } - } - else { - self.$displayList = null; - } - }; - DisplayObject.prototype.$cacheDirtyUp = function () { - var p = this.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - }; - Object.defineProperty(DisplayObject.prototype, "alpha", { - /** - * Indicates the alpha transparency value of the object specified. Valid values are 0 (fully transparent) to 1 (fully opaque). - * The default value is 1. Display objects with alpha set to 0 are active, even though they are invisible. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示指定对象的 Alpha 透明度值。 - * 有效值为 0(完全透明)到 1(完全不透明)。alpha 设置为 0 的显示对象是可触摸的,即使它们不可见。 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$alpha; - }, - set: function (value) { - this.$setAlpha(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - DisplayObject.prototype.$setAlpha = function (value) { - var self = this; - self.$alpha = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setAlpha(value); - } - else { - self.$updateRenderMode(); - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(DisplayObject.prototype, "touchEnabled", { - /** - * Specifies whether this object receives touch or other user input. The default value is false, which means that - * by default any DisplayObject instance that is on the display list cannot receive touch events. If touchEnabled is - * set to false, the instance does not receive any touch events (or other user input events). Any children of - * this instance on the display list are not affected. To change the touchEnabled behavior for all children of - * an object on the display list, use DisplayObjectContainer.touchChildren. - * @see egret.DisplayObjectContainer#touchChildren - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定此对象是否接收触摸或其他用户输入。默认值为 false,这表示默认情况下,显示列表上的任何 DisplayObject 实例都不会接收触摸事件或 - * 其他用户输入事件。如果将 touchEnabled 设置为 false,则实例将不接收任何触摸事件(或其他用户输入事件)。显示列表上的该实例的任 - * 何子级都不会受到影响。要更改显示列表上对象的所有子级的 touchEnabled 行为,请使用 DisplayObjectContainer.touchChildren。 - * @see egret.DisplayObjectContainer#touchChildren - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getTouchEnabled(); - }, - set: function (value) { - this.$setTouchEnabled(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - DisplayObject.prototype.$getTouchEnabled = function () { - return this.$touchEnabled; - }; - /** - * @private - */ - DisplayObject.prototype.$setTouchEnabled = function (value) { - this.$touchEnabled = value; - }; - Object.defineProperty(DisplayObject.prototype, "scrollRect", { - /** - * The scroll rectangle bounds of the display object. The display object is cropped to the size defined by the rectangle, - * and it scrolls within the rectangle when you change the x and y properties of the scrollRect object. A scrolled display - * object always scrolls in whole pixel increments.You can scroll an object left and right by setting the x property of - * the scrollRect Rectangle object. You can scroll an object up and down by setting the y property of the scrollRect - * Rectangle object. If the display object is rotated 90° and you scroll it left and right, the display object actually - * scrolls up and down.
    - * - * Note: to change the value of a display object's scrollRect, you must make a copy of the entire scrollRect object, then copy - * the new object into the scrollRect property of the display object. - * @example the following code increases the x value of a display object's scrollRect - *
    -             *     let myRectangle:Rectangle = myDisplayObject.scrollRect;
    -             *     myRectangle.x += 10;
    -             *     myDisplayObject.scrollRect = myRectangle;
    -             * 
    - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 显示对象的滚动矩形范围。显示对象被裁切为矩形定义的大小,当您更改 scrollRect 对象的 x 和 y 属性时,它会在矩形内滚动。 - * 滚动的显示对象始终以整像素为增量进行滚动。您可以通过设置 scrollRect Rectangle 对象的 x 属性来左右滚动对象, 还可以通过设置 - * scrollRect 对象的 y 属性来上下滚动对象。如果显示对象旋转了 90 度,并且您左右滚动它,则实际上显示对象会上下滚动。
    - * - * 注意:要改变一个显示对象 scrollRect 属性的值,您必引用整个 scrollRect 对象,然后将它重新赋值给显示对象的 scrollRect 属性。 - * @example 以下代码改变了显示对象 scrollRect 的 x 属性值: - *
    -             *     let myRectangle:Rectangle = myDisplayObject.scrollRect;
    -             *     myRectangle.x += 10;
    -             *     myDisplayObject.scrollRect = myRectangle;//设置完scrollRect的x、y、width、height值之后,一定要对myDisplayObject重新赋值scrollRect,不然会出问题。
    -             * 
    - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$scrollRect; - }, - set: function (value) { - this.$setScrollRect(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - DisplayObject.prototype.$setScrollRect = function (value) { - var self = this; - if (!value && !self.$scrollRect) { - self.$updateRenderMode(); - return; - } - if (value) { - if (!self.$scrollRect) { - self.$scrollRect = new egret.Rectangle(); - } - self.$scrollRect.copyFrom(value); - if (egret.nativeRender) { - self.$nativeDisplayObject.setScrollRect(value.x, value.y, value.width, value.height); - } - } - else { - self.$scrollRect = null; - if (egret.nativeRender) { - self.$nativeDisplayObject.setScrollRect(0, 0, 0, 0); - } - } - if (!egret.nativeRender) { - self.$updateRenderMode(); - } - }; - Object.defineProperty(DisplayObject.prototype, "blendMode", { - /** - * A value from the BlendMode class that specifies which blend mode to use. Determine how a source image (new one) - * is drawn on the target image (old one).
    - * If you attempt to set this property to an invalid value, Egret runtime set the value to BlendMode.NORMAL. - * @default egret.BlendMode.NORMAL - * @see egret.BlendMode - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * BlendMode 枚举中的一个值,用于指定要使用的混合模式,确定如何将一个源(新的)图像绘制到目标(已有)的图像上
    - * 如果尝试将此属性设置为无效值,则运行时会将此值设置为 BlendMode.NORMAL。 - * @default egret.BlendMode.NORMAL - * @see egret.BlendMode - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return egret.sys.numberToBlendMode(this.$blendMode); - }, - set: function (value) { - var self = this; - var mode = egret.sys.blendModeToNumber(value); - self.$blendMode = mode; - if (egret.nativeRender) { - self.$nativeDisplayObject.setBlendMode(mode); - } - else { - self.$updateRenderMode(); - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "mask", { - /** - * The calling display object is masked by the specified mask object. To ensure that masking works when the Stage - * is scaled, the mask display object must be in an active part of the display list. The mask object itself is not drawn. - * Set mask to null to remove the mask. To be able to scale a mask object, it must be on the display list. To be - * able to drag a mask object , it must be on the display list.
    - * Note: A single mask object cannot be used to mask more than one calling display object. When the mask is assigned - * to a second display object, it is removed as the mask of the first object, and that object's mask property becomes null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 调用显示对象被指定的 mask 对象遮罩。要确保当舞台缩放时蒙版仍然有效,mask 显示对象必须处于显示列表的活动部分。 - * 但不绘制 mask 对象本身。将 mask 设置为 null 可删除蒙版。要能够缩放遮罩对象,它必须在显示列表中。要能够拖动蒙版 - * 对象,它必须在显示列表中。
    - * 注意:单个 mask 对象不能用于遮罩多个执行调用的显示对象。在将 mask 分配给第二个显示对象时,会撤消其作为第一个对象的遮罩, - * 该对象的 mask 属性将变为 null。 - * - * 下面例子为 mask 为 Rectangle 类型对象,这种情况下,修改 mask 的值后,一定要对 myDisplayObject 重新赋值 mask,不然会出问题。 - * @example 以下代码改变了显示对象 mask 的 x 属性值: - *
    -             *     let myMask:Rectangle = myDisplayObject.mask;
    -             *     myMask.x += 10;
    -             *     myDisplayObject.mask = myMask;//设置完 mask 的x、y、width、height值之后,一定要对myDisplayObject重新赋值 mask,不然会出问题。
    -             * 
    - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - var self = this; - return self.$mask ? self.$mask : self.$maskRect; - }, - set: function (value) { - var self = this; - if (value === self) { - return; - } - if (value) { - if (value instanceof DisplayObject) { - if (value == self.$mask) { - return; - } - if (value.$maskedObject) { - value.$maskedObject.mask = null; - } - value.$maskedObject = self; - self.$mask = value; - if (!egret.nativeRender) { - value.$updateRenderMode(); - } - if (self.$maskRect) { - if (egret.nativeRender) { - self.$nativeDisplayObject.setMaskRect(0, 0, 0, 0); - } - self.$maskRect = null; - } - if (egret.nativeRender) { - self.$nativeDisplayObject.setMask(value.$nativeDisplayObject.id); - } - } - else { - if (!self.$maskRect) { - self.$maskRect = new egret.Rectangle(); - } - self.$maskRect.copyFrom(value); - if (egret.nativeRender) { - self.$nativeDisplayObject.setMaskRect(value.x, value.y, value.width, value.height); - } - if (self.$mask) { - self.$mask.$maskedObject = null; - if (!egret.nativeRender) { - self.$mask.$updateRenderMode(); - } - } - if (self.mask) { - if (egret.nativeRender) { - self.$nativeDisplayObject.setMask(-1); - } - self.$mask = null; - } - } - } - else { - if (self.$mask) { - self.$mask.$maskedObject = null; - if (!egret.nativeRender) { - self.$mask.$updateRenderMode(); - } - } - if (self.mask) { - if (egret.nativeRender) { - self.$nativeDisplayObject.setMask(-1); - } - self.$mask = null; - } - if (self.$maskRect) { - if (egret.nativeRender) { - self.$nativeDisplayObject.setMaskRect(0, 0, 0, 0); - } - self.$maskRect = null; - } - } - if (!egret.nativeRender) { - self.$updateRenderMode(); - } - }, - enumerable: true, - configurable: true - }); - DisplayObject.prototype.$setMaskRect = function (value) { - var self = this; - if (!value && !self.$maskRect) { - return; - } - if (value) { - if (!self.$maskRect) { - self.$maskRect = new egret.Rectangle(); - } - self.$maskRect.copyFrom(value); - } - else { - self.$maskRect = null; - } - }; - Object.defineProperty(DisplayObject.prototype, "filters", { - /** - * An indexed array that contains each filter object currently associated with the display object. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 包含当前与显示对象关联的每个滤镜对象的索引数组。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$filters; - }, - set: function (value) { - var self = this; - var filters = self.$filters; - if (!filters && !value) { - self.$filters = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setFilters(null); - } - else { - self.$updateRenderMode(); - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - return; - } - if (value && value.length) { - value = value.concat(); - self.$filters = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setFilters(value); - } - } - else { - self.$filters = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setFilters(null); - } - } - if (!egret.nativeRender) { - self.$updateRenderMode(); - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }, - enumerable: true, - configurable: true - }); - /** - * Returns a rectangle that defines the area of the display object relative to the coordinate system of the targetCoordinateSpace object. - * @param targetCoordinateSpace The display object that defines the coordinate system to use. - * @param resultRect A reusable instance of Rectangle for saving the results. Passing this parameter can reduce the number of reallocate objects - *, which allows you to get better code execution performance.. - * @returns The rectangle that defines the area of the display object relative to the targetCoordinateSpace object's coordinate system. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回一个矩形,该矩形定义相对于 targetCoordinateSpace 对象坐标系的显示对象区域。 - * @param targetCoordinateSpace 定义要使用的坐标系的显示对象。 - * @param resultRect 一个用于存储结果的可复用Rectangle实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。 - * @returns 定义与 targetCoordinateSpace 对象坐标系统相关的显示对象面积的矩形。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObject.prototype.getTransformedBounds = function (targetCoordinateSpace, resultRect) { - targetCoordinateSpace = targetCoordinateSpace || this; - return this.$getTransformedBounds(targetCoordinateSpace, resultRect); - }; - /** - * Obtain measurement boundary of display object - * @param resultRect {Rectangle} Optional. It is used to import Rectangle object for saving results, preventing duplicate object creation. - * @param calculateAnchor {boolean} Optional. It is used to determine whether to calculate anchor point. - * @returns {Rectangle} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取显示对象的测量边界 - * @param resultRect {Rectangle} 可选参数,传入用于保存结果的Rectangle对象,避免重复创建对象。 - * @param calculateAnchor {boolean} 可选参数,是否会计算锚点。 - * @returns {Rectangle} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObject.prototype.getBounds = function (resultRect, calculateAnchor) { - if (calculateAnchor === void 0) { calculateAnchor = true; } - var self = this; - resultRect = self.$getTransformedBounds(self, resultRect); - if (calculateAnchor) { - if (self.$anchorOffsetX != 0) { - resultRect.x -= self.$anchorOffsetX; - } - if (self.$anchorOffsetY != 0) { - resultRect.y -= self.$anchorOffsetY; - } - } - return resultRect; - }; - /** - * @private - */ - DisplayObject.prototype.$getTransformedBounds = function (targetCoordinateSpace, resultRect) { - var self = this; - var bounds = self.$getOriginalBounds(); - if (!resultRect) { - resultRect = new egret.Rectangle(); - } - resultRect.copyFrom(bounds); - if (targetCoordinateSpace == self) { - return resultRect; - } - var m; - if (targetCoordinateSpace) { - m = egret.$TempMatrix; - var invertedTargetMatrix = targetCoordinateSpace.$getInvertedConcatenatedMatrix(); - invertedTargetMatrix.$preMultiplyInto(self.$getConcatenatedMatrix(), m); - } - else { - m = self.$getConcatenatedMatrix(); - } - m.$transformBounds(resultRect); - return resultRect; - }; - /** - * Converts the point object from the Stage (global) coordinates to the display object's (local) coordinates. - * @param stageX the x value in the global coordinates - * @param stageY the y value in the global coordinates - * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the - * number of reallocate objects, which allows you to get better code execution performance. - * @returns A Point object with coordinates relative to the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将从舞台(全局)坐标转换为显示对象的(本地)坐标。 - * @param stageX 舞台坐标x - * @param stageY 舞台坐标y - * @param resultPoint 一个用于存储结果的可复用 Point 实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。 - * @returns 具有相对于显示对象的坐标的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObject.prototype.globalToLocal = function (stageX, stageY, resultPoint) { - if (stageX === void 0) { stageX = 0; } - if (stageY === void 0) { stageY = 0; } - if (egret.nativeRender) { - egret_native.updateNativeRender(); - var result = egret_native.nrGlobalToLocal(this.$nativeDisplayObject.id, stageX, stageY); - var arr = result.split(","); - var x = parseFloat(arr[0]); - var y = parseFloat(arr[1]); - if (resultPoint) { - resultPoint.setTo(x, y); - } - else { - resultPoint = new egret.Point(x, y); - } - return resultPoint; - } - else { - var m = this.$getInvertedConcatenatedMatrix(); - return m.transformPoint(stageX, stageY, resultPoint); - } - }; - /** - * Converts the point object from the display object's (local) coordinates to the Stage (global) coordinates. - * @param localX the x value in the local coordinates - * @param localY the x value in the local coordinates - * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the - * number of reallocate objects, which allows you to get better code execution performance. - * @returns A Point object with coordinates relative to the Stage. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将显示对象的(本地)坐标转换为舞台(全局)坐标。 - * @param localX 本地坐标 x - * @param localY 本地坐标 y - * @param resultPoint 一个用于存储结果的可复用 Point 实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。 - * @returns 一个具有相对于舞台坐标的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObject.prototype.localToGlobal = function (localX, localY, resultPoint) { - if (localX === void 0) { localX = 0; } - if (localY === void 0) { localY = 0; } - if (egret.nativeRender) { - egret_native.updateNativeRender(); - var result = egret_native.nrLocalToGlobal(this.$nativeDisplayObject.id, localX, localY); - var arr = result.split(","); - var x = parseFloat(arr[0]); - var y = parseFloat(arr[1]); - if (resultPoint) { - resultPoint.setTo(x, y); - } - else { - resultPoint = new egret.Point(x, y); - } - return resultPoint; - } - else { - var m = this.$getConcatenatedMatrix(); - return m.transformPoint(localX, localY, resultPoint); - } - }; - /** - * @private - * 获取显示对象占用的矩形区域集合,通常包括自身绘制的测量区域,如果是容器,还包括所有子项占据的区域。 - */ - DisplayObject.prototype.$getOriginalBounds = function () { - var self = this; - var bounds = self.$getContentBounds(); - self.$measureChildBounds(bounds); - var offset = self.$measureFiltersOffset(false); - if (offset) { - bounds.x += offset.minX; - bounds.y += offset.minY; - bounds.width += -offset.minX + offset.maxX; - bounds.height += -offset.minY + offset.maxY; - } - return bounds; - }; - /** - * @private - * 测量子项占用的矩形区域 - * @param bounds 测量结果存储在这个矩形对象内 - */ - DisplayObject.prototype.$measureChildBounds = function (bounds) { - }; - /** - * @private - */ - DisplayObject.prototype.$getContentBounds = function () { - var bounds = egret.$TempRectangle; - bounds.setEmpty(); - this.$measureContentBounds(bounds); - return bounds; - }; - /** - * @private - * 测量自身占用的矩形区域,注意:此测量结果并不包括子项占据的区域。 - * @param bounds 测量结果存储在这个矩形对象内 - */ - DisplayObject.prototype.$measureContentBounds = function (bounds) { - }; - /** - * @private - * 获取渲染节点 - */ - DisplayObject.prototype.$getRenderNode = function () { - var self = this; - var node = self.$renderNode; - if (!node) { - return null; - } - if (self.$renderDirty) { - node.cleanBeforeRender(); - self.$updateRenderNode(); - self.$renderDirty = false; - node = self.$renderNode; - } - return node; - }; - DisplayObject.prototype.$updateRenderMode = function () { - var self = this; - if (!self.$visible || self.$alpha <= 0 || self.$maskedObject) { - self.$renderMode = 1 /* NONE */; - } - else if (self.filters && self.filters.length > 0) { - self.$renderMode = 2 /* FILTER */; - } - else if (self.$blendMode !== 0 || (self.$mask && self.$mask.$stage)) { - self.$renderMode = 3 /* CLIP */; - } - else if (self.$scrollRect || self.$maskRect) { - self.$renderMode = 4 /* SCROLLRECT */; - } - else { - self.$renderMode = null; - } - }; - /** - * @private - */ - DisplayObject.prototype.$measureFiltersOffset = function (fromParent) { - var display = this; - var minX = 0; - var minY = 0; - var maxX = 0; - var maxY = 0; - while (display) { - var filters = display.$filters; - if (filters && filters.length) { - var length_1 = filters.length; - for (var i = 0; i < length_1; i++) { - var filter = filters[i]; - //todo 缓存这个数据 - if (filter.type == "blur") { - var offsetX = filter.blurX; - var offsetY = filter.blurY; - minX -= offsetX; - minY -= offsetY; - maxX += offsetX; - maxY += offsetY; - } - else if (filter.type == "glow") { - var offsetX = filter.blurX; - var offsetY = filter.blurY; - minX -= offsetX; - minY -= offsetY; - maxX += offsetX; - maxY += offsetY; - var distance = filter.distance || 0; - var angle = filter.angle || 0; - var distanceX = 0; - var distanceY = 0; - if (distance != 0) { - distanceX = distance * egret.NumberUtils.cos(angle); - if (distanceX > 0) { - distanceX = Math.ceil(distanceX); - } - else { - distanceX = Math.floor(distanceX); - } - distanceY = distance * egret.NumberUtils.sin(angle); - if (distanceY > 0) { - distanceY = Math.ceil(distanceY); - } - else { - distanceY = Math.floor(distanceY); - } - minX += distanceX; - maxX += distanceX; - minY += distanceY; - maxY += distanceY; - } - } - else if (filter.type == "custom") { - var padding = filter.padding; - minX -= padding; - minY -= padding; - maxX += padding; - maxY += padding; - } - } - } - if (fromParent) { - display = display.$parent; - } - else { - display = null; - } - } - minX = Math.min(minX, 0); - minY = Math.min(minY, 0); - maxX = Math.max(maxX, 0); - maxY = Math.max(maxY, 0); - return { minX: minX, minY: minY, maxX: maxX, maxY: maxY }; - }; - /** - * @private - * 获取相对于指定根节点的连接矩阵。 - * @param root 根节点显示对象 - * @param matrix 目标显示对象相对于舞台的完整连接矩阵。 - */ - DisplayObject.prototype.$getConcatenatedMatrixAt = function (root, matrix) { - var invertMatrix = root.$getInvertedConcatenatedMatrix(); - if (invertMatrix.a === 0 || invertMatrix.d === 0) { - var target = this; - var rootLevel = root.$nestLevel; - matrix.identity(); - while (target.$nestLevel > rootLevel) { - var rect = target.$scrollRect; - if (rect) { - matrix.concat(egret.$TempMatrix.setTo(1, 0, 0, 1, -rect.x, -rect.y)); - } - matrix.concat(target.$getMatrix()); - target = target.$parent; - } - } - else { - invertMatrix.$preMultiplyInto(matrix, matrix); - } - }; - /** - * @private - * 更新renderNode - */ - DisplayObject.prototype.$updateRenderNode = function () { - }; - /** - * @private - */ - DisplayObject.prototype.$hitTest = function (stageX, stageY) { - var self = this; - if (!self.$renderNode || !self.$visible || self.$scaleX == 0 || self.$scaleY == 0) { - return null; - } - var m = self.$getInvertedConcatenatedMatrix(); - if (m.a == 0 && m.b == 0 && m.c == 0 && m.d == 0) { - return null; - } - var bounds = self.$getContentBounds(); - var localX = m.a * stageX + m.c * stageY + m.tx; - var localY = m.b * stageX + m.d * stageY + m.ty; - if (bounds.contains(localX, localY)) { - if (!self.$children) { - var rect = self.$scrollRect ? self.$scrollRect : self.$maskRect; - if (rect && !rect.contains(localX, localY)) { - return null; - } - if (self.$mask && !self.$mask.$hitTest(stageX, stageY)) { - return null; - } - } - return self; - } - return null; - }; - /** - * Calculate the display object to determine whether it overlaps or crosses with the points specified by the x and y parameters. The x and y parameters specify the points in the coordinates of the stage, rather than the points in the display object container that contains display objects (except the situation where the display object container is a stage). - * Note: Don't use accurate pixel collision detection on a large number of objects. Otherwise, this will cause serious performance deterioration. - * @param x {number} x coordinate of the object to be tested. - * @param y {number} y coordinate of the object to be tested. - * @param shapeFlag {boolean} Whether to check the actual pixel of object (true) or check that of border (false).Write realized. - * @returns {boolean} If display object overlaps or crosses with the specified point, it is true; otherwise, it is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计算显示对象,以确定它是否与 x 和 y 参数指定的点重叠或相交。x 和 y 参数指定舞台的坐标空间中的点,而不是包含显示对象的显示对象容器中的点(除非显示对象容器是舞台)。 - * 注意,不要在大量物体中使用精确碰撞像素检测,这回带来巨大的性能开销 - * @param x {number} 要测试的此对象的 x 坐标。 - * @param y {number} 要测试的此对象的 y 坐标。 - * @param shapeFlag {boolean} 是检查对象 (true) 的实际像素,还是检查边框 (false) 的实际像素。 - * @returns {boolean} 如果显示对象与指定的点重叠或相交,则为 true;否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObject.prototype.hitTestPoint = function (x, y, shapeFlag) { - var self = this; - if (!shapeFlag) { - if (self.$scaleX == 0 || self.$scaleY == 0) { - return false; - } - var m = self.$getInvertedConcatenatedMatrix(); - var bounds = self.getBounds(null, false); - var localX = m.a * x + m.c * y + m.tx; - var localY = m.b * x + m.d * y + m.ty; - if (bounds.contains(localX, localY)) { - //这里不考虑设置mask的情况 - var rect = self.$scrollRect ? self.$scrollRect : self.$maskRect; - if (rect && !rect.contains(localX, localY)) { - return false; - } - return true; - } - return false; - } - else { - var m = self.$getInvertedConcatenatedMatrix(); - var localX = m.a * x + m.c * y + m.tx; - var localY = m.b * x + m.d * y + m.ty; - var data = void 0; - if (egret.nativeRender) { - var buffer = egret.sys.customHitTestBuffer; - buffer.resize(3, 3); - egret_native.forHitTest = true; - egret_native.activateBuffer(buffer); - egret_native.updateNativeRender(); - egret_native.nrRenderDisplayObject2(self.$nativeDisplayObject.id, 1 - localX, 1 - localY, true); - try { - data = new Uint8Array(4); - egret_native.nrGetPixels(1, 1, 1, 1, data); - } - catch (e) { - throw new Error(egret.sys.tr(1039)); - } - egret_native.activateBuffer(null); - egret_native.forHitTest = false; - if (data[3] === 0) { - return false; - } - return true; - } - else { - var displayList = self.$displayList; - if (displayList) { - var buffer = displayList.renderBuffer; - try { - data = buffer.getPixels(localX - displayList.offsetX, localY - displayList.offsetY); - } - catch (e) { - throw new Error(egret.sys.tr(1039)); - } - } - else { - var buffer = egret.sys.customHitTestBuffer; - buffer.resize(3, 3); - var matrix = egret.Matrix.create(); - matrix.identity(); - matrix.translate(1 - localX, 1 - localY); - egret.sys.systemRenderer.render(this, buffer, matrix, true); - egret.Matrix.release(matrix); - try { - data = buffer.getPixels(1, 1); - } - catch (e) { - throw new Error(egret.sys.tr(1039)); - } - } - if (data[3] === 0) { - return false; - } - return true; - } - } - }; - /** - * @private - */ - DisplayObject.prototype.$addListener = function (type, listener, thisObject, useCapture, priority, dispatchOnce) { - _super.prototype.$addListener.call(this, type, listener, thisObject, useCapture, priority, dispatchOnce); - var isEnterFrame = (type == egret.Event.ENTER_FRAME); - if (isEnterFrame || type == egret.Event.RENDER) { - var list = isEnterFrame ? DisplayObject.$enterFrameCallBackList : DisplayObject.$renderCallBackList; - if (list.indexOf(this) == -1) { - list.push(this); - } - } - }; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - DisplayObject.prototype.removeEventListener = function (type, listener, thisObject, useCapture) { - _super.prototype.removeEventListener.call(this, type, listener, thisObject, useCapture); - var isEnterFrame = (type == egret.Event.ENTER_FRAME); - if ((isEnterFrame || type == egret.Event.RENDER) && !this.hasEventListener(type)) { - var list = isEnterFrame ? DisplayObject.$enterFrameCallBackList : DisplayObject.$renderCallBackList; - var index = list.indexOf(this); - if (index !== -1) { - list.splice(index, 1); - } - } - }; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - DisplayObject.prototype.dispatchEvent = function (event) { - if (!event.$bubbles) { - return _super.prototype.dispatchEvent.call(this, event); - } - var list = this.$getPropagationList(this); - var targetIndex = list.length * 0.5; - event.$setTarget(this); - this.$dispatchPropagationEvent(event, list, targetIndex); - return !event.$isDefaultPrevented; - }; - /** - * @private - * 获取事件流列表。注意:Egret框架的事件流与Flash实现并不一致。 - * - * 事件流有三个阶段:捕获,目标,冒泡。 - * Flash里默认的的事件监听若不开启useCapture将监听目标和冒泡阶段。若开始capture将只能监听捕获当不包括目标的事件。 - * 可以在Flash中写一个简单的测试:实例化一个非容器显示对象,例如TextField。分别监听useCapture为true和false时的鼠标事件。 - * 点击后将只有useCapture为false的回调函数输出信息。也就带来一个问题「Flash的捕获阶段不能监听到最内层对象本身,只在父级列表有效」。 - * - * 而HTML里的事件流设置useCapture为true时是能监听到目标阶段的,也就是目标阶段会被触发两次,在捕获和冒泡过程各触发一次。这样可以避免 - * 前面提到的监听捕获无法监听目标本身的问题。 - * - * Egret最终采用了HTML里目标节点触发两次的事件流方式。 - */ - DisplayObject.prototype.$getPropagationList = function (target) { - var list = []; - while (target) { - list.push(target); - target = target.$parent; - } - var captureList = list.concat(); - captureList.reverse(); //使用一次reverse()方法比多次调用unshift()性能高。 - list = captureList.concat(list); - return list; - }; - /** - * @private - */ - DisplayObject.prototype.$dispatchPropagationEvent = function (event, list, targetIndex) { - var length = list.length; - var captureIndex = targetIndex - 1; - for (var i = 0; i < length; i++) { - var currentTarget = list[i]; - event.$currentTarget = currentTarget; - if (i < captureIndex) - event.$eventPhase = 1 /* CAPTURING_PHASE */; - else if (i == targetIndex || i == captureIndex) - event.$eventPhase = 2 /* AT_TARGET */; - else - event.$eventPhase = 3 /* BUBBLING_PHASE */; - currentTarget.$notifyListener(event, i < targetIndex); - if (event.$isPropagationStopped || event.$isPropagationImmediateStopped) { - return; - } - } - }; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - DisplayObject.prototype.willTrigger = function (type) { - var parent = this; - while (parent) { - if (parent.hasEventListener(type)) - return true; - parent = parent.$parent; - } - return false; - }; - /** - * @private - * The default touchEnabled property of DisplayObject - * @default false - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * @private - * 显示对象默认的 touchEnabled 属性 - * @default false - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - DisplayObject.defaultTouchEnabled = false; - /** - * @private - */ - DisplayObject.$enterFrameCallBackList = []; - /** - * @private - */ - DisplayObject.$renderCallBackList = []; - return DisplayObject; - }(egret.EventDispatcher)); - egret.DisplayObject = DisplayObject; - __reflect(DisplayObject.prototype, "egret.DisplayObject"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - egret.$TextureScaleFactor = 1; - /** - * The Texture class encapsulates different image resources on different platforms. - * In HTML5, resource is an HTMLElement object - * In OpenGL / WebGL, resource is a texture ID obtained after the GPU is submitted - * The Texture class encapsulates the details implemented on the underlayer. Developers just need to focus on interfaces - * @see http://edn.egret.com/cn/docs/page/135 The use of texture packs - * @see http://edn.egret.com/cn/docs/page/123 Several ways of access to resources - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Texture.ts - * @language en_US - */ - /** - * 纹理类是对不同平台不同的图片资源的封装 - * 在HTML5中,资源是一个HTMLElement对象 - * 在OpenGL / WebGL中,资源是一个提交GPU后获取的纹理id - * Texture类封装了这些底层实现的细节,开发者只需要关心接口即可 - * @see http://edn.egret.com/cn/docs/page/135 纹理集的使用 - * @see http://edn.egret.com/cn/docs/page/123 获取资源的几种方式 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Texture.ts - * @language zh_CN - */ - var Texture = (function (_super) { - __extends(Texture, _super); - /** - * Create an egret.Texture object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.Texture 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Texture() { - var _this = _super.call(this) || this; - /** - * Whether to destroy the corresponding BitmapData when the texture is destroyed - * @version Egret 5.0.8 - * @platform Web,Native - * @language en_US - */ - /** - * 销毁纹理时是否销毁对应BitmapData - * @version Egret 5.0.8 - * @platform Web,Native - * @language zh_CN - */ - _this.disposeBitmapData = true; - /** - * @private - * 表示这个纹理在 bitmapData 上的 x 起始位置 - */ - _this.$bitmapX = 0; - /** - * @private - * 表示这个纹理在 bitmapData 上的 y 起始位置 - */ - _this.$bitmapY = 0; - /** - * @private - * 表示这个纹理在 bitmapData 上的宽度 - */ - _this.$bitmapWidth = 0; - /** - * @private - * 表示这个纹理在 bitmapData 上的高度 - */ - _this.$bitmapHeight = 0; - /** - * @private - * 表示这个纹理显示了之后在 x 方向的渲染偏移量 - */ - _this.$offsetX = 0; - /** - * @private - * 表示这个纹理显示了之后在 y 方向的渲染偏移量 - */ - _this.$offsetY = 0; - /** - * @private - * 纹理宽度 - */ - _this.$textureWidth = 0; - /** - * @private - * 纹理高度 - */ - _this.$textureHeight = 0; - /** - * @private - * 表示bitmapData.width - */ - _this.$sourceWidth = 0; - /** - * @private - * 表示bitmapData.height - */ - _this.$sourceHeight = 0; - /** - * @private - */ - _this.$bitmapData = null; - /** - * @private - */ - _this.$rotated = false; - return _this; - } - Object.defineProperty(Texture.prototype, "textureWidth", { - /** - * Texture width, read only - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 纹理宽度,只读属性,不可以设置 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getTextureWidth(); - }, - enumerable: true, - configurable: true - }); - Texture.prototype.$getTextureWidth = function () { - return this.$textureWidth; - }; - Object.defineProperty(Texture.prototype, "textureHeight", { - /** - * Texture height, read only - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 纹理高度,只读属性,不可以设置 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getTextureHeight(); - }, - enumerable: true, - configurable: true - }); - Texture.prototype.$getTextureHeight = function () { - return this.$textureHeight; - }; - Texture.prototype.$getScaleBitmapWidth = function () { - return this.$bitmapWidth * egret.$TextureScaleFactor; - }; - Texture.prototype.$getScaleBitmapHeight = function () { - return this.$bitmapHeight * egret.$TextureScaleFactor; - }; - Object.defineProperty(Texture.prototype, "bitmapData", { - /** - * The BitmapData object being referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的 BitmapData 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$bitmapData; - }, - set: function (value) { - this._setBitmapData(value); - }, - enumerable: true, - configurable: true - }); - /** - * Set the BitmapData object. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 设置 BitmapData 对象。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - Texture.prototype._setBitmapData = function (value) { - this.$bitmapData = value; - var scale = egret.$TextureScaleFactor; - var w = value.width * scale; - var h = value.height * scale; - this.$initData(0, 0, w, h, 0, 0, w, h, value.width, value.height); - }; - /** - * @private - * 设置Texture数据 - * @param bitmapX - * @param bitmapY - * @param bitmapWidth - * @param bitmapHeight - * @param offsetX - * @param offsetY - * @param textureWidth - * @param textureHeight - * @param sourceWidth - * @param sourceHeight - */ - Texture.prototype.$initData = function (bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, sourceWidth, sourceHeight, rotated) { - if (rotated === void 0) { rotated = false; } - var scale = egret.$TextureScaleFactor; - this.$bitmapX = bitmapX / scale; - this.$bitmapY = bitmapY / scale; - this.$bitmapWidth = bitmapWidth / scale; - this.$bitmapHeight = bitmapHeight / scale; - this.$offsetX = offsetX; - this.$offsetY = offsetY; - this.$textureWidth = textureWidth; - this.$textureHeight = textureHeight; - this.$sourceWidth = sourceWidth; - this.$sourceHeight = sourceHeight; - this.$rotated = rotated; - //todo - egret.BitmapData.$invalidate(this.$bitmapData); - }; - /** - * @deprecated - */ - Texture.prototype.getPixel32 = function (x, y) { - throw new Error(); - }; - /** - * Obtain the color value for the specified pixel region - * @param x The x coordinate of the pixel region - * @param y The y coordinate of the pixel region - * @param width The width of the pixel region - * @param height The height of the pixel region - * @returns Specifies the color value for the pixel region - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 获取指定像素区域的颜色值 - * @param x 像素区域的X轴坐标 - * @param y 像素区域的Y轴坐标 - * @param width 像素点的Y轴坐标 - * @param height 像素点的Y轴坐标 - * @returns 指定像素区域的颜色值 - * @version Egret 3.2.1 - * @platform Web - * @language zh_CN - */ - Texture.prototype.getPixels = function (x, y, width, height) { - if (width === void 0) { width = 1; } - if (height === void 0) { height = 1; } - throw new Error(); - }; - /** - * Convert base64 string, if the picture (or pictures included) cross-border or null - * @param type Type conversions, such as "image / png" - * @param rect The need to convert the area - * @param smoothing Whether to convert data to the smoothing process - * @returns {any} base64 string - * @version Egret 2.4 - * @language en_US - */ - /** - * 转换成base64字符串,如果图片(或者包含的图片)跨域,则返回null - * @param type 转换的类型,如 "image/png" - * @param rect 需要转换的区域 - * @param {any} encoderOptions 编码用的参数 - * @returns {any} base64字符串 - * @version Egret 2.4 - * @language zh_CN - */ - Texture.prototype.toDataURL = function (type, rect, encoderOptions) { - throw new Error(); - }; - /** - * Crop designated area and save it as image. - * native support only "image / png" and "image / jpeg"; Web browser because of the various implementations are not the same, it is recommended to use only these two kinds. - * @param type Type conversions, such as "image / png" - * @param filePath The path name of the image (the home directory for the game's private space, the path can not have "../",Web supports only pass names.) - * @param rect The need to convert the area - * @version Egret 2.4 - * @platform Native - * @language en_US - */ - /** - * 裁剪指定区域并保存成图片。 - * native只支持 "image/png" 和 "image/jpeg";Web中由于各个浏览器的实现不一样,因此建议也只用这2种。 - * @param type 转换的类型,如 "image/png" - * @param filePath 图片的名称的路径(主目录为游戏的私有空间,路径中不能有 "../",Web只支持传名称。) - * @param rect 需要转换的区域 - * @version Egret 2.4 - * @platform Native - * @language zh_CN - */ - Texture.prototype.saveToFile = function (type, filePath, rect) { - throw new Error(); - }; - /** - * dispose texture - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放纹理 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Texture.prototype.dispose = function () { - if (this.$bitmapData) { - if (this.disposeBitmapData) { - this.$bitmapData.$dispose(); - } - this.$bitmapData = null; - } - if (egret.nativeRender) { - egret_native.NativeDisplayObject.disposeTexture(this); - } - }; - return Texture; - }(egret.HashObject)); - egret.Texture = Texture; - __reflect(Texture.prototype, "egret.Texture"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The Event class is used as the base class for the creation of Event objects, which are passed as parameters to event - * listeners when an event occurs.The properties of the Event class carry basic information about an event, such as - * the event's type or whether the event's default behavior can be canceled. For many events, such as the events represented - * by the Event class constants, this basic information is sufficient. Other events, however, may require more detailed - * information. Events associated with a touch tap, for example, need to include additional information about the - * location of the touch event. You can pass such additional information to event listeners by extending the Event class, - * which is what the TouchEvent class does. Egret API defines several Event subclasses for common events that require - * additional information. Events associated with each of the Event subclasses are described in the documentation for - * each class.The methods of the Event class can be used in event listener functions to affect the behavior of the event - * object. Some events have an associated default behavior. Your event listener can cancel this behavior by calling the - * preventDefault() method. You can also make the current event listener the last one to process an event by calling - * the stopPropagation() or stopImmediatePropagation() method. - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/Event.ts - * @see http://edn.egret.com/cn/docs/page/798 取消触摸事件 - * @language en_US - */ - /** - * Event 类作为创建事件实例的基类,当发生事件时,Event 实例将作为参数传递给事件侦听器。Event 类的属性包含有关事件的基本信息,例如事件 - * 的类型或者是否可以取消事件的默认行为。对于许多事件(如由 Event 类常量表示的事件),此基本信息就足够了。但其他事件可能需要更详细的信息。 - * 例如,与触摸关联的事件需要包括有关触摸事件的位置信息。您可以通过扩展 Event 类(TouchEvent 类执行的操作)将此类其他信息传递给事件侦听器。 - * Egret API 为需要其他信息的常见事件定义多个 Event 子类。与每个 Event 子类关联的事件将在每个类的文档中加以介绍。Event 类的方法可以在 - * 事件侦听器函数中使用以影响事件对象的行为。某些事件有关联的默认行为,通过调用 preventDefault() 方法,您的事件侦听器可以取消此行为。 - * 可以通过调用 stopPropagation() 或 stopImmediatePropagation() 方法,将当前事件侦听器作为处理事件的最后一个事件侦听器。 - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/Event.ts - * @see http://edn.egret.com/cn/docs/page/798 取消触摸事件 - * @language zh_CN - */ - var Event = (function (_super) { - __extends(Event, _super); - /** - * Creates an Event object to pass as a parameter to event listeners. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param data the optional data associated with this event - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个作为参数传递给事件侦听器的 Event 对象。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param data 与此事件对象关联的可选数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Event(type, bubbles, cancelable, data) { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.$eventPhase = 2; - /** - * @private - */ - _this.$currentTarget = null; - /** - * @private - */ - _this.$target = null; - /** - * @private - */ - _this.$isDefaultPrevented = false; - /** - * @private - */ - _this.$isPropagationStopped = false; - /** - * @private - */ - _this.$isPropagationImmediateStopped = false; - _this.$type = type; - _this.$bubbles = !!bubbles; - _this.$cancelable = !!cancelable; - _this.data = data; - return _this; - } - Object.defineProperty(Event.prototype, "type", { - /** - * The type of event. The type is case-sensitive. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件的类型。类型区分大小写。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$type; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Event.prototype, "bubbles", { - /** - * Indicates whether an event is a bubbling event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示事件是否为冒泡事件。如果事件可以冒泡,则此值为 true;否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$bubbles; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Event.prototype, "cancelable", { - /** - * Indicates whether the behavior associated with the event can be prevented. If the behavior can be - * canceled, this value is true; otherwise it is false. - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示是否可以阻止与事件相关联的行为。如果可以取消该行为,则此值为 true;否则为 false。 - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$cancelable; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Event.prototype, "eventPhase", { - /** - * The current phase in the event flow. This property can contain the following numeric values: - * The capture phase (EventPhase.CAPTURING_PHASE). - * The target phase (EventPhase.AT_TARGET) - * The bubbling phase (EventPhase.BUBBLING_PHASE). - * @see egret.EventPhase - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件流中的当前阶段。此属性可以包含以下数值: - * 捕获阶段 (EventPhase.CAPTURING_PHASE)。 - * 目标阶段 (EventPhase.AT_TARGET)。 - * 冒泡阶段 (EventPhase.BUBBLING_PHASE)。 - * @see egret.EventPhase - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$eventPhase; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Event.prototype, "currentTarget", { - /** - * The object that is actively processing the Event object with an event listener. For example, if a - * user clicks an OK button, the current target could be the node containing that button or one of its ancestors - * that has registered an event listener for that event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前正在使用某个事件侦听器处理 Event 对象的对象。例如,如果用户单击“确定”按钮, - * 则当前目标可以是包含该按钮的节点,也可以是它的已为该事件注册了事件侦听器的始祖之一。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$currentTarget; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Event.prototype, "target", { - /** - * The event target. This property contains the target node. For example, if a user clicks an OK button, - * the target node is the display list node containing that button. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件目标。此属性包含目标节点。例如,如果用户单击“确定”按钮,则目标节点就是包含该按钮的显示列表节点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$target; - }, - enumerable: true, - configurable: true - }); - Event.prototype.$setTarget = function (target) { - this.$target = target; - return true; - }; - /** - * Checks whether the preventDefault() method has been called on the event. If the preventDefault() method has been - * called, returns true; otherwise, returns false. - * @returns If preventDefault() has been called, returns true; otherwise, returns false. - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查是否已对事件调用 preventDefault() 方法。 - * @returns 如果已调用 preventDefault() 方法,则返回 true;否则返回 false。 - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.prototype.isDefaultPrevented = function () { - return this.$isDefaultPrevented; - }; - /** - * Cancels an event's default behavior if that behavior can be canceled.Many events have associated behaviors that - * are carried out by default. For example, if a user types a character into a text input, the default behavior - * is that the character is displayed in the text input. Because the TextEvent.TEXT_INPUT event's default behavior - * can be canceled, you can use the preventDefault() method to prevent the character from appearing. - * You can use the Event.cancelable property to check whether you can prevent the default behavior associated with - * a particular event. If the value of Event.cancelable is true, then preventDefault() can be used to cancel the event; - * otherwise, preventDefault() has no effect. - * @see #cancelable - * @see #isDefaultPrevented - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果可以取消事件的默认行为,则取消该行为。 - * 许多事件都有默认执行的关联行为。例如,如果用户在文本字段中键入一个字符,则默认行为就是在文本字段中显示该字符。 - * 由于可以取消 TextEvent.TEXT_INPUT 事件的默认行为,因此您可以使用 preventDefault() 方法来防止显示该字符。 - * 您可以使用 Event.cancelable 属性来检查是否可以防止与特定事件关联的默认行为。如果 Event.cancelable 的值为 true, - * 则可以使用 preventDefault() 来取消事件;否则,preventDefault() 无效。 - * @see #cancelable - * @see #isDefaultPrevented - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.prototype.preventDefault = function () { - if (this.$cancelable) - this.$isDefaultPrevented = true; - }; - /** - * Prevents processing of any event listeners in nodes subsequent to the current node in the event flow. This method - * does not affect any event listeners in the current node (currentTarget). In contrast, the stopImmediatePropagation() - * method prevents processing of event listeners in both the current node and subsequent nodes. Additional calls to this - * method have no effect. This method can be called in any phase of the event flow.
    - * Note: This method does not cancel the behavior associated with this event; see preventDefault() for that functionality. - * @see #stopImmediatePropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 防止对事件流中当前节点的后续节点中的所有事件侦听器进行处理。此方法不会影响当前节点 currentTarget 中的任何事件侦听器。 - * 相比之下,stopImmediatePropagation() 方法可以防止对当前节点中和后续节点中的事件侦听器进行处理。 - * 对此方法的其它调用没有任何效果。可以在事件流的任何阶段中调用此方法。
    - * 注意:此方法不会取消与此事件相关联的行为;有关此功能的信息,请参阅 preventDefault()。 - * @see #stopImmediatePropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.prototype.stopPropagation = function () { - if (this.$bubbles) - this.$isPropagationStopped = true; - }; - /** - * Prevents processing of any event listeners in the current node and any subsequent nodes in the event flow. - * This method takes effect immediately, and it affects event listeners in the current node. In contrast, the - * stopPropagation() method doesn't take effect until all the event listeners in the current node finish processing.
    - * Note: This method does not cancel the behavior associated with this event; see preventDefault() for that functionality. - * @see #stopPropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 防止对事件流中当前节点中和所有后续节点中的事件侦听器进行处理。此方法会立即生效,并且会影响当前节点中的事件侦听器。 - * 相比之下,在当前节点中的所有事件侦听器都完成处理之前,stopPropagation() 方法不会生效。
    - * 注意:此方法不会取消与此事件相关联的行为;有关此功能的信息,请参阅 preventDefault()。 - * @see #stopPropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.prototype.stopImmediatePropagation = function () { - if (this.$bubbles) - this.$isPropagationImmediateStopped = true; - }; - /** - * This method will be called automatically when you pass the event object as the parameters to the Event.release() method. - * If your custom event is designed for reusable,you should override this method to make sure all the references to external - * objects are cleaned. if not,it may cause memory leaking. - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当事件实例传递给Event.release()静态方法时,实例上的clean()方法将会被自动调用。 - * 若此自定义事件的实例设计为可以循环复用的,为了避免引起内存泄露,自定义事件需要覆盖此方法来确保实例被缓存前断开对外部对象的一切引用。 - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.prototype.clean = function () { - this.data = this.$currentTarget = null; - this.$setTarget(null); - }; - /** - * EventDispatcher object using the specified event object thrown Event. Objects thrown objects will be cached in the pool for the next round robin. - * @param target the event target - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param data {any} data - * @method egret.Event.dispatchEvent - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的 EventDispatcher 对象来抛出 Event 事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param type {string} 事件类型 - * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param data {any} 事件data - * @method egret.Event.dispatchEvent - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.dispatchEvent = function (target, type, bubbles, data) { - if (bubbles === void 0) { bubbles = false; } - var event = Event.create(Event, type, bubbles); - var props = Event._getPropertyData(Event); - if (data != undefined) { - props.data = data; - } - var result = target.dispatchEvent(event); - Event.release(event); - return result; - }; - /** - * @private - * - * @param EventClass - * @returns - */ - Event._getPropertyData = function (EventClass) { - var props = EventClass._props; - if (!props) - props = EventClass._props = {}; - return props; - }; - /** - * Gets one event instance from the object pool or create a new one. We highly recommend using the Event.create() - * and Event.release() methods to create and release an event object,it can reduce the number of reallocate objects, - * which allows you to get better code execution performance.
    - * Note: If you want to use this method to initialize your custom event object,you must make sure the constructor - * of your custom event is the same as the constructor of egret.Event. - * @param EventClass Event Class。 - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @example - *
    -         *    let event = Event.create(Event,type, bubbles);
    -         *    event.data = data;    //optional,initializes custom data here
    -         *    this.dispatchEvent(event);
    -         *    Event.release(event);
    -         * 
    - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的事件实例。我们建议您尽可能使用Event.create()和Event.release() 这一对方法来创建和释放事件对象, - * 这一对方法会将事件实例在内部缓存下来供下次循环使用,减少对象的创建次数,从而获得更高的代码运行性能。
    - * 注意:若使用此方法来创建自定义事件的实例,自定义的构造函数参数列表必须跟Event类一致。 - * @param EventClass Event类名。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @example - *
    -         *    let event = Event.create(Event,type, bubbles);
    -         *    event.data = data;  //可选,若指定义事件上需要附加其他参数,可以在获取实例后在此处设置。
    -         *    this.dispatchEvent(event);
    -         *    Event.release(event);
    -         * 
    - * @see #clean() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.create = function (EventClass, type, bubbles, cancelable) { - var eventPool = EventClass.eventPool; - if (!eventPool) { - eventPool = EventClass.eventPool = []; - } - if (eventPool.length) { - var event_2 = eventPool.pop(); - event_2.$type = type; - event_2.$bubbles = !!bubbles; - event_2.$cancelable = !!cancelable; - event_2.$isDefaultPrevented = false; - event_2.$isPropagationStopped = false; - event_2.$isPropagationImmediateStopped = false; - event_2.$eventPhase = 2 /* AT_TARGET */; - return event_2; - } - return new EventClass(type, bubbles, cancelable); - }; - /** - * Releases an event object and cache it into the object pool.We highly recommend using the Event.create() - * and Event.release() methods to create and release an event object,it can reduce the number of reallocate objects, - * which allows you to get better code execution performance.
    - * Note: The parameters of this method only accepts an instance created by the Event.create() method. - * if not,it may throw an error. - * @example - *
    -         *    let event = Event.create(Event,type, bubbles);
    -         *    event.data = data; //optional,initializes custom data here
    -         *    this.dispatchEvent(event);
    -         *    Event.release(event);
    -         * 
    - * @see #clean() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个事件对象,并缓存到对象池。我们建议您尽可能使用Event.create()和Event.release() 这一对方法来创建和释放事件对象, - * 这一对方法会将事件实例在内部缓存下来供下次循环使用,减少对象的创建次数,从而获得更高的代码运行性能。
    - * 注意:此方法只能传入由Event.create()创建的事件实例,传入非法对象实例可能会导致报错。 - * @example - *
    -         *    let event = Event.create(Event,type, bubbles);
    -         *    event.data = data;   //可选,若指定义事件上需要附加其他参数,可以在获取实例后在此处设置。
    -         *    this.dispatchEvent(event);
    -         *    Event.release(event);
    -         * 
    - * @see #clean() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.release = function (event) { - event.clean(); - var EventClass = Object.getPrototypeOf(event).constructor; - EventClass.eventPool.push(event); - }; - /** - * Dispatched when a display object is added to the on stage display list, either directly or through the addition - * of a sub tree in which the display object is contained. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在将显示对象直接添加到舞台显示列表或将包含显示对象的子树添加至舞台显示列表中时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.ADDED_TO_STAGE = "addedToStage"; - /** - * Dispatched when a display object is about to be removed from the display list, either directly or through the removal - * of a sub tree in which the display object is contained. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在从显示列表中直接删除显示对象或删除包含显示对象的子树时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.REMOVED_FROM_STAGE = "removedFromStage"; - /** - * Dispatched when a display object is added to the display list. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将显示对象添加到显示列表中时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.ADDED = "added"; - /** - * Dispatched when a display object is about to be removed from the display list. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将要从显示列表中删除显示对象时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.REMOVED = "removed"; - /** - * [broadcast event] Dispatched when the playhead is entering a new frame. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * [广播事件] 进入新的一帧,监听此事件将会在下一帧开始时触发一次回调。这是一个广播事件,可以在任何一个显示对象上监听,无论它是否在显示列表中。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.ENTER_FRAME = "enterFrame"; - /** - * Dispatched when the display list is about to be updated and rendered. - * Note: Every time you want to receive a render event,you must call the stage.invalidate() method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 渲染事件,监听此事件将会在本帧末即将开始渲染的前一刻触发回调,这是一个广播事件,可以在任何一个显示对象上监听,无论它是否在显示列表中。 - * 注意:每次您希望 Egret 发送 Event.RENDER 事件时,都必须调用 stage.invalidate() 方法,由于每帧只会触发一次屏幕刷新, - * 若在 Event.RENDER 回调函数执行期间再次调用stage.invalidate(),将会被忽略。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.RENDER = "render"; - /** - * Dispatched when the size of stage or UIComponent is changed. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 舞台尺寸或UI组件尺寸发生改变 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.RESIZE = "resize"; - /** - * Dispatched when the value or selection of a property is chaned. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 属性值或状态发生改变。通常是按钮的选中状态,或者列表的选中项索引改变。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.CHANGE = "change"; - /** - * Dispatched when the value or selection of a property is going to change.you can cancel this by calling the - * preventDefault() method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 属性值或状态即将发生改变,通常是按钮的选中状态,或者列表的选中项索引改变。可以通过调用 preventDefault() 方法阻止索引发生更改。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.CHANGING = "changing"; - /** - * Dispatched when the net request is complete. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 网络请求加载完成 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.COMPLETE = "complete"; - /** - * Dispatched when loop completed. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 循环完成。循环最后一次只派发 COMPLETE 事件,不派发 LOOP_COMPLETE 事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.LOOP_COMPLETE = "loopComplete"; - /** - * Dispatched when the TextInput instance gets focus. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * TextInput实例获得焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.FOCUS_IN = "focusIn"; - /** - * Dispatched when the TextInput instance loses focus. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * TextInput实例失去焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.FOCUS_OUT = "focusOut"; - /** - * Dispatched when the playback is ended. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 动画声音等播放完成 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.ENDED = "ended"; - /** - * 游戏激活 - * @version Egret 2.4 - * @platform Web,Native - */ - Event.ACTIVATE = "activate"; - /** - * 取消激活 - * @version Egret 2.4 - * @platform Web,Native - */ - Event.DEACTIVATE = "deactivate"; - /** - * Event.CLOSE 常量定义 close 事件对象的 type 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - */ - Event.CLOSE = "close"; - /** - * Event.CONNECT 常量定义 connect 事件对象的 type 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - */ - Event.CONNECT = "connect"; - /** - * Event.LEAVE_STAGE 常量定义 leaveStage 事件对象的 type 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - */ - Event.LEAVE_STAGE = "leaveStage"; - /** - * Event.SOUND_COMPLETE 常量定义 在声音完成播放后调度。 - * @version Egret 2.4 - * @platform Web,Native - */ - Event.SOUND_COMPLETE = "soundComplete"; - return Event; - }(egret.HashObject)); - egret.Event = Event; - __reflect(Event.prototype, "egret.Event"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -global.DEBUG = true; -global.RELEASE = false; -var egret; -(function (egret) { - /** - * @private - */ - function _getString(code) { - var params = []; - for (var _i = 1; _i < arguments.length; _i++) { - params[_i - 1] = arguments[_i]; - } - return egret.sys.tr.apply(egret.sys, arguments); - } - egret.getString = _getString; - function _error(code) { - var params = []; - for (var _i = 1; _i < arguments.length; _i++) { - params[_i - 1] = arguments[_i]; - } - var text = egret.sys.tr.apply(null, arguments); - if (true) { - egret.sys.$errorToFPS("Error #" + code + ": " + text); - } - throw new Error("#" + code + ": " + text); //使用这种方式报错能够终止后续代码继续运行 - } - egret.$error = _error; - function _warn(code) { - var params = []; - for (var _i = 1; _i < arguments.length; _i++) { - params[_i - 1] = arguments[_i]; - } - var text = egret.sys.tr.apply(null, arguments); - if (true) { - egret.sys.$warnToFPS("Warning #" + code + ": " + text); - } - egret.warn("Warning #" + code + ": " + text); - } - egret.$warn = _warn; - function _markReadOnly(instance, property, isProperty) { - if (isProperty === void 0) { isProperty = true; } - var data = Object.getOwnPropertyDescriptor(isProperty ? instance.prototype : instance, property); - if (data == null) { - console.log(instance); - return; - } - data.set = function (value) { - if (isProperty) { - egret.$warn(1010, egret.getQualifiedClassName(instance), property); - } - else { - egret.$warn(1014, egret.getQualifiedClassName(instance), property); - } - }; - Object.defineProperty(instance.prototype, property, data); - } - function markCannotUse(instance, property, defaultValue) { - Object.defineProperty(instance.prototype, property, { - get: function () { - egret.$warn(1009, egret.getQualifiedClassName(instance), property); - return defaultValue; - }, - set: function (value) { - egret.$error(1009, egret.getQualifiedClassName(instance), property); - }, - enumerable: true, - configurable: true - }); - } - egret.$markCannotUse = markCannotUse; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var pointPool = []; - var DEG_TO_RAD = Math.PI / 180; - /** - * The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal - * axis and y represents the vertical axis. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Point.ts - * @language en_US - */ - /** - * Point 对象表示二维坐标系统中的某个位置,其中 x 表示水平轴,y 表示垂直轴。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Point.ts - * @language zh_CN - */ - var Point = (function (_super) { - __extends(Point, _super); - /** - * Creates a new point. If you pass no parameters to this method, a point is created at (0,0). - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。 - * @param x 该对象的x属性值,默认为0 - * @param y 该对象的y属性值,默认为0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Point(x, y) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - var _this = _super.call(this) || this; - _this.x = x; - _this.y = y; - return _this; - } - /** - * Releases a point instance to the object pool - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个Point实例到对象池 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.release = function (point) { - if (!point) { - return; - } - pointPool.push(point); - }; - /** - * get a point instance from the object pool or create a new one. - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的Point对象。 - * @param x 该对象的x属性值,默认为0 - * @param y 该对象的y属性值,默认为0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.create = function (x, y) { - var point = pointPool.pop(); - if (!point) { - point = new Point(); - } - return point.setTo(x, y); - }; - Object.defineProperty(Point.prototype, "length", { - /** - * The length of the line segment from (0,0) to this point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 (0,0) 到此点的线段长度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return Math.sqrt(this.x * this.x + this.y * this.y); - }, - enumerable: true, - configurable: true - }); - /** - * Sets the members of Point to the specified values - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Point 的成员设置为指定值 - * @param x 该对象的x属性值 - * @param y 该对象的y属性值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.prototype.setTo = function (x, y) { - this.x = x; - this.y = y; - return this; - }; - /** - * Creates a copy of this Point object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 克隆点对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.prototype.clone = function () { - return new Point(this.x, this.y); - }; - /** - * Determines whether two points are equal. Two points are equal if they have the same x and y values. - * @param toCompare The point to be compared. - * @returns A value of true if the object is equal to this Point object; false if it is not equal. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定两个点是否相同。如果两个点具有相同的 x 和 y 值,则它们是相同的点。 - * @param toCompare 要比较的点。 - * @returns 如果该对象与此 Point 对象相同,则为 true 值,如果不相同,则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.prototype.equals = function (toCompare) { - return this.x == toCompare.x && this.y == toCompare.y; - }; - /** - * Returns the distance between pt1 and pt2. - * @param p1 The first point. - * @param p2 The second point. - * @returns The distance between the first and second points. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回 pt1 和 pt2 之间的距离。 - * @param p1 第一个点 - * @param p2 第二个点 - * @returns 第一个点和第二个点之间的距离。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.distance = function (p1, p2) { - return Math.sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y)); - }; - /** - * Copies all of the point data from the source Point object into the calling Point object. - * @param sourcePoint The Point object from which to copy the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将源 Point 对象中的所有点数据复制到调用方 Point 对象中。 - * @param sourcePoint 要从中复制数据的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.prototype.copyFrom = function (sourcePoint) { - this.x = sourcePoint.x; - this.y = sourcePoint.y; - }; - /** - * Adds the coordinates of another point to the coordinates of this point to create a new point. - * @param v The point to be added. - * @returns The new point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将另一个点的坐标添加到此点的坐标以创建一个新点。 - * @param v 要添加的点。 - * @returns 新点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.prototype.add = function (v) { - return new Point(this.x + v.x, this.y + v.y); - }; - /** - * Determines a point between two specified points. - * The parameter f determines where the new interpolated point is located relative to the two end points specified by parameters pt1 and pt2. The closer the value of the parameter f is to 1.0, the closer the interpolated point is to the first point (parameter pt1). The closer the value of the parameter f is to 0, the closer the interpolated point is to the second point (parameter pt2). - * @param pt1 The first point. - * @param pt2 The second point. - * @param f The level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned. - * @returns The new interpolated point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定两个指定点之间的点。 - * 参数 f 确定新的内插点相对于参数 pt1 和 pt2 指定的两个端点所处的位置。参数 f 的值越接近 1.0,则内插点就越接近第一个点(参数 pt1)。参数 f 的值越接近 0,则内插点就越接近第二个点(参数 pt2)。 - * @param pt1 第一个点。 - * @param pt2 第二个点。 - * @param f 两个点之间的内插级别。表示新点将位于 pt1 和 pt2 连成的直线上的什么位置。如果 f=1,则返回 pt1;如果 f=0,则返回 pt2。 - * @returns 新的内插点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.interpolate = function (pt1, pt2, f) { - var f1 = 1 - f; - return new Point(pt1.x * f + pt2.x * f1, pt1.y * f + pt2.y * f1); - }; - /** - * Scales the line segment between (0,0) and the current point to a set length. - * @param thickness The scaling value. For example, if the current point is (0,5), and you normalize it to 1, the point returned is at (0,1). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 (0,0) 和当前点之间的线段缩放为设定的长度。 - * @param thickness 缩放值。例如,如果当前点为 (0,5) 并且您将它规范化为 1,则返回的点位于 (0,1) 处。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.prototype.normalize = function (thickness) { - if (this.x != 0 || this.y != 0) { - var relativeThickness = thickness / this.length; - this.x *= relativeThickness; - this.y *= relativeThickness; - } - }; - /** - * Offsets the Point object by the specified amount. The value of dx is added to the original value of x to create the new x value. The value of dy is added to the original value of y to create the new y value. - * @param dx The amount by which to offset the horizontal coordinate, x. - * @param dy The amount by which to offset the vertical coordinate, y. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 按指定量偏移 Point 对象。dx 的值将添加到 x 的原始值中以创建新的 x 值。dy 的值将添加到 y 的原始值中以创建新的 y 值。 - * @param dx 水平坐标 x 的偏移量。 - * @param dy 水平坐标 y 的偏移量。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.prototype.offset = function (dx, dy) { - this.x += dx; - this.y += dy; - }; - /** - * Converts a pair of polar coordinates to a Cartesian point coordinate. - * @param len The length coordinate of the polar pair. - * @param angle The angle, in radians, of the polar pair. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将一对极坐标转换为笛卡尔点坐标。 - * @param len 极坐标对的长度。 - * @param angle 极坐标对的角度(以弧度表示)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.polar = function (len, angle) { - return new Point(len * egret.NumberUtils.cos(angle / DEG_TO_RAD), len * egret.NumberUtils.sin(angle / DEG_TO_RAD)); - }; - /** - * Subtracts the coordinates of another point from the coordinates of this point to create a new point. - * @param v The point to be subtracted. - * @returns The new point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从此点的坐标中减去另一个点的坐标以创建一个新点。 - * @param v 要减去的点。 - * @returns 新点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.prototype.subtract = function (v) { - return new Point(this.x - v.x, this.y - v.y); - }; - /** - * Returns a string that contains the values of the x and y coordinates. The string has the form "(x=x, y=y)", so calling the toString() method for a point at 23,17 would return "(x=23, y=17)". - * @returns The string representation of the coordinates. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回包含 x 和 y 坐标的值的字符串。该字符串的格式为 "(x=x, y=y)",因此为点 23,17 调用 toString() 方法将返回 "(x=23, y=17)"。 - * @returns 坐标的字符串表示形式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.prototype.toString = function () { - return "(x=" + this.x + ", y=" + this.y + ")"; - }; - return Point; - }(egret.HashObject)); - egret.Point = Point; - __reflect(Point.prototype, "egret.Point"); - /** - * @private - * 仅供框架内复用,要防止暴露引用到外部。 - */ - egret.$TempPoint = new Point(); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The DisplayObjectContainer class is a basic display list building block: a display list node that can contain children. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObjectContainer.ts - * @language en_US - */ - /** - * DisplayObjectContainer 类是基本显示列表构造块:一个可包含子项的显示列表节点。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObjectContainer.ts - * @language zh_CN - */ - var DisplayObjectContainer = (function (_super) { - __extends(DisplayObjectContainer, _super); - /** - * Creates a new DisplayObjectContainer instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 实例化一个容器 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function DisplayObjectContainer() { - var _this = _super.call(this) || this; - _this.$touchChildren = true; - _this.$children = []; - return _this; - } - Object.defineProperty(DisplayObjectContainer.prototype, "numChildren", { - /** - * Returns the number of children of this object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回此对象的子项数目。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$children.length; - }, - enumerable: true, - configurable: true - }); - /** - * Adds a child DisplayObject instance to this DisplayObjectContainer instance. The child is added to the front - * (top) of all other children in this DisplayObjectContainer instance. (To add a child to a specific index position, - * use the addChildAt() method.)If you add a child object that already has a different display object container - * as a parent, the object is removed from the child list of the other display object container. - * @param child The DisplayObject instance to add as a child of this DisplayObjectContainer instance. - * @returns 在 child The DisplayObject instance that you pass in the child parameter. - * @see #addChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将一个 DisplayObject 子实例添加到该 DisplayObjectContainer 实例中。子项将被添加到该 DisplayObjectContainer 实例中其他 - * 所有子项的前(上)面。(要将某子项添加到特定索引位置,请使用 addChildAt() 方法。) - * @param child 要作为该 DisplayObjectContainer 实例的子项添加的 DisplayObject 实例。 - * @returns 在 child 参数中传递的 DisplayObject 实例。 - * @see #addChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.addChild = function (child) { - var index = this.$children.length; - if (child.$parent == this) - index--; - return this.$doAddChild(child, index); - }; - /** - * Adds a child DisplayObject instance to this DisplayObjectContainer instance. The child is added at the index position - * specified. An index of 0 represents the back (bottom) of the display list for this DisplayObjectContainer object. - * If you add a child object that already has a different display object container as a parent, the object is removed - * from the child list of the other display object container. - * @param child The DisplayObject instance to add as a child of this DisplayObjectContainer instance. - * @param index The index position to which the child is added. If you specify a currently occupied index position, - * the child object that exists at that position and all higher positions are moved up one position in the child list. - * @returns The DisplayObject instance that you pass in the child parameter. - * @see #addChild() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将一个 DisplayObject 子实例添加到该 DisplayObjectContainer 实例中。该子项将被添加到指定的索引位置。索引为 0 表示该 - * DisplayObjectContainer 对象的显示列表的后(底)部。如果添加一个已将其它显示对象容器作为父项的子对象,则会从其它显示对象容器的子列表中删除该对象。 - * @param child 要作为该 DisplayObjectContainer 实例的子项添加的 DisplayObject 实例。 - * @param index 添加该子项的索引位置。 如果指定当前占用的索引位置,则该位置以及所有更高位置上的子对象会在子级列表中上移一个位置。 - * @returns 在 child 参数中传递的 DisplayObject 实例。 - * @see #addChild() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.addChildAt = function (child, index) { - index = +index | 0; - if (index < 0 || index >= this.$children.length) { - index = this.$children.length; - if (child.$parent == this) { - index--; - } - } - return this.$doAddChild(child, index); - }; - /** - * @private - */ - DisplayObjectContainer.prototype.$doAddChild = function (child, index, notifyListeners) { - if (notifyListeners === void 0) { notifyListeners = true; } - var self = this; - if (true) { - if (child == self) { - egret.$error(1005); - } - else if ((child instanceof egret.DisplayObjectContainer) && child.contains(self)) { - egret.$error(1004); - } - } - var host = child.$parent; - if (host == self) { - self.doSetChildIndex(child, index); - return child; - } - if (host) { - host.removeChild(child); - } - self.$children.splice(index, 0, child); - child.$setParent(self); - var stage = self.$stage; - if (stage) { - child.$onAddToStage(stage, self.$nestLevel + 1); - } - if (notifyListeners) { - child.dispatchEventWith(egret.Event.ADDED, true); - } - if (stage) { - var list = DisplayObjectContainer.$EVENT_ADD_TO_STAGE_LIST; - while (list.length) { - var childAddToStage = list.shift(); - if (childAddToStage.$stage && notifyListeners) { - childAddToStage.dispatchEventWith(egret.Event.ADDED_TO_STAGE); - } - } - } - if (egret.nativeRender) { - self.$nativeDisplayObject.addChildAt(child.$nativeDisplayObject.id, index); - } - else { - if (child.$maskedObject) { - child.$maskedObject.$updateRenderMode(); - } - if (!self.$cacheDirty) { - self.$cacheDirty = true; - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - } - this.$childAdded(child, index); - return child; - }; - /** - * Determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance - * itself. The search includes the entire display list including this DisplayObjectContainer instance. Grandchildren, - * great-grandchildren, and so on each return true. - * @param child The child object to test. - * @returns true if the child object is a child of the DisplayObjectContainer or the container itself; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定指定显示对象是 DisplayObjectContainer 实例的子项或该实例本身。搜索包括整个显示列表(其中包括此 DisplayObjectContainer 实例)。 - * 孙项、曾孙项等,每项都返回 true。 - * @param child 要测试的子对象。 - * @returns 如果 child 对象是 DisplayObjectContainer 的子项或容器本身,则为 true;否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.contains = function (child) { - while (child) { - if (child == this) { - return true; - } - child = child.$parent; - } - return false; - }; - /** - * Returns the child display object instance that exists at the specified index. - * @param index The index position of the child object. - * @returns The child display object at the specified index position. - * @see #getChildByName() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回位于指定索引处的子显示对象实例。 - * @param index 子对象的索引位置。 - * @returns 位于指定索引位置处的子显示对象。 - * @see #getChildByName() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.getChildAt = function (index) { - index = +index | 0; - if (index >= 0 && index < this.$children.length) { - return this.$children[index]; - } - else { - true && egret.$error(1007); - return null; - } - }; - /** - * Returns the index position of a child DisplayObject instance. - * @param child The DisplayObject instance to identify. - * @returns The index position of the child display object to identify. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回 DisplayObject 的 child 实例的索引位置。 - * @param child 要测试的子对象。 - * @returns 要查找的子显示对象的索引位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.getChildIndex = function (child) { - return this.$children.indexOf(child); - }; - /** - * Returns the child display object that exists with the specified name. If more that one child display object has - * the specified name, the method returns the first object in the child list.The getChildAt() method is faster than - * the getChildByName() method. The getChildAt() method accesses a child from a cached array, whereas the getChildByName() - * method has to traverse a linked list to access a child. - * @param name The name of the child to return. - * @returns The child display object with the specified name. - * @see #getChildAt() - * @see egret.DisplayObject#name - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回具有指定名称的子显示对象。如果多个子显示对象具有指定名称,则该方法会返回子级列表中的第一个对象。 - * getChildAt() 方法比 getChildByName() 方法快。getChildAt() 方法从缓存数组中访问子项,而 getChildByName() 方法则必须遍历链接的列表来访问子项。 - * @param name 要返回的子项的名称。 - * @returns 具有指定名称的子显示对象。 - * @see #getChildAt() - * @see egret.DisplayObject#name - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.getChildByName = function (name) { - var children = this.$children; - var length = children.length; - var displayObject; - for (var i = 0; i < length; i++) { - displayObject = children[i]; - if (displayObject.name == name) { - return displayObject; - } - } - return null; - }; - /** - * Removes the specified child DisplayObject instance from the child list of the DisplayObjectContainer instance. - * The parent property of the removed child is set to null , and the object is garbage collected if no other references - * to the child exist. The index positions of any display objects above the child in the DisplayObjectContainer are - * decreased by 1. - * @param child The DisplayObject instance to remove. - * @returns The DisplayObject instance that you pass in the child parameter. - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 DisplayObjectContainer 实例的子列表中删除指定的 child DisplayObject 实例。将已删除子项的 parent 属性设置为 null; - * 如果不存在对该子项的任何其它引用,则将该对象作为垃圾回收。DisplayObjectContainer 中该子项之上的任何显示对象的索引位置都减去 1。 - * @param child 要删除的 DisplayObject 实例。 - * @returns 在 child 参数中传递的 DisplayObject 实例。 - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.removeChild = function (child) { - var index = this.$children.indexOf(child); - if (index >= 0) { - return this.$doRemoveChild(index); - } - else { - true && egret.$error(1006); - return null; - } - }; - /** - * Removes a child DisplayObject from the specified index position in the child list of the DisplayObjectContainer. - * The parent property of the removed child is set to null, and the object is garbage collected if no other references - * to the child exist. The index positions of any display objects above the child in the DisplayObjectContainer are decreased by 1. - * @param index The child index of the DisplayObject to remove. - * @returns The DisplayObject instance that was removed. - * @see #removeChild() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 DisplayObjectContainer 的子列表中指定的 index 位置删除子 DisplayObject。将已删除子项的 parent 属性设置为 null; - * 如果没有对该子项的任何其他引用,则将该对象作为垃圾回收。DisplayObjectContainer 中该子项之上的任何显示对象的索引位置都减去 1。 - * @param index 要删除的 DisplayObject 的子索引。 - * @returns 已删除的 DisplayObject 实例。 - * @see #removeChild() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.removeChildAt = function (index) { - index = +index | 0; - if (index >= 0 && index < this.$children.length) { - return this.$doRemoveChild(index); - } - else { - true && egret.$error(1007); - return null; - } - }; - /** - * @private - */ - DisplayObjectContainer.prototype.$doRemoveChild = function (index, notifyListeners) { - if (notifyListeners === void 0) { notifyListeners = true; } - index = +index | 0; - var self = this; - var children = this.$children; - var child = children[index]; - this.$childRemoved(child, index); - if (notifyListeners) { - child.dispatchEventWith(egret.Event.REMOVED, true); - } - if (this.$stage) { - child.$onRemoveFromStage(); - var list = DisplayObjectContainer.$EVENT_REMOVE_FROM_STAGE_LIST; - while (list.length > 0) { - var childAddToStage = list.shift(); - if (notifyListeners && childAddToStage.$hasAddToStage) { - childAddToStage.$hasAddToStage = false; - childAddToStage.dispatchEventWith(egret.Event.REMOVED_FROM_STAGE); - } - childAddToStage.$hasAddToStage = false; - childAddToStage.$stage = null; - } - } - var displayList = this.$displayList || this.$parentDisplayList; - child.$setParent(null); - var indexNow = children.indexOf(child); - if (indexNow != -1) { - children.splice(indexNow, 1); - } - if (egret.nativeRender) { - self.$nativeDisplayObject.removeChild(child.$nativeDisplayObject.id); - } - else { - if (child.$maskedObject) { - child.$maskedObject.$updateRenderMode(); - } - if (!self.$cacheDirty) { - self.$cacheDirty = true; - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - } - return child; - }; - /** - * Changes the position of an existing child in the display object container. This affects the layering of child objects. - * @param child The child DisplayObject instance for which you want to change the index number. - * @param index The resulting index number for the child display object. - * @see #addChildAt() - * @see #getChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 更改现有子项在显示对象容器中的位置。这会影响子对象的分层。 - * @param child 要为其更改索引编号的 DisplayObject 子实例。 - * @param index 生成的 child 显示对象的索引编号。当新的索引编号小于0或大于已有子元件数量时,新加入的DisplayObject对象将会放置于最上层。 - * @see #addChildAt() - * @see #getChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.setChildIndex = function (child, index) { - index = +index | 0; - if (index < 0 || index >= this.$children.length) { - index = this.$children.length - 1; - } - this.doSetChildIndex(child, index); - }; - /** - * @private - */ - DisplayObjectContainer.prototype.doSetChildIndex = function (child, index) { - var self = this; - var lastIndex = this.$children.indexOf(child); - if (lastIndex < 0) { - true && egret.$error(1006); - } - if (lastIndex == index) { - return; - } - this.$childRemoved(child, lastIndex); - //从原来的位置删除 - this.$children.splice(lastIndex, 1); - //放到新的位置 - this.$children.splice(index, 0, child); - this.$childAdded(child, index); - if (egret.nativeRender) { - this.$nativeDisplayObject.removeChild(child.$nativeDisplayObject.id); - this.$nativeDisplayObject.addChildAt(child.$nativeDisplayObject.id, index); - } - else { - if (!self.$cacheDirty) { - self.$cacheDirty = true; - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - } - }; - /** - * Swaps the z-order (front-to-back order) of the child objects at the two specified index positions in the child - * list. All other child objects in the display object container remain in the same index positions. - * @param index1 The index position of the first child object. - * @param index2 The index position of the second child object. - * @see #swapChildren() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在子级列表中两个指定的索引位置,交换子对象的 Z 轴顺序(前后顺序)。显示对象容器中所有其他子对象的索引位置保持不变。 - * @param index1 第一个子对象的索引位置。 - * @param index2 第二个子对象的索引位置。 - * @see #swapChildren() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.swapChildrenAt = function (index1, index2) { - index1 = +index1 | 0; - index2 = +index2 | 0; - if (index1 >= 0 && index1 < this.$children.length && index2 >= 0 && index2 < this.$children.length) { - this.doSwapChildrenAt(index1, index2); - } - else { - true && egret.$error(1007); - } - }; - /** - * Swaps the z-order (front-to-back order) of the two specified child objects. All other child objects in the - * display object container remain in the same index positions. - * @param child1 The first child object. - * @param child2 The second child object. - * @see #swapChildrenAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 交换两个指定子对象的 Z 轴顺序(从前到后顺序)。显示对象容器中所有其他子对象的索引位置保持不变。 - * @param child1 第一个子对象。 - * @param child2 第二个子对象。 - * @see #swapChildrenAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.swapChildren = function (child1, child2) { - var index1 = this.$children.indexOf(child1); - var index2 = this.$children.indexOf(child2); - if (index1 == -1 || index2 == -1) { - true && egret.$error(1006); - } - else { - this.doSwapChildrenAt(index1, index2); - } - }; - /** - * @private - */ - DisplayObjectContainer.prototype.doSwapChildrenAt = function (index1, index2) { - var self = this; - if (index1 > index2) { - var temp = index2; - index2 = index1; - index1 = temp; - } - else if (index1 == index2) { - return; - } - var list = this.$children; - var child1 = list[index1]; - var child2 = list[index2]; - this.$childRemoved(child1, index1); - this.$childRemoved(child2, index2); - list[index1] = child2; - list[index2] = child1; - this.$childAdded(child2, index1); - this.$childAdded(child1, index2); - if (egret.nativeRender) { - this.$nativeDisplayObject.swapChild(index1, index2); - } - else { - if (!self.$cacheDirty) { - self.$cacheDirty = true; - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - } - }; - /** - * Removes all child DisplayObject instances from the child list of the DisplayObjectContainer instance. The parent - * property of the removed children is set to null , and the objects are garbage collected if no other references to the children exist. - * @see #removeChild() - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 DisplayObjectContainer 实例的子级列表中删除所有 child DisplayObject 实例。 - * @see #removeChild() - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.removeChildren = function () { - var children = this.$children; - for (var i = children.length - 1; i >= 0; i--) { - this.$doRemoveChild(i); - } - }; - /** - * @private - * 一个子项被添加到容器内,此方法不仅在操作addChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 - * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 - */ - DisplayObjectContainer.prototype.$childAdded = function (child, index) { - }; - /** - * @private - * 一个子项从容器内移除,此方法不仅在操作removeChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 - * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 - */ - DisplayObjectContainer.prototype.$childRemoved = function (child, index) { - }; - /** - * @private - */ - DisplayObjectContainer.prototype.$onAddToStage = function (stage, nestLevel) { - _super.prototype.$onAddToStage.call(this, stage, nestLevel); - var children = this.$children; - var length = children.length; - nestLevel++; - for (var i = 0; i < length; i++) { - var child = this.$children[i]; - child.$onAddToStage(stage, nestLevel); - if (child.$maskedObject) { - child.$maskedObject.$updateRenderMode(); - } - } - }; - /** - * @private - * - */ - DisplayObjectContainer.prototype.$onRemoveFromStage = function () { - _super.prototype.$onRemoveFromStage.call(this); - var children = this.$children; - var length = children.length; - for (var i = 0; i < length; i++) { - var child = children[i]; - child.$onRemoveFromStage(); - } - }; - /** - * @private - */ - DisplayObjectContainer.prototype.$measureChildBounds = function (bounds) { - var children = this.$children; - var length = children.length; - if (length == 0) { - return; - } - var xMin = 0, xMax = 0, yMin = 0, yMax = 0; - var found = false; - for (var i = -1; i < length; i++) { - var childBounds = void 0; - if (i == -1) { - childBounds = bounds; - } - else { - children[i].getBounds(egret.$TempRectangle); - children[i].$getMatrix().$transformBounds(egret.$TempRectangle); - childBounds = egret.$TempRectangle; - } - if (childBounds.isEmpty()) { - continue; - } - if (found) { - xMin = Math.min(xMin, childBounds.x); - xMax = Math.max(xMax, childBounds.x + childBounds.width); - yMin = Math.min(yMin, childBounds.y); - yMax = Math.max(yMax, childBounds.y + childBounds.height); - } - else { - found = true; - xMin = childBounds.x; - xMax = xMin + childBounds.width; - yMin = childBounds.y; - yMax = yMin + childBounds.height; - } - } - bounds.setTo(xMin, yMin, xMax - xMin, yMax - yMin); - }; - Object.defineProperty(DisplayObjectContainer.prototype, "touchChildren", { - /** - * Determines whether or not the children of the object are touch, or user input device, enabled. If an object is - * enabled, a user can interact with it by using a touch or user input device. - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定对象的子级是否支持触摸或用户输入设备。如果对象支持触摸或用户输入设备,用户可以通过使用触摸或用户输入设备与之交互。 - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getTouchChildren(); - }, - set: function (value) { - this.$setTouchChildren(!!value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @returns - */ - DisplayObjectContainer.prototype.$getTouchChildren = function () { - return this.$touchChildren; - }; - /** - * @private - */ - DisplayObjectContainer.prototype.$setTouchChildren = function (value) { - if (this.$touchChildren == value) { - return false; - } - this.$touchChildren = value; - return true; - }; - /** - * @private - */ - DisplayObjectContainer.prototype.$hitTest = function (stageX, stageY) { - if (!this.$visible) { - return null; - } - var m = this.$getInvertedConcatenatedMatrix(); - var localX = m.a * stageX + m.c * stageY + m.tx; - var localY = m.b * stageX + m.d * stageY + m.ty; - var rect = this.$scrollRect ? this.$scrollRect : this.$maskRect; - if (rect && !rect.contains(localX, localY)) { - return null; - } - if (this.$mask && !this.$mask.$hitTest(stageX, stageY)) { - return null; - } - var children = this.$children; - var found = false; - var target = null; - for (var i = children.length - 1; i >= 0; i--) { - var child = children[i]; - if (child.$maskedObject) { - continue; - } - target = child.$hitTest(stageX, stageY); - if (target) { - found = true; - if (target.$touchEnabled) { - break; - } - else { - target = null; - } - } - } - if (target) { - if (this.$touchChildren) { - return target; - } - return this; - } - if (found) { - return this; - } - return _super.prototype.$hitTest.call(this, stageX, stageY); - }; - /** - * @private - */ - DisplayObjectContainer.$EVENT_ADD_TO_STAGE_LIST = []; - /** - * @private - */ - DisplayObjectContainer.$EVENT_REMOVE_FROM_STAGE_LIST = []; - return DisplayObjectContainer; - }(egret.DisplayObject)); - egret.DisplayObjectContainer = DisplayObjectContainer; - __reflect(DisplayObjectContainer.prototype, "egret.DisplayObjectContainer"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * SpriteSheet is a mosaic of multiple sub-bitmaps, comprising a plurality of Texture objects. - * Each Texture object shares the set bitmap of SpriteSheet, but it points to its different areas. - * On WebGL / OpenGL, this operation can significantly improve performance. - * At the same time, SpriteSheet can carry out material integration easily to reduce the number of HTTP requests - * For specification of the SpriteSheet format, see the document https://github.com/egret-labs/egret-core/wiki/Egret-SpriteSheet-Specification - * @see http://edn.egret.com/cn/docs/page/135 The use of texture packs - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/SpriteSheet.ts - * @language en_US - */ - /** - * SpriteSheet 是一张由多个子位图拼接而成的集合位图,它包含多个 Texture 对象。 - * 每一个 Texture 都共享 SpriteSheet 的集合位图,但是指向它的不同的区域。 - * 在WebGL / OpenGL上,这种做法可以显著提升性能 - * 同时,SpriteSheet可以很方便的进行素材整合,降低HTTP请求数量 - * SpriteSheet 格式的具体规范可以参见此文档 https://github.com/egret-labs/egret-core/wiki/Egret-SpriteSheet-Specification - * @see http://edn.egret.com/cn/docs/page/135 纹理集的使用 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/SpriteSheet.ts - * @language zh_CN - */ - var SpriteSheet = (function (_super) { - __extends(SpriteSheet, _super); - /** - * Create an egret.SpriteSheet object - * @param texture {Texture} Texture - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.SpriteSheet 对象 - * @param texture {Texture} 纹理 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function SpriteSheet(texture) { - var _this = _super.call(this) || this; - /** - * @private - * 表示这个SpriteSheet的位图区域在bitmapData上的起始位置x。 - */ - _this._bitmapX = 0; - /** - * @private - * 表示这个SpriteSheet的位图区域在bitmapData上的起始位置y。 - */ - _this._bitmapY = 0; - /** - * @private - * 纹理缓存字典 - */ - _this._textureMap = egret.createMap(); - _this.$texture = texture; - _this._bitmapX = texture.$bitmapX - texture.$offsetX; - _this._bitmapY = texture.$bitmapY - texture.$offsetY; - return _this; - } - /** - * Obtain a cached Texture object according to the specified texture name - * @param name {string} Cache the name of this Texture object - * @returns {egret.Texture} The Texture object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 根据指定纹理名称获取一个缓存的 Texture 对象 - * @param name {string} 缓存这个 Texture 对象所使用的名称 - * @returns {egret.Texture} Texture 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - SpriteSheet.prototype.getTexture = function (name) { - return this._textureMap[name]; - }; - /** - * Create a new Texture object for the specified area on SpriteSheet and cache it - * @param name {string} Cache the name of this Texture object. If the name already exists, the previous Texture object will be overwrited. - * @param bitmapX {number} Starting coordinate x of texture area on bitmapData - * @param bitmapY {number} Starting coordinate y of texture area on bitmapData - * @param bitmapWidth {number} Width of texture area on bitmapData - * @param bitmapHeight {number} Height of texture area on bitmapData - * @param offsetX {number} Starting point x for a non-transparent area of the original bitmap - * @param offsetY {number} Starting point y for a non-transparent area of the original bitmap - * @param textureWidth {number} Width of the original bitmap. If it is not passed, use the bitmapWidth value. - * @param textureHeight {number} Height of the original bitmap. If it is not passed, use the bitmapHeight value. - * @returns {egret.Texture} The created Texture object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 为 SpriteSheet 上的指定区域创建一个新的 Texture 对象并缓存它 - * @param name {string} 缓存这个 Texture 对象所使用的名称,如果名称已存在,将会覆盖之前的 Texture 对象 - * @param bitmapX {number} 纹理区域在 bitmapData 上的起始坐标x - * @param bitmapY {number} 纹理区域在 bitmapData 上的起始坐标y - * @param bitmapWidth {number} 纹理区域在 bitmapData 上的宽度 - * @param bitmapHeight {number} 纹理区域在 bitmapData 上的高度 - * @param offsetX {number} 原始位图的非透明区域 x 起始点 - * @param offsetY {number} 原始位图的非透明区域 y 起始点 - * @param textureWidth {number} 原始位图的高度,若不传入,则使用 bitmapWidth 的值。 - * @param textureHeight {number} 原始位图的宽度,若不传入,则使用 bitmapHeight 的值。 - * @returns {egret.Texture} 创建的 Texture 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - SpriteSheet.prototype.createTexture = function (name, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight) { - if (offsetX === void 0) { offsetX = 0; } - if (offsetY === void 0) { offsetY = 0; } - if (textureWidth === void 0) { - textureWidth = offsetX + bitmapWidth; - } - if (textureHeight === void 0) { - textureHeight = offsetY + bitmapHeight; - } - var texture = new egret.Texture(); - texture.disposeBitmapData = false; - texture.$bitmapData = this.$texture.$bitmapData; - texture.$initData(this._bitmapX + bitmapX, this._bitmapY + bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, this.$texture.$sourceWidth, this.$texture.$sourceHeight); - this._textureMap[name] = texture; - return texture; - }; - /** - * dispose texture - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放纹理 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - SpriteSheet.prototype.dispose = function () { - if (this.$texture) { - this.$texture.dispose(); - } - }; - return SpriteSheet; - }(egret.HashObject)); - egret.SpriteSheet = SpriteSheet; - __reflect(SpriteSheet.prototype, "egret.SpriteSheet"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - */ - egret.$locale_strings = egret.$locale_strings || {}; - /** - * @private - */ - egret.$language = "en_US"; -})(egret || (egret = {})); -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 全局多语言翻译函数 - * @param code 要查询的字符串代码 - * @param args 替换字符串中{0}标志的参数列表 - * @returns 返回拼接后的字符串 - */ - function tr(code) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - var text = egret.$locale_strings[egret.$language][code]; - if (!text) { - return "{" + code + "}"; - } - var length = args.length; - for (var i = 0; i < length; i++) { - text = text.replace("{" + i + "}", args[i]); - } - return text; - } - sys.tr = tr; - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The Bitmap class represents display objects that represent bitmap images. - * The Bitmap() constructor allows you to create a Bitmap object that contains a reference to a BitmapData object. - * After you create a Bitmap object, use the addChild() or addChildAt() method of the parent DisplayObjectContainer - * instance to place the bitmap on the display list.A Bitmap object can share its texture reference among several - * Bitmap objects, independent of translation or rotation properties. Because you can create multiple Bitmap objects - * that reference the same texture object, multiple display objects can use the same complex texture object - * without incurring the memory overhead of a texture object for each display object instance. - * - * @see egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Bitmap.ts - * @language en_US - */ - /** - * Bitmap 类表示用于显示位图图片的显示对象。 - * 利用 Bitmap() 构造函数,可以创建包含对 BitmapData 对象引用的 Bitmap 对象。创建了 Bitmap 对象后, - * 使用父级 DisplayObjectContainer 实例的 addChild() 或 addChildAt() 方法可以将位图放在显示列表中。 - * 一个 Bitmap 对象可在若干 Bitmap 对象之中共享其 texture 引用,与缩放或旋转属性无关。 - * 由于能够创建引用相同 texture 对象的多个 Bitmap 对象,因此,多个显示对象可以使用相同的 texture 对象, - * 而不会因为每个显示对象实例使用一个 texture 对象而产生额外内存开销。 - * - * @see egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Bitmap.ts - * @language zh_CN - */ - var Bitmap = (function (_super) { - __extends(Bitmap, _super); - /** - * Initializes a Bitmap object to refer to the specified Texture object. - * @param value The Texture object being referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个引用指定 Texture 实例的 Bitmap 对象 - * @param value 被引用的 Texture 实例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Bitmap(value) { - var _this = _super.call(this) || this; - _this.$texture = null; - _this.$bitmapData = null; - _this.$bitmapX = 0; - _this.$bitmapY = 0; - _this.$bitmapWidth = 0; - _this.$bitmapHeight = 0; - _this.$offsetX = 0; - _this.$offsetY = 0; - _this.$textureWidth = 0; - _this.$textureHeight = 0; - _this.$sourceWidth = 0; - _this.$sourceHeight = 0; - _this.$smoothing = Bitmap.defaultSmoothing; - _this.$explicitBitmapWidth = NaN; - _this.$explicitBitmapHeight = NaN; - /** - * @private - */ - _this.$scale9Grid = null; - /** - * @private - */ - _this.$fillMode = "scale"; - _this._pixelHitTest = false; - _this.$renderNode = new egret.sys.NormalBitmapNode(); - _this.$setTexture(value); - if (value) { - _this.$renderNode.rotated = value.$rotated; - } - return _this; - } - Bitmap.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(1 /* BITMAP */); - }; - /** - * @private - * 显示对象添加到舞台 - */ - Bitmap.prototype.$onAddToStage = function (stage, nestLevel) { - _super.prototype.$onAddToStage.call(this, stage, nestLevel); - var texture = this.$texture; - if (texture && texture.$bitmapData) { - egret.BitmapData.$addDisplayObject(this, texture.$bitmapData); - } - }; - /** - * @private - * 显示对象从舞台移除 - */ - Bitmap.prototype.$onRemoveFromStage = function () { - _super.prototype.$onRemoveFromStage.call(this); - var texture = this.$texture; - if (texture) { - egret.BitmapData.$removeDisplayObject(this, texture.$bitmapData); - } - }; - Object.defineProperty(Bitmap.prototype, "texture", { - /** - * The Texture object being referenced. - * If you pass the constructor of type BitmapData or last set for bitmapData, this value returns null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的 Texture 对象。 - * 如果传入构造函数的类型为 BitmapData 或者最后设置的为 bitmapData,则此值返回 null。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$texture; - }, - set: function (value) { - var self = this; - self.$setTexture(value); - if (value && self.$renderNode) { - self.$renderNode.rotated = value.$rotated; - } - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - Bitmap.prototype.$setTexture = function (value) { - var self = this; - var oldTexture = self.$texture; - if (value == oldTexture) { - return false; - } - self.$texture = value; - if (value) { - self.$refreshImageData(); - } - else { - if (oldTexture) { - egret.BitmapData.$removeDisplayObject(self, oldTexture.$bitmapData); - } - self.setImageData(null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - self.$renderDirty = true; - var p_1 = self.$parent; - if (p_1 && !p_1.$cacheDirty) { - p_1.$cacheDirty = true; - p_1.$cacheDirtyUp(); - } - var maskedObject_1 = self.$maskedObject; - if (maskedObject_1 && !maskedObject_1.$cacheDirty) { - maskedObject_1.$cacheDirty = true; - maskedObject_1.$cacheDirtyUp(); - } - if (egret.nativeRender) { - this.setBitmapDataToWasm(null); - } - return true; - } - if (self.$stage) { - if (oldTexture && oldTexture.$bitmapData) { - var oldHashCode = oldTexture.$bitmapData.hashCode; - var newHashCode = value.$bitmapData ? value.$bitmapData.hashCode : -1; - if (oldHashCode == newHashCode) { - self.$renderDirty = true; - var p_2 = self.$parent; - if (p_2 && !p_2.$cacheDirty) { - p_2.$cacheDirty = true; - p_2.$cacheDirtyUp(); - } - var maskedObject_2 = self.$maskedObject; - if (maskedObject_2 && !maskedObject_2.$cacheDirty) { - maskedObject_2.$cacheDirty = true; - maskedObject_2.$cacheDirtyUp(); - } - return true; - } - egret.BitmapData.$removeDisplayObject(self, oldTexture.$bitmapData); - } - egret.BitmapData.$addDisplayObject(self, value.$bitmapData); - } - self.$renderDirty = true; - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - return true; - }; - Bitmap.prototype.$setBitmapData = function (value) { - this.$setTexture(value); - }; - /** - * @private - */ - Bitmap.prototype.setBitmapDataToWasm = function (data) { - this.$nativeDisplayObject.setBitmapData(data); - }; - /** - * @private - */ - Bitmap.prototype.$refreshImageData = function () { - var texture = this.$texture; - if (texture) { - if (egret.nativeRender) { - this.setBitmapDataToWasm(texture); - } - this.setImageData(texture.$bitmapData, texture.$bitmapX, texture.$bitmapY, texture.$bitmapWidth, texture.$bitmapHeight, texture.$offsetX, texture.$offsetY, texture.$getTextureWidth(), texture.$getTextureHeight(), texture.$sourceWidth, texture.$sourceHeight); - } - else { - if (egret.nativeRender) { - this.setBitmapDataToWasm(null); - } - } - }; - /** - * @private - */ - Bitmap.prototype.setImageData = function (bitmapData, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, sourceWidth, sourceHeight) { - this.$bitmapData = bitmapData; - this.$bitmapX = bitmapX; - this.$bitmapY = bitmapY; - this.$bitmapWidth = bitmapWidth; - this.$bitmapHeight = bitmapHeight; - this.$offsetX = offsetX; - this.$offsetY = offsetY; - this.$textureWidth = textureWidth; - this.$textureHeight = textureHeight; - this.$sourceWidth = sourceWidth; - this.$sourceHeight = sourceHeight; - }; - Object.defineProperty(Bitmap.prototype, "scale9Grid", { - /** - * Represent a Rectangle Area that the 9 scale area of Image. - * Notice: This property is valid only when fillMode - * is BitmapFillMode.SCALE. - * - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形区域,它定义素材对象的九个缩放区域。 - * 注意:此属性仅在fillModeBitmapFillMode.SCALE时有效。 - * - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$scale9Grid; - }, - set: function (value) { - this.$setScale9Grid(value); - }, - enumerable: true, - configurable: true - }); - Bitmap.prototype.$setScale9Grid = function (value) { - var self = this; - self.$scale9Grid = value; - self.$renderDirty = true; - if (egret.nativeRender) { - if (value) { - self.$nativeDisplayObject.setScale9Grid(value.x, value.y, value.width, value.height); - } - else { - self.$nativeDisplayObject.setScale9Grid(0, 0, -1, -1); - } - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(Bitmap.prototype, "fillMode", { - /** - * Determines how the bitmap fills in the dimensions. - *

    When set to BitmapFillMode.REPEAT, the bitmap - * repeats to fill the region.

    - *

    When set to BitmapFillMode.SCALE, the bitmap - * stretches to fill the region.

    - * - * @default BitmapFillMode.SCALE - * - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 确定位图填充尺寸的方式。 - *

    设置为 BitmapFillMode.REPEAT时,位图将重复以填充区域。

    - *

    设置为 BitmapFillMode.SCALE时,位图将拉伸以填充区域。

    - * - * @default BitmapFillMode.SCALE - * - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$fillMode; - }, - set: function (value) { - this.$setFillMode(value); - }, - enumerable: true, - configurable: true - }); - Bitmap.prototype.$setFillMode = function (value) { - if (value == this.$fillMode) { - return false; - } - this.$fillMode = value; - if (egret.nativeRender) { - this.$nativeDisplayObject.setBitmapFillMode(this.$fillMode); - } - return true; - }; - Object.defineProperty(Bitmap.prototype, "smoothing", { - /** - * Whether or not the bitmap is smoothed when scaled. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否对位图进行平滑处理。 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$smoothing; - }, - set: function (value) { - if (value == this.$smoothing) { - return; - } - this.$smoothing = value; - this.$renderNode.smoothing = value; - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - Bitmap.prototype.$setWidth = function (value) { - var self = this; - if (value < 0 || value == self.$explicitBitmapWidth) { - return false; - } - self.$explicitBitmapWidth = value; - self.$renderDirty = true; - if (egret.nativeRender) { - self.$nativeDisplayObject.setWidth(value); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - return true; - }; - /** - * @private - * - * @param value - */ - Bitmap.prototype.$setHeight = function (value) { - var self = this; - if (value < 0 || value == self.$explicitBitmapHeight) { - return false; - } - self.$explicitBitmapHeight = value; - self.$renderDirty = true; - if (egret.nativeRender) { - self.$nativeDisplayObject.setHeight(value); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - return true; - }; - /** - * @private - * 获取显示宽度 - */ - Bitmap.prototype.$getWidth = function () { - return isNaN(this.$explicitBitmapWidth) ? this.$getContentBounds().width : this.$explicitBitmapWidth; - }; - /** - * @private - * 获取显示宽度 - */ - Bitmap.prototype.$getHeight = function () { - return isNaN(this.$explicitBitmapHeight) ? this.$getContentBounds().height : this.$explicitBitmapHeight; - }; - /** - * @private - */ - Bitmap.prototype.$measureContentBounds = function (bounds) { - if (this.$bitmapData) { - var w = !isNaN(this.$explicitBitmapWidth) ? this.$explicitBitmapWidth : this.$textureWidth; - var h = !isNaN(this.$explicitBitmapHeight) ? this.$explicitBitmapHeight : this.$textureHeight; - bounds.setTo(0, 0, w, h); - } - else { - var w = !isNaN(this.$explicitBitmapWidth) ? this.$explicitBitmapWidth : 0; - var h = !isNaN(this.$explicitBitmapHeight) ? this.$explicitBitmapHeight : 0; - bounds.setTo(0, 0, w, h); - } - }; - /** - * @private - */ - Bitmap.prototype.$updateRenderNode = function () { - if (this.$texture) { - var destW = !isNaN(this.$explicitBitmapWidth) ? this.$explicitBitmapWidth : this.$textureWidth; - var destH = !isNaN(this.$explicitBitmapHeight) ? this.$explicitBitmapHeight : this.$textureHeight; - var scale9Grid = this.scale9Grid || this.$texture["scale9Grid"]; - if (scale9Grid) { - if (this.$renderNode instanceof egret.sys.NormalBitmapNode) { - this.$renderNode = new egret.sys.BitmapNode(); - } - egret.sys.BitmapNode.$updateTextureDataWithScale9Grid(this.$renderNode, this.$bitmapData, scale9Grid, this.$bitmapX, this.$bitmapY, this.$bitmapWidth, this.$bitmapHeight, this.$offsetX, this.$offsetY, this.$textureWidth, this.$textureHeight, destW, destH, this.$sourceWidth, this.$sourceHeight, this.$smoothing); - } - else { - if (this.fillMode == egret.BitmapFillMode.REPEAT && this.$renderNode instanceof egret.sys.NormalBitmapNode) { - this.$renderNode = new egret.sys.BitmapNode(); - } - egret.sys.BitmapNode.$updateTextureData(this.$renderNode, this.$bitmapData, this.$bitmapX, this.$bitmapY, this.$bitmapWidth, this.$bitmapHeight, this.$offsetX, this.$offsetY, this.$textureWidth, this.$textureHeight, destW, destH, this.$sourceWidth, this.$sourceHeight, this.$fillMode, this.$smoothing); - } - } - }; - Object.defineProperty(Bitmap.prototype, "pixelHitTest", { - /** - * Specifies whether this object use precise hit testing by checking the alpha value of each pixel.If pixelHitTest - * is set to true,the transparent area of the bitmap will be touched through.
    - * Note:If the image is loaded from cross origin,that we can't access to the pixel data,so it might cause - * the pixelHitTest property invalid. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否开启精确像素碰撞。设置为true显示对象本身的透明区域将能够被穿透。
    - * 注意:若图片资源是以跨域方式从外部服务器加载的,将无法访问图片的像素数据,而导致此属性失效。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._pixelHitTest; - }, - set: function (value) { - this._pixelHitTest = !!value; - }, - enumerable: true, - configurable: true - }); - Bitmap.prototype.$hitTest = function (stageX, stageY) { - var target = _super.prototype.$hitTest.call(this, stageX, stageY); - if (target && this._pixelHitTest) { - var boo = this.hitTestPoint(stageX, stageY, true); - if (!boo) { - target = null; - } - } - return target; - }; - /** - * The default value of whether or not is smoothed when scaled. - * When object such as Bitmap is created,smoothing property will be set to this value. - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否进行平滑处理的默认值。 - * 在 Bitmap 等对象创建时,smoothing 属性会被设置为该值。 - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language zh_CN - */ - Bitmap.defaultSmoothing = true; - return Bitmap; - }(egret.DisplayObject)); - egret.Bitmap = Bitmap; - __reflect(Bitmap.prototype, "egret.Bitmap"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 渲染节点基类 - */ - var RenderNode = (function () { - function RenderNode() { - /** - * 节点类型.. - */ - this.type = 0; - /** - * 绘制数据 - */ - this.drawData = []; - /** - * 绘制次数 - */ - this.renderCount = 0; - } - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - RenderNode.prototype.cleanBeforeRender = function () { - this.drawData.length = 0; - this.renderCount = 0; - }; - RenderNode.prototype.$getRenderCount = function () { - return this.renderCount; - }; - return RenderNode; - }()); - sys.RenderNode = RenderNode; - __reflect(RenderNode.prototype, "egret.sys.RenderNode"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 2D路径 - */ - var Path2D = (function () { - function Path2D() { - /** - * 路径类型 - */ - this.type = 0; - this.$commands = []; - this.$data = []; - this.commandPosition = 0; - this.dataPosition = 0; - /** - * 当前移动到的坐标X - * 注意:目前只有drawArc之前会被赋值 - */ - this.$lastX = 0; - /** - * 当前移动到的坐标Y - * 注意:目前只有drawArc之前会被赋值 - */ - this.$lastY = 0; - } - /** - * 将当前绘图位置移动到 (x, y)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - */ - Path2D.prototype.moveTo = function (x, y) { - this.$commands[this.commandPosition++] = 1 /* MoveTo */; - var pos = this.dataPosition; - this.$data[pos++] = x; - this.$data[pos++] = y; - this.dataPosition = pos; - }; - /** - * 使用当前线条样式绘制一条从当前绘图位置开始到 (x, y) 结束的直线;当前绘图位置随后会设置为 (x, y)。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - */ - Path2D.prototype.lineTo = function (x, y) { - this.$commands[this.commandPosition++] = 2 /* LineTo */; - var pos = this.dataPosition; - this.$data[pos++] = x; - this.$data[pos++] = y; - this.dataPosition = pos; - }; - /** - * 使用当前线条样式和由 (controlX, controlY) 指定的控制点绘制一条从当前绘图位置开始到 (anchorX, anchorY) 结束的二次贝塞尔曲线。当前绘图位置随后设置为 (anchorX, anchorY)。 - * 如果在调用 moveTo() 方法之前调用了 curveTo() 方法,则当前绘图位置的默认值为 (0, 0)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * 绘制的曲线是二次贝塞尔曲线。二次贝塞尔曲线包含两个锚点和一个控制点。该曲线内插这两个锚点,并向控制点弯曲。 - * @param controlX 一个数字,指定控制点相对于父显示对象注册点的水平位置。 - * @param controlY 一个数字,指定控制点相对于父显示对象注册点的垂直位置。 - * @param anchorX 一个数字,指定下一个锚点相对于父显示对象注册点的水平位置。 - * @param anchorY 一个数字,指定下一个锚点相对于父显示对象注册点的垂直位置。 - */ - Path2D.prototype.curveTo = function (controlX, controlY, anchorX, anchorY) { - this.$commands[this.commandPosition++] = 3 /* CurveTo */; - var pos = this.dataPosition; - this.$data[pos++] = controlX; - this.$data[pos++] = controlY; - this.$data[pos++] = anchorX; - this.$data[pos++] = anchorY; - this.dataPosition = pos; - }; - /** - * 从当前绘图位置到指定的锚点绘制一条三次贝塞尔曲线。三次贝塞尔曲线由两个锚点和两个控制点组成。该曲线内插这两个锚点,并向两个控制点弯曲。 - * @param controlX1 指定首个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY1 指定首个控制点相对于父显示对象的注册点的垂直位置。 - * @param controlX2 指定第二个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY2 指定第二个控制点相对于父显示对象的注册点的垂直位置。 - * @param anchorX 指定锚点相对于父显示对象的注册点的水平位置。 - * @param anchorY 指定锚点相对于父显示对象的注册点的垂直位置。 - */ - Path2D.prototype.cubicCurveTo = function (controlX1, controlY1, controlX2, controlY2, anchorX, anchorY) { - this.$commands[this.commandPosition++] = 4 /* CubicCurveTo */; - var pos = this.dataPosition; - this.$data[pos++] = controlX1; - this.$data[pos++] = controlY1; - this.$data[pos++] = controlX2; - this.$data[pos++] = controlY2; - this.$data[pos++] = anchorX; - this.$data[pos++] = anchorY; - this.dataPosition = pos; - }; - /** - * 绘制一个矩形 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - */ - Path2D.prototype.drawRect = function (x, y, width, height) { - var x2 = x + width; - var y2 = y + height; - this.moveTo(x, y); - this.lineTo(x2, y); - this.lineTo(x2, y2); - this.lineTo(x, y2); - this.lineTo(x, y); - }; - /** - * 绘制一个圆角矩形。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @param ellipseWidth 用于绘制圆角的椭圆的宽度(以像素为单位)。 - * @param ellipseHeight 用于绘制圆角的椭圆的高度(以像素为单位)。 (可选)如果未指定值,则默认值与为 ellipseWidth 参数提供的值相匹配。 - */ - Path2D.prototype.drawRoundRect = function (x, y, width, height, ellipseWidth, ellipseHeight) { - var radiusX = (ellipseWidth * 0.5) | 0; - var radiusY = ellipseHeight ? (ellipseHeight * 0.5) | 0 : radiusX; - if (!radiusX || !radiusY) { - this.drawRect(x, y, width, height); - return; - } - var hw = width * 0.5; - var hh = height * 0.5; - if (radiusX > hw) { - radiusX = hw; - } - if (radiusY > hh) { - radiusY = hh; - } - if (hw === radiusX && hh === radiusY) { - if (radiusX === radiusY) { - this.drawCircle(x + radiusX, y + radiusY, radiusX); - } - else { - this.drawEllipse(x, y, radiusX * 2, radiusY * 2); - } - return; - } - // A-----B - // H C - // G D - // F-----E - // 从D点开始,结束在D点 - var right = x + width; - var bottom = y + height; - var xlw = x + radiusX; - var xrw = right - radiusX; - var ytw = y + radiusY; - var ybw = bottom - radiusY; - this.moveTo(right, ybw); - this.curveTo(right, bottom, xrw, bottom); - this.lineTo(xlw, bottom); - this.curveTo(x, bottom, x, ybw); - this.lineTo(x, ytw); - this.curveTo(x, y, xlw, y); - this.lineTo(xrw, y); - this.curveTo(right, y, right, ytw); - this.lineTo(right, ybw); - }; - /** - * 绘制一个圆。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param radius 圆的半径(以像素为单位)。 - */ - Path2D.prototype.drawCircle = function (x, y, radius) { - this.arcToBezier(x, y, radius, radius, 0, Math.PI * 2); - }; - /** - * 绘制一个椭圆。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - */ - Path2D.prototype.drawEllipse = function (x, y, width, height) { - var radiusX = width * 0.5; - var radiusY = height * 0.5; - // 移动x和y到椭圆的中心. - x += radiusX; - y += radiusY; - this.arcToBezier(x, y, radiusX, radiusY, 0, Math.PI * 2); - }; - /** - * 绘制一段圆弧路径。圆弧路径的圆心在 (x, y) 位置,半径为 r ,根据anticlockwise (默认为顺时针)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radius 圆弧的半径。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * 注意,必须在0~2π之间。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * 注意,必须在0~2π之间。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - */ - Path2D.prototype.drawArc = function (x, y, radius, startAngle, endAngle, anticlockwise) { - if (anticlockwise) { - if (endAngle >= startAngle) { - endAngle -= Math.PI * 2; - } - } - else { - if (endAngle <= startAngle) { - endAngle += Math.PI * 2; - } - } - this.arcToBezier(x, y, radius, radius, startAngle, endAngle, anticlockwise); - }; - /** - * 绘制一段圆弧路径 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radiusX 圆弧的半径 x。 - * @param radiusY 圆弧的半径 y。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * 注意:必须为正数。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * 注意:与startAngle差值必须在0~2π之间。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - * 注意:如果为true,endAngle必须小于startAngle,反之必须大于。 - */ - Path2D.prototype.arcToBezier = function (x, y, radiusX, radiusY, startAngle, endAngle, anticlockwise) { - var halfPI = Math.PI * 0.5; - var start = startAngle; - var end = start; - if (anticlockwise) { - end += -halfPI - (start % halfPI); - if (end < endAngle) { - end = endAngle; - } - } - else { - end += halfPI - (start % halfPI); - if (end > endAngle) { - end = endAngle; - } - } - var currentX = x + Math.cos(start) * radiusX; - var currentY = y + Math.sin(start) * radiusY; - if (this.$lastX != currentX || this.$lastY != currentY) { - this.moveTo(currentX, currentY); - } - var u = Math.cos(start); - var v = Math.sin(start); - for (var i = 0; i < 4; i++) { - var addAngle = end - start; - var a = 4 * Math.tan(addAngle / 4) / 3; - var x1 = currentX - v * a * radiusX; - var y1 = currentY + u * a * radiusY; - u = Math.cos(end); - v = Math.sin(end); - currentX = x + u * radiusX; - currentY = y + v * radiusY; - var x2 = currentX + v * a * radiusX; - var y2 = currentY - u * a * radiusY; - this.cubicCurveTo(x1, y1, x2, y2, currentX, currentY); - if (end === endAngle) { - break; - } - start = end; - if (anticlockwise) { - end = start - halfPI; - if (end < endAngle) { - end = endAngle; - } - } - else { - end = start + halfPI; - if (end > endAngle) { - end = endAngle; - } - } - } - }; - return Path2D; - }()); - sys.Path2D = Path2D; - __reflect(Path2D.prototype, "egret.sys.Path2D"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/** - * @private - */ -var egret; -(function (egret) { - //todo remove - /** - * @private - */ - egret.fontMapping = {}; -})(egret || (egret = {})); -var egret; -(function (egret) { - /** - * @private - */ - function createMap() { - var obj = Object.create(null); - obj.__v8__ = undefined; - delete obj.__v8__; - return obj; - } - egret.createMap = createMap; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @class egret.GlowFilter - * @classdesc - * 使用 GlowFilter 类可以对显示对象应用发光效果。在投影滤镜的 distance 和 angle 属性设置为 0 时,发光滤镜与投影滤镜极为相似。 - * @extends egret.Filter - * @version Egret 3.1.4 - * @platform Web,Native - */ - var GlowFilter = (function (_super) { - __extends(GlowFilter, _super); - /** - * Initializes a new GlowFilter instance. - * @method egret.GlowFilter#constructor - * @param color {number} The color of the glow. Valid values are in the hexadecimal format 0xRRGGBB. The default value is 0xFF0000. - * @param alpha {number} The alpha transparency value for the color. Valid values are 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1. - * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point). - * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point). - * @param strength {number} The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255. - * @param quality {number} The number of times to apply the filter. - * @param inner {boolean} Specifies whether the glow is an inner glow. The value true indicates an inner glow. The default is false, an outer glow (a glow around the outer edges of the object). - * @param knockout {number} Specifies whether the object has a knockout effect. A value of true makes the object's fill transparent and reveals the background color of the document. The default value is false (no knockout effect). - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 初始化 GlowFilter 对象 - * @method egret.GlowFilter#constructor - * @param color {number} 光晕颜色,采用十六进制格式 0xRRGGBB。默认值为 0xFF0000。 - * @param alpha {number} 颜色的 Alpha 透明度值。有效值为 0 到 1。例如,0.25 设置透明度值为 25%。 - * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。 - * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。 - * @param strength {number} 印记或跨页的强度。该值越高,压印的颜色越深,而且发光与背景之间的对比度也越强。有效值为 0 到 255。 - * @param quality {number} 应用滤镜的次数。暂未实现。 - * @param inner {boolean} 指定发光是否为内侧发光。值 true 指定发光是内侧发光。值 false 指定发光是外侧发光(对象外缘周围的发光)。 - * @param knockout {number} 指定对象是否具有挖空效果。值为 true 将使对象的填充变为透明,并显示文档的背景颜色。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - function GlowFilter(color, alpha, blurX, blurY, strength, quality, inner, knockout) { - if (color === void 0) { color = 0xFF0000; } - if (alpha === void 0) { alpha = 1.0; } - if (blurX === void 0) { blurX = 6.0; } - if (blurY === void 0) { blurY = 6.0; } - if (strength === void 0) { strength = 2; } - if (quality === void 0) { quality = 1; } - if (inner === void 0) { inner = false; } - if (knockout === void 0) { knockout = false; } - var _this = _super.call(this) || this; - var self = _this; - self.type = "glow"; - self.$color = color; - self.$blue = color & 0x0000FF; - self.$green = (color & 0x00ff00) >> 8; - self.$red = color >> 16; - self.$alpha = alpha; - self.$blurX = blurX; - self.$blurY = blurY; - self.$strength = strength; - self.$quality = quality; - self.$inner = inner; - self.$knockout = knockout; - self.$uniforms.color = { x: _this.$red / 255, y: _this.$green / 255, z: _this.$blue / 255, w: 1 }; - self.$uniforms.alpha = alpha; - self.$uniforms.blurX = blurX; - self.$uniforms.blurY = blurY; - self.$uniforms.strength = strength; - // this.$uniforms.quality = quality; - self.$uniforms.inner = inner ? 1 : 0; - self.$uniforms.knockout = knockout ? 0 : 1; - self.$uniforms.dist = 0; - self.$uniforms.angle = 0; - self.$uniforms.hideObject = 0; - self.onPropertyChange(); - return _this; - } - Object.defineProperty(GlowFilter.prototype, "color", { - /** - * The color of the glow. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 光晕颜色。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$color; - }, - set: function (value) { - if (this.$color == value) { - return; - } - this.$color = value; - this.$blue = value & 0x0000FF; - this.$green = (value & 0x00ff00) >> 8; - this.$red = value >> 16; - this.$uniforms.color.x = this.$red / 255; - this.$uniforms.color.y = this.$green / 255; - this.$uniforms.color.z = this.$blue / 255; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GlowFilter.prototype, "alpha", { - /** - * The alpha transparency value for the color. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 颜色的 Alpha 透明度值。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$alpha; - }, - set: function (value) { - if (this.$alpha == value) { - return; - } - this.$alpha = value; - this.$uniforms.alpha = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GlowFilter.prototype, "blurX", { - /** - * The amount of horizontal blur. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 水平模糊量。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$blurX; - }, - set: function (value) { - var self = this; - if (self.$blurX == value) { - return; - } - self.$blurX = value; - self.$uniforms.blurX = value; - self.onPropertyChange(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GlowFilter.prototype, "blurY", { - /** - * The amount of vertical blur. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 垂直模糊量。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$blurY; - }, - set: function (value) { - var self = this; - if (self.$blurY == value) { - return; - } - self.$blurY = value; - self.$uniforms.blurY = value; - self.onPropertyChange(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GlowFilter.prototype, "strength", { - /** - * The strength of the imprint or spread. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 印记或跨页的强度。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$strength; - }, - set: function (value) { - if (this.$strength == value) { - return; - } - this.$strength = value; - this.$uniforms.strength = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GlowFilter.prototype, "quality", { - /** - * The number of times to apply the filter. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 应用滤镜的次数。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$quality; - }, - set: function (value) { - if (this.$quality == value) { - return; - } - this.$quality = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GlowFilter.prototype, "inner", { - /** - * Specifies whether the glow is an inner glow. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 指定发光是否为内侧发光。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$inner; - }, - set: function (value) { - if (this.$inner == value) { - return; - } - this.$inner = value; - this.$uniforms.inner = value ? 1 : 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GlowFilter.prototype, "knockout", { - /** - * Specifies whether the object has a knockout effect. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 指定对象是否具有挖空效果。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$knockout; - }, - set: function (value) { - if (this.$knockout == value) { - return; - } - this.$knockout = value; - this.$uniforms.knockout = value ? 0 : 1; - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - GlowFilter.prototype.$toJson = function () { - return '{"color": ' + this.$color + ', "red": ' + this.$red + ', "green": ' + this.$green + ', "blue": ' + this.$blue + ', "alpha": ' + this.$alpha + ', "blurX": ' + this.$blurX + ', "blurY": ' + this.blurY + ', "strength": ' + this.$strength + ', "quality": ' + this.$quality + ', "inner": ' + this.$inner + ', "knockout": ' + this.$knockout + '}'; - }; - GlowFilter.prototype.updatePadding = function () { - var self = this; - self.paddingLeft = self.blurX; - self.paddingRight = self.blurX; - self.paddingTop = self.blurY; - self.paddingBottom = self.blurY; - }; - return GlowFilter; - }(egret.Filter)); - egret.GlowFilter = GlowFilter; - __reflect(GlowFilter.prototype, "egret.GlowFilter"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - //混合模式在Web端只有部分被支持,在 Native 中全部都支持。 - //目前所有平台的浏览器都支持的有:Layer,Alpha,Normal,Add,ERASE。 - //IOS中的所有浏览器以及Android内的部分浏览器还支持:Multiply,Screen,Lighten,Darken,Difference,Overlay,HardLight。 - //仅在 Native 端支持的有:Subtract,Invert。 - /** - * A class that provides constant values for visual blend mode effects. These constants are used in the blendMode - * property of the DisplayObject class. - * @see egret.DisplayObject#blendMode - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BlendMode.ts - * @see http://edn.egret.com/cn/docs/page/108 显示容器的概念与实现 - * @language en_US - */ - /** - * 提供混合模式可视效果的常量值的类,通常用于 DisplayObject 的 blendMode 属性上。 - * @see egret.DisplayObject#blendMode - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BlendMode.ts - * @see http://edn.egret.com/cn/docs/page/108 显示容器的概念与实现 - * @language zh_CN - */ - var BlendMode = (function () { - function BlendMode() { - } - /** - * The display object appears in front of the background. Pixel values of the display object override the pixel - * values of the background. Where the display object is transparent, the background is visible. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该显示对象出现在背景前面。显示对象的像素值会覆盖背景的像素值。在显示对象为透明的区域,背景是可见的。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - BlendMode.NORMAL = "normal"; - /** - * Adds the values of the constituent colors of the display object to the colors of its background, applying a - * ceiling of 0xFF. This setting is commonly used for animating a lightening dissolve between two objects.
    - * For example, if the display object has a pixel with an RGB value of 0xAAA633, and the background pixel has an - * RGB value of 0xDD2200, the resulting RGB value for the displayed pixel is 0xFFC833 (because 0xAA + 0xDD > 0xFF, - * 0xA6 + 0x22 = 0xC8, and 0x33 + 0x00 = 0x33). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将显示对象的原色值添加到它的背景颜色中,上限值为 0xFF。此设置通常用于使两个对象间的加亮溶解产生动画效果。
    - * 例如,如果显示对象的某个像素的 RGB 值为 0xAAA633,背景像素的 RGB 值为 0xDD2200,则显示像素的结果 RGB 值为 0xFFC833 - * (因为 0xAA + 0xDD > 0xFF,0xA6 + 0x22 = 0xC8,且 0x33 + 0x00 = 0x33)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - BlendMode.ADD = "add"; - /** - * Erases the background based on the alpha value of the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 根据显示对象的 Alpha 值擦除背景。Alpha 值不为0的区域将被擦除。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - BlendMode.ERASE = "erase"; - return BlendMode; - }()); - egret.BlendMode = BlendMode; - __reflect(BlendMode.prototype, "egret.BlendMode"); -})(egret || (egret = {})); -(function (egret) { - var sys; - (function (sys) { - var blendModeString = ["normal", "add", "erase"]; - var blendModeNumber = {}; - var length = blendModeString.length; - for (var i = 0; i < length; i++) { - var str = blendModeString[i]; - blendModeNumber[str] = i; - } - /** - * @private - * 转换 blendMode 字符串为数字。 - */ - function blendModeToNumber(blendMode) { - var num = blendModeNumber[blendMode]; - return num === undefined ? 0 : num; - } - sys.blendModeToNumber = blendModeToNumber; - /** - * @private - * 转换数字为 blendMode 字符串。 - */ - function numberToBlendMode(blendMode) { - var str = blendModeString[blendMode]; - return str === undefined ? "normal" : str; - } - sys.numberToBlendMode = numberToBlendMode; - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The CapsStyle class is an enumeration of constant values that specify the caps style to use in drawing lines. - * The constants are provided for use as values in the caps parameter of the egret.Graphics.lineStyle() method. - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * CapsStyle 类是可指定在绘制线条中使用的端点样式的常量值枚举。常量可用作 egret.Graphics.lineStyle() 方法的 caps 参数中的值。 - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - egret.CapsStyle = { - /** - * Used to specify no caps in the caps parameter of the egret.Graphics.lineStyle() method. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * 用于在 egret.Graphics.lineStyle() 方法的 caps 参数中指定没有端点。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - NONE: "none", - /** - * Used to specify round caps in the caps parameter of the egret.Graphics.lineStyle() method. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * 用于在 egret.Graphics.lineStyle() 方法的 caps 参数中指定圆头端点。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - ROUND: "round", - /** - * Used to specify square caps in the caps parameter of the egret.Graphics.lineStyle() method. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * 用于在 egret.Graphics.lineStyle() 方法的 caps 参数中指定方头端点。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - SQUARE: "square" - }; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - */ - var WebGLUtils = (function () { - function WebGLUtils() { - } - WebGLUtils.compileProgram = function (gl, vertexSrc, fragmentSrc) { - var fragmentShader = WebGLUtils.compileFragmentShader(gl, fragmentSrc); - var vertexShader = WebGLUtils.compileVertexShader(gl, vertexSrc); - var shaderProgram = gl.createProgram(); - gl.attachShader(shaderProgram, vertexShader); - gl.attachShader(shaderProgram, fragmentShader); - gl.linkProgram(shaderProgram); - if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) { - egret.$warn(1020); - } - return shaderProgram; - }; - WebGLUtils.compileFragmentShader = function (gl, shaderSrc) { - return WebGLUtils._compileShader(gl, shaderSrc, gl.FRAGMENT_SHADER); - }; - WebGLUtils.compileVertexShader = function (gl, shaderSrc) { - return WebGLUtils._compileShader(gl, shaderSrc, gl.VERTEX_SHADER); - }; - WebGLUtils._compileShader = function (gl, shaderSrc, shaderType) { - var shader = gl.createShader(shaderType); - gl.shaderSource(shader, shaderSrc); - gl.compileShader(shader); - if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { - //egret.info(gl.getShaderInfoLog(shader)); - return null; - } - return shader; - }; - WebGLUtils.checkCanUseWebGL = function () { - if (WebGLUtils.canUseWebGL == undefined) { - try { - var canvas = document.createElement("canvas"); - WebGLUtils.canUseWebGL = !!window["WebGLRenderingContext"] - && !!(canvas.getContext("webgl") || canvas.getContext("experimental-webgl")); - } - catch (e) { - WebGLUtils.canUseWebGL = false; - } - } - return WebGLUtils.canUseWebGL; - }; - WebGLUtils.deleteWebGLTexture = function (bitmapData) { - if (bitmapData) { - var gl = bitmapData.glContext; - if (gl) { - gl.deleteTexture(bitmapData); - } - } - }; - return WebGLUtils; - }()); - egret.WebGLUtils = WebGLUtils; - __reflect(WebGLUtils.prototype, "egret.WebGLUtils"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - // export interface TextField{ - // addEventListener(type: "focusIn" | - // "focusOut" - // , listener: (this: Z, e: FocusEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number); - // addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number); - // } - /** - * When the user changes the focus from one object in the display list to another object, the object dispatches a FocusEvent object. Currently only supports input text. - * Focus events: FocusEvent.FOCUS_IN FocusEvent.FOCUS_OUT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用户将焦点从显示列表中的一个对象更改到另一个对象时,对象将调度 FocusEvent 对象。目前只支持输入文本。 - * 焦点事件:FocusEvent.FOCUS_IN FocusEvent.FOCUS_OUT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var FocusEvent = (function (_super) { - __extends(FocusEvent, _super); - /** - * Create a egret.FocusEvent objects - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.FocusEvent 对象 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function FocusEvent(type, bubbles, cancelable) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - return _super.call(this, type, bubbles, cancelable) || this; - } - /** - * Gets focus - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获得焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - FocusEvent.FOCUS_IN = "focusIn"; - /** - * Loses focus - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 失去焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - FocusEvent.FOCUS_OUT = "focusOut"; - return FocusEvent; - }(egret.Event)); - egret.FocusEvent = FocusEvent; - __reflect(FocusEvent.prototype, "egret.FocusEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The GeolocationEvent represents the position and altitude of the device on Earth, - * and show errors occurred while getting the location of the device. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Geolocation.ts - * @see http://edn.egret.com/cn/docs/page/662 获取位置信息 - * @language en_US - */ - /** - * GeolocationEvent 提供设备的地理位置信息和获取位置时发生的错误信息 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Geolocation.ts - * @see http://edn.egret.com/cn/docs/page/662 获取位置信息 - * @language zh_CN - */ - var GeolocationEvent = (function (_super) { - __extends(GeolocationEvent, _super); - function GeolocationEvent() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * The acquisition of the location information failed because of app don't have permission. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由于用户拒绝访问位置信息,获取位置信息失败 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - GeolocationEvent.PERMISSION_DENIED = "permissionDenied"; - /** - * The acquisition of the location failed because at least one internal source of position returned an internal error. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设备位置服务不可用或者超时等原因没有得到位置信息 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - GeolocationEvent.UNAVAILABLE = "unavailable"; - return GeolocationEvent; - }(egret.Event)); - egret.GeolocationEvent = GeolocationEvent; - __reflect(GeolocationEvent.prototype, "egret.GeolocationEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * When a network request returns an HTTP status code, the application dispatches HTTPStatusEvent objects. - * Before error or completion events will always send HTTPStatusEvent object. HTTPStatusEvent object does not necessarily indicate an error condition; it simply reflects the HTTP status code provided by the network stack (if any). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在网络请求返回 HTTP 状态代码时,应用程序将调度 HTTPStatusEvent 对象。 - * 在错误或完成事件之前,将始终发送 HTTPStatusEvent 对象。HTTPStatusEvent 对象不一定表示错误条件;它仅反映网络堆栈提供的 HTTP 状态代码(如果有的话)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var HTTPStatusEvent = (function (_super) { - __extends(HTTPStatusEvent, _super); - /** - * Create a egret.HTTPStatusEvent objects - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.HTTPStatusEvent 对象 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function HTTPStatusEvent(type, bubbles, cancelable) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - var _this = _super.call(this, type, bubbles, cancelable) || this; - /** - * @private - */ - _this._status = 0; - return _this; - } - Object.defineProperty(HTTPStatusEvent.prototype, "status", { - /** - * he server returns the HTTP status code. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由服务器返回的 HTTP 状态代码。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._status; - }, - enumerable: true, - configurable: true - }); - /** - * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin. - * @param target {egret.IEventDispatcher} Distribute event target - * @param status {number} The server returns the HTTP status code - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param status {number} 由服务器返回的 HTTP 状态代码 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HTTPStatusEvent.dispatchHTTPStatusEvent = function (target, status) { - var event = egret.Event.create(HTTPStatusEvent, HTTPStatusEvent.HTTP_STATUS); - event._status = status; - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * HTTPStatusEvent.HTTP_STATUS constant defines the value of the type property httpStatus event object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HTTPStatusEvent.HTTP_STATUS 常量定义 httpStatus 事件对象的 type 属性值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HTTPStatusEvent.HTTP_STATUS = "httpStatus"; - return HTTPStatusEvent; - }(egret.Event)); - egret.HTTPStatusEvent = HTTPStatusEvent; - __reflect(HTTPStatusEvent.prototype, "egret.HTTPStatusEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @classdesc IO流事件,当错误导致输入或输出操作失败时调度 IOErrorEvent 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IOErrorEvent.ts - * @language en_US - */ - /** - * @classdesc IO流事件,当错误导致输入或输出操作失败时调度 IOErrorEvent 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IOErrorEvent.ts - * @language zh_CN - */ - var IOErrorEvent = (function (_super) { - __extends(IOErrorEvent, _super); - /** - * Create a egret.IOErrorEvent objects - * @param type {string} Type of event, accessible as Event.type. - * @param bubbles {boolean} Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable {boolean} Determine whether the Event object can be canceled. The default value is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.IOErrorEvent 对象 - * @param type {string} 事件的类型,可以作为 Event.type 访问。 - * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable {boolean} 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function IOErrorEvent(type, bubbles, cancelable) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - return _super.call(this, type, bubbles, cancelable) || this; - } - /** - * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin. - * @param target {egret.IEventDispatcher} Distribute event target - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - IOErrorEvent.dispatchIOErrorEvent = function (target) { - var event = egret.Event.create(IOErrorEvent, IOErrorEvent.IO_ERROR); - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * io error - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * io发生错误 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - IOErrorEvent.IO_ERROR = "ioError"; - return IOErrorEvent; - }(egret.Event)); - egret.IOErrorEvent = IOErrorEvent; - __reflect(IOErrorEvent.prototype, "egret.IOErrorEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * MotionEvent represents the device's movement - * Acceleration and accelerationIncludingGravity to represents the device's acceleration - * RotationRate to represents the device's rotation - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Motion.ts - * @language en_US - */ - /** - * MotionEvent 类呈现设备运动的具体信息 - * Acceleration 和 accelerationIncludingGravity 呈现设备三个维度的加速度信息 - * RotationRate 呈现设备的旋转状态信息 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Motion.ts - * @language zh_CN - */ - var MotionEvent = (function (_super) { - __extends(MotionEvent, _super); - function MotionEvent() { - return _super !== null && _super.apply(this, arguments) || this; - } - return MotionEvent; - }(egret.Event)); - egret.MotionEvent = MotionEvent; - __reflect(MotionEvent.prototype, "egret.MotionEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The OrientationEvent provides information from the physical orientation of the device. - * Note: Currently, Browsers on the iOS and Android does not handle the coordinates the same way. - * Take care about this while using them. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/DeviceOrientation.ts - * @language en_US - */ - /** - * OrientationEvent 提供设备的方向信息 - * 注意: 目前各个浏览器和操作系统处理方向的方式不完全相同,请根据使用场景做相应的校正, - * 比如使用两次方向数据的变化而不是直接使用方向的值 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/DeviceOrientation.ts - * @language zh_CN - */ - var OrientationEvent = (function (_super) { - __extends(OrientationEvent, _super); - function OrientationEvent() { - return _super !== null && _super.apply(this, arguments) || this; - } - return OrientationEvent; - }(egret.Event)); - egret.OrientationEvent = OrientationEvent; - __reflect(OrientationEvent.prototype, "egret.OrientationEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * When a load operation has begun or a socket has received data, ProgressEvent object is dispatched. - * There are two types of progress events: ProgressEvent.PROGRESS and ProgressEvent.SOCKET_DATA. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当加载操作已开始或套接字已接收到数据时,将调度 ProgressEvent 对象。 - * 有两种类型的进程事件:ProgressEvent.PROGRESS 和 ProgressEvent.SOCKET_DATA。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var ProgressEvent = (function (_super) { - __extends(ProgressEvent, _super); - /** - * 创建一个 egret.ProgressEvent 对象 - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param bytesLoaded {number} Number of items or bytes loaded - * @param bytesTotal {number} The total number of items or bytes loaded - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.ProgressEvent 对象 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param bytesLoaded {number} 加载的项数或字节数 - * @param bytesTotal {number} 加载的总项数或总字节数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function ProgressEvent(type, bubbles, cancelable, bytesLoaded, bytesTotal) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - if (bytesLoaded === void 0) { bytesLoaded = 0; } - if (bytesTotal === void 0) { bytesTotal = 0; } - var _this = _super.call(this, type, bubbles, cancelable) || this; - /** - * Number of items or bytes when the listener processes the event。 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在侦听器处理事件时加载的项数或字节数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.bytesLoaded = 0; - /** - * If the loading process succeeds, the total number or the total number of bytes that will be loaded term. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果加载过程成功,将加载的总项数或总字节数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.bytesTotal = 0; - _this.bytesLoaded = bytesLoaded; - _this.bytesTotal = bytesTotal; - return _this; - } - /** - * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin. - * @param target {egret.IEventDispatcher} Distribute event target - * @param type The type of the event, accessible as Event.type. - * @param bytesLoaded {number} Number of items or bytes loaded - * @param bytesTotal {number} The total number of items or bytes loaded - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param type {string} 事件类型 - * @param bytesLoaded {number} 加载的项数或字节数 - * @param bytesTotal {number} 加载的总项数或总字节数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ProgressEvent.dispatchProgressEvent = function (target, type, bytesLoaded, bytesTotal) { - if (bytesLoaded === void 0) { bytesLoaded = 0; } - if (bytesTotal === void 0) { bytesTotal = 0; } - var event = egret.Event.create(ProgressEvent, type); - event.bytesLoaded = bytesLoaded; - event.bytesTotal = bytesTotal; - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * Changes in the loading progress - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 加载进度发生变化 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ProgressEvent.PROGRESS = "progress"; - /** - * Get the data - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取到数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ProgressEvent.SOCKET_DATA = "socketData"; - return ProgressEvent; - }(egret.Event)); - egret.ProgressEvent = ProgressEvent; - __reflect(ProgressEvent.prototype, "egret.ProgressEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * When the direction of the stage of change, Stage object dispatches StageOrientationEvent object. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/StageOrientationEvent.ts - * @language en_US - */ - /** - * 当舞台的方向更改时,Stage 对象将调度 StageOrientationEvent 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/StageOrientationEvent.ts - * @language zh_CN - */ - var StageOrientationEvent = (function (_super) { - __extends(StageOrientationEvent, _super); - /** - * Creating contains specific information related to the event and the stage direction of StageOrientationEvent object. - * @param type Event types:StageOrientationEvent.ORIENTATION_CHANGE - * @param bubbles It indicates whether the Event object participates in the bubbling stage of the event flow. - * @param cancelable It indicates whether the Event object can be canceled. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建包含与舞台方向事件相关的特定信息的 StageOrientationEvent 对象。 - * @param type 事件的类型:StageOrientationEvent.ORIENTATION_CHANGE - * @param bubbles 表示 Event 对象是否参与事件流的冒泡阶段。 - * @param cancelable 表示是否可以取消 Event 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function StageOrientationEvent(type, bubbles, cancelable) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - return _super.call(this, type, bubbles, cancelable) || this; - } - /** - * 派发一个屏幕旋转的事件。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param type {egret.IEventDispatcher} 派发事件类型 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 派发一个屏幕旋转的事件。 - * @param target {egret.IEventDispatcher} Distribute event target - * @param type {egret.IEventDispatcher} Distribute event type - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - StageOrientationEvent.dispatchStageOrientationEvent = function (target, type) { - var event = egret.Event.create(StageOrientationEvent, type); - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * After screen rotation distribute events. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 屏幕旋转后派发的事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - StageOrientationEvent.ORIENTATION_CHANGE = "orientationChange"; - return StageOrientationEvent; - }(egret.Event)); - egret.StageOrientationEvent = StageOrientationEvent; - __reflect(StageOrientationEvent.prototype, "egret.StageOrientationEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - // export interface TextField{ - // addEventListener(type: "link" - // , listener: (this: Z, e: TextEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number); - // addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number); - // } - /** - * When a user clicks a hyperlink rich text object dispatches TextEvent object. Text Event Type: TextEvent.LINK. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TextEvent.ts - * @language en_US - */ - /** - * 用户在富文本中单击超链接时,对象将调度 TextEvent 对象。文本事件类型:TextEvent.LINK。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TextEvent.ts - * @language zh_CN - */ - var TextEvent = (function (_super) { - __extends(TextEvent, _super); - /** - * TextEvent create an object that contains information about text events. - * @param type Type of event, you can access the TextEvent.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determine whether the Event object can be canceled. The default value is false. - * @param text One or more characters of text entered by the user. Event listeners can access this information through the text property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 TextEvent 对象,其中包含有关文本事件的信息。 - * @param type 事件的类型,可以作为 TextEvent.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param text 用户输入的一个或多个文本字符。事件侦听器可以通过 text 属性访问此信息。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function TextEvent(type, bubbles, cancelable, text) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - if (text === void 0) { text = ""; } - var _this = _super.call(this, type, bubbles, cancelable) || this; - _this.text = text; - return _this; - } - /** - * EventDispatcher object using the specified event object thrown TextEvent. The objects will be thrown in the object cache pool for the next round robin. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param text Text TextEvent object assignment - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出TextEvent事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 派发事件目标 - * @param type 事件类型 - * @param text TextEvent对象的text赋值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TextEvent.dispatchTextEvent = function (target, type, text) { - var event = egret.Event.create(TextEvent, type); - event.text = text; - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * It defines the value of the type property of a link event object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 定义 link 事件对象的 type 属性值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TextEvent.LINK = "link"; - return TextEvent; - }(egret.Event)); - egret.TextEvent = TextEvent; - __reflect(TextEvent.prototype, "egret.TextEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * A Timer object dispatches a TimerEvent objects whenever the Timer object reaches the interval specified by the Timer.delay property. - * @see egret.Timer - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TimerEvent.ts - * @language en_US - */ - /** - * 每当 Timer 对象达到由 Timer.delay 属性指定的间隔时,Timer 对象即会调度 TimerEvent 对象。 - * @see egret.Timer - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TimerEvent.ts - * @language zh_CN - */ - var TimerEvent = (function (_super) { - __extends(TimerEvent, _super); - /** - * Creates an Event object with specific information relevant to timer events. - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param cancelable Determines whether the Event object can be canceled. Event listeners can access this information - * through the inherited cancelable property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Event 对象,其中包含有关 timer 事件的特定信息。 - * @param type 事件的类型。事件侦听器可以通过继承的 type 属性访问此信息。 - * @param bubbles 确定 Event 对象是否冒泡。事件侦听器可以通过继承的 bubbles 属性访问此信息。 - * @param cancelable 确定是否可以取消 Event 对象。事件侦听器可以通过继承的 cancelable 属性访问此信息。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function TimerEvent(type, bubbles, cancelable) { - return _super.call(this, type, bubbles, cancelable) || this; - } - /** - * Instructs Egret runtime to render after processing of this event completes, if the display list has been modified. - * @example - *
    -         *    function onTimer(event:TimerEvent):void {
    -         *        if (40 < mySp.x && mySp.x < 375) {
    -         *            mySp.x-= 50;
    -         *        } else {
    -         *            mySp.x=374;
    -         *        }
    -         *        event.updateAfterEvent();
    -         *    }
    -         *
    -         *    let moveTimer:Timer=new Timer(50,250);
    -         *    moveTimer.addEventListener(TimerEvent.TIMER,onTimer);
    -         *    moveTimer.start();
    -         * 
    - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果已修改显示列表,调用此方法将会忽略帧频限制,在此事件处理完成后立即重绘屏幕。 - * @example - *
    -         *    function onTimer(event:TimerEvent):void {
    -         *        if (40 < mySp.x && mySp.x < 375) {
    -         *            mySp.x-= 50;
    -         *        } else {
    -         *            mySp.x=374;
    -         *        }
    -         *        event.updateAfterEvent();
    -         *    }
    -         *
    -         *    let moveTimer:Timer=new Timer(50,250);
    -         *    moveTimer.addEventListener(TimerEvent.TIMER,onTimer);
    -         *    moveTimer.start();
    -         * 
    - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TimerEvent.prototype.updateAfterEvent = function () { - egret.sys.$requestRenderingFlag = true; - }; - /** - * uses a specified target to dispatchEvent an event. Using this method can reduce the number of - * reallocate event objects, which allows you to get better code execution performance. - * @param target the event target - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param cancelable Determines whether the Event object can be canceled. Event listeners can access this information - * through the inherited cancelable property. - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 事件派发目标 - * @param type 事件的类型。事件侦听器可以通过继承的 type 属性访问此信息。 - * @param bubbles 确定 Event 对象是否冒泡。事件侦听器可以通过继承的 bubbles 属性访问此信息。 - * @param cancelable 确定是否可以取消 Event 对象。事件侦听器可以通过继承的 cancelable 属性访问此信息。 - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TimerEvent.dispatchTimerEvent = function (target, type, bubbles, cancelable) { - var event = egret.Event.create(TimerEvent, type, bubbles, cancelable); - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * Dispatched whenever a Timer object reaches an interval specified according to the Timer.delay property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 每当 Timer 对象达到根据 Timer.delay 属性指定的间隔时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TimerEvent.TIMER = "timer"; - /** - * Dispatched whenever it has completed the number of requests set by Timer.repeatCount. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 每当它完成 Timer.repeatCount 设置的请求数后调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TimerEvent.TIMER_COMPLETE = "timerComplete"; - return TimerEvent; - }(egret.Event)); - egret.TimerEvent = TimerEvent; - __reflect(TimerEvent.prototype, "egret.TimerEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * A BitmapData object contains an array of pixel data. This data can represent either a fully opaque bitmap or a - * transparent bitmap that contains alpha channel data. Either type of BitmapData object is stored as a buffer of 32-bit - * integers. Each 32-bit integer determines the properties of a single pixel in the bitmap.
    - * Each 32-bit integer is a combination of four 8-bit channel values (from 0 to 255) that describe the alpha transparency - * and the red, green, and blue (ARGB) values of the pixel. (For ARGB values, the most significant byte represents the - * alpha channel value, followed by red, green, and blue.) - * @see egret.Bitmap - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * BitmapData 对象是一个包含像素数据的数组。此数据可以表示完全不透明的位图,或表示包含 Alpha 通道数据的透明位图。 - * 以上任一类型的 BitmapData 对象都作为 32 位整数的缓冲区进行存储。每个 32 位整数确定位图中单个像素的属性。
    - * 每个 32 位整数都是四个 8 位通道值(从 0 到 255)的组合,这些值描述像素的 Alpha 透明度以及红色、绿色、蓝色 (ARGB) 值。 - * (对于 ARGB 值,最高有效字节代表 Alpha 通道值,其后的有效字节分别代表红色、绿色和蓝色通道值。) - * @see egret.Bitmap - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var BitmapData = (function (_super) { - __extends(BitmapData, _super); - /** - * Initializes a BitmapData object to refer to the specified source object. - * @param source The source object being referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个引用指定 source 实例的 BitmapData 对象 - * @param source 被引用的 source 实例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function BitmapData(source) { - var _this = _super.call(this) || this; - /** - * Texture format. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 纹理格式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.format = "image"; - /** - * @private - * webgl纹理生成后,是否删掉原始图像数据 - */ - _this.$deleteSource = true; - _this.source = source; - _this.width = source.width; - _this.height = source.height; - return _this; - } - BitmapData.create = function (type, data, callback) { - var base64 = ""; - if (type === "arraybuffer") { - base64 = egret.Base64Util.encode(data); - } - else { - base64 = data; - } - var imageType = "image/png"; //default value - if (base64.charAt(0) === '/') { - imageType = "image/jpeg"; - } - else if (base64.charAt(0) === 'R') { - imageType = "image/gif"; - } - else if (base64.charAt(0) === 'i') { - imageType = "image/png"; - } - var img = new Image(); - img.src = "data:" + imageType + ";base64," + base64; - img.crossOrigin = '*'; - var bitmapData = new BitmapData(img); - img.onload = function () { - img.onload = undefined; - bitmapData.source = img; - bitmapData.height = img.height; - bitmapData.width = img.width; - if (callback) { - callback(bitmapData); - } - }; - return bitmapData; - }; - BitmapData.prototype.$dispose = function () { - if (egret.Capabilities.renderMode == "webgl" && this.webGLTexture) { - egret.WebGLUtils.deleteWebGLTexture(this.webGLTexture); - this.webGLTexture = null; - } - //native or WebGLRenderTarget - if (this.source && this.source.dispose) { - this.source.dispose(); - } - this.source = null; - BitmapData.$dispose(this); - }; - BitmapData.$addDisplayObject = function (displayObject, bitmapData) { - if (!bitmapData) { - return; - } - var hashCode = bitmapData.hashCode; - if (!hashCode) { - return; - } - if (!BitmapData._displayList[hashCode]) { - BitmapData._displayList[hashCode] = [displayObject]; - return; - } - var tempList = BitmapData._displayList[hashCode]; - if (tempList.indexOf(displayObject) < 0) { - tempList.push(displayObject); - } - }; - BitmapData.$removeDisplayObject = function (displayObject, bitmapData) { - if (!bitmapData) { - return; - } - var hashCode = bitmapData.hashCode; - if (!hashCode) { - return; - } - if (!BitmapData._displayList[hashCode]) { - return; - } - var tempList = BitmapData._displayList[hashCode]; - var index = tempList.indexOf(displayObject); - if (index >= 0) { - tempList.splice(index, 1); - } - }; - BitmapData.$invalidate = function (bitmapData) { - if (!bitmapData) { - return; - } - var hashCode = bitmapData.hashCode; - if (!hashCode) { - return; - } - if (!BitmapData._displayList[hashCode]) { - return; - } - var tempList = BitmapData._displayList[hashCode]; - for (var i = 0; i < tempList.length; i++) { - if (tempList[i] instanceof egret.Bitmap) { - tempList[i].$refreshImageData(); - } - var bitmap = tempList[i]; - bitmap.$renderDirty = true; - var p = bitmap.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = bitmap.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - BitmapData.$dispose = function (bitmapData) { - if (!bitmapData) { - return; - } - var hashCode = bitmapData.hashCode; - if (!hashCode) { - return; - } - if (!BitmapData._displayList[hashCode]) { - return; - } - var tempList = BitmapData._displayList[hashCode]; - for (var _i = 0, tempList_1 = tempList; _i < tempList_1.length; _i++) { - var node = tempList_1[_i]; - if (node instanceof egret.Bitmap) { - node.$bitmapData = null; - } - node.$renderDirty = true; - var p = node.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = node.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - if (egret.nativeRender) { - egret_native.NativeDisplayObject.disposeBitmapData(bitmapData); - } - delete BitmapData._displayList[hashCode]; - }; - BitmapData._displayList = egret.createMap(); - return BitmapData; - }(egret.HashObject)); - egret.BitmapData = BitmapData; - __reflect(BitmapData.prototype, "egret.BitmapData"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/// -var egret; -(function (egret) { - var localPoint = new egret.Point(); - /** - * The TouchEvent class lets you handle events on devices that detect user contact with the device (such as a finger - * on a touch screen).When a user interacts with a device such as a mobile phone or tablet with a touch screen, the - * user typically touches the screen with his or her fingers or a pointing device. You can develop applications that - * respond to basic touch events (such as a single finger tap) with the TouchEvent class. Create event listeners using - * the event types defined in this class. - * Note: When objects are nested on the display list, touch events target the deepest possible nested object that is - * visible in the display list. This object is called the target node. To have a target node's ancestor (an object - * containing the target node in the display list) receive notification of a touch event, use EventDispatcher.addEventListener() - * on the ancestor node with the type parameter set to the specific touch event you want to detect. - * - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TouchEvent.ts - * @language en_US - */ - /** - * 使用 TouchEvent 类,您可以处理设备上那些检测用户与设备之间的接触的事件。 - * 当用户与带有触摸屏的移动电话或平板电脑等设备交互时,用户通常使用手指或指针设备接触屏幕。可使用 TouchEvent - * 类开发响应基本触摸事件(如单个手指点击)的应用程序。使用此类中定义的事件类型创建事件侦听器。 - * 注意:当对象嵌套在显示列表中时,触摸事件的目标将是显示列表中可见的最深的可能嵌套对象。 - * 此对象称为目标节点。要使目标节点的祖代(祖代是一个包含显示列表中所有目标节点的对象,从舞台到目标节点的父节点均包括在内) - * 接收触摸事件的通知,请对祖代节点使用 EventDispatcher.on() 并将 type 参数设置为要检测的特定触摸事件。 - * - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TouchEvent.ts - * @language zh_CN - */ - var TouchEvent = (function (_super) { - __extends(TouchEvent, _super); - /** - * Creates an Event object that contains information about touch events. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param stageX The horizontal coordinate at which the event occurred in global Stage coordinates. - * @param stageY The vertical coordinate at which the event occurred in global Stage coordinates. - * @param touchPointID A unique identification number assigned to the touch point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 TouchEvent 对象,其中包含有关Touch事件的信息 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param stageX 事件发生点在全局舞台坐标系中的水平坐标 - * @param stageY 事件发生点在全局舞台坐标系中的垂直坐标 - * @param touchPointID 分配给触摸点的唯一标识号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function TouchEvent(type, bubbles, cancelable, stageX, stageY, touchPointID) { - var _this = _super.call(this, type, bubbles, cancelable) || this; - _this.targetChanged = true; - /** - * Whether the touch is pressed (true) or not pressed (false). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示触摸已按下 (true) 还是未按下 (false)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.touchDown = false; - _this.$initTo(stageX, stageY, touchPointID); - return _this; - } - /** - * @private - */ - TouchEvent.prototype.$initTo = function (stageX, stageY, touchPointID) { - this.touchPointID = +touchPointID || 0; - this.$stageX = +stageX || 0; - this.$stageY = +stageY || 0; - }; - Object.defineProperty(TouchEvent.prototype, "stageX", { - /** - * The horizontal coordinate at which the event occurred in global Stage coordinates. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点在全局舞台坐标中的水平坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$stageX; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TouchEvent.prototype, "stageY", { - /** - * The vertical coordinate at which the event occurred in global Stage coordinates. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点在全局舞台坐标中的垂直坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$stageY; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TouchEvent.prototype, "localX", { - /** - * The horizontal coordinate at which the event occurred relative to the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点相对于所属显示对象的水平坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - if (this.targetChanged) { - this.getLocalXY(); - } - return this._localX; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TouchEvent.prototype, "localY", { - /** - * The vertical coordinate at which the event occurred relative to the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点相对于所属显示对象的垂直坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - if (this.targetChanged) { - this.getLocalXY(); - } - return this._localY; - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - TouchEvent.prototype.getLocalXY = function () { - this.targetChanged = false; - var m = this.$target.$getInvertedConcatenatedMatrix(); - m.transformPoint(this.$stageX, this.$stageY, localPoint); - this._localX = localPoint.x; - this._localY = localPoint.y; - }; - TouchEvent.prototype.$setTarget = function (target) { - this.$target = target; - this.targetChanged = !!target; - return true; - }; - /** - * Instructs Egret runtime to render after processing of this event completes, if the display list has been modified. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果已修改显示列表,调用此方法将会忽略帧频限制,在此事件处理完成后立即重绘屏幕。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TouchEvent.prototype.updateAfterEvent = function () { - egret.sys.$requestRenderingFlag = true; - }; - /** - * uses a specified target to dispatchEvent an event. Using this method can reduce the number of - * reallocate event objects, which allows you to get better code execution performance. - * @param target the event target - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param stageX The horizontal coordinate at which the event occurred in global Stage coordinates. - * @param stageY The vertical coordinate at which the event occurred in global Stage coordinates. - * @param touchPointID A unique identification number (as an int) assigned to the touch point. - * - * @see egret.Event.create() - * @see egret.Event.release() - * - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 派发事件目标 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param stageX 事件发生点在全局舞台坐标系中的水平坐标 - * @param stageY 事件发生点在全局舞台坐标系中的垂直坐标 - * @param touchPointID 分配给触摸点的唯一标识号 - * - * @see egret.Event.create() - * @see egret.Event.release() - * - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TouchEvent.dispatchTouchEvent = function (target, type, bubbles, cancelable, stageX, stageY, touchPointID, touchDown) { - if (touchDown === void 0) { touchDown = false; } - if (!bubbles && !target.hasEventListener(type)) { - return true; - } - var event = egret.Event.create(TouchEvent, type, bubbles, cancelable); - event.$initTo(stageX, stageY, touchPointID); - event.touchDown = touchDown; - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * Dispatched when the user touches the device, and is continuously dispatched until the point of contact is removed. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户触碰设备时进行调度,而且会连续调度,直到接触点被删除。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TouchEvent.TOUCH_MOVE = "touchMove"; - /** - * Dispatched when the user first contacts a touch-enabled device (such as touches a finger to a mobile phone or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户第一次触摸启用触摸的设备时(例如,用手指触摸配有触摸屏的移动电话或平板电脑)调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TouchEvent.TOUCH_BEGIN = "touchBegin"; - /** - * Dispatched when the user removes contact with a touch-enabled device (such as lifts a finger off a mobile phone - * or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户移除与启用触摸的设备的接触时(例如,将手指从配有触摸屏的移动电话或平板电脑上抬起)调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TouchEvent.TOUCH_END = "touchEnd"; - /** - * Dispatched when an event of some kind occurred that canceled the touch. - * Such as the eui.Scroller will dispatch 'TOUCH_CANCEL' when it start move, the 'TOUCH_END' and 'TOUCH_TAP' will not be triggered. - * @version Egret 3.0.1 - * @platform Web,Native - * @language en_US - */ - /** - * 由于某个事件取消了触摸时触发。比如 eui.Scroller 在开始滚动后会触发 'TOUCH_CANCEL' 事件,不再触发后续的 'TOUCH_END' 和 'TOUCH_TAP' 事件 - * @version Egret 3.0.1 - * @platform Web,Native - * @language zh_CN - */ - TouchEvent.TOUCH_CANCEL = "touchCancel"; - /** - * Dispatched when the user lifts the point of contact over the same DisplayObject instance on which the contact - * was initiated on a touch-enabled device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户在触摸设备上与开始触摸的同一 DisplayObject 实例上抬起接触点时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TouchEvent.TOUCH_TAP = "touchTap"; - /** - * Dispatched when the user lifts the point of contact over the different DisplayObject instance on which the contact - * was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display - * object on a mobile phone or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户在触摸设备上与开始触摸的不同 DisplayObject 实例上抬起接触点时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TouchEvent.TOUCH_RELEASE_OUTSIDE = "touchReleaseOutside"; - return TouchEvent; - }(egret.Event)); - egret.TouchEvent = TouchEvent; - __reflect(TouchEvent.prototype, "egret.TouchEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The BlurFilter class lets you apply a blur visual effect to display objects. A blur effect softens the details of an image. - * You can produce blurs that range from a softly unfocused look to a Gaussian blur, a hazy appearance like viewing an image through semi-opaque glass. - * @version Egret 3.0.1 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947#模糊滤镜 模糊滤镜 - * @language en_US - */ - /** - * 可使用 BlurFilter 类将模糊视觉效果应用于显示对象。模糊效果可以柔化图像的细节。 - * 您可以生成一些模糊效果,范围从创建一个柔化的、未聚焦的外观到高斯模糊(就像通过半透明玻璃查看图像一样的朦胧的外观)。 - * @version Egret 3.1.0 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947#模糊滤镜 模糊滤镜 - * @language zh_CN - */ - var BlurFilter = (function (_super) { - __extends(BlurFilter, _super); - /** - * Initializes a BlurFilter object. - * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point). - * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point). - * @param quality {number} The number of times to apply the filter. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 创建一个 BlurFilter 对象。 - * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。 - * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。 - * @param quality {number} 应用滤镜的次数。暂未实现。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - function BlurFilter(blurX, blurY, quality) { - if (blurX === void 0) { blurX = 4; } - if (blurY === void 0) { blurY = 4; } - if (quality === void 0) { quality = 1; } - var _this = _super.call(this) || this; - var self = _this; - self.type = "blur"; - self.$blurX = blurX; - self.$blurY = blurY; - self.$quality = quality; - self.blurXFilter = new BlurXFilter(blurX); - self.blurYFilter = new BlurYFilter(blurY); - self.onPropertyChange(); - return _this; - } - Object.defineProperty(BlurFilter.prototype, "blurX", { - /** - * The amount of horizontal blur. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 水平模糊量。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$blurX; - }, - set: function (value) { - var self = this; - if (self.$blurX == value) { - return; - } - self.$blurX = value; - self.blurXFilter.blurX = value; - self.onPropertyChange(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(BlurFilter.prototype, "blurY", { - /** - * The amount of vertical blur. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 垂直模糊量。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$blurY; - }, - set: function (value) { - var self = this; - if (self.$blurY == value) { - return; - } - self.$blurY = value; - self.blurYFilter.blurY = value; - self.onPropertyChange(); - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - BlurFilter.prototype.$toJson = function () { - return '{"blurX": ' + this.$blurX + ', "blurY": ' + this.$blurY + ', "quality": 1}'; - }; - BlurFilter.prototype.updatePadding = function () { - var self = this; - self.paddingLeft = self.blurX; - self.paddingRight = self.blurX; - self.paddingTop = self.blurY; - self.paddingBottom = self.blurY; - }; - BlurFilter.prototype.onPropertyChange = function () { - var self = this; - self.updatePadding(); - if (egret.nativeRender) { - egret_native.NativeDisplayObject.setFilterPadding(self.blurXFilter.$id, 0, 0, self.paddingLeft, self.paddingRight); - egret_native.NativeDisplayObject.setFilterPadding(self.blurYFilter.$id, self.paddingTop, self.paddingBottom, 0, 0); - egret_native.NativeDisplayObject.setDataToFilter(self); - } - }; - return BlurFilter; - }(egret.Filter)); - egret.BlurFilter = BlurFilter; - __reflect(BlurFilter.prototype, "egret.BlurFilter"); - var BlurXFilter = (function (_super) { - __extends(BlurXFilter, _super); - function BlurXFilter(blurX) { - if (blurX === void 0) { blurX = 4; } - var _this = _super.call(this) || this; - if (egret.nativeRender) { - _this.type = "blur"; - } - else { - _this.type = "blurX"; - } - _this.$uniforms.blur = { x: blurX, y: 0 }; - _this.onPropertyChange(); - return _this; - } - Object.defineProperty(BlurXFilter.prototype, "blurX", { - get: function () { - return this.$uniforms.blur.x; - }, - set: function (value) { - this.$uniforms.blur.x = value; - }, - enumerable: true, - configurable: true - }); - return BlurXFilter; - }(egret.Filter)); - __reflect(BlurXFilter.prototype, "BlurXFilter", ["egret.IBlurXFilter"]); - var BlurYFilter = (function (_super) { - __extends(BlurYFilter, _super); - function BlurYFilter(blurY) { - if (blurY === void 0) { blurY = 4; } - var _this = _super.call(this) || this; - if (egret.nativeRender) { - _this.type = "blur"; - } - else { - _this.type = "blurY"; - } - _this.$uniforms.blur = { x: 0, y: blurY }; - _this.onPropertyChange(); - return _this; - } - Object.defineProperty(BlurYFilter.prototype, "blurY", { - get: function () { - return this.$uniforms.blur.y; - }, - set: function (value) { - this.$uniforms.blur.y = value; - }, - enumerable: true, - configurable: true - }); - return BlurYFilter; - }(egret.Filter)); - __reflect(BlurYFilter.prototype, "BlurYFilter", ["egret.IBlurYFilter"]); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The ColorMatrixFilter class lets you apply a 4 x 5 matrix transformation on the RGBA color and alpha values of every pixel in the input image to produce a result with a new set of RGBA color and alpha values. - * It allows saturation changes, hue rotation, luminance to alpha, and various other effects. - * @version Egret 3.1.0 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947 颜色矩阵滤镜 - * @language en_US - */ - /** - * 使用 ColorMatrixFilter 类可以将 4 x 5 矩阵转换应用于输入图像上的每个像素的 RGBA 颜色和 Alpha 值,以生成具有一组新的 RGBA 颜色和 Alpha 值的结果。 - * 该类允许饱和度更改、色相旋转、亮度为 Alpha 以及各种其他效果。 - * @version Egret 3.1.0 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947 颜色矩阵滤镜 - * @language zh_CN - */ - var ColorMatrixFilter = (function (_super) { - __extends(ColorMatrixFilter, _super); - /** - * Initializes a ColorMatrixFilter object. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 创建一个 ColorMatrixFilter 对象。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - function ColorMatrixFilter(matrix) { - if (matrix === void 0) { matrix = null; } - var _this = _super.call(this) || this; - /** - * @private - */ - _this.$matrix = []; - /** - * @private - */ - _this.matrix2 = []; - _this.type = "colorTransform"; - _this.$uniforms.matrix = [ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ]; - _this.$uniforms.colorAdd = { x: 0, y: 0, z: 0, w: 0 }; - _this.setMatrix(matrix); - _this.onPropertyChange(); - return _this; - } - Object.defineProperty(ColorMatrixFilter.prototype, "matrix", { - /** - * A comma delimited list of 20 doubles that comprise a 4x5 matrix applied to the rendered element. - * The matrix is in row major order -- that is, the first five elements are multipled by the vector [srcR,srcG,srcB,srcA,1] to determine the output red value, the second five determine the output green value, etc. - * The value must either be an array or comma delimited string of 20 numbers. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 构成应用于所呈示的元素的一个 4x5 矩阵的、以逗号分隔的 20 个双精度数的列表。 - * 矩阵以行作为主要顺序,即用第一行五个元素乘以矢量 [srcR,srcG,srcB,srcA,1] 以确定输出的红色值,用第二行的五个元素确定输出的绿色值,等等。 - * 该值必须为 20 个数字组成的数组或以逗号分隔的字符串。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - get: function () { - for (var i = 0; i < 20; i++) { - this.matrix2[i] = this.$matrix[i]; - } - return this.matrix2; - }, - set: function (value) { - this.setMatrix(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - ColorMatrixFilter.prototype.setMatrix = function (value) { - if (value) { - for (var i = 0; i < 20; i++) { - this.$matrix[i] = value[i]; - } - } - else { - for (var i = 0; i < 20; i++) { - this.$matrix[i] = (i == 0 || i == 6 || i == 12 || i == 18) ? 1 : 0; - } - } - var $matrix = this.$matrix; - var matrix = this.$uniforms.matrix; - var colorAdd = this.$uniforms.colorAdd; - for (var i = 0, j = 0; i < $matrix.length; i++) { - if (i === 4) { - colorAdd.x = $matrix[i] / 255; - } - else if (i === 9) { - colorAdd.y = $matrix[i] / 255; - } - else if (i === 14) { - colorAdd.z = $matrix[i] / 255; - } - else if (i === 19) { - colorAdd.w = $matrix[i] / 255; - } - else { - matrix[j] = $matrix[i]; - j++; - } - } - this.onPropertyChange(); - }; - /** - * @private - */ - ColorMatrixFilter.prototype.$toJson = function () { - return '{"matrix": [' + this.$matrix.toString() + ']}'; - }; - return ColorMatrixFilter; - }(egret.Filter)); - egret.ColorMatrixFilter = ColorMatrixFilter; - __reflect(ColorMatrixFilter.prototype, "egret.ColorMatrixFilter"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var SOURCE_KEY_MAP = {}; - var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''); - var uuid = new Array(36); - var rnd = 0, r; - /** - * generate uuid - * http://www.broofa.com/Tools/Math.uuid.htm - */ - var generateUUID = function () { - for (var i = 0; i < 36; i++) { - if (i === 8 || i === 13 || i === 18 || i === 23) { - uuid[i] = '-'; - } - else if (i === 14) { - uuid[i] = '4'; - } - else { - if (rnd <= 0x02) - rnd = 0x2000000 + (Math.random() * 0x1000000) | 0; - r = rnd & 0xf; - rnd = rnd >> 4; - uuid[i] = chars[(i === 19) ? (r & 0x3) | 0x8 : r]; - } - } - return uuid.join(''); - }; - /** - * custom filter, now support WebGL mode only. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 自定义滤镜,目前仅支持WebGL模式 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - var CustomFilter = (function (_super) { - __extends(CustomFilter, _super); - /** - * Initialize the CustomFilter object. - * @param vertexSrc Custom vertex shader program. - * @param fragmentSrc Custom fragment shader program. - * @param uniforms The initial value of the uniform in the shader (key, value one-to-one correspondence), currently only supports numbers and arrays. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 初始化 CustomFilter 对象 - * @param vertexSrc 自定义的顶点着色器程序。 - * @param fragmentSrc 自定义的片段着色器程序。 - * @param uniforms 着色器中uniform的初始值(key,value一一对应),目前仅支持数字和数组。 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - function CustomFilter(vertexSrc, fragmentSrc, uniforms) { - if (uniforms === void 0) { uniforms = {}; } - var _this = _super.call(this) || this; - _this.$padding = 0; - _this.$vertexSrc = vertexSrc; - _this.$fragmentSrc = fragmentSrc; - var tempKey = vertexSrc + fragmentSrc; - if (!SOURCE_KEY_MAP[tempKey]) { - SOURCE_KEY_MAP[tempKey] = generateUUID(); - } - _this.$shaderKey = SOURCE_KEY_MAP[tempKey]; - _this.$uniforms = uniforms; - _this.type = "custom"; - return _this; - } - Object.defineProperty(CustomFilter.prototype, "padding", { - /** - * The inner margin of the filter. - * If the desired area of the custom filter is larger than the original area (stroke, etc.), you need to set it manually. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 滤镜的内边距 - * 如果自定义滤镜所需区域比原区域大(描边等),需要手动设置 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$padding; - }, - set: function (value) { - var self = this; - if (self.$padding == value) { - return; - } - self.$padding = value; - self.onPropertyChange(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CustomFilter.prototype, "uniforms", { - /** - * The initial value of the uniform in the shader (key, value one-to-one correspondence), currently only supports numbers and arrays. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 着色器中uniform的初始值(key,value一一对应),目前仅支持数字和数组。 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$uniforms; - }, - enumerable: true, - configurable: true - }); - CustomFilter.prototype.onPropertyChange = function () { - if (egret.nativeRender) { - var self_1 = this; - egret_native.NativeDisplayObject.setFilterPadding(self_1.$id, self_1.$padding, self_1.$padding, self_1.$padding, self_1.$padding); - egret_native.NativeDisplayObject.setDataToFilter(self_1); - } - }; - return CustomFilter; - }(egret.Filter)); - egret.CustomFilter = CustomFilter; - __reflect(CustomFilter.prototype, "egret.CustomFilter"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @class egret.DropShadowFilter - * @classdesc - * 可使用 DropShadowFilter 类向显示对象添加投影。 - * @extends egret.GlowFilter - * @version Egret 3.1.4 - * @platform Web,Native - */ - var DropShadowFilter = (function (_super) { - __extends(DropShadowFilter, _super); - /** - * Initializes a new DropShadowFilter instance. - * @method egret.DropShadowFilter#constructor - * @param distance {number} The offset distance of the bevel. Valid values are in pixels (floating point). - * @param angle {number} The angle of the bevel. Valid values are from 0 to 360°. - * @param color {number} The color of the glow. Valid values are in the hexadecimal format 0xRRGGBB. The default value is 0xFF0000. - * @param alpha {number} The alpha transparency value for the color. Valid values are 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1. - * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point). - * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point). - * @param strength {number} The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255. - * @param quality {number} The number of times to apply the filter. - * @param inner {boolean} Specifies whether the glow is an inner glow. The value true indicates an inner glow. The default is false, an outer glow (a glow around the outer edges of the object). - * @param knockout {number} Specifies whether the object has a knockout effect. A value of true makes the object's fill transparent and reveals the background color of the document. The default value is false (no knockout effect). - * @param hideObject {number} Indicates whether or not the object is hidden. The value true indicates that the object itself is not drawn; only the shadow is visible. The default is false, meaning that the object is shown. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 初始化 DropShadowFilter 对象 - * @method egret.DropShadowFilter#constructor - * @param distance {number} 阴影的偏移距离,以像素为单位。 - * @param angle {number} 阴影的角度,0 到 360 度(浮点)。 - * @param color {number} 光晕颜色,采用十六进制格式 0xRRGGBB。默认值为 0xFF0000。 - * @param alpha {number} 颜色的 Alpha 透明度值。有效值为 0 到 1。例如,0.25 设置透明度值为 25%。 - * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。 - * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。 - * @param strength {number} 印记或跨页的强度。该值越高,压印的颜色越深,而且发光与背景之间的对比度也越强。有效值为 0 到 255。 - * @param quality {number} 应用滤镜的次数。暂未实现。 - * @param inner {boolean} 指定发光是否为内侧发光。值 true 指定发光是内侧发光。值 false 指定发光是外侧发光(对象外缘周围的发光)。 - * @param knockout {number} 指定对象是否具有挖空效果。值为 true 将使对象的填充变为透明,并显示文档的背景颜色。 - * @param hideObject {number} 表示是否隐藏对象。如果值为 true,则表示没有绘制对象本身,只有阴影是可见的。默认值为 false(显示对象)。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - function DropShadowFilter(distance, angle, color, alpha, blurX, blurY, strength, quality, inner, knockout, hideObject) { - if (distance === void 0) { distance = 4.0; } - if (angle === void 0) { angle = 45; } - if (color === void 0) { color = 0; } - if (alpha === void 0) { alpha = 1.0; } - if (blurX === void 0) { blurX = 4.0; } - if (blurY === void 0) { blurY = 4.0; } - if (strength === void 0) { strength = 1.0; } - if (quality === void 0) { quality = 1; } - if (inner === void 0) { inner = false; } - if (knockout === void 0) { knockout = false; } - if (hideObject === void 0) { hideObject = false; } - var _this = _super.call(this, color, alpha, blurX, blurY, strength, quality, inner, knockout) || this; - var self = _this; - self.$distance = distance; - self.$angle = angle; - self.$hideObject = hideObject; - self.$uniforms.dist = distance; - self.$uniforms.angle = angle / 180 * Math.PI; - self.$uniforms.hideObject = hideObject ? 1 : 0; - self.onPropertyChange(); - return _this; - } - Object.defineProperty(DropShadowFilter.prototype, "distance", { - /** - * The offset distance of the bevel. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 阴影的偏移距离,以像素为单位。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$distance; - }, - set: function (value) { - var self = this; - if (self.$distance == value) { - return; - } - self.$distance = value; - self.$uniforms.dist = value; - self.onPropertyChange(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DropShadowFilter.prototype, "angle", { - /** - * The angle of the bevel. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 阴影的角度。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$angle; - }, - set: function (value) { - var self = this; - if (self.$angle == value) { - return; - } - self.$angle = value; - self.$uniforms.angle = value / 180 * Math.PI; - self.onPropertyChange(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DropShadowFilter.prototype, "hideObject", { - /** - * Indicates whether or not the object is hidden. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 表示是否隐藏对象。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$hideObject; - }, - set: function (value) { - if (this.$hideObject == value) { - return; - } - this.$hideObject = value; - this.$uniforms.hideObject = value ? 1 : 0; - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - DropShadowFilter.prototype.$toJson = function () { - return '{"distance": ' + this.$distance + ', "angle": ' + this.$angle + ', "color": ' + this.$color + ', "red": ' + this.$red + ', "green": ' + this.$green + ', "blue": ' + this.$blue + ', "alpha": ' + this.$alpha + ', "blurX": ' + this.$blurX + ', "blurY": ' + this.blurY + ', "strength": ' + this.$strength + ', "quality": ' + this.$quality + ', "inner": ' + this.$inner + ', "knockout": ' + this.$knockout + ', "hideObject": ' + this.$hideObject + '}'; - }; - DropShadowFilter.prototype.updatePadding = function () { - var self = this; - self.paddingLeft = self.blurX; - self.paddingRight = self.blurX; - self.paddingTop = self.blurY; - self.paddingBottom = self.blurY; - var distance = self.distance || 0; - var angle = self.angle || 0; - var distanceX = 0; - var distanceY = 0; - if (distance != 0) { - distanceX = distance * egret.NumberUtils.cos(angle); - if (distanceX > 0) { - distanceX = Math.ceil(distanceX); - } - else { - distanceX = Math.floor(distanceX); - } - distanceY = distance * egret.NumberUtils.sin(angle); - if (distanceY > 0) { - distanceY = Math.ceil(distanceY); - } - else { - distanceY = Math.floor(distanceY); - } - self.paddingLeft += distanceX; - self.paddingRight += distanceX; - self.paddingTop += distanceY; - self.paddingBottom += distanceY; - } - }; - return DropShadowFilter; - }(egret.GlowFilter)); - egret.DropShadowFilter = DropShadowFilter; - __reflect(DropShadowFilter.prototype, "egret.DropShadowFilter"); -})(egret || (egret = {})); -var egret; -(function (egret) { - /** - * The GradientType class provides values for the type parameter in the beginGradientFill() methods of the egret.Graphics class. - * - * @see egret.Graphics#beginGradientFill() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * GradientType 类为 egret.Graphics 类的 beginGradientFill() 方法中的 type 参数提供值。 - * - * @see egret.Graphics#beginGradientFill() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var GradientType = (function () { - function GradientType() { - } - /** - * Value used to specify a linear gradient fill. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定线性渐变填充的值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - GradientType.LINEAR = "linear"; - /** - * Value used to specify a radial gradient fill. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定放射状渐变填充的值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - GradientType.RADIAL = "radial"; - return GradientType; - }()); - egret.GradientType = GradientType; - __reflect(GradientType.prototype, "egret.GradientType"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - * 格式化弧线角度的值 - */ - function clampAngle(value) { - value %= Math.PI * 2; - if (value < 0) { - value += Math.PI * 2; - } - return value; - } - /** - * @private - * 根据传入的锚点组返回贝塞尔曲线上的一组点,返回类型为egret.Point[]; - * @param pointsData 锚点组,保存着所有控制点的x和y坐标,格式为[x0,y0,x1,y1,x2,y2...] - * @param pointsAmount 要获取的点的总个数,实际返回点数不一定等于该属性,与范围有关 - * @param range 要获取的点与中心锚点的范围值,0~1之间 - * @returns egret.Point[]; - */ - function createBezierPoints(pointsData, pointsAmount) { - var points = []; - for (var i = 0; i < pointsAmount; i++) { - var point = getBezierPointByFactor(pointsData, i / pointsAmount); - if (point) - points.push(point); - } - return points; - } - /** - * @private - * 根据锚点组与取值系数获取贝塞尔曲线上的一点 - * @param pointsData 锚点组,保存着所有控制点的x和y坐标,格式为[x0,y0,x1,y1,x2,y2...] - * @param t 取值系数 - * @returns egret.Point - */ - function getBezierPointByFactor(pointsData, t) { - var i = 0; - var x = 0, y = 0; - var len = pointsData.length; - //根据传入的数据数量判断是二次贝塞尔还是三次贝塞尔 - if (len / 2 == 3) { - //二次 - var x0 = pointsData[i++]; - var y0 = pointsData[i++]; - var x1 = pointsData[i++]; - var y1 = pointsData[i++]; - var x2 = pointsData[i++]; - var y2 = pointsData[i++]; - x = getCurvePoint(x0, x1, x2, t); - y = getCurvePoint(y0, y1, y2, t); - } - else if (len / 2 == 4) { - //三次 - var x0 = pointsData[i++]; - var y0 = pointsData[i++]; - var x1 = pointsData[i++]; - var y1 = pointsData[i++]; - var x2 = pointsData[i++]; - var y2 = pointsData[i++]; - var x3 = pointsData[i++]; - var y3 = pointsData[i++]; - x = getCubicCurvePoint(x0, x1, x2, x3, t); - y = getCubicCurvePoint(y0, y1, y2, y3, t); - } - return egret.Point.create(x, y); - } - /** - * 通过factor参数获取二次贝塞尔曲线上的位置 - * 公式为B(t) = (1-t)^2 * P0 + 2t(1-t) * P1 + t^2 * P2 - * @param value0 P0 - * @param value1 P1 - * @param value2 P2 - * @param factor t,从0到1的闭区间 - */ - function getCurvePoint(value0, value1, value2, factor) { - var result = Math.pow((1 - factor), 2) * value0 + 2 * factor * (1 - factor) * value1 + Math.pow(factor, 2) * value2; - return result; - } - /** - * 通过factor参数获取三次贝塞尔曲线上的位置 - * 公式为B(t) = (1-t)^3 * P0 + 3t(1-t)^2 * P1 + 3t^2 * (1-t) t^2 * P2 + t^3 *P3 - * @param value0 P0 - * @param value1 P1 - * @param value2 P2 - * @param value3 P3 - * @param factor t,从0到1的闭区间 - */ - function getCubicCurvePoint(value0, value1, value2, value3, factor) { - var result = Math.pow((1 - factor), 3) * value0 + 3 * factor * Math.pow((1 - factor), 2) * value1 + 3 * (1 - factor) * Math.pow(factor, 2) * value2 + Math.pow(factor, 3) * value3; - return result; - } - /** - * The Graphics class contains a set of methods for creating vector shape. Display objects that support drawing include Sprite and Shape objects. Each class in these classes includes the graphics attribute that is a Graphics object. - * The following auxiliary functions are provided for ease of use: drawRect(), drawRoundRect(), drawCircle(), and drawEllipse(). - * @see http://edn.egret.com/cn/docs/page/136 Draw Rectangle - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Graphics.ts - * @language en_US - */ - /** - * Graphics 类包含一组可用来创建矢量形状的方法。支持绘制的显示对象包括 Sprite 和 Shape 对象。这些类中的每一个类都包括 graphics 属性,该属性是一个 Graphics 对象。 - * 以下是为便于使用而提供的一些辅助函数:drawRect()、drawRoundRect()、drawCircle() 和 drawEllipse()。 - * @see http://edn.egret.com/cn/docs/page/136 绘制矩形 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Graphics.ts - * @language zh_CN - */ - var Graphics = (function (_super) { - __extends(Graphics, _super); - /** - * Initializes a Graphics object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Graphics 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Graphics() { - var _this = _super.call(this) || this; - /** - * 当前移动到的坐标X - */ - _this.lastX = 0; - /** - * 当前移动到的坐标Y - */ - _this.lastY = 0; - /** - * 当前正在绘制的填充 - */ - _this.fillPath = null; - /** - * 当前正在绘制的线条 - */ - _this.strokePath = null; - /** - * 线条的左上方宽度 - */ - _this.topLeftStrokeWidth = 0; - /** - * 线条的右下方宽度 - */ - _this.bottomRightStrokeWidth = 0; - /** - * @private - */ - _this.minX = Infinity; - /** - * @private - */ - _this.minY = Infinity; - /** - * @private - */ - _this.maxX = -Infinity; - /** - * @private - */ - _this.maxY = -Infinity; - /** - * 是否已经包含上一次moveTo的坐标点 - */ - _this.includeLastPosition = true; - _this.$renderNode = new egret.sys.GraphicsNode(); - return _this; - } - /** - * @private - * 设置绑定到的目标显示对象 - */ - Graphics.prototype.$setTarget = function (target) { - if (this.$targetDisplay) { - this.$targetDisplay.$renderNode = null; - } - target.$renderNode = this.$renderNode; - this.$targetDisplay = target; - this.$targetIsSprite = target instanceof egret.Sprite; - }; - /** - * 对1像素和3像素特殊处理,向右下角偏移0.5像素,以显示清晰锐利的线条。 - */ - Graphics.prototype.setStrokeWidth = function (width) { - switch (width) { - case 1: - this.topLeftStrokeWidth = 0; - this.bottomRightStrokeWidth = 1; - break; - case 3: - this.topLeftStrokeWidth = 1; - this.bottomRightStrokeWidth = 2; - break; - default: - var half = Math.ceil(width * 0.5) | 0; - this.topLeftStrokeWidth = half; - this.bottomRightStrokeWidth = half; - break; - } - }; - /** - * Specify a simple single color fill that will be used for subsequent calls to other Graphics methods (for example, lineTo() and drawCircle()) when drawing. - * Calling the clear() method will clear the fill. - * @param color Filled color - * @param alpha Filled Alpha value - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * 调用 clear() 方法会清除填充。 - * @param color 填充的颜色 - * @param alpha 填充的 Alpha 值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.beginFill = function (color, alpha) { - if (alpha === void 0) { alpha = 1; } - color = +color || 0; - alpha = +alpha || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setBeginFill(color, alpha); - } - this.fillPath = this.$renderNode.beginFill(color, alpha, this.strokePath); - if (this.$renderNode.drawData.length > 1) { - this.fillPath.moveTo(this.lastX, this.lastY); - } - }; - /** - * Specifies a gradient fill used by subsequent calls to other Graphics methods (such as lineTo() or drawCircle()) for the object. - * Calling the clear() method clears the fill. - * @param type A value from the GradientType class that specifies which gradient type to use: GradientType.LINEAR or GradientType.RADIAL. - * @param colors An array of RGB hexadecimal color values used in the gradient; for example, red is 0xFF0000, blue is 0x0000FF, and so on. You can specify up to 15 colors. For each color, specify a corresponding value in the alphas and ratios parameters. - * @param alphas An array of alpha values for the corresponding colors in the colors array; - * @param ratios An array of color distribution ratios; valid values are 0-255. - * @param matrix A transformation matrix as defined by the egret.Matrix class. The egret.Matrix class includes a createGradientBox() method, which lets you conveniently set up the matrix for use with the beginGradientFill() method. - * @platform Web,Native - * @version Egret 2.4 - * @language en_US - */ - /** - * 指定一种渐变填充,用于随后调用对象的其他 Graphics 方法(如 lineTo() 或 drawCircle())。 - * 调用 clear() 方法会清除填充。 - * @param type 用于指定要使用哪种渐变类型的 GradientType 类的值:GradientType.LINEAR 或 GradientType.RADIAL。 - * @param colors 渐变中使用的 RGB 十六进制颜色值的数组(例如,红色为 0xFF0000,蓝色为 0x0000FF,等等)。对于每种颜色,请在 alphas 和 ratios 参数中指定对应值。 - * @param alphas colors 数组中对应颜色的 alpha 值数组。 - * @param ratios 颜色分布比率的数组。有效值为 0 到 255。 - * @param matrix 一个由 egret.Matrix 类定义的转换矩阵。egret.Matrix 类包括 createGradientBox() 方法,通过该方法可以方便地设置矩阵,以便与 beginGradientFill() 方法一起使用 - * @platform Web,Native - * @version Egret 2.4 - * @language zh_CN - */ - Graphics.prototype.beginGradientFill = function (type, colors, alphas, ratios, matrix) { - if (matrix === void 0) { matrix = null; } - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setBeginGradientFill(type, colors, alphas, ratios, matrix); - } - this.fillPath = this.$renderNode.beginGradientFill(type, colors, alphas, ratios, matrix, this.strokePath); - if (this.$renderNode.drawData.length > 1) { - this.fillPath.moveTo(this.lastX, this.lastY); - } - }; - /** - * Apply fill to the lines and curves added after the previous calling to the beginFill() method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 对从上一次调用 beginFill()方法之后添加的直线和曲线应用填充。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.endFill = function () { - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setEndFill(); - } - this.fillPath = null; - }; - /** - * Specify a line style that will be used for subsequent calls to Graphics methods such as lineTo() and drawCircle(). - * @param thickness An integer, indicating the thickness of the line in points. Valid values are 0 to 255. If a number is not specified, or if the parameter is undefined, a line is not drawn. If a value less than 0 is passed, the default value is 0. Value 0 indicates hairline thickness; the maximum thickness is 255. If a value greater than 255 is passed, the default value is 255. - * @param color A hexadecimal color value of the line (for example, red is 0xFF0000, and blue is 0x0000FF, etc.). If no value is specified, the default value is 0x000000 (black). Optional. - * @param alpha Indicates Alpha value of the line's color. Valid values are 0 to 1. If no value is specified, the default value is 1 (solid). If the value is less than 0, the default value is 0. If the value is greater than 1, the default value is 1. - * @param pixelHinting A boolean value that specifies whether to hint strokes to full pixels. This affects both the position of anchors of a curve and the line stroke size itself. With pixelHinting set to true, the line width is adjusted to full pixel width. With pixelHinting set to false, disjoints can appear for curves and straight lines. - * @param scaleMode Specifies the scale mode to be used - * @param caps Specifies the value of the CapsStyle class of the endpoint type at the end of the line. (default = CapsStyle.ROUND) - * @param joints Specifies the type of joint appearance of corner. (default = JointStyle.ROUND) - * @param miterLimit Indicates the limit number of cut miter. - * @param lineDash set the line dash. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。 - * @param thickness 一个整数,以点为单位表示线条的粗细,有效值为 0 到 255。如果未指定数字,或者未定义该参数,则不绘制线条。如果传递的值小于 0,则默认值为 0。值 0 表示极细的粗细;最大粗细为 255。如果传递的值大于 255,则默认值为 255。 - * @param color 线条的十六进制颜色值(例如,红色为 0xFF0000,蓝色为 0x0000FF 等)。如果未指明值,则默认值为 0x000000(黑色)。可选。 - * @param alpha 表示线条颜色的 Alpha 值的数字;有效值为 0 到 1。如果未指明值,则默认值为 1(纯色)。如果值小于 0,则默认值为 0。如果值大于 1,则默认值为 1。 - * @param pixelHinting 布尔型值,指定是否提示笔触采用完整像素。它同时影响曲线锚点的位置以及线条笔触大小本身。在 pixelHinting 设置为 true 的情况下,线条宽度会调整到完整像素宽度。在 pixelHinting 设置为 false 的情况下,对于曲线和直线可能会出现脱节。 - * @param scaleMode 用于指定要使用的比例模式 - * @param caps 用于指定线条末端处端点类型的 CapsStyle 类的值。默认值:CapsStyle.ROUND - * @param joints 指定用于拐角的连接外观的类型。默认值:JointStyle.ROUND - * @param miterLimit 用于表示剪切斜接的极限值的数字。 - * @param lineDash 设置虚线样式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.lineStyle = function (thickness, color, alpha, pixelHinting, scaleMode, caps, joints, miterLimit, lineDash) { - if (thickness === void 0) { thickness = NaN; } - if (color === void 0) { color = 0; } - if (alpha === void 0) { alpha = 1.0; } - if (pixelHinting === void 0) { pixelHinting = false; } - if (scaleMode === void 0) { scaleMode = "normal"; } - if (caps === void 0) { caps = null; } - if (joints === void 0) { joints = null; } - if (miterLimit === void 0) { miterLimit = 3; } - thickness = +thickness || 0; - color = +color || 0; - alpha = +alpha || 0; - miterLimit = +miterLimit || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setLineStyle(thickness, color, alpha, pixelHinting, scaleMode, caps, joints, miterLimit); - } - if (thickness <= 0) { - this.strokePath = null; - this.setStrokeWidth(0); - } - else { - this.setStrokeWidth(thickness); - this.strokePath = this.$renderNode.lineStyle(thickness, color, alpha, caps, joints, miterLimit, lineDash); - if (this.$renderNode.drawData.length > 1) { - this.strokePath.moveTo(this.lastX, this.lastY); - } - } - }; - /** - * Draw a rectangle - * @param x x position of the center, relative to the registration point of the parent display object (in pixels). - * @param y y position of the center, relative to the registration point of the parent display object (in pixels). - * @param width Width of the rectangle (in pixels). - * @param height Height of the rectangle (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个矩形 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.drawRect = function (x, y, width, height) { - x = +x || 0; - y = +y || 0; - width = +width || 0; - height = +height || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setDrawRect(x, y, width, height); - } - var fillPath = this.fillPath; - var strokePath = this.strokePath; - fillPath && fillPath.drawRect(x, y, width, height); - strokePath && strokePath.drawRect(x, y, width, height); - this.extendBoundsByPoint(x + width, y + height); - this.updatePosition(x, y); - this.dirty(); - }; - /** - * Draw a rectangle with rounded corners. - * @param x x position of the center, relative to the registration point of the parent display object (in pixels). - * @param y y position of the center, relative to the registration point of the parent display object (in pixels). - * @param width Width of the rectangle (in pixels). - * @param height Height of the rectangle (in pixels). - * @param ellipseWidth Width used to draw an ellipse with rounded corners (in pixels). - * @param ellipseHeight Height used to draw an ellipse with rounded corners (in pixels). (Optional) If no value is specified, the default value matches the value of the ellipseWidth parameter. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个圆角矩形。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @param ellipseWidth 用于绘制圆角的椭圆的宽度(以像素为单位)。 - * @param ellipseHeight 用于绘制圆角的椭圆的高度(以像素为单位)。 (可选)如果未指定值,则默认值与为 ellipseWidth 参数提供的值相匹配。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.drawRoundRect = function (x, y, width, height, ellipseWidth, ellipseHeight) { - x = +x || 0; - y = +y || 0; - width = +width || 0; - height = +height || 0; - ellipseWidth = +ellipseWidth || 0; - ellipseHeight = +ellipseHeight || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setDrawRoundRect(x, y, width, height, ellipseWidth, ellipseHeight); - } - var fillPath = this.fillPath; - var strokePath = this.strokePath; - fillPath && fillPath.drawRoundRect(x, y, width, height, ellipseWidth, ellipseHeight); - strokePath && strokePath.drawRoundRect(x, y, width, height, ellipseWidth, ellipseHeight); - var radiusX = (ellipseWidth * 0.5) | 0; - var radiusY = ellipseHeight ? (ellipseHeight * 0.5) | 0 : radiusX; - var right = x + width; - var bottom = y + height; - var ybw = bottom - radiusY; - this.extendBoundsByPoint(x, y); - this.extendBoundsByPoint(right, bottom); - this.updatePosition(right, ybw); - this.dirty(); - }; - /** - * Draw a circle. - * @param x x position of the center, relative to the registration point of the parent display object (in pixels). - * @param y y position of the center, relative to the registration point of the parent display object (in pixels). - * @param r Radius of the circle (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个圆。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param radius 圆的半径(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.drawCircle = function (x, y, radius) { - x = +x || 0; - y = +y || 0; - radius = +radius || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setDrawCircle(x, y, radius); - } - var fillPath = this.fillPath; - var strokePath = this.strokePath; - fillPath && fillPath.drawCircle(x, y, radius); - strokePath && strokePath.drawCircle(x, y, radius); - //-1 +2 解决WebGL裁切问题 - this.extendBoundsByPoint(x - radius - 1, y - radius - 1); - this.extendBoundsByPoint(x + radius + 2, y + radius + 2); - this.updatePosition(x + radius, y); - this.dirty(); - }; - /** - * Draw an ellipse. - * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels). - * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels). - * @param width Width of the rectangle (in pixels). - * @param height Height of the rectangle (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个椭圆。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.drawEllipse = function (x, y, width, height) { - x = +x || 0; - y = +y || 0; - width = +width || 0; - height = +height || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setDrawEllipse(x, y, width, height); - } - var fillPath = this.fillPath; - var strokePath = this.strokePath; - fillPath && fillPath.drawEllipse(x, y, width, height); - strokePath && strokePath.drawEllipse(x, y, width, height); - //-1 +2 解决WebGL裁切问题 - this.extendBoundsByPoint(x - 1, y - 1); - this.extendBoundsByPoint(x + width + 2, y + height + 2); - this.updatePosition(x + width, y + height * 0.5); - this.dirty(); - }; - /** - * Move the current drawing position to (x, y). If any of these parameters is missed, calling this method will fail and the current drawing position keeps unchanged. - * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels). - * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将当前绘图位置移动到 (x, y)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.moveTo = function (x, y) { - x = +x || 0; - y = +y || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setMoveTo(x, y); - } - var fillPath = this.fillPath; - var strokePath = this.strokePath; - fillPath && fillPath.moveTo(x, y); - strokePath && strokePath.moveTo(x, y); - this.includeLastPosition = false; - this.lastX = x; - this.lastY = y; - this.dirty(); - }; - /** - * Draw a straight line from the current drawing position to (x, y) using the current line style; the current drawing position is then set to (x, y). - * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels). - * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用当前线条样式绘制一条从当前绘图位置开始到 (x, y) 结束的直线;当前绘图位置随后会设置为 (x, y)。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.lineTo = function (x, y) { - x = +x || 0; - y = +y || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setLineTo(x, y); - } - var fillPath = this.fillPath; - var strokePath = this.strokePath; - fillPath && fillPath.lineTo(x, y); - strokePath && strokePath.lineTo(x, y); - this.updatePosition(x, y); - this.dirty(); - }; - /** - * Draw a quadratic Bezier curve from the current drawing position to (anchorX, anchorY) using the current line style according to the control points specified by (controlX, controlY). The current drawing position is then set to (anchorX, anchorY). - * If the curveTo() method is called before the moveTo() method, the default value of the current drawing position is (0, 0). If any of these parameters is missed, calling this method will fail and the current drawing position keeps unchanged. - * The drawn curve is a quadratic Bezier curve. A quadratic Bezier curve contains two anchor points and one control point. The curve interpolates the two anchor points and bends to the control point. - * @param controlX A number indicating the horizontal position of the control point, relative to the registration point of the parent display object. - * @param controlY A number indicating the vertical position of the control point, relative to the registration point of the parent display object. - * @param anchorX A number indicating the horizontal position of the next anchor point, relative to the registration point of the parent display object. - * @param anchorY A number indicating the vertical position of the next anchor point, relative to the registration point of the parent display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用当前线条样式和由 (controlX, controlY) 指定的控制点绘制一条从当前绘图位置开始到 (anchorX, anchorY) 结束的二次贝塞尔曲线。当前绘图位置随后设置为 (anchorX, anchorY)。 - * 如果在调用 moveTo() 方法之前调用了 curveTo() 方法,则当前绘图位置的默认值为 (0, 0)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * 绘制的曲线是二次贝塞尔曲线。二次贝塞尔曲线包含两个锚点和一个控制点。该曲线内插这两个锚点,并向控制点弯曲。 - * @param controlX 一个数字,指定控制点相对于父显示对象注册点的水平位置。 - * @param controlY 一个数字,指定控制点相对于父显示对象注册点的垂直位置。 - * @param anchorX 一个数字,指定下一个锚点相对于父显示对象注册点的水平位置。 - * @param anchorY 一个数字,指定下一个锚点相对于父显示对象注册点的垂直位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.curveTo = function (controlX, controlY, anchorX, anchorY) { - controlX = +controlX || 0; - controlY = +controlY || 0; - anchorX = +anchorX || 0; - anchorY = +anchorY || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setCurveTo(controlX, controlY, anchorX, anchorY); - } - var fillPath = this.fillPath; - var strokePath = this.strokePath; - fillPath && fillPath.curveTo(controlX, controlY, anchorX, anchorY); - strokePath && strokePath.curveTo(controlX, controlY, anchorX, anchorY); - var lastX = this.lastX || 0; - var lastY = this.lastY || 0; - var bezierPoints = createBezierPoints([lastX, lastY, controlX, controlY, anchorX, anchorY], 50); - for (var i = 0; i < bezierPoints.length; i++) { - var point = bezierPoints[i]; - this.extendBoundsByPoint(point.x, point.y); - egret.Point.release(point); - } - this.extendBoundsByPoint(anchorX, anchorY); - this.updatePosition(anchorX, anchorY); - this.dirty(); - }; - /** - * Draws a cubic Bezier curve from the current drawing position to the specified anchor. Cubic Bezier curves consist of two anchor points and two control points. The curve interpolates the two anchor points and two control points to the curve. - * @param controlX1 Specifies the first control point relative to the registration point of the parent display the horizontal position of the object. - * @param controlY1 Specifies the first control point relative to the registration point of the parent display the vertical position of the object. - * @param controlX2 Specify the second control point relative to the registration point of the parent display the horizontal position of the object. - * @param controlY2 Specify the second control point relative to the registration point of the parent display the vertical position of the object. - * @param anchorX Specifies the anchor point relative to the registration point of the parent display the horizontal position of the object. - * @param anchorY Specifies the anchor point relative to the registration point of the parent display the vertical position of the object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从当前绘图位置到指定的锚点绘制一条三次贝塞尔曲线。三次贝塞尔曲线由两个锚点和两个控制点组成。该曲线内插这两个锚点,并向两个控制点弯曲。 - * @param controlX1 指定首个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY1 指定首个控制点相对于父显示对象的注册点的垂直位置。 - * @param controlX2 指定第二个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY2 指定第二个控制点相对于父显示对象的注册点的垂直位置。 - * @param anchorX 指定锚点相对于父显示对象的注册点的水平位置。 - * @param anchorY 指定锚点相对于父显示对象的注册点的垂直位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.cubicCurveTo = function (controlX1, controlY1, controlX2, controlY2, anchorX, anchorY) { - controlX1 = +controlX1 || 0; - controlY1 = +controlY1 || 0; - controlX2 = +controlX2 || 0; - controlY2 = +controlY2 || 0; - anchorX = +anchorX || 0; - anchorY = +anchorY || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setCubicCurveTo(controlX1, controlY1, controlX2, controlY2, anchorX, anchorY); - } - var fillPath = this.fillPath; - var strokePath = this.strokePath; - fillPath && fillPath.cubicCurveTo(controlX1, controlY1, controlX2, controlY2, anchorX, anchorY); - strokePath && strokePath.cubicCurveTo(controlX1, controlY1, controlX2, controlY2, anchorX, anchorY); - var lastX = this.lastX || 0; - var lastY = this.lastY || 0; - var bezierPoints = createBezierPoints([lastX, lastY, controlX1, controlY1, controlX2, controlY2, anchorX, anchorY], 50); - for (var i = 0; i < bezierPoints.length; i++) { - var point = bezierPoints[i]; - this.extendBoundsByPoint(point.x, point.y); - egret.Point.release(point); - } - this.extendBoundsByPoint(anchorX, anchorY); - this.updatePosition(anchorX, anchorY); - this.dirty(); - }; - /** - * adds an arc to the path which is centered at (x, y) position with radius r starting at startAngle and ending - * at endAngle going in the given direction by anticlockwise (defaulting to clockwise). - * @param x The x coordinate of the arc's center. - * @param y The y coordinate of the arc's center. - * @param radius The arc's radius. - * @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians. - * @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians. - * @param anticlockwise if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一段圆弧路径。圆弧路径的圆心在 (x, y) 位置,半径为 r ,根据anticlockwise (默认为顺时针)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radius 圆弧的半径。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.drawArc = function (x, y, radius, startAngle, endAngle, anticlockwise) { - if (radius < 0 || startAngle === endAngle) { - return; - } - x = +x || 0; - y = +y || 0; - radius = +radius || 0; - startAngle = +startAngle || 0; - endAngle = +endAngle || 0; - anticlockwise = !!anticlockwise; - startAngle = clampAngle(startAngle); - endAngle = clampAngle(endAngle); - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setDrawArc(x, y, radius, startAngle, endAngle, anticlockwise); - } - var fillPath = this.fillPath; - var strokePath = this.strokePath; - if (fillPath) { - fillPath.$lastX = this.lastX; - fillPath.$lastY = this.lastY; - fillPath.drawArc(x, y, radius, startAngle, endAngle, anticlockwise); - } - if (strokePath) { - strokePath.$lastX = this.lastX; - strokePath.$lastY = this.lastY; - strokePath.drawArc(x, y, radius, startAngle, endAngle, anticlockwise); - } - if (anticlockwise) { - this.arcBounds(x, y, radius, endAngle, startAngle); - } - else { - this.arcBounds(x, y, radius, startAngle, endAngle); - } - var endX = x + Math.cos(endAngle) * radius; - var endY = y + Math.sin(endAngle) * radius; - this.updatePosition(endX, endY); - this.dirty(); - }; - Graphics.prototype.dirty = function () { - var self = this; - self.$renderNode.dirtyRender = true; - if (!egret.nativeRender) { - var target = self.$targetDisplay; - target.$cacheDirty = true; - var p = target.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = target.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - /** - * @private - * 测量圆弧的矩形大小 - */ - Graphics.prototype.arcBounds = function (x, y, radius, startAngle, endAngle) { - var PI = Math.PI; - if (Math.abs(startAngle - endAngle) < 0.01) { - this.extendBoundsByPoint(x - radius, y - radius); - this.extendBoundsByPoint(x + radius, y + radius); - return; - } - if (startAngle > endAngle) { - endAngle += PI * 2; - } - var startX = Math.cos(startAngle) * radius; - var endX = Math.cos(endAngle) * radius; - var xMin = Math.min(startX, endX); - var xMax = Math.max(startX, endX); - var startY = Math.sin(startAngle) * radius; - var endY = Math.sin(endAngle) * radius; - var yMin = Math.min(startY, endY); - var yMax = Math.max(startY, endY); - var startRange = startAngle / (PI * 0.5); - var endRange = endAngle / (PI * 0.5); - for (var i = Math.ceil(startRange); i <= endRange; i++) { - switch (i % 4) { - case 0: - xMax = radius; - break; - case 1: - yMax = radius; - break; - case 2: - xMin = -radius; - break; - case 3: - yMin = -radius; - break; - } - } - xMin = Math.floor(xMin); - yMin = Math.floor(yMin); - xMax = Math.ceil(xMax); - yMax = Math.ceil(yMax); - this.extendBoundsByPoint(xMin + x, yMin + y); - this.extendBoundsByPoint(xMax + x, yMax + y); - }; - /** - * Clear graphics that are drawn to this Graphics object, and reset fill and line style settings. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 清除绘制到此 Graphics 对象的图形,并重置填充和线条样式设置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.clear = function () { - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setGraphicsClear(); - } - this.$renderNode.clear(); - this.updatePosition(0, 0); - this.minX = Infinity; - this.minY = Infinity; - this.maxX = -Infinity; - this.maxY = -Infinity; - this.dirty(); - }; - /** - * @private - */ - Graphics.prototype.extendBoundsByPoint = function (x, y) { - this.extendBoundsByX(x); - this.extendBoundsByY(y); - }; - /** - * @private - */ - Graphics.prototype.extendBoundsByX = function (x) { - this.minX = Math.min(this.minX, x - this.topLeftStrokeWidth); - this.maxX = Math.max(this.maxX, x + this.bottomRightStrokeWidth); - this.updateNodeBounds(); - }; - /** - * @private - */ - Graphics.prototype.extendBoundsByY = function (y) { - this.minY = Math.min(this.minY, y - this.topLeftStrokeWidth); - this.maxY = Math.max(this.maxY, y + this.bottomRightStrokeWidth); - this.updateNodeBounds(); - }; - /** - * @private - */ - Graphics.prototype.updateNodeBounds = function () { - var node = this.$renderNode; - node.x = this.minX; - node.y = this.minY; - node.width = Math.ceil(this.maxX - this.minX); - node.height = Math.ceil(this.maxY - this.minY); - }; - /** - * 更新当前的lineX和lineY值,并标记尺寸失效。 - * @private - */ - Graphics.prototype.updatePosition = function (x, y) { - if (!this.includeLastPosition) { - this.extendBoundsByPoint(this.lastX, this.lastY); - this.includeLastPosition = true; - } - this.lastX = x; - this.lastY = y; - this.extendBoundsByPoint(x, y); - }; - /** - * @private - */ - Graphics.prototype.$measureContentBounds = function (bounds) { - if (this.minX === Infinity) { - bounds.setEmpty(); - } - else { - bounds.setTo(this.minX, this.minY, this.maxX - this.minX, this.maxY - this.minY); - } - }; - /** - * @private - * - */ - Graphics.prototype.$hitTest = function (stageX, stageY) { - var target = this.$targetDisplay; - var m = target.$getInvertedConcatenatedMatrix(); - var localX = m.a * stageX + m.c * stageY + m.tx; - var localY = m.b * stageX + m.d * stageY + m.ty; - var buffer = egret.sys.canvasHitTestBuffer; - buffer.resize(3, 3); - var node = this.$renderNode; - var matrix = egret.Matrix.create(); - matrix.identity(); - matrix.translate(1 - localX, 1 - localY); - egret.sys.canvasRenderer.drawNodeToBuffer(node, buffer, matrix, true); - egret.Matrix.release(matrix); - try { - var data = buffer.getPixels(1, 1); - if (data[3] === 0) { - return null; - } - } - catch (e) { - throw new Error(egret.sys.tr(1039)); - } - return target; - }; - /** - * @private - */ - Graphics.prototype.$onRemoveFromStage = function () { - if (this.$renderNode) { - this.$renderNode.clean(); - } - if (egret.nativeRender) { - egret_native.NativeDisplayObject.disposeGraphicData(this); - } - }; - return Graphics; - }(egret.HashObject)); - egret.Graphics = Graphics; - __reflect(Graphics.prototype, "egret.Graphics"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var PI = Math.PI; - var TwoPI = PI * 2; - var DEG_TO_RAD = PI / 180; - var matrixPool = []; - /** - * The Matrix class represents a transformation matrix that determines how to map points from one coordinate space to - * another. You can perform various graphical transformations on a display object by setting the properties of a Matrix - * object, applying that Matrix object to the matrix property of a display object, These transformation functions include - * translation (x and y repositioning), rotation, scaling, and skewing. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Matrix.ts - * @language en_US - */ - /** - * Matrix 类表示一个转换矩阵,它确定如何将点从一个坐标空间映射到另一个坐标空间。 - * 您可以对一个显示对象执行不同的图形转换,方法是设置 Matrix 对象的属性,将该 Matrix - * 对象应用于显示对象的 matrix 属性。这些转换函数包括平移(x 和 y 重新定位)、旋转、缩放和倾斜。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Matrix.ts - * @language zh_CN - */ - var Matrix = (function (_super) { - __extends(Matrix, _super); - /** - * Creates a new Matrix object with the specified parameters. - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定参数创建一个 Matrix 对象 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值。 - * @param b 旋转或倾斜图像时影响像素沿 y 轴定位的值。 - * @param c 旋转或倾斜图像时影响像素沿 x 轴定位的值。 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值。 - * @param tx 沿 x 轴平移每个点的距离。 - * @param ty 沿 y 轴平移每个点的距离。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Matrix(a, b, c, d, tx, ty) { - if (a === void 0) { a = 1; } - if (b === void 0) { b = 0; } - if (c === void 0) { c = 0; } - if (d === void 0) { d = 1; } - if (tx === void 0) { tx = 0; } - if (ty === void 0) { ty = 0; } - var _this = _super.call(this) || this; - _this.a = a; - _this.b = b; - _this.c = c; - _this.d = d; - _this.tx = tx; - _this.ty = ty; - return _this; - } - /** - * Releases a matrix instance to the object pool - * @param matrix matrix that Needs to be recycled - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个Matrix实例到对象池 - * @param matrix 需要回收的 matrix - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.release = function (matrix) { - if (!matrix) { - return; - } - matrixPool.push(matrix); - }; - /** - * get a matrix instance from the object pool or create a new one. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的Matrix对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.create = function () { - var matrix = matrixPool.pop(); - if (!matrix) { - matrix = new Matrix(); - } - return matrix; - }; - /** - * Returns a new Matrix object that is a clone of this matrix, with an exact copy of the contained object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回一个新的 Matrix 对象,它是此矩阵的克隆,带有与所含对象完全相同的副本。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.clone = function () { - return new Matrix(this.a, this.b, this.c, this.d, this.tx, this.ty); - }; - /** - * Concatenates a matrix with the current matrix, effectively combining the geometric effects of the two. In mathematical - * terms, concatenating two matrixes is the same as combining them using matrix multiplication. - * @param other The matrix to be concatenated to the source matrix. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将某个矩阵与当前矩阵连接,从而将这两个矩阵的几何效果有效地结合在一起。在数学术语中,将两个矩阵连接起来与使用矩阵乘法将它们结合起来是相同的。 - * @param other 要连接到源矩阵的矩阵。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.concat = function (other) { - var a = this.a * other.a; - var b = 0.0; - var c = 0.0; - var d = this.d * other.d; - var tx = this.tx * other.a + other.tx; - var ty = this.ty * other.d + other.ty; - if (this.b !== 0.0 || this.c !== 0.0 || other.b !== 0.0 || other.c !== 0.0) { - a += this.b * other.c; - d += this.c * other.b; - b += this.a * other.b + this.b * other.d; - c += this.c * other.a + this.d * other.c; - tx += this.ty * other.c; - ty += this.tx * other.b; - } - this.a = a; - this.b = b; - this.c = c; - this.d = d; - this.tx = tx; - this.ty = ty; - }; - /** - * Copies all of the matrix data from the source Point object into the calling Matrix object. - * @param other The Matrix object from which to copy the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将源 Matrix 对象中的所有矩阵数据复制到调用方 Matrix 对象中。 - * @param other 要拷贝的目标矩阵 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.copyFrom = function (other) { - this.a = other.a; - this.b = other.b; - this.c = other.c; - this.d = other.d; - this.tx = other.tx; - this.ty = other.ty; - return this; - }; - /** - * Sets each matrix property to a value that causes a null transformation. An object transformed by applying an - * identity matrix will be identical to the original. After calling the identity() method, the resulting matrix - * has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 为每个矩阵属性设置一个值,该值将导致矩阵无转换。通过应用恒等矩阵转换的对象将与原始对象完全相同。 - * 调用 identity() 方法后,生成的矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0 和 ty=0。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.identity = function () { - this.a = this.d = 1; - this.b = this.c = this.tx = this.ty = 0; - }; - /** - * Performs the opposite transformation of the original matrix. You can apply an inverted matrix to an object to - * undo the transformation performed when applying the original matrix. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 执行原始矩阵的逆转换。 - * 您可以将一个逆矩阵应用于对象来撤消在应用原始矩阵时执行的转换。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.invert = function () { - this.$invertInto(this); - }; - /** - * @private - */ - Matrix.prototype.$invertInto = function (target) { - var a = this.a; - var b = this.b; - var c = this.c; - var d = this.d; - var tx = this.tx; - var ty = this.ty; - if (b == 0 && c == 0) { - target.b = target.c = 0; - if (a == 0 || d == 0) { - target.a = target.d = target.tx = target.ty = 0; - } - else { - a = target.a = 1 / a; - d = target.d = 1 / d; - target.tx = -a * tx; - target.ty = -d * ty; - } - return; - } - var determinant = a * d - b * c; - if (determinant == 0) { - target.identity(); - return; - } - determinant = 1 / determinant; - var k = target.a = d * determinant; - b = target.b = -b * determinant; - c = target.c = -c * determinant; - d = target.d = a * determinant; - target.tx = -(k * tx + c * ty); - target.ty = -(b * tx + d * ty); - }; - /** - * Applies a rotation transformation to the Matrix object. - * The rotate() method alters the a, b, c, and d properties of the Matrix object. - * @param angle The rotation angle in radians. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 对 Matrix 对象应用旋转转换。 - * rotate() 方法将更改 Matrix 对象的 a、b、c 和 d 属性。 - * @param angle 以弧度为单位的旋转角度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.rotate = function (angle) { - angle = +angle; - if (angle !== 0) { - angle = angle / DEG_TO_RAD; - var u = egret.NumberUtils.cos(angle); - var v = egret.NumberUtils.sin(angle); - var ta = this.a; - var tb = this.b; - var tc = this.c; - var td = this.d; - var ttx = this.tx; - var tty = this.ty; - this.a = ta * u - tb * v; - this.b = ta * v + tb * u; - this.c = tc * u - td * v; - this.d = tc * v + td * u; - this.tx = ttx * u - tty * v; - this.ty = ttx * v + tty * u; - } - }; - /** - * Applies a scaling transformation to the matrix. The x axis is multiplied by sx, and the y axis it is multiplied by sy. - * The scale() method alters the a and d properties of the Matrix object. - * @param sx A multiplier used to scale the object along the x axis. - * @param sy A multiplier used to scale the object along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 对矩阵应用缩放转换。x 轴乘以 sx,y 轴乘以 sy。 - * scale() 方法将更改 Matrix 对象的 a 和 d 属性。 - * @param sx 用于沿 x 轴缩放对象的乘数。 - * @param sy 用于沿 y 轴缩放对象的乘数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.scale = function (sx, sy) { - if (sx !== 1) { - this.a *= sx; - this.c *= sx; - this.tx *= sx; - } - if (sy !== 1) { - this.b *= sy; - this.d *= sy; - this.ty *= sy; - } - }; - /** - * Sets the members of Matrix to the specified values - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Matrix 的成员设置为指定值 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值。 - * @param b 旋转或倾斜图像时影响像素沿 y 轴定位的值。 - * @param c 旋转或倾斜图像时影响像素沿 x 轴定位的值。 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值。 - * @param tx 沿 x 轴平移每个点的距离。 - * @param ty 沿 y 轴平移每个点的距离。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.setTo = function (a, b, c, d, tx, ty) { - this.a = a; - this.b = b; - this.c = c; - this.d = d; - this.tx = tx; - this.ty = ty; - return this; - }; - /** - * Returns the result of applying the geometric transformation represented by the Matrix object to the specified point. - * @param pointX The x coordinate for which you want to get the result of the Matrix transformation. - * @param pointY The y coordinate for which you want to get the result of the Matrix transformation. - * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the - * number of reallocate objects, which allows you to get better code execution performance. - * @returns The point resulting from applying the Matrix transformation. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回将 Matrix 对象表示的几何转换应用于指定点所产生的结果。 - * @param pointX 想要获得其矩阵转换结果的点的x坐标。 - * @param pointY 想要获得其矩阵转换结果的点的y坐标。 - * @param resultPoint 框架建议尽可能减少创建对象次数来优化性能,可以从外部传入一个复用的Point对象来存储结果,若不传入将创建一个新的Point对象返回。 - * @returns 由应用矩阵转换所产生的点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.transformPoint = function (pointX, pointY, resultPoint) { - var x = this.a * pointX + this.c * pointY + this.tx; - var y = this.b * pointX + this.d * pointY + this.ty; - if (resultPoint) { - resultPoint.setTo(x, y); - return resultPoint; - } - return new egret.Point(x, y); - }; - /** - * Translates the matrix along the x and y axes, as specified by the dx and dy parameters. - * @param dx The amount of movement along the x axis to the right, in pixels. - * @param dy The amount of movement down along the y axis, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 沿 x 和 y 轴平移矩阵,由 dx 和 dy 参数指定。 - * @param dx 沿 x 轴向右移动的量(以像素为单位)。 - * @param dy 沿 y 轴向下移动的量(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.translate = function (dx, dy) { - this.tx += dx; - this.ty += dy; - }; - /** - * Determines whether two matrixes are equal. - * @param other The matrix to be compared. - * @returns A value of true if the object is equal to this Matrix object; false if it is not equal. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否与另一个矩阵数据相等 - * @param other 要比较的另一个矩阵对象。 - * @returns 是否相等,ture表示相等。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.equals = function (other) { - return this.a == other.a && this.b == other.b && - this.c == other.c && this.d == other.d && - this.tx == other.tx && this.ty == other.ty; - }; - /** - * prepend matrix - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @returns matrix - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 前置矩阵 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param b 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param c 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param tx 沿 x 轴平移每个点的距离 - * @param ty 沿 y 轴平移每个点的距离 - * @returns 矩阵自身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.prepend = function (a, b, c, d, tx, ty) { - var tx1 = this.tx; - if (a != 1 || b != 0 || c != 0 || d != 1) { - var a1 = this.a; - var c1 = this.c; - this.a = a1 * a + this.b * c; - this.b = a1 * b + this.b * d; - this.c = c1 * a + this.d * c; - this.d = c1 * b + this.d * d; - } - this.tx = tx1 * a + this.ty * c + tx; - this.ty = tx1 * b + this.ty * d + ty; - return this; - }; - /** - * append matrix - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @returns matrix - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 后置矩阵 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param b 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param c 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param tx 沿 x 轴平移每个点的距离 - * @param ty 沿 y 轴平移每个点的距离 - * @returns 矩阵自身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.append = function (a, b, c, d, tx, ty) { - var a1 = this.a; - var b1 = this.b; - var c1 = this.c; - var d1 = this.d; - if (a != 1 || b != 0 || c != 0 || d != 1) { - this.a = a * a1 + b * c1; - this.b = a * b1 + b * d1; - this.c = c * a1 + d * c1; - this.d = c * b1 + d * d1; - } - this.tx = tx * a1 + ty * c1 + this.tx; - this.ty = tx * b1 + ty * d1 + this.ty; - return this; - }; - /** - * Given a point in the pretransform coordinate space, returns the coordinates of that point after the transformation occurs. - * Unlike the standard transformation applied using the transformPoint() method, the deltaTransformPoint() method's transformation does not consider the translation parameters tx and ty. - * @param point The point for which you want to get the result of the matrix transformation. - * @returns The point resulting from applying the matrix transformation. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果给定预转换坐标空间中的点,则此方法返回发生转换后该点的坐标。 - * 与使用 transformPoint() 方法应用的标准转换不同,deltaTransformPoint() 方法的转换不考虑转换参数 tx 和 ty。 - * @param point 想要获得其矩阵转换结果的点 - * @returns 由应用矩阵转换所产生的点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.deltaTransformPoint = function (point) { - var self = this; - var x = self.a * point.x + self.c * point.y; - var y = self.b * point.x + self.d * point.y; - return new egret.Point(x, y); - }; - /** - * Returns a text value listing the properties of the Matrix object. - * @returns A string containing the values of the properties of the Matrix object: a, b, c, d, tx, and ty. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回将 Matrix 对象表示的几何转换应用于指定点所产生的结果。 - * @returns 一个字符串,它包含 Matrix 对象的属性值:a、b、c、d、tx 和 ty。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.toString = function () { - return "(a=" + this.a + ", b=" + this.b + ", c=" + this.c + ", d=" + this.d + ", tx=" + this.tx + ", ty=" + this.ty + ")"; - }; - /** - * Includes parameters for scaling, rotation, and translation. When applied to a matrix it sets the matrix's values based on those parameters. - * @param scaleX The factor by which to scale horizontally. - * @param scaleY The factor by which scale vertically. - * @param rotation The amount to rotate, in radians. - * @param tx The number of pixels to translate (move) to the right along the x axis. - * @param ty The number of pixels to translate (move) down along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 包括用于缩放、旋转和转换的参数。当应用于矩阵时,该方法会基于这些参数设置矩阵的值。 - * @param scaleX 水平缩放所用的系数 - * @param scaleY 垂直缩放所用的系数 - * @param rotation 旋转量(以弧度为单位) - * @param tx 沿 x 轴向右平移(移动)的像素数 - * @param ty 沿 y 轴向下平移(移动)的像素数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.createBox = function (scaleX, scaleY, rotation, tx, ty) { - if (rotation === void 0) { rotation = 0; } - if (tx === void 0) { tx = 0; } - if (ty === void 0) { ty = 0; } - var self = this; - if (rotation !== 0) { - rotation = rotation / DEG_TO_RAD; - var u = egret.NumberUtils.cos(rotation); - var v = egret.NumberUtils.sin(rotation); - self.a = u * scaleX; - self.b = v * scaleY; - self.c = -v * scaleX; - self.d = u * scaleY; - } - else { - self.a = scaleX; - self.b = 0; - self.c = 0; - self.d = scaleY; - } - self.tx = tx; - self.ty = ty; - }; - /** - * Creates the specific style of matrix expected by the beginGradientFill() and lineGradientStyle() methods of the Graphics class. - * Width and height are scaled to a scaleX/scaleY pair and the tx/ty values are offset by half the width and height. - * @param width The width of the gradient box. - * @param height The height of the gradient box. - * @param rotation The amount to rotate, in radians. - * @param tx The distance, in pixels, to translate to the right along the x axis. This value is offset by half of the width parameter. - * @param ty The distance, in pixels, to translate down along the y axis. This value is offset by half of the height parameter. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建 Graphics 类的 beginGradientFill() 和 lineGradientStyle() 方法所需的矩阵的特定样式。 - * 宽度和高度被缩放为 scaleX/scaleY 对,而 tx/ty 值偏移了宽度和高度的一半。 - * @param width 渐变框的宽度 - * @param height 渐变框的高度 - * @param rotation 旋转量(以弧度为单位) - * @param tx 沿 x 轴向右平移的距离(以像素为单位)。此值将偏移 width 参数的一半 - * @param ty 沿 y 轴向下平移的距离(以像素为单位)。此值将偏移 height 参数的一半 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.createGradientBox = function (width, height, rotation, tx, ty) { - if (rotation === void 0) { rotation = 0; } - if (tx === void 0) { tx = 0; } - if (ty === void 0) { ty = 0; } - this.createBox(width / 1638.4, height / 1638.4, rotation, tx + width / 2, ty + height / 2); - }; - /** - * @private - */ - Matrix.prototype.$transformBounds = function (bounds) { - var a = this.a; - var b = this.b; - var c = this.c; - var d = this.d; - var tx = this.tx; - var ty = this.ty; - var x = bounds.x; - var y = bounds.y; - var xMax = x + bounds.width; - var yMax = y + bounds.height; - var x0 = a * x + c * y + tx; - var y0 = b * x + d * y + ty; - var x1 = a * xMax + c * y + tx; - var y1 = b * xMax + d * y + ty; - var x2 = a * xMax + c * yMax + tx; - var y2 = b * xMax + d * yMax + ty; - var x3 = a * x + c * yMax + tx; - var y3 = b * x + d * yMax + ty; - var tmp = 0; - if (x0 > x1) { - tmp = x0; - x0 = x1; - x1 = tmp; - } - if (x2 > x3) { - tmp = x2; - x2 = x3; - x3 = tmp; - } - bounds.x = Math.floor(x0 < x2 ? x0 : x2); - bounds.width = Math.ceil((x1 > x3 ? x1 : x3) - bounds.x); - if (y0 > y1) { - tmp = y0; - y0 = y1; - y1 = tmp; - } - if (y2 > y3) { - tmp = y2; - y2 = y3; - y3 = tmp; - } - bounds.y = Math.floor(y0 < y2 ? y0 : y2); - bounds.height = Math.ceil((y1 > y3 ? y1 : y3) - bounds.y); - }; - /** - * @private - */ - Matrix.prototype.getDeterminant = function () { - return this.a * this.d - this.b * this.c; - }; - /** - * @private - */ - Matrix.prototype.$getScaleX = function () { - var m = this; - if (m.b == 0) { - return m.a; - } - var result = Math.sqrt(m.a * m.a + m.b * m.b); - return this.getDeterminant() < 0 ? -result : result; - }; - /** - * @private - */ - Matrix.prototype.$getScaleY = function () { - var m = this; - if (m.c == 0) { - return m.d; - } - var result = Math.sqrt(m.c * m.c + m.d * m.d); - return this.getDeterminant() < 0 ? -result : result; - }; - /** - * @private - */ - Matrix.prototype.$getSkewX = function () { - if (this.d < 0) { - return Math.atan2(this.d, this.c) + (PI / 2); - } - else { - return Math.atan2(this.d, this.c) - (PI / 2); - } - }; - /** - * @private - */ - Matrix.prototype.$getSkewY = function () { - if (this.a < 0) { - return Math.atan2(this.b, this.a) - PI; - } - else { - return Math.atan2(this.b, this.a); - } - }; - /** - * @private - */ - Matrix.prototype.$updateScaleAndRotation = function (scaleX, scaleY, skewX, skewY) { - if ((skewX == 0 || skewX == TwoPI) && (skewY == 0 || skewY == TwoPI)) { - this.a = scaleX; - this.b = this.c = 0; - this.d = scaleY; - return; - } - skewX = skewX / DEG_TO_RAD; - skewY = skewY / DEG_TO_RAD; - var u = egret.NumberUtils.cos(skewX); - var v = egret.NumberUtils.sin(skewX); - if (skewX == skewY) { - this.a = u * scaleX; - this.b = v * scaleX; - } - else { - this.a = egret.NumberUtils.cos(skewY) * scaleX; - this.b = egret.NumberUtils.sin(skewY) * scaleX; - } - this.c = -v * scaleY; - this.d = u * scaleY; - }; - /** - * @private - * target = other * this - */ - Matrix.prototype.$preMultiplyInto = function (other, target) { - var a = other.a * this.a; - var b = 0.0; - var c = 0.0; - var d = other.d * this.d; - var tx = other.tx * this.a + this.tx; - var ty = other.ty * this.d + this.ty; - if (other.b !== 0.0 || other.c !== 0.0 || this.b !== 0.0 || this.c !== 0.0) { - a += other.b * this.c; - d += other.c * this.b; - b += other.a * this.b + other.b * this.d; - c += other.c * this.a + other.d * this.c; - tx += other.ty * this.c; - ty += other.tx * this.b; - } - target.a = a; - target.b = b; - target.c = c; - target.d = d; - target.tx = tx; - target.ty = ty; - }; - return Matrix; - }(egret.HashObject)); - egret.Matrix = Matrix; - __reflect(Matrix.prototype, "egret.Matrix"); - /** - * @private - * 仅供框架内复用,要防止暴露引用到外部。 - */ - egret.$TempMatrix = new Matrix(); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var rectanglePool = []; - /** - * A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its - * width and its height.
    - * The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of - * one property has no effect on the others. However, the right and bottom properties are integrally related to those - * four properties. For example, if you change the value of the right property, the value of the width property changes; - * if you change the bottom property, the value of the height property changes. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Rectangle.ts - * @language en_US - */ - /** - * Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。
    - * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 - * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width - * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Rectangle.ts - * @language zh_CN - */ - var Rectangle = (function (_super) { - __extends(Rectangle, _super); - /** - * Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified - * width and height parameters. - * @param x The x coordinate of the top-left corner of the rectangle. - * @param y The y coordinate of the top-left corner of the rectangle. - * @param width The width of the rectangle, in pixels. - * @param height The height of the rectangle, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个新 Rectangle 对象,其左上角由 x 和 y 参数指定,并具有指定的 width 和 height 参数。 - * @param x 矩形左上角的 x 坐标。 - * @param y 矩形左上角的 y 坐标。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Rectangle(x, y, width, height) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - if (width === void 0) { width = 0; } - if (height === void 0) { height = 0; } - var _this = _super.call(this) || this; - _this.x = x; - _this.y = y; - _this.width = width; - _this.height = height; - return _this; - } - /** - * Releases a rectangle instance to the object pool. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个Rectangle实例到对象池 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.release = function (rect) { - if (!rect) { - return; - } - rectanglePool.push(rect); - }; - /** - * get a rectangle instance from the object pool or create a new one. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的Rectangle对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.create = function () { - var rect = rectanglePool.pop(); - if (!rect) { - rect = new Rectangle(); - } - return rect; - }; - Object.defineProperty(Rectangle.prototype, "right", { - /** - * The sum of the x and width properties. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * x 和 width 属性的和。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.x + this.width; - }, - set: function (value) { - this.width = value - this.x; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "bottom", { - /** - * The sum of the y and height properties. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * y 和 height 属性的和。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.y + this.height; - }, - set: function (value) { - this.height = value - this.y; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "left", { - /** - * The x coordinate of the top-left corner of the rectangle. Changing the left property of a Rectangle object has - * no effect on the y and height properties. However it does affect the width property, whereas changing the x value - * does not affect the width property. - * The value of the left property is equal to the value of the x property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 x 坐标。更改 Rectangle 对象的 left 属性对 y 和 height 属性没有影响。但是,它会影响 width 属性,而更改 x 值不会影响 width 属性。 - * left 属性的值等于 x 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.x; - }, - set: function (value) { - this.width += this.x - value; - this.x = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "top", { - /** - * The y coordinate of the top-left corner of the rectangle. Changing the top property of a Rectangle object has - * no effect on the x and width properties. However it does affect the height property, whereas changing the y - * value does not affect the height property.
    - * The value of the top property is equal to the value of the y property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 y 坐标。更改 Rectangle 对象的 top 属性对 x 和 width 属性没有影响。但是,它会影响 height 属性,而更改 y 值不会影响 height 属性。
    - * top 属性的值等于 y 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.y; - }, - set: function (value) { - this.height += this.y - value; - this.y = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "topLeft", { - /** - * The location of the Rectangle object's top-left corner, determined by the x and y coordinates of the point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由该点的 x 和 y 坐标确定的 Rectangle 对象左上角的位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return new egret.Point(this.left, this.top); - }, - set: function (value) { - this.top = value.y; - this.left = value.x; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "bottomRight", { - /** - * The location of the Rectangle object's bottom-right corner, determined by the values of the right and bottom properties. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由 right 和 bottom 属性的值确定的 Rectangle 对象的右下角的位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return new egret.Point(this.right, this.bottom); - }, - set: function (value) { - this.bottom = value.y; - this.right = value.x; - }, - enumerable: true, - configurable: true - }); - /** - * Copies all of rectangle data from the source Rectangle object into the calling Rectangle object. - * @param sourceRect The Rectangle object from which to copy the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将源 Rectangle 对象中的所有矩形数据复制到调用方 Rectangle 对象中。 - * @param sourceRect 要从中复制数据的 Rectangle 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.copyFrom = function (sourceRect) { - this.x = sourceRect.x; - this.y = sourceRect.y; - this.width = sourceRect.width; - this.height = sourceRect.height; - return this; - }; - /** - * Sets the members of Rectangle to the specified values - * @param x The x coordinate of the top-left corner of the rectangle. - * @param y The y coordinate of the top-left corner of the rectangle. - * @param width The width of the rectangle, in pixels. - * @param height The height of the rectangle, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Rectangle 的成员设置为指定值 - * @param x 矩形左上角的 x 坐标。 - * @param y 矩形左上角的 y 坐标。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.setTo = function (x, y, width, height) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - return this; - }; - /** - * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. - * @param x The x coordinate (horizontal position) of the point. - * @param y The y coordinate (vertical position) of the point. - * @returns A value of true if the Rectangle object contains the specified point; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定由此 Rectangle 对象定义的矩形区域内是否包含指定的点。 - * @param x 检测点的x轴 - * @param y 检测点的y轴 - * @returns 如果检测点位于矩形内,返回true,否则,返回false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.contains = function (x, y) { - return this.x <= x && - this.x + this.width >= x && - this.y <= y && - this.y + this.height >= y; - }; - /** - * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns - * the area of intersection as a Rectangle object. If the rectangles do not intersect, this method returns an empty - * Rectangle object with its properties set to 0. - * @param toIntersect The Rectangle object to compare against to see if it intersects with this Rectangle object. - * @returns A Rectangle object that equals the area of intersection. If the rectangles do not intersect, this method - * returns an empty Rectangle object; that is, a rectangle with its x, y, width, and height properties set to 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果在 toIntersect 参数中指定的 Rectangle 对象与此 Rectangle 对象相交,则返回交集区域作为 Rectangle 对象。如果矩形不相交, - * 则此方法返回一个空的 Rectangle 对象,其属性设置为 0。 - * @param toIntersect 要对照比较以查看其是否与此 Rectangle 对象相交的 Rectangle 对象。 - * @returns 等于交集区域的 Rectangle 对象。如果该矩形不相交,则此方法返回一个空的 Rectangle 对象;即,其 x、y、width 和 - * height 属性均设置为 0 的矩形。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.intersection = function (toIntersect) { - return this.clone().$intersectInPlace(toIntersect); - }; - /** - * Increases the size of the Rectangle object by the specified amounts, in pixels. - * The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value. - * @param dx The value to be added to the left and the right of the Rectangle object. - * @param dy The value to be added to the top and the bottom of the Rectangle. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 按指定量增加 Rectangle 对象的大小(以像素为单位) - * 保持 Rectangle 对象的中心点不变,使用 dx 值横向增加它的大小,使用 dy 值纵向增加它的大小。 - * @param dx Rectangle 对象横向增加的值。 - * @param dy Rectangle 对象纵向增加的值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.inflate = function (dx, dy) { - this.x -= dx; - this.width += 2 * dx; - this.y -= dy; - this.height += 2 * dy; - }; - /** - * @private - */ - Rectangle.prototype.$intersectInPlace = function (clipRect) { - var x0 = this.x; - var y0 = this.y; - var x1 = clipRect.x; - var y1 = clipRect.y; - var l = Math.max(x0, x1); - var r = Math.min(x0 + this.width, x1 + clipRect.width); - if (l <= r) { - var t = Math.max(y0, y1); - var b = Math.min(y0 + this.height, y1 + clipRect.height); - if (t <= b) { - this.setTo(l, t, r - l, b - t); - return this; - } - } - this.setEmpty(); - return this; - }; - /** - * Determines whether the object specified in the toIntersect parameter intersects with this Rectangle object. - * This method checks the x, y, width, and height properties of the specified Rectangle object to see if it - * intersects with this Rectangle object. - * @param toIntersect The Rectangle object to compare against this Rectangle object. - * @returns A value of true if the specified object intersects with this Rectangle object; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定在 toIntersect 参数中指定的对象是否与此 Rectangle 对象相交。此方法检查指定的 Rectangle - * 对象的 x、y、width 和 height 属性,以查看它是否与此 Rectangle 对象相交。 - * @param toIntersect 要与此 Rectangle 对象比较的 Rectangle 对象。 - * @returns 如果两个矩形相交,返回true,否则返回false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.intersects = function (toIntersect) { - return Math.max(this.x, toIntersect.x) <= Math.min(this.right, toIntersect.right) - && Math.max(this.y, toIntersect.y) <= Math.min(this.bottom, toIntersect.bottom); - }; - /** - * Determines whether or not this Rectangle object is empty. - * @returns A value of true if the Rectangle object's width or height is less than or equal to 0; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定此 Rectangle 对象是否为空。 - * @returns 如果 Rectangle 对象的宽度或高度小于等于 0,则返回 true 值,否则返回 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.isEmpty = function () { - return this.width <= 0 || this.height <= 0; - }; - /** - * Sets all of the Rectangle object's properties to 0. A Rectangle object is empty if its width or height is less than or equal to 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Rectangle 对象的所有属性设置为 0。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.setEmpty = function () { - this.x = 0; - this.y = 0; - this.width = 0; - this.height = 0; - }; - /** - * Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. - * @returns A new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回一个新的 Rectangle 对象,其 x、y、width 和 height 属性的值与原始 Rectangle 对象的对应值相同。 - * @returns 新的 Rectangle 对象,其 x、y、width 和 height 属性的值与原始 Rectangle 对象的对应值相同。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.clone = function () { - return new Rectangle(this.x, this.y, this.width, this.height); - }; - /** - * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. - * This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter. - * @param point The point, as represented by its x and y coordinates. - * @returns A value of true if the Rectangle object contains the specified point; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定由此 Rectangle 对象定义的矩形区域内是否包含指定的点。 - * 此方法与 Rectangle.contains() 方法类似,只不过它采用 Point 对象作为参数。 - * @param point 包含点对象 - * @returns 如果包含,返回true,否则返回false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.containsPoint = function (point) { - if (this.x <= point.x - && this.x + this.width > point.x - && this.y <= point.y - && this.y + this.height > point.y) { - return true; - } - return false; - }; - /** - * Determines whether the Rectangle object specified by the rect parameter is contained within this Rectangle object. - * A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first. - * @param rect The Rectangle object being checked. - * @returns A value of true if the Rectangle object that you specify is contained by this Rectangle object; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定此 Rectangle 对象内是否包含由 rect 参数指定的 Rectangle 对象。 - * 如果一个 Rectangle 对象完全在另一个 Rectangle 的边界内,我们说第二个 Rectangle 包含第一个 Rectangle。 - * @param rect 所检查的 Rectangle 对象 - * @returns 如果此 Rectangle 对象包含您指定的 Rectangle 对象,则返回 true 值,否则返回 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.containsRect = function (rect) { - var r1 = rect.x + rect.width; - var b1 = rect.y + rect.height; - var r2 = this.x + this.width; - var b2 = this.y + this.height; - return (rect.x >= this.x) && (rect.x < r2) && (rect.y >= this.y) && (rect.y < b2) && (r1 > this.x) && (r1 <= r2) && (b1 > this.y) && (b1 <= b2); - }; - /** - * Determines whether the object specified in the toCompare parameter is equal to this Rectangle object. - * This method compares the x, y, width, and height properties of an object against the same properties of this Rectangle object. - * @param The rectangle to compare to this Rectangle object. - * @returns A value of true if the object has exactly the same values for the x, y, width, and height properties as this Rectangle object; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定在 toCompare 参数中指定的对象是否等于此 Rectangle 对象。 - * 此方法将某个对象的 x、y、width 和 height 属性与此 Rectangle 对象所对应的相同属性进行比较。 - * @param toCompare 要与此 Rectangle 对象进行比较的矩形。 - * @returns 如果对象具有与此 Rectangle 对象完全相同的 x、y、width 和 height 属性值,则返回 true 值,否则返回 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.equals = function (toCompare) { - if (this === toCompare) { - return true; - } - return this.x === toCompare.x && this.y === toCompare.y - && this.width === toCompare.width && this.height === toCompare.height; - }; - /** - * Increases the size of the Rectangle object. This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter. - * @param point 此 Point 对象的 x 属性用于增加 Rectangle 对象的水平尺寸。y 属性用于增加 Rectangle 对象的垂直尺寸。 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 增加 Rectangle 对象的大小。此方法与 Rectangle.inflate() 方法类似,只不过它采用 Point 对象作为参数。 - * @param point The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object. - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.inflatePoint = function (point) { - this.inflate(point.x, point.y); - }; - /** - * Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts. - * @param dx Moves the x value of the Rectangle object by this amount. - * @param dy Moves the y value of the Rectangle object by this amount. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 按指定量调整 Rectangle 对象的位置(由其左上角确定)。 - * @param dx 将 Rectangle 对象的 x 值移动此数量。 - * @param dy 将 Rectangle 对象的 t 值移动此数量。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.offset = function (dx, dy) { - this.x += dx; - this.y += dy; - }; - /** - * Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter. - * @param point A Point object to use to offset this Rectangle object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Point 对象用作参数来调整 Rectangle 对象的位置。此方法与 Rectangle.offset() 方法类似,只不过它采用 Point 对象作为参数。 - * @param point 要用于偏移此 Rectangle 对象的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.offsetPoint = function (point) { - this.offset(point.x, point.y); - }; - /** - * Builds and returns a string that lists the horizontal and vertical positions and the width and height of the Rectangle object. - * @returns A string listing the value of each of the following properties of the Rectangle object: x, y, width, and height. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 生成并返回一个字符串,该字符串列出 Rectangle 对象的水平位置和垂直位置以及高度和宽度。 - * @returns 一个字符串,它列出了 Rectangle 对象的下列各个属性的值:x、y、width 和 height。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.toString = function () { - return "(x=" + this.x + ", y=" + this.y + ", width=" + this.width + ", height=" + this.height + ")"; - }; - /** - * Adds two rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two rectangles. - * @param toUnion A Rectangle object to add to this Rectangle object. - * @returns A new Rectangle object that is the union of the two rectangles. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 通过填充两个矩形之间的水平和垂直空间,将这两个矩形组合在一起以创建一个新的 Rectangle 对象。 - * @param toUnion 要添加到此 Rectangle 对象的 Rectangle 对象。 - * @returns 充当两个矩形的联合的新 Rectangle 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.union = function (toUnion) { - var result = this.clone(); - if (toUnion.isEmpty()) { - return result; - } - if (result.isEmpty()) { - result.copyFrom(toUnion); - return result; - } - var l = Math.min(result.x, toUnion.x); - var t = Math.min(result.y, toUnion.y); - result.setTo(l, t, Math.max(result.right, toUnion.right) - l, Math.max(result.bottom, toUnion.bottom) - t); - return result; - }; - /** - * @private - */ - Rectangle.prototype.$getBaseWidth = function (angle) { - var u = Math.abs(Math.cos(angle)); - var v = Math.abs(Math.sin(angle)); - return u * this.width + v * this.height; - }; - /** - * @private - */ - Rectangle.prototype.$getBaseHeight = function (angle) { - var u = Math.abs(Math.cos(angle)); - var v = Math.abs(Math.sin(angle)); - return v * this.width + u * this.height; - }; - return Rectangle; - }(egret.HashObject)); - egret.Rectangle = Rectangle; - __reflect(Rectangle.prototype, "egret.Rectangle"); - /** - * @private - * 仅供框架内复用,要防止暴露引用到外部。 - */ - egret.$TempRectangle = new Rectangle(); -})(egret || (egret = {})); -var egret; -(function (egret) { - egret.$locale_strings = egret.$locale_strings || {}; - egret.$locale_strings["en_US"] = egret.$locale_strings["en_US"] || {}; - var locale_strings = egret.$locale_strings["en_US"]; - //core 1000-1999 - locale_strings[1001] = "Could not find Egret entry class: {0}。"; - locale_strings[1002] = "Egret entry class '{0}' must inherit from egret.DisplayObject."; - locale_strings[1003] = "Parameter {0} must be non-null."; - locale_strings[1004] = "An object cannot be added as a child to one of it's children (or children's children, etc.)."; - locale_strings[1005] = "An object cannot be added as a child of itself."; - locale_strings[1006] = "The supplied DisplayObject must be a child of the caller."; - locale_strings[1007] = "An index specified for a parameter was out of range."; - locale_strings[1008] = "Instantiate singleton error,singleton class {0} can not create multiple instances."; - locale_strings[1009] = "the Class {0} cannot use the property \"{1}\""; - locale_strings[1010] = "the property \"{1}\" of the Class \"{0}\" is readonly"; - locale_strings[1011] = "Stream Error. URL: {0}"; - locale_strings[1012] = "The type of parameter {0} must be Class."; - locale_strings[1013] = "Variable assignment is NaN, please see the code!"; - locale_strings[1014] = "the constant \"{1}\" of the Class \"{0}\" is read-only"; - locale_strings[1015] = "xml not found!"; - locale_strings[1016] = "{0}has been obsoleted"; - locale_strings[1017] = "The format of JSON file is incorrect: {0}\ndata: {1}"; - locale_strings[1018] = "the scale9Grid is not correct"; - locale_strings[1019] = "Network ab:{0}"; - locale_strings[1020] = "Cannot initialize Shader"; - locale_strings[1021] = "Current browser does not support webgl"; - locale_strings[1022] = "{0} ArgumentError"; - locale_strings[1023] = "This method is not available in the ScrollView!"; - locale_strings[1025] = "end of the file"; - locale_strings[1026] = "! EncodingError The code point {0} could not be encoded."; - locale_strings[1027] = "DecodingError"; - locale_strings[1028] = ". called injection is not configured rule: {0}, please specify configuration during its initial years of injection rule, and then call the corresponding single case."; - locale_strings[1029] = "Function.prototype.bind - what is trying to be bound is not callable"; - locale_strings[1033] = "Photos can not be used across domains toDataURL to convert base64"; - locale_strings[1034] = "Music file decoding failed: \"{0}\", please use the standard conversion tool reconversion under mp3."; - locale_strings[1035] = "Native does not support this feature!"; - locale_strings[1036] = "Sound has stopped, please recall Sound.play () to play the sound!"; - locale_strings[1037] = "Non-load the correct blob!"; - locale_strings[1038] = "XML format error!"; - locale_strings[1039] = "Cross domains pictures can not get pixel information!"; - locale_strings[1040] = "hitTestPoint can not detect crossOrigin images! Please check if the display object has crossOrigin elements."; - locale_strings[1041] = "{0} is deprecated, please use {1} replace"; - locale_strings[1042] = "The parameters passed in the region needs is an integer in drawToTexture method. Otherwise, some browsers will draw abnormal."; - locale_strings[1043] = "Compile errors in {0}, the attribute name: {1}, the attribute value: {2}."; - locale_strings[1044] = "The current version of the Runtime does not support video playback, please use the latest version"; - locale_strings[1045] = "The resource url is not found"; - locale_strings[1046] = "BitmapText no corresponding characters: {0}, please check the configuration file"; - locale_strings[1047] = "egret.localStorage.setItem save failed,key={0}&value={1}"; - locale_strings[1048] = "Video loading failed"; - locale_strings[1049] = "In the absence of sound is not allowed to play after loading"; - locale_strings[1050] = "ExternalInterface calls the method without js registration: {0}"; - //gui 3000-3099 - locale_strings[3000] = "Theme configuration file failed to load: {0}"; - locale_strings[3001] = "Cannot find the skin name which is configured in Theme: {0}"; - locale_strings[3002] = "Index:\"{0}\" is out of the collection element index range"; - locale_strings[3003] = "Cannot be available in this component. If this component is container, please continue to use"; - locale_strings[3004] = "addChild(){0}addElement() replace"; - locale_strings[3005] = "addChildAt(){0}addElementAt() replace"; - locale_strings[3006] = "removeChild(){0}removeElement() replace"; - locale_strings[3007] = "removeChildAt(){0}removeElementAt() replace"; - locale_strings[3008] = "setChildIndex(){0}setElementIndex() replace"; - locale_strings[3009] = "swapChildren(){0}swapElements() replace"; - locale_strings[3010] = "swapChildrenAt(){0}swapElementsAt() replace"; - locale_strings[3011] = "Index:\"{0}\" is out of the visual element index range"; - locale_strings[3012] = "This method is not available in Scroller component!"; - locale_strings[3013] = "UIStage is GUI root container, and only one such instant is in the display list!"; - locale_strings[3014] = "set fullscreen error"; - //socket 3100-3199 - locale_strings[3100] = "Current browser does not support WebSocket"; - locale_strings[3101] = "Please connect Socket firstly"; - locale_strings[3102] = "Please set the type of binary type"; - //db 4000-4299 - locale_strings[4000] = "An Bone cannot be added as a child to itself or one of its children (or children's children, etc.)"; - locale_strings[4001] = "Abstract class can not be instantiated!"; - locale_strings[4002] = "Unnamed data!"; - locale_strings[4003] = "Nonsupport version!"; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The JointStyle class is an enumeration of constant values that specify the joint style to use in drawing lines. - * These constants are provided for use as values in the joints parameter of the egret.Graphics.lineStyle() method. - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * JointStyle 类是指定要在绘制线条中使用的联接点样式的常量值枚举。提供的这些常量用作 egret.Graphics.lineStyle() 方法的 joints 参数中的值。 - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - egret.JointStyle = { - /** - * Specifies beveled joints in the joints parameter of the egret.Graphics.lineStyle() method. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * 在 egret.Graphics.lineStyle() 方法的 joints 参数中指定斜角连接。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - BEVEL: "bevel", - /** - * Specifies mitered joints in the joints parameter of the egret.Graphics.lineStyle() method. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * 在 egret.Graphics.lineStyle() 方法的 joints 参数中指定尖角连接。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - MITER: "miter", - /** - * Specifies round joints in the joints parameter of the egret.Graphics.lineStyle() method. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * 在 egret.Graphics.lineStyle() 方法的 joints 参数中指定圆角连接。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - ROUND: "round" - }; -})(egret || (egret = {})); -var egret; -(function (egret) { - egret.$locale_strings = egret.$locale_strings || {}; - egret.$locale_strings["zh_CN"] = egret.$locale_strings["zh_CN"] || {}; - var locale_strings = egret.$locale_strings["zh_CN"]; - //eui 2000-2999 - //RES 3200-3299 - //core 1000-1999 - locale_strings[1001] = "找不到Egret入口类: {0}。"; - locale_strings[1002] = "Egret入口类 {0} 必须继承自egret.DisplayObject。"; - locale_strings[1003] = "参数 {0} 不能为 null。"; - locale_strings[1004] = "无法将对象添加为它的一个子对象(或子对象的子对象等)的子对象。"; - locale_strings[1005] = "不能将对象添加为其自身的子对象。"; - locale_strings[1006] = "提供的 DisplayObject 必须是调用者的子级。"; - locale_strings[1007] = "为参数指定的索引不在范围内。"; - locale_strings[1008] = "实例化单例出错,不允许实例化多个 {0} 对象。"; - locale_strings[1009] = "类 {0} 不可以使用属性 {1}"; - locale_strings[1010] = "类 {0} 属性 {1} 是只读的"; - locale_strings[1011] = "流错误。URL: {0}"; - locale_strings[1012] = "参数 {0} 的类型必须为 Class。"; - locale_strings[1013] = "变量赋值为NaN,请查看代码!"; - locale_strings[1014] = "类 {0} 常量 {1} 是只读的"; - locale_strings[1015] = "xml not found!"; - locale_strings[1016] = "{0}已经废弃"; - locale_strings[1017] = "JSON文件格式不正确: {0}\ndata: {1}"; - locale_strings[1018] = "9宫格设置错误"; - locale_strings[1019] = "网络异常:{0}"; - locale_strings[1020] = "无法初始化着色器"; - locale_strings[1021] = "当前浏览器不支持webgl"; - locale_strings[1022] = "{0} ArgumentError"; - locale_strings[1023] = "此方法在ScrollView内不可用!"; - locale_strings[1025] = "遇到文件尾"; - locale_strings[1026] = "EncodingError! The code point {0} could not be encoded."; - locale_strings[1027] = "DecodingError"; - locale_strings[1028] = "调用了未配置的注入规则:{0}。 请先在项目初始化里配置指定的注入规则,再调用对应单例。"; - locale_strings[1029] = "Function.prototype.bind - what is trying to be bound is not callable"; - locale_strings[1033] = "跨域图片不可以使用toDataURL来转换成base64"; - locale_strings[1034] = "音乐文件解码失败:\"{0}\",请使用标准的转换工具重新转换下mp3。"; - locale_strings[1035] = "Native 下暂未实现此功能!"; - locale_strings[1036] = "声音已停止,请重新调用 Sound.play() 来播放声音!"; - locale_strings[1037] = "非正确的blob加载!"; - locale_strings[1038] = "XML 格式错误!"; - locale_strings[1039] = "跨域图片不能获取像素信息!"; - locale_strings[1040] = "hitTestPoint 不能对跨域图片进行检测! 请检查该显示对象内是否含有跨域元素"; - locale_strings[1041] = "{0} 已废弃,请使用 {1} 代替"; - locale_strings[1042] = "drawToTexture方法传入的区域各个参数需要为整数,否则某些浏览器绘制会出现异常"; - locale_strings[1043] = "{0} 中存在编译错误,属性名 : {1},属性值 : {2}"; - locale_strings[1044] = "当前的 runtime 版本不支持视频播放,请使用最新的版本"; - locale_strings[1045] = "没有设置要加载的资源地址"; - locale_strings[1046] = "BitmapText 找不到对应字符:{0},请检查配置文件"; - locale_strings[1047] = "egret.localStorage.setItem保存失败,key={0}&value={1}"; - locale_strings[1048] = "视频加载失败"; - locale_strings[1049] = "声音在没有加载完之前不允许播放"; - locale_strings[1050] = "ExternalInterface调用了js没有注册的方法: {0}"; - //gui 3000-3099 - locale_strings[3000] = "主题配置文件加载失败: {0}"; - locale_strings[3001] = "找不到主题中所配置的皮肤类名: {0}"; - locale_strings[3002] = "索引:\"{0}\"超出集合元素索引范围"; - locale_strings[3003] = "在此组件中不可用,若此组件为容器类,请使用"; - locale_strings[3004] = "addChild(){0}addElement()代替"; - locale_strings[3005] = "addChildAt(){0}addElementAt()代替"; - locale_strings[3006] = "removeChild(){0}removeElement()代替"; - locale_strings[3007] = "removeChildAt(){0}removeElementAt()代替"; - locale_strings[3008] = "setChildIndex(){0}setElementIndex()代替"; - locale_strings[3009] = "swapChildren(){0}swapElements()代替"; - locale_strings[3010] = "swapChildrenAt(){0}swapElementsAt()代替"; - locale_strings[3011] = "索引:\"{0}\"超出可视元素索引范围"; - locale_strings[3012] = "此方法在Scroller组件内不可用!"; - locale_strings[3013] = "UIStage是GUI根容器,只能有一个此实例在显示列表中!"; - locale_strings[3014] = "设置全屏模式失败"; - //socket 3100-3199 - locale_strings[3100] = "当前浏览器不支持WebSocket"; - locale_strings[3101] = "请先连接WebSocket"; - locale_strings[3102] = "请先设置type为二进制类型"; - //db 4000-4299 - locale_strings[4000] = "An Bone cannot be added as a child to itself or one of its children (or children's children, etc.)"; - locale_strings[4001] = "Abstract class can not be instantiated!"; - locale_strings[4002] = "Unnamed data!"; - locale_strings[4003] = "Nonsupport version!"; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/** - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/localStorage/localStorage.ts - */ -var egret; -(function (egret) { - var localStorage; - (function (localStorage) { - })(localStorage = egret.localStorage || (egret.localStorage = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - var usingChannel = []; - /** - * @private - * @param channel - */ - function $pushSoundChannel(channel) { - if (usingChannel.indexOf(channel) < 0) { - usingChannel.push(channel); - } - } - sys.$pushSoundChannel = $pushSoundChannel; - /** - * @private - * @param channel - */ - function $popSoundChannel(channel) { - var index = usingChannel.indexOf(channel); - if (index >= 0) { - usingChannel.splice(index, 1); - return true; - } - return false; - } - sys.$popSoundChannel = $popSoundChannel; - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The HttpMethod class provides values that specify whether the HttpRequest object should use the POST method - * or the GET method when sending data to a server. - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HttpRequestMethod 类提供了一些值,这些值可指定在将数据发送到服务器时, - * HttpRequest 对象应使用 POST 方法还是 GET 方法。 - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var HttpMethod; - (function (HttpMethod) { - /** - * Specifies that the HttpRequest object is a GET. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 HttpRequest 对象是一个 GET。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HttpMethod.GET = "GET"; - /** - * Specifies that the HttpRequest object is a POST. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 HttpRequest 对象是一个 POST。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HttpMethod.POST = "POST"; - })(HttpMethod = egret.HttpMethod || (egret.HttpMethod = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The HttpResponseType class provides values that specify how downloaded data is received. - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * URLLoaderDataFormat 类提供了一些用于指定如何接收已下载数据的值。 - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var HttpResponseType = (function () { - function HttpResponseType() { - } - /** - * Specifies that downloaded data is received as text. This is the default value of HttpRequest.responseType - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回字符串。HttpRequest.responseType属性的默认值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HttpResponseType.TEXT = "text"; - /** - * Specifies that downloaded data is received as raw binary data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回二进制的ArrayBuffer对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HttpResponseType.ARRAY_BUFFER = "arraybuffer"; - return HttpResponseType; - }()); - egret.HttpResponseType = HttpResponseType; - __reflect(HttpResponseType.prototype, "egret.HttpResponseType"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - var displayListPool = []; - var blendModes = ["source-over", "lighter", "destination-out"]; - var defaultCompositeOp = "source-over"; - /** - * @private - * 显示列表 - */ - var DisplayList = (function (_super) { - __extends(DisplayList, _super); - /** - * @private - * 创建一个DisplayList对象 - */ - function DisplayList(root) { - var _this = _super.call(this) || this; - _this.isStage = false; - /** - * 位图渲染节点 - */ - _this.$renderNode = new sys.BitmapNode(); - /** - * @private - */ - _this.renderBuffer = null; - /** - * @private - */ - _this.offsetX = 0; - /** - * @private - */ - _this.offsetY = 0; - /** - * @private - */ - _this.offsetMatrix = new egret.Matrix(); - _this.$canvasScaleX = 1; - _this.$canvasScaleY = 1; - _this.root = root; - _this.isStage = (root instanceof egret.Stage); - return _this; - } - /** - * 创建一个DisplayList对象,若内存不足或无法创建RenderBuffer,将会返回null。 - */ - DisplayList.create = function (target) { - var displayList = new egret.sys.DisplayList(target); - try { - var buffer = new sys.RenderBuffer(); - displayList.renderBuffer = buffer; - } - catch (e) { - return null; - } - displayList.root = target; - return displayList; - }; - /** - * @private - * 获取渲染节点 - */ - DisplayList.prototype.$getRenderNode = function () { - return this.$renderNode; - }; - /** - * @private - * 设置剪裁边界,不再绘制完整目标对象,画布尺寸由外部决定,超过边界的节点将跳过绘制。 - */ - DisplayList.prototype.setClipRect = function (width, height) { - width *= DisplayList.$canvasScaleX; - height *= DisplayList.$canvasScaleY; - this.renderBuffer.resize(width, height); - }; - /** - * @private - * 绘制根节点显示对象到目标画布,返回draw的次数。 - */ - DisplayList.prototype.drawToSurface = function () { - var drawCalls = 0; - this.$canvasScaleX = this.offsetMatrix.a = DisplayList.$canvasScaleX; - this.$canvasScaleY = this.offsetMatrix.d = DisplayList.$canvasScaleY; - if (!this.isStage) { - this.changeSurfaceSize(); - } - var buffer = this.renderBuffer; - buffer.clear(); - drawCalls = sys.systemRenderer.render(this.root, buffer, this.offsetMatrix); - if (!this.isStage) { - var surface = buffer.surface; - var renderNode = this.$renderNode; - renderNode.drawData.length = 0; - var width = surface.width; - var height = surface.height; - if (!this.bitmapData) { - this.bitmapData = new egret.BitmapData(surface); - } - else { - this.bitmapData.source = surface; - this.bitmapData.width = width; - this.bitmapData.height = height; - } - renderNode.image = this.bitmapData; - renderNode.imageWidth = width; - renderNode.imageHeight = height; - renderNode.drawImage(0, 0, width, height, -this.offsetX, -this.offsetY, width / this.$canvasScaleX, height / this.$canvasScaleY); - } - return drawCalls; - }; - /** - * @private - * 改变画布的尺寸,由于画布尺寸修改会清空原始画布。所以这里将原始画布绘制到一个新画布上,再与原始画布交换。 - */ - DisplayList.prototype.changeSurfaceSize = function () { - var root = this.root; - var oldOffsetX = this.offsetX; - var oldOffsetY = this.offsetY; - var bounds = this.root.$getOriginalBounds(); - var scaleX = this.$canvasScaleX; - var scaleY = this.$canvasScaleY; - this.offsetX = -bounds.x; - this.offsetY = -bounds.y; - this.offsetMatrix.setTo(this.offsetMatrix.a, 0, 0, this.offsetMatrix.d, this.offsetX, this.offsetY); - var buffer = this.renderBuffer; - //在chrome里,小等于256*256的canvas会不启用GPU加速。 - var width = Math.max(257, bounds.width * scaleX); - var height = Math.max(257, bounds.height * scaleY); - if (this.offsetX == oldOffsetX && - this.offsetY == oldOffsetY && - buffer.surface.width == width && - buffer.surface.height == height) { - return; - } - buffer.resize(width, height); - }; - /** - * @private - */ - DisplayList.$setCanvasScale = function (x, y) { - DisplayList.$canvasScaleX = x; - DisplayList.$canvasScaleY = y; - if (egret.nativeRender) { - egret_native.nrSetCanvasScaleFactor(DisplayList.$canvasScaleFactor, x, y); - } - }; - DisplayList.$canvasScaleFactor = 1; - /** - * @private - */ - DisplayList.$canvasScaleX = 1; - DisplayList.$canvasScaleY = 1; - return DisplayList; - }(egret.HashObject)); - sys.DisplayList = DisplayList; - __reflect(DisplayList.prototype, "egret.sys.DisplayList"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * Egret播放器 - */ - var Player = (function (_super) { - __extends(Player, _super); - /** - * @private - * 实例化一个播放器对象。 - */ - function Player(buffer, stage, entryClassName) { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.isPlaying = false; - if (true && !buffer) { - egret.$error(1003, "buffer"); - } - _this.entryClassName = entryClassName; - _this.stage = stage; - _this.screenDisplayList = _this.createDisplayList(stage, buffer); - _this.showFPS = false; - _this.showLog = false; - _this.stageDisplayList = null; - if (egret.nativeRender) { - egret_native.rootWebGLBuffer = buffer; - } - return _this; - } - /** - * @private - */ - Player.prototype.createDisplayList = function (stage, buffer) { - var displayList = new sys.DisplayList(stage); - displayList.renderBuffer = buffer; - stage.$displayList = displayList; - return displayList; - }; - /** - * @private - * 启动播放器 - */ - Player.prototype.start = function () { - if (this.isPlaying || !this.stage) { - return; - } - sys.$TempStage = sys.$TempStage || this.stage; - this.isPlaying = true; - if (!this.root) { - this.initialize(); - } - egret.ticker.$addPlayer(this); - }; - /** - * @private - */ - Player.prototype.initialize = function () { - var rootClass; - if (this.entryClassName) { - rootClass = egret.getDefinitionByName(this.entryClassName); - } - if (rootClass) { - var rootContainer = new rootClass(); - this.root = rootContainer; - if (rootContainer instanceof egret.DisplayObject) { - this.stage.addChild(rootContainer); - } - else { - true && egret.$error(1002, this.entryClassName); - } - } - else { - true && egret.$error(1001, this.entryClassName); - } - }; - /** - * @private - * 停止播放器,停止后将不能重新启动。 - */ - Player.prototype.stop = function () { - this.pause(); - this.stage = null; - }; - /** - * @private - * 暂停播放器,后续可以通过调用start()重新启动播放器。 - */ - Player.prototype.pause = function () { - if (!this.isPlaying) { - return; - } - this.isPlaying = false; - egret.ticker.$removePlayer(this); - }; - /** - * @private - * 渲染屏幕 - */ - Player.prototype.$render = function (triggerByFrame, costTicker) { - if (egret.nativeRender) { - egret_native.updateNativeRender(); - egret_native.nrRender(); - return; - } - var stage = this.stage; - var t1 = egret.getTimer(); - var drawCalls = stage.$displayList.drawToSurface(); - var t2 = egret.getTimer(); - if (triggerByFrame && this.showFPS) { - fpsDisplay.update(drawCalls, t2 - t1, costTicker); - } - }; - /** - * @private - * 更新舞台尺寸 - * @param stageWidth 舞台宽度(以像素为单位) - * @param stageHeight 舞台高度(以像素为单位) - */ - Player.prototype.updateStageSize = function (stageWidth, stageHeight) { - var stage = this.stage; - stage.$stageWidth = stageWidth; - stage.$stageHeight = stageHeight; - if (egret.nativeRender) { - egret_native.nrResize(stageWidth, stageHeight); - } - else { - this.screenDisplayList.setClipRect(stageWidth, stageHeight); - if (this.stageDisplayList) { - this.stageDisplayList.setClipRect(stageWidth, stageHeight); - } - } - stage.dispatchEventWith(egret.Event.RESIZE); - }; - /** - * @private - * 显示FPS。 - */ - Player.prototype.displayFPS = function (showFPS, showLog, logFilter, styles) { - showLog = !!showLog; - if (showLog) { - egret.log = function () { - var length = arguments.length; - var info = ""; - for (var i = 0; i < length; i++) { - info += arguments[i] + " "; - } - sys.$logToFPS(info); - console.log.apply(console, toArray(arguments)); - }; - egret.warn = function () { - var length = arguments.length; - var info = ""; - for (var i = 0; i < length; i++) { - info += arguments[i] + " "; - } - sys.$warnToFPS(info); - console.warn.apply(console, toArray(arguments)); - }; - egret.error = function () { - var length = arguments.length; - var info = ""; - for (var i = 0; i < length; i++) { - info += arguments[i] + " "; - } - sys.$errorToFPS(info); - console.error.apply(console, toArray(arguments)); - }; - } - this.showFPS = !!showFPS; - this.showLog = showLog; - if (!fpsDisplay) { - fpsDisplay = new FPS(this.stage, showFPS, showLog, logFilter, styles); - var logLength = logLines.length; - for (var i = 0; i < logLength; i++) { - fpsDisplay.updateInfo(logLines[i]); - } - logLines = null; - var warnLength = warnLines.length; - for (var i = 0; i < warnLength; i++) { - fpsDisplay.updateWarn(warnLines[i]); - } - warnLines = null; - var errorLength = errorLines.length; - for (var i = 0; i < errorLength; i++) { - fpsDisplay.updateError(errorLines[i]); - } - errorLines = null; - } - }; - return Player; - }(egret.HashObject)); - sys.Player = Player; - __reflect(Player.prototype, "egret.sys.Player"); - var logLines = []; - var warnLines = []; - var errorLines = []; - var fpsDisplay; - sys.$logToFPS = function (info) { - if (!fpsDisplay) { - logLines.push(info); - return; - } - fpsDisplay.updateInfo(info); - }; - sys.$warnToFPS = function (info) { - if (!fpsDisplay) { - warnLines.push(info); - return; - } - fpsDisplay.updateWarn(info); - }; - sys.$errorToFPS = function (info) { - if (!fpsDisplay) { - errorLines.push(info); - return; - } - fpsDisplay.updateError(info); - }; - var FPSImpl = (function () { - function FPSImpl(stage, showFPS, showLog, logFilter, styles) { - this.showFPS = showFPS; - this.showLog = showLog; - this.logFilter = logFilter; - this.styles = styles; - this.infoLines = []; - this.totalTime = 0; - this.totalTick = 0; - this.lastTime = 0; - this.drawCalls = 0; - this.costRender = 0; - this.costTicker = 0; - this.infoLines = []; - this.totalTime = 0; - this.totalTick = 0; - this.lastTime = 0; - this.drawCalls = 0; - this.costRender = 0; - this.costTicker = 0; - this._stage = stage; - this.showFPS = showFPS; - this.showLog = showLog; - this.logFilter = logFilter; - this.styles = styles; - this.fpsDisplay = new egret.FPSDisplay(stage, showFPS, showLog, logFilter, styles); - var logFilterRegExp; - try { - logFilterRegExp = logFilter ? new RegExp(logFilter) : null; - } - catch (e) { - egret.log(e); - } - this.filter = function (message) { - if (logFilterRegExp) - return logFilterRegExp.test(message); - return !logFilter || message.indexOf(logFilter) == 0; - }; - } - FPSImpl.prototype.update = function (drawCalls, costRender, costTicker) { - var current = egret.getTimer(); - this.totalTime += current - this.lastTime; - this.lastTime = current; - //todo 多Player - this.totalTick++; - this.drawCalls += drawCalls; - this.costRender += costRender; - this.costTicker += costTicker; - if (this.totalTime >= 1000) { - var lastFPS = Math.min(Math.ceil(this.totalTick * 1000 / this.totalTime), egret.ticker.$frameRate); - var lastDrawCalls = Math.round(this.drawCalls / this.totalTick); - var lastCostRender = Math.round(this.costRender / this.totalTick); - var lastCostTicker = Math.round(this.costTicker / this.totalTick); - this.fpsDisplay.update({ - fps: lastFPS, - draw: lastDrawCalls, - costTicker: lastCostTicker, - costRender: lastCostRender - }); - this.totalTick = 0; - this.totalTime = this.totalTime % 1000; - this.drawCalls = 0; - this.costRender = 0; - this.costTicker = 0; - } - }; - FPSImpl.prototype.updateInfo = function (info) { - if (!info) { - return; - } - if (!this.showLog) { - return; - } - if (!this.filter(info)) { - return; - } - this.fpsDisplay.updateInfo(info); - }; - FPSImpl.prototype.updateWarn = function (info) { - if (!info) { - return; - } - if (!this.showLog) { - return; - } - if (!this.filter(info)) { - return; - } - if (this.fpsDisplay.updateWarn) { - this.fpsDisplay.updateWarn(info); - } - else { - this.fpsDisplay.updateInfo("[Warning]" + info); - } - }; - FPSImpl.prototype.updateError = function (info) { - if (!info) { - return; - } - if (!this.showLog) { - return; - } - if (!this.filter(info)) { - return; - } - if (this.fpsDisplay.updateError) { - this.fpsDisplay.updateError(info); - } - else { - this.fpsDisplay.updateInfo("[Error]" + info); - } - }; - return FPSImpl; - }()); - __reflect(FPSImpl.prototype, "FPSImpl"); - __global.FPS = FPSImpl; - function toArray(argument) { - var args = []; - for (var i = 0; i < argument.length; i++) { - args.push(argument[i]); - } - return args; - } - egret.warn = function () { - console.warn.apply(console, toArray(arguments)); - }; - egret.error = function () { - console.error.apply(console, toArray(arguments)); - }; - egret.assert = function () { - console.assert.apply(console, toArray(arguments)); - }; - egret.log = function () { - console.log.apply(console, toArray(arguments)); - }; - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -/** - * @private - */ -(function (egret) { - /** - * @private - */ - egret.nativeRender = __global.nativeRender; - //检测版本是否匹配,不匹配改用非原生加速渲染方式 - if (egret.nativeRender) { - var nrABIVersion = egret_native.nrABIVersion; - var nrMinEgretVersion = egret_native.nrMinEgretVersion; - var requiredNrABIVersion = 4; - if (nrABIVersion < requiredNrABIVersion) { - egret.nativeRender = false; - var msg = "需要升级微端版本到 0.1.8 才可以开启原生渲染加速"; - egret.sys.$warnToFPS(msg); - egret.warn(msg); - } - else if (nrABIVersion > requiredNrABIVersion) { - egret.nativeRender = false; - var msg = "\u9700\u8981\u5347\u7EA7\u5F15\u64CE\u7248\u672C\u5230 " + nrMinEgretVersion + " \u624D\u53EF\u4EE5\u5F00\u542F\u539F\u751F\u6E32\u67D3\u52A0\u901F"; - egret.sys.$warnToFPS(msg); - egret.warn(msg); - } - } -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - */ - var Mesh = (function (_super) { - __extends(Mesh, _super); - function Mesh(value) { - var _this = _super.call(this, value) || this; - /** - * @private - */ - _this._verticesDirty = true; - _this._bounds = new egret.Rectangle(); - _this.$renderNode = new egret.sys.MeshNode(); - return _this; - } - Mesh.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(12 /* MESH */); - }; - /** - * @private - */ - Mesh.prototype.setBitmapDataToWasm = function (data) { - this.$nativeDisplayObject.setBitmapDataToMesh(data); - }; - /** - * @private - */ - Mesh.prototype.$updateRenderNode = function () { - var image = this.$bitmapData; - if (!image) { - return; - } - var scale = egret.$TextureScaleFactor; - var node = this.$renderNode; - node.smoothing = this.$smoothing; - node.image = image; - node.imageWidth = this.$sourceWidth; - node.imageHeight = this.$sourceHeight; - var destW = !isNaN(this.$explicitBitmapWidth) ? this.$explicitBitmapWidth : this.$textureWidth; - var destH = !isNaN(this.$explicitBitmapHeight) ? this.$explicitBitmapHeight : this.$textureHeight; - var tsX = destW / this.$textureWidth; - var tsY = destH / this.$textureHeight; - var bitmapWidth = this.$bitmapWidth; - var bitmapHeight = this.$bitmapHeight; - node.drawMesh(this.$bitmapX, this.$bitmapY, bitmapWidth, bitmapHeight, this.$offsetX * tsX, this.$offsetY * tsY, tsX * bitmapWidth, tsY * bitmapHeight); - }; - /** - * @private - */ - Mesh.prototype.$updateVertices = function () { - var self = this; - self._verticesDirty = true; - self.$renderDirty = true; - if (egret.nativeRender) { - var renderNode = (this.$renderNode); - this.$nativeDisplayObject.setDataToMesh(renderNode.vertices, renderNode.indices, renderNode.uvs); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - /** - * @private - */ - Mesh.prototype.$measureContentBounds = function (bounds) { - if (this._verticesDirty) { - this._verticesDirty = false; - var node = this.$renderNode; - var vertices = node.vertices; - if (vertices.length) { - this._bounds.setTo(Number.MAX_VALUE, Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); - for (var i = 0, l = vertices.length; i < l; i += 2) { - var x = vertices[i]; - var y = vertices[i + 1]; - if (this._bounds.x > x) - this._bounds.x = x; - if (this._bounds.width < x) - this._bounds.width = x; - if (this._bounds.y > y) - this._bounds.y = y; - if (this._bounds.height < y) - this._bounds.height = y; - } - this._bounds.width -= this._bounds.x; - this._bounds.height -= this._bounds.y; - } - else { - this._bounds.setTo(0, 0, 0, 0); - } - node.bounds.copyFrom(this._bounds); - } - bounds.copyFrom(this._bounds); - }; - return Mesh; - }(egret.Bitmap)); - egret.Mesh = Mesh; - __reflect(Mesh.prototype, "egret.Mesh"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 屏幕适配器默认实现,开发者可以实现自定义规则的屏幕适配器。并在初始化加载时将适配器的实例赋值给egret.sys.screenAdapter上,从而替换掉默认适配器。 - */ - var DefaultScreenAdapter = (function (_super) { - __extends(DefaultScreenAdapter, _super); - /** - * @private - */ - function DefaultScreenAdapter() { - return _super.call(this) || this; - } - /** - * @private - * 计算舞台显示尺寸 - * @param scaleMode 当前的缩放模式 - * @param screenWidth 播放器视口宽度 - * @param screenHeight 播放器视口高度 - * @param contentWidth 初始化内容宽度 - * @param contentHeight 初始化内容高度 - */ - DefaultScreenAdapter.prototype.calculateStageSize = function (scaleMode, screenWidth, screenHeight, contentWidth, contentHeight) { - var displayWidth = screenWidth; - var displayHeight = screenHeight; - var stageWidth = contentWidth; - var stageHeight = contentHeight; - var scaleX = (screenWidth / stageWidth) || 0; - var scaleY = (screenHeight / stageHeight) || 0; - switch (scaleMode) { - case egret.StageScaleMode.EXACT_FIT: - break; - case egret.StageScaleMode.FIXED_HEIGHT: - stageWidth = Math.round(screenWidth / scaleY); - break; - case egret.StageScaleMode.FIXED_WIDTH: - stageHeight = Math.round(screenHeight / scaleX); - break; - case egret.StageScaleMode.NO_BORDER: - if (scaleX > scaleY) { - displayHeight = Math.round(stageHeight * scaleX); - } - else { - displayWidth = Math.round(stageWidth * scaleY); - } - break; - case egret.StageScaleMode.SHOW_ALL: - if (scaleX > scaleY) { - displayWidth = Math.round(stageWidth * scaleY); - } - else { - displayHeight = Math.round(stageHeight * scaleX); - } - break; - case egret.StageScaleMode.FIXED_NARROW: - if (scaleX > scaleY) { - stageWidth = Math.round(screenWidth / scaleY); - } - else { - stageHeight = Math.round(screenHeight / scaleX); - } - break; - case egret.StageScaleMode.FIXED_WIDE: - if (scaleX > scaleY) { - stageHeight = Math.round(screenHeight / scaleX); - } - else { - stageWidth = Math.round(screenWidth / scaleY); - } - break; - default: - stageWidth = screenWidth; - stageHeight = screenHeight; - break; - } - //宽高不是2的整数倍会导致图片绘制出现问题 - if (stageWidth % 2 != 0) { - stageWidth += 1; - } - if (stageHeight % 2 != 0) { - stageHeight += 1; - } - if (displayWidth % 2 != 0) { - displayWidth += 1; - } - if (displayHeight % 2 != 0) { - displayHeight += 1; - } - return { - stageWidth: stageWidth, - stageHeight: stageHeight, - displayWidth: displayWidth, - displayHeight: displayHeight - }; - }; - return DefaultScreenAdapter; - }(egret.HashObject)); - sys.DefaultScreenAdapter = DefaultScreenAdapter; - __reflect(DefaultScreenAdapter.prototype, "egret.sys.DefaultScreenAdapter", ["egret.sys.IScreenAdapter"]); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * StageScaleMode class provides values for the stage zoom mode. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/player/StageScaleMode.ts - * @language en_US - */ - /** - * StageScaleMode 类为舞台缩放模式提供值。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/player/StageScaleMode.ts - * @language zh_CN - */ - var StageScaleMode = (function () { - function StageScaleMode() { - } - /** - * Do not scale application content. Even when you change the player viewport size, it remains unchanged. If the player is smaller than the viewport content, possibly with some cropping.
    - * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) always with the player viewport size consistent. - * @language en_US - */ - /** - * 不缩放应用程序内容。即使在更改播放器视口大小时,它仍然保持不变。如果播放器视口比内容小,则可能进行一些裁切。
    - * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终跟播放器视口大小保持一致。 - * @language zh_CN - */ - StageScaleMode.NO_SCALE = "noScale"; - /** - * Keep the original aspect ratio scaling application content, after scaling a wide directions application content to fill the viewport players on both sides in the other direction may not be wide enough and left black bars.
    - * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较宽方向填满播放器视口,另一个方向的两侧可能会不够宽而留有黑边。
    - * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - * @language zh_CN - */ - StageScaleMode.SHOW_ALL = "showAll"; - /** - * Keep the original aspect ratio scaling application content, after scaling a narrow direction of application content to fill the viewport players on both sides in the other direction may exceed the viewport and the player is cut.
    - * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较窄方向填满播放器视口,另一个方向的两侧可能会超出播放器视口而被裁切。
    - * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - * @language zh_CN - */ - StageScaleMode.NO_BORDER = "noBorder"; - /** - * Do not keep the original aspect ratio scaling application content, after scaling application content just fill the player viewport.
    - * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - * @language en_US - */ - /** - * 不保持原始宽高比缩放应用程序内容,缩放后应用程序内容正好填满播放器视口。
    - * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - * @language zh_CN - */ - StageScaleMode.EXACT_FIT = "exactFit"; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant width, height may change.
    - * In this mode, the stage width (Stage.stageWidth) is always equal to initialize external incoming application content width. Stage height (Stage.stageHeight) by the current scale with the player viewport height decision. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始宽度不变,高度可能会改变。
    - * 在此模式下,舞台宽度(Stage.stageWidth)始终等于初始化时外部传入的应用程序内容宽度。舞台高度(Stage.stageHeight)由当前的缩放比例与播放器视口高度决定。 - * @language zh_CN - */ - StageScaleMode.FIXED_WIDTH = "fixedWidth"; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant height, width may change.
    - * In this mode, the stage height (Stage.stageHeight) is always equal to initialize external incoming application content height. Stage width (Stage.stageWidth) by the current scale with the player viewport width decision. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始高度不变,宽度可能会改变。
    - * 在此模式下,舞台高度(Stage.stageHeight)始终等于初始化时外部传入的应用程序内容高度。舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽度决定。 - * @language zh_CN - */ - StageScaleMode.FIXED_HEIGHT = "fixedHeight"; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player,a narrow direction may not be wide enough and fill.
    - * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较窄方向可能会不够宽而填充。
    - * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 - * @language zh_CN - */ - StageScaleMode.FIXED_NARROW = "fixedNarrow"; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, a wide direction may exceed the viewport and the player is cut.
    - * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较宽方向的两侧可能会超出播放器视口而被裁切。
    - * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 - * @language zh_CN - */ - StageScaleMode.FIXED_WIDE = "fixedWide"; - return StageScaleMode; - }()); - egret.StageScaleMode = StageScaleMode; - __reflect(StageScaleMode.prototype, "egret.StageScaleMode"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - */ - sys.$START_TIME = 0; - /** - * @private - * 是否要广播Event.RENDER事件的标志。 - */ - sys.$invalidateRenderFlag = false; - /** - * @private - * 需要立即刷新屏幕的标志 - */ - sys.$requestRenderingFlag = false; - /** - * Egret心跳计时器 - */ - var SystemTicker = (function () { - /** - * @private - */ - function SystemTicker() { - /** - * @private - */ - this.playerList = []; - /** - * @private - */ - this.callBackList = []; - /** - * @private - */ - this.thisObjectList = []; - /** - * @private - * 全局帧率 - */ - this.$frameRate = 30; - /** - * @private - */ - this.lastTimeStamp = 0; - /** - * @private - * ticker 花销的时间 - */ - this.costEnterFrame = 0; - /** - * @private - * 是否被暂停 - */ - this.isPaused = false; - if (true && egret.ticker) { - egret.$error(1008, "egret.sys.SystemTicker"); - } - sys.$START_TIME = Date.now(); - this.frameDeltaTime = 1000 / this.$frameRate; - this.lastCount = this.frameInterval = Math.round(60000 / this.$frameRate); - } - /** - * @private - * 注册一个播放器实例并运行 - */ - SystemTicker.prototype.$addPlayer = function (player) { - if (this.playerList.indexOf(player) != -1) { - return; - } - if (true) { - egret_stages.push(player.stage); - } - this.playerList = this.playerList.concat(); - this.playerList.push(player); - }; - /** - * @private - * 停止一个播放器实例的运行。 - */ - SystemTicker.prototype.$removePlayer = function (player) { - var index = this.playerList.indexOf(player); - if (index !== -1) { - if (true) { - var i = egret_stages.indexOf(player.stage); - egret_stages.splice(i, 1); - } - this.playerList = this.playerList.concat(); - this.playerList.splice(index, 1); - } - }; - /** - * @private - */ - SystemTicker.prototype.$startTick = function (callBack, thisObject) { - var index = this.getTickIndex(callBack, thisObject); - if (index != -1) { - return; - } - this.concatTick(); - this.callBackList.push(callBack); - this.thisObjectList.push(thisObject); - }; - /** - * @private - */ - SystemTicker.prototype.$stopTick = function (callBack, thisObject) { - var index = this.getTickIndex(callBack, thisObject); - if (index == -1) { - return; - } - this.concatTick(); - this.callBackList.splice(index, 1); - this.thisObjectList.splice(index, 1); - }; - /** - * @private - */ - SystemTicker.prototype.getTickIndex = function (callBack, thisObject) { - var callBackList = this.callBackList; - var thisObjectList = this.thisObjectList; - for (var i = callBackList.length - 1; i >= 0; i--) { - if (callBackList[i] == callBack && - thisObjectList[i] == thisObject) { - return i; - } - } - return -1; - }; - /** - * @private - * - */ - SystemTicker.prototype.concatTick = function () { - this.callBackList = this.callBackList.concat(); - this.thisObjectList = this.thisObjectList.concat(); - }; - /** - * @private - * 设置全局帧率 - */ - SystemTicker.prototype.$setFrameRate = function (value) { - if (value <= 0) { - return false; - } - if (this.$frameRate == value) { - return false; - } - this.$frameRate = value; - if (value > 60) { - value = 60; - } - this.frameDeltaTime = 1000 / value; - //这里用60*1000来避免浮点数计算不准确的问题。 - this.lastCount = this.frameInterval = Math.round(60000 / value); - return true; - }; - /** - * Pause the ticker. - * @version Egret 5.0.2 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停心跳 - * @version Egret 5.0.2 - * @platform Web,Native - * @language zh_CN - */ - SystemTicker.prototype.pause = function () { - this.isPaused = true; - }; - /** - * Resume the ticker. - * @version Egret 5.0.2 - * @platform Web,Native - * @language en_US - */ - /** - * 恢复心跳 - * @version Egret 5.0.2 - * @platform Web,Native - * @language zh_CN - */ - SystemTicker.prototype.resume = function () { - this.isPaused = false; - }; - /** - * @private - * 执行一次刷新 - */ - SystemTicker.prototype.update = function () { - var t1 = egret.getTimer(); - var callBackList = this.callBackList; - var thisObjectList = this.thisObjectList; - var length = callBackList.length; - var requestRenderingFlag = sys.$requestRenderingFlag; - var timeStamp = egret.getTimer(); - var contexts = egret.lifecycle.contexts; - for (var _i = 0, contexts_1 = contexts; _i < contexts_1.length; _i++) { - var c = contexts_1[_i]; - if (c.onUpdate) { - c.onUpdate(); - } - } - if (this.isPaused) { - this.lastTimeStamp = timeStamp; - return; - } - this.callLaterAsyncs(); - for (var i = 0; i < length; i++) { - if (callBackList[i].call(thisObjectList[i], timeStamp)) { - requestRenderingFlag = true; - } - } - var t2 = egret.getTimer(); - var deltaTime = timeStamp - this.lastTimeStamp; - this.lastTimeStamp = timeStamp; - if (deltaTime >= this.frameDeltaTime) { - this.lastCount = this.frameInterval; - } - else { - this.lastCount -= 1000; - if (this.lastCount > 0) { - if (requestRenderingFlag) { - this.render(false, this.costEnterFrame + t2 - t1); - } - return; - } - this.lastCount += this.frameInterval; - } - this.render(true, this.costEnterFrame + t2 - t1); - var t3 = egret.getTimer(); - this.broadcastEnterFrame(); - var t4 = egret.getTimer(); - this.costEnterFrame = t4 - t3; - }; - /** - * @private - * 执行一次屏幕渲染 - */ - SystemTicker.prototype.render = function (triggerByFrame, costTicker) { - var playerList = this.playerList; - var length = playerList.length; - if (length == 0) { - return; - } - this.callLaters(); - if (sys.$invalidateRenderFlag) { - this.broadcastRender(); - sys.$invalidateRenderFlag = false; - } - for (var i = 0; i < length; i++) { - playerList[i].$render(triggerByFrame, costTicker); - } - sys.$requestRenderingFlag = false; - }; - /** - * @private - * 广播EnterFrame事件。 - */ - SystemTicker.prototype.broadcastEnterFrame = function () { - var list = egret.DisplayObject.$enterFrameCallBackList; - var length = list.length; - if (length == 0) { - return; - } - list = list.concat(); - for (var i = 0; i < length; i++) { - list[i].dispatchEventWith(egret.Event.ENTER_FRAME); - } - }; - /** - * @private - * 广播Render事件。 - */ - SystemTicker.prototype.broadcastRender = function () { - var list = egret.DisplayObject.$renderCallBackList; - var length = list.length; - if (length == 0) { - return; - } - list = list.concat(); - for (var i = 0; i < length; i++) { - list[i].dispatchEventWith(egret.Event.RENDER); - } - }; - /** - * @private - */ - SystemTicker.prototype.callLaters = function () { - var functionList; - var thisList; - var argsList; - if (egret.$callLaterFunctionList.length > 0) { - functionList = egret.$callLaterFunctionList; - egret.$callLaterFunctionList = []; - thisList = egret.$callLaterThisList; - egret.$callLaterThisList = []; - argsList = egret.$callLaterArgsList; - egret.$callLaterArgsList = []; - } - if (functionList) { - var length_2 = functionList.length; - for (var i = 0; i < length_2; i++) { - var func = functionList[i]; - if (func != null) { - func.apply(thisList[i], argsList[i]); - } - } - } - }; - /** - * @private - */ - SystemTicker.prototype.callLaterAsyncs = function () { - if (egret.$callAsyncFunctionList.length > 0) { - var locCallAsyncFunctionList = egret.$callAsyncFunctionList; - var locCallAsyncThisList = egret.$callAsyncThisList; - var locCallAsyncArgsList = egret.$callAsyncArgsList; - egret.$callAsyncFunctionList = []; - egret.$callAsyncThisList = []; - egret.$callAsyncArgsList = []; - for (var i = 0; i < locCallAsyncFunctionList.length; i++) { - var func = locCallAsyncFunctionList[i]; - if (func != null) { - func.apply(locCallAsyncThisList[i], locCallAsyncArgsList[i]); - } - } - } - }; - return SystemTicker; - }()); - sys.SystemTicker = SystemTicker; - __reflect(SystemTicker.prototype, "egret.sys.SystemTicker"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -(function (egret) { - var lifecycle; - (function (lifecycle) { - /** - * @private - */ - lifecycle.contexts = []; - var isActivate = true; - var LifecycleContext = (function () { - function LifecycleContext() { - } - LifecycleContext.prototype.pause = function () { - if (isActivate) { - isActivate = false; - lifecycle.stage.dispatchEvent(new egret.Event(egret.Event.DEACTIVATE)); - if (lifecycle.onPause) { - lifecycle.onPause(); - } - } - }; - LifecycleContext.prototype.resume = function () { - if (!isActivate) { - isActivate = true; - lifecycle.stage.dispatchEvent(new egret.Event(egret.Event.ACTIVATE)); - if (lifecycle.onResume) { - lifecycle.onResume(); - } - } - }; - return LifecycleContext; - }()); - lifecycle.LifecycleContext = LifecycleContext; - __reflect(LifecycleContext.prototype, "egret.lifecycle.LifecycleContext"); - function addLifecycleListener(plugin) { - var context = new LifecycleContext(); - lifecycle.contexts.push(context); - plugin(context); - } - lifecycle.addLifecycleListener = addLifecycleListener; - })(lifecycle = egret.lifecycle || (egret.lifecycle = {})); - /** - * 心跳计时器单例 - */ - egret.ticker = new egret.sys.SystemTicker(); -})(egret || (egret = {})); -if (true) { - global.egret_stages = []; -} -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 用户交互操作管理器 - */ - var TouchHandler = (function (_super) { - __extends(TouchHandler, _super); - /** - * @private - */ - function TouchHandler(stage) { - var _this = _super.call(this) || this; - _this.maxTouches = 0; - _this.useTouchesCount = 0; - /** - * @private - */ - _this.touchDownTarget = {}; - /** - * @private - */ - _this.lastTouchX = -1; - /** - * @private - */ - _this.lastTouchY = -1; - _this.stage = stage; - return _this; - } - /** - * @private - * 设置同时触摸数量 - */ - TouchHandler.prototype.$initMaxTouches = function () { - this.maxTouches = this.stage.$maxTouches; - }; - /** - * @private - * 触摸开始(按下) - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - TouchHandler.prototype.onTouchBegin = function (x, y, touchPointID) { - if (this.useTouchesCount >= this.maxTouches) { - return; - } - this.lastTouchX = x; - this.lastTouchY = y; - var target = this.findTarget(x, y); - if (this.touchDownTarget[touchPointID] == null) { - this.touchDownTarget[touchPointID] = target; - this.useTouchesCount++; - } - egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_BEGIN, true, true, x, y, touchPointID, true); - }; - /** - * @private - * 触摸移动 - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - TouchHandler.prototype.onTouchMove = function (x, y, touchPointID) { - if (this.touchDownTarget[touchPointID] == null) { - return; - } - if (this.lastTouchX == x && this.lastTouchY == y) { - return; - } - this.lastTouchX = x; - this.lastTouchY = y; - var target = this.findTarget(x, y); - egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_MOVE, true, true, x, y, touchPointID, true); - }; - /** - * @private - * 触摸结束(弹起) - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - TouchHandler.prototype.onTouchEnd = function (x, y, touchPointID) { - if (this.touchDownTarget[touchPointID] == null) { - return; - } - var target = this.findTarget(x, y); - var oldTarget = this.touchDownTarget[touchPointID]; - delete this.touchDownTarget[touchPointID]; - this.useTouchesCount--; - egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_END, true, true, x, y, touchPointID, false); - if (oldTarget == target) { - egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_TAP, true, true, x, y, touchPointID, false); - } - else { - egret.TouchEvent.dispatchTouchEvent(oldTarget, egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, true, true, x, y, touchPointID, false); - } - }; - /** - * @private - * 获取舞台坐标下的触摸对象 - */ - TouchHandler.prototype.findTarget = function (stageX, stageY) { - var target = this.stage.$hitTest(stageX, stageY); - if (!target) { - target = this.stage; - } - return target; - }; - return TouchHandler; - }(egret.HashObject)); - sys.TouchHandler = TouchHandler; - __reflect(TouchHandler.prototype, "egret.sys.TouchHandler"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 位图渲染节点 - */ - var BitmapNode = (function (_super) { - __extends(BitmapNode, _super); - function BitmapNode() { - var _this = _super.call(this) || this; - /** - * 要绘制的位图 - */ - _this.image = null; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - _this.smoothing = true; - /** - * 使用的混合模式 - */ - _this.blendMode = null; - /** - * 相对透明度 - */ - _this.alpha = NaN; - /** - * 颜色变换滤镜 - */ - _this.filter = null; - /** - * 翻转 - */ - _this.rotated = false; - _this.type = 1 /* BitmapNode */; - return _this; - } - /** - * 绘制一次位图 - */ - BitmapNode.prototype.drawImage = function (sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH) { - this.drawData.push(sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH); - this.renderCount++; - }; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - BitmapNode.prototype.cleanBeforeRender = function () { - _super.prototype.cleanBeforeRender.call(this); - this.image = null; - this.matrix = null; - this.blendMode = null; - this.alpha = NaN; - this.filter = null; - }; - BitmapNode.$updateTextureData = function (node, image, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH, sourceWidth, sourceHeight, fillMode, smoothing) { - if (!image) { - return; - } - var scale = egret.$TextureScaleFactor; - node.smoothing = smoothing; - node.image = image; - node.imageWidth = sourceWidth; - node.imageHeight = sourceHeight; - if (fillMode == egret.BitmapFillMode.SCALE) { - var tsX = destW / textureWidth * scale; - var tsY = destH / textureHeight * scale; - node.drawImage(bitmapX, bitmapY, bitmapWidth, bitmapHeight, tsX * offsetX, tsY * offsetY, tsX * bitmapWidth, tsY * bitmapHeight); - } - else if (fillMode == egret.BitmapFillMode.CLIP) { - var displayW = Math.min(textureWidth, destW); - var displayH = Math.min(textureHeight, destH); - var scaledBitmapW = bitmapWidth * scale; - var scaledBitmapH = bitmapHeight * scale; - BitmapNode.drawClipImage(node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, displayW, displayH); - } - else { - var scaledBitmapW = bitmapWidth * scale; - var scaledBitmapH = bitmapHeight * scale; - for (var startX = 0; startX < destW; startX += textureWidth) { - for (var startY = 0; startY < destH; startY += textureHeight) { - var displayW = Math.min(destW - startX, textureWidth); - var displayH = Math.min(destH - startY, textureHeight); - BitmapNode.drawClipImage(node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, displayW, displayH, startX, startY); - } - } - } - }; - /** - * @private - * 绘制九宫格位图 - */ - BitmapNode.$updateTextureDataWithScale9Grid = function (node, image, scale9Grid, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH, sourceWidth, sourceHeight, smoothing) { - node.smoothing = smoothing; - node.image = image; - node.imageWidth = sourceWidth; - node.imageHeight = sourceHeight; - var imageWidth = bitmapWidth; - var imageHeight = bitmapHeight; - destW = destW - (textureWidth - bitmapWidth * egret.$TextureScaleFactor); - destH = destH - (textureHeight - bitmapHeight * egret.$TextureScaleFactor); - var targetW0 = scale9Grid.x - offsetX; - var targetH0 = scale9Grid.y - offsetY; - var sourceW0 = targetW0 / egret.$TextureScaleFactor; - var sourceH0 = targetH0 / egret.$TextureScaleFactor; - var sourceW1 = scale9Grid.width / egret.$TextureScaleFactor; - var sourceH1 = scale9Grid.height / egret.$TextureScaleFactor; - //防止空心的情况出现。 - if (sourceH1 == 0) { - sourceH1 = 1; - if (sourceH0 >= imageHeight) { - sourceH0--; - } - } - if (sourceW1 == 0) { - sourceW1 = 1; - if (sourceW0 >= imageWidth) { - sourceW0--; - } - } - var sourceX0 = bitmapX; - var sourceX1 = sourceX0 + sourceW0; - var sourceX2 = sourceX1 + sourceW1; - var sourceW2 = imageWidth - sourceW0 - sourceW1; - var sourceY0 = bitmapY; - var sourceY1 = sourceY0 + sourceH0; - var sourceY2 = sourceY1 + sourceH1; - var sourceH2 = imageHeight - sourceH0 - sourceH1; - var targetW2 = sourceW2 * egret.$TextureScaleFactor; - var targetH2 = sourceH2 * egret.$TextureScaleFactor; - if ((sourceW0 + sourceW2) * egret.$TextureScaleFactor > destW || (sourceH0 + sourceH2) * egret.$TextureScaleFactor > destH) { - node.drawImage(bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, destW, destH); - return; - } - var targetX0 = offsetX; - var targetX1 = targetX0 + targetW0; - var targetX2 = targetX0 + (destW - targetW2); - var targetW1 = destW - targetW0 - targetW2; - var targetY0 = offsetY; - var targetY1 = targetY0 + targetH0; - var targetY2 = targetY0 + destH - targetH2; - var targetH1 = destH - targetH0 - targetH2; - // - // x0 x1 x2 - // y0 +------+------+------+ - // | | | | h0 - // | | | | - // y1 +------+------+------+ - // | | | | h1 - // | | | | - // y2 +------+------+------+ - // | | | | h2 - // | | | | - // +------+------+------+ - // w0 w1 w2 - // - if (sourceH0 > 0) { - if (sourceW0 > 0) - node.drawImage(sourceX0, sourceY0, sourceW0, sourceH0, targetX0, targetY0, targetW0, targetH0); - if (sourceW1 > 0) - node.drawImage(sourceX1, sourceY0, sourceW1, sourceH0, targetX1, targetY0, targetW1, targetH0); - if (sourceW2 > 0) - node.drawImage(sourceX2, sourceY0, sourceW2, sourceH0, targetX2, targetY0, targetW2, targetH0); - } - if (sourceH1 > 0) { - if (sourceW0 > 0) - node.drawImage(sourceX0, sourceY1, sourceW0, sourceH1, targetX0, targetY1, targetW0, targetH1); - if (sourceW1 > 0) - node.drawImage(sourceX1, sourceY1, sourceW1, sourceH1, targetX1, targetY1, targetW1, targetH1); - if (sourceW2 > 0) - node.drawImage(sourceX2, sourceY1, sourceW2, sourceH1, targetX2, targetY1, targetW2, targetH1); - } - if (sourceH2 > 0) { - if (sourceW0 > 0) - node.drawImage(sourceX0, sourceY2, sourceW0, sourceH2, targetX0, targetY2, targetW0, targetH2); - if (sourceW1 > 0) - node.drawImage(sourceX1, sourceY2, sourceW1, sourceH2, targetX1, targetY2, targetW1, targetH2); - if (sourceW2 > 0) - node.drawImage(sourceX2, sourceY2, sourceW2, sourceH2, targetX2, targetY2, targetW2, targetH2); - } - }; - /** - * @private - */ - BitmapNode.drawClipImage = function (node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, destW, destH, startX, startY) { - if (startX === void 0) { startX = 0; } - if (startY === void 0) { startY = 0; } - var offset = offsetX + scaledBitmapW - destW; - if (offset > 0) { - scaledBitmapW -= offset; - } - offset = offsetY + scaledBitmapH - destH; - if (offset > 0) { - scaledBitmapH -= offset; - } - node.drawImage(bitmapX, bitmapY, scaledBitmapW / scale, scaledBitmapH / scale, startX + offsetX, startY + offsetY, scaledBitmapW, scaledBitmapH); - }; - return BitmapNode; - }(sys.RenderNode)); - sys.BitmapNode = BitmapNode; - __reflect(BitmapNode.prototype, "egret.sys.BitmapNode"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - var CAPS_STYLES = ["none", "round", "square"]; - var JOINT_STYLES = ["bevel", "miter", "round"]; - /** - * @private - * 矢量渲染节点 - */ - var GraphicsNode = (function (_super) { - __extends(GraphicsNode, _super); - function GraphicsNode() { - var _this = _super.call(this) || this; - /** - * 脏渲染标记 - * 暂时调用lineStyle,beginFill,beginGradientFill标记,实际应该draw时候标记在Path2D - */ - _this.dirtyRender = true; - _this.type = 3 /* GraphicsNode */; - return _this; - } - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * @param color 填充的颜色 - * @param alpha 填充的 Alpha 值 - * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 - */ - GraphicsNode.prototype.beginFill = function (color, alpha, beforePath) { - if (alpha === void 0) { alpha = 1; } - var path = new sys.FillPath(); - path.fillColor = color; - path.fillAlpha = alpha; - if (beforePath) { - var index = this.drawData.lastIndexOf(beforePath); - this.drawData.splice(index, 0, path); - } - else { - this.drawData.push(path); - } - this.renderCount++; - return path; - }; - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * 调用 clear() 方法会清除填充。 - * @param type 用于指定要使用哪种渐变类型的 GradientType 类的值:GradientType.LINEAR 或 GradientType.RADIAL。 - * @param colors 渐变中使用的 RGB 十六进制颜色值的数组(例如,红色为 0xFF0000,蓝色为 0x0000FF,等等)。对于每种颜色,请在 alphas 和 ratios 参数中指定对应值。 - * @param alphas colors 数组中对应颜色的 alpha 值数组。 - * @param ratios 颜色分布比率的数组。有效值为 0 到 255。 - * @param matrix 一个由 egret.Matrix 类定义的转换矩阵。egret.Matrix 类包括 createGradientBox() 方法,通过该方法可以方便地设置矩阵,以便与 beginGradientFill() 方法一起使用 - * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 - */ - GraphicsNode.prototype.beginGradientFill = function (type, colors, alphas, ratios, matrix, beforePath) { - var m = new egret.Matrix(); - if (matrix) { - m.a = matrix.a * 819.2; - m.b = matrix.b * 819.2; - m.c = matrix.c * 819.2; - m.d = matrix.d * 819.2; - m.tx = matrix.tx; - m.ty = matrix.ty; - } - else { - //默认值 - m.a = 100; - m.d = 100; - } - var path = new sys.GradientFillPath(); - path.gradientType = type; - path.colors = colors; - path.alphas = alphas; - path.ratios = ratios; - path.matrix = m; - if (beforePath) { - var index = this.drawData.lastIndexOf(beforePath); - this.drawData.splice(index, 0, path); - } - else { - this.drawData.push(path); - } - this.renderCount++; - return path; - }; - /** - * 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。 - * @param thickness 一个整数,以点为单位表示线条的粗细,有效值为 0 到 255。如果未指定数字,或者未定义该参数,则不绘制线条。如果传递的值小于 0,则默认值为 0。值 0 表示极细的粗细;最大粗细为 255。如果传递的值大于 255,则默认值为 255。 - * @param color 线条的十六进制颜色值(例如,红色为 0xFF0000,蓝色为 0x0000FF 等)。如果未指明值,则默认值为 0x000000(黑色)。可选。 - * @param alpha 表示线条颜色的 Alpha 值的数字;有效值为 0 到 1。如果未指明值,则默认值为 1(纯色)。如果值小于 0,则默认值为 0。如果值大于 1,则默认值为 1。 - * @param caps 用于指定线条末端处端点类型的 CapsStyle 类的值。默认值:CapsStyle.ROUND - * @param joints 指定用于拐角的连接外观的类型。默认值:JointStyle.ROUND - * @param miterLimit 用于表示剪切斜接的极限值的数字。 - */ - GraphicsNode.prototype.lineStyle = function (thickness, color, alpha, caps, joints, miterLimit, lineDash) { - if (alpha === void 0) { alpha = 1; } - if (miterLimit === void 0) { miterLimit = 3; } - if (lineDash === void 0) { lineDash = []; } - if (CAPS_STYLES.indexOf(caps) == -1) { - caps = "round"; - } - if (JOINT_STYLES.indexOf(joints) == -1) { - joints = "round"; - } - var path = new sys.StrokePath(); - path.lineWidth = thickness; - path.lineColor = color; - path.lineAlpha = alpha; - path.caps = caps || egret.CapsStyle.ROUND; - path.joints = joints; - path.miterLimit = miterLimit; - path.lineDash = lineDash; - this.drawData.push(path); - this.renderCount++; - return path; - }; - /** - * 清空所有缓存的绘制数据 - */ - GraphicsNode.prototype.clear = function () { - this.drawData.length = 0; - this.dirtyRender = true; - this.renderCount = 0; - }; - /** - * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 - */ - GraphicsNode.prototype.cleanBeforeRender = function () { - }; - /** - * 清除非绘制的缓存数据 - */ - GraphicsNode.prototype.clean = function () { - if (this.$texture) { - egret.WebGLUtils.deleteWebGLTexture(this.$texture); - this.$texture = null; - this.dirtyRender = true; - } - }; - return GraphicsNode; - }(sys.RenderNode)); - sys.GraphicsNode = GraphicsNode; - __reflect(GraphicsNode.prototype, "egret.sys.GraphicsNode"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 组渲染节点,用于组合多个渲染节点 - */ - var GroupNode = (function (_super) { - __extends(GroupNode, _super); - function GroupNode() { - var _this = _super.call(this) || this; - _this.type = 4 /* GroupNode */; - return _this; - } - GroupNode.prototype.addNode = function (node) { - this.drawData.push(node); - }; - /** - * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 - * 这里只是想清空绘制命令,因此不调用super - */ - GroupNode.prototype.cleanBeforeRender = function () { - var data = this.drawData; - for (var i = data.length - 1; i >= 0; i--) { - data[i].cleanBeforeRender(); - } - }; - GroupNode.prototype.$getRenderCount = function () { - var result = 0; - var data = this.drawData; - for (var i = data.length - 1; i >= 0; i--) { - result += data[i].$getRenderCount(); - } - return result; - }; - return GroupNode; - }(sys.RenderNode)); - sys.GroupNode = GroupNode; - __reflect(GroupNode.prototype, "egret.sys.GroupNode"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * Mesh 渲染节点 - */ - var MeshNode = (function (_super) { - __extends(MeshNode, _super); - function MeshNode() { - var _this = _super.call(this) || this; - /** - * 要绘制的位图 - */ - _this.image = null; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - _this.smoothing = true; - /** - * 顶点索引。 - */ - _this.bounds = new egret.Rectangle(); - /** - * 使用的混合模式 - */ - _this.blendMode = null; - /** - * 相对透明度 - */ - _this.alpha = NaN; - /** - * 颜色变换滤镜 - */ - _this.filter = null; - /** - * 翻转 - */ - _this.rotated = false; - _this.type = 5 /* MeshNode */; - _this.vertices = []; - _this.uvs = []; - _this.indices = []; - return _this; - } - /** - * 绘制一次位图 - */ - MeshNode.prototype.drawMesh = function (sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH) { - this.drawData.push(sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH); - this.renderCount++; - }; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - MeshNode.prototype.cleanBeforeRender = function () { - _super.prototype.cleanBeforeRender.call(this); - this.image = null; - this.matrix = null; - }; - return MeshNode; - }(sys.RenderNode)); - sys.MeshNode = MeshNode; - __reflect(MeshNode.prototype, "egret.sys.MeshNode"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 位图渲染节点 - */ - var NormalBitmapNode = (function (_super) { - __extends(NormalBitmapNode, _super); - function NormalBitmapNode() { - var _this = _super.call(this) || this; - /** - * 要绘制的位图 - */ - _this.image = null; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - _this.smoothing = true; - /** - * 翻转 - */ - _this.rotated = false; - _this.type = 6 /* NormalBitmapNode */; - return _this; - } - /** - * 绘制一次位图 - */ - NormalBitmapNode.prototype.drawImage = function (sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH) { - var self = this; - self.sourceX = sourceX; - self.sourceY = sourceY; - self.sourceW = sourceW; - self.sourceH = sourceH; - self.drawX = drawX; - self.drawY = drawY; - self.drawW = drawW; - self.drawH = drawH; - self.renderCount = 1; - }; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - NormalBitmapNode.prototype.cleanBeforeRender = function () { - _super.prototype.cleanBeforeRender.call(this); - this.image = null; - }; - return NormalBitmapNode; - }(sys.RenderNode)); - sys.NormalBitmapNode = NormalBitmapNode; - __reflect(NormalBitmapNode.prototype, "egret.sys.NormalBitmapNode"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * OrientationMode 类为舞台初始旋转模式提供值。 - */ - egret.OrientationMode = { - /** - * 适配屏幕 - */ - AUTO: "auto", - /** - * 默认竖屏 - */ - PORTRAIT: "portrait", - /** - * 默认横屏,舞台顺时针旋转90度 - */ - LANDSCAPE: "landscape", - /** - * 默认横屏,舞台逆时针旋转90度 - */ - LANDSCAPE_FLIPPED: "landscapeFlipped" - }; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 文本渲染节点 - */ - var TextNode = (function (_super) { - __extends(TextNode, _super); - function TextNode() { - var _this = _super.call(this) || this; - /** - * 颜色值 - */ - _this.textColor = 0xFFFFFF; - /** - * 描边颜色值 - */ - _this.strokeColor = 0x000000; - /** - * 字号 - */ - _this.size = 30; - /** - * 描边大小 - */ - _this.stroke = 0; - /** - * 是否加粗 - */ - _this.bold = false; - /** - * 是否倾斜 - */ - _this.italic = false; - /** - * 字体名称 - */ - _this.fontFamily = "Arial"; - /** - * 脏渲染标记 - */ - _this.dirtyRender = true; - _this.type = 2 /* TextNode */; - return _this; - } - /** - * 绘制一行文本 - */ - TextNode.prototype.drawText = function (x, y, text, format) { - this.drawData.push(x, y, text, format); - this.renderCount++; - this.dirtyRender = true; - }; - /** - * 清除非绘制的缓存数据 - */ - TextNode.prototype.clean = function () { - if (this.$texture) { - egret.WebGLUtils.deleteWebGLTexture(this.$texture); - this.$texture = null; - this.dirtyRender = true; - } - }; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - TextNode.prototype.cleanBeforeRender = function () { - _super.prototype.cleanBeforeRender.call(this); - this.dirtyRender = true; - }; - return TextNode; - }(sys.RenderNode)); - sys.TextNode = TextNode; - __reflect(TextNode.prototype, "egret.sys.TextNode"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 填充路径 - */ - var FillPath = (function (_super) { - __extends(FillPath, _super); - function FillPath() { - var _this = _super.call(this) || this; - _this.type = 1 /* Fill */; - return _this; - } - return FillPath; - }(sys.Path2D)); - sys.FillPath = FillPath; - __reflect(FillPath.prototype, "egret.sys.FillPath"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 渐变填充路径 - */ - var GradientFillPath = (function (_super) { - __extends(GradientFillPath, _super); - function GradientFillPath() { - var _this = _super.call(this) || this; - _this.type = 2 /* GradientFill */; - return _this; - } - return GradientFillPath; - }(sys.Path2D)); - sys.GradientFillPath = GradientFillPath; - __reflect(GradientFillPath.prototype, "egret.sys.GradientFillPath"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * RenderTexture is a dynamic texture - * @extends egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/RenderTexture.ts - * @language en_US - */ - /** - * RenderTexture 是动态纹理类,他实现了将显示对象及其子对象绘制成为一个纹理的功能 - * @extends egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/RenderTexture.ts - * @language zh_CN - */ - var RenderTexture = (function (_super) { - __extends(RenderTexture, _super); - function RenderTexture() { - var _this = _super.call(this) || this; - _this.$renderBuffer = new egret.sys.RenderBuffer(); - var bitmapData = new egret.BitmapData(_this.$renderBuffer.surface); - bitmapData.$deleteSource = false; - _this._setBitmapData(bitmapData); - return _this; - } - /** - * The specified display object is drawn as a texture - * @param displayObject {egret.DisplayObject} the display to draw - * @param clipBounds {egret.Rectangle} clip rect - * @param scale {number} scale factor - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定显示对象绘制为一个纹理 - * @param displayObject {egret.DisplayObject} 需要绘制的显示对象 - * @param clipBounds {egret.Rectangle} 绘制矩形区域 - * @param scale {number} 缩放比例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - RenderTexture.prototype.drawToTexture = function (displayObject, clipBounds, scale) { - if (scale === void 0) { scale = 1; } - if (clipBounds && (clipBounds.width == 0 || clipBounds.height == 0)) { - return false; - } - var bounds = clipBounds || displayObject.$getOriginalBounds(); - if (bounds.width == 0 || bounds.height == 0) { - return false; - } - scale /= egret.$TextureScaleFactor; - var width = (bounds.x + bounds.width) * scale; - var height = (bounds.y + bounds.height) * scale; - if (clipBounds) { - width = bounds.width * scale; - height = bounds.height * scale; - } - var renderBuffer = this.$renderBuffer; - if (!renderBuffer) { - return false; - } - renderBuffer.resize(width, height); - this.$bitmapData.width = width; - this.$bitmapData.height = height; - if (egret.nativeRender) { - egret_native.activateBuffer(this.$renderBuffer); - var useClip = false; - var clipX = 0; - var clipY = 0; - var clipW = 0; - var clipH = 0; - if (clipBounds) { - useClip = true; - clipX = clipBounds.x; - clipY = clipBounds.y; - clipW = clipBounds.width; - clipH = clipBounds.height; - } - egret_native.updateNativeRender(); - egret_native.nrRenderDisplayObject(displayObject.$nativeDisplayObject.id, scale, useClip, clipX, clipY, clipW, clipH); - egret_native.activateBuffer(null); - } - else { - var matrix = egret.Matrix.create(); - matrix.identity(); - matrix.scale(scale, scale); - //应用裁切 - if (clipBounds) { - matrix.translate(-clipBounds.x, -clipBounds.y); - } - egret.sys.systemRenderer.render(displayObject, renderBuffer, matrix, true); - egret.Matrix.release(matrix); - } - //设置纹理参数 - this.$initData(0, 0, width, height, 0, 0, width, height, width, height); - return true; - }; - /** - * @inheritDoc - */ - RenderTexture.prototype.getPixel32 = function (x, y) { - var data; - if (this.$renderBuffer) { - var scale = egret.$TextureScaleFactor; - x = Math.round(x / scale); - y = Math.round(y / scale); - data = this.$renderBuffer.getPixels(x, y, 1, 1); - } - return data; - }; - /** - * @inheritDoc - */ - RenderTexture.prototype.dispose = function () { - _super.prototype.dispose.call(this); - this.$renderBuffer = null; - }; - return RenderTexture; - }(egret.Texture)); - egret.RenderTexture = RenderTexture; - __reflect(RenderTexture.prototype, "egret.RenderTexture"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 线条路径。 - * 注意:当线条宽度(lineWidth)为1或3像素时,需要特殊处理,往右下角偏移0.5像素,以显示清晰锐利的线条。 - */ - var StrokePath = (function (_super) { - __extends(StrokePath, _super); - function StrokePath() { - var _this = _super.call(this) || this; - _this.type = 3 /* Stroke */; - return _this; - } - return StrokePath; - }(sys.Path2D)); - sys.StrokePath = StrokePath; - __reflect(StrokePath.prototype, "egret.sys.StrokePath"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var blendModes = ["source-over", "lighter", "destination-out"]; - var defaultCompositeOp = "source-over"; - var BLACK_COLOR = "#000000"; - var CAPS_STYLES = { none: 'butt', square: 'square', round: 'round' }; - var renderBufferPool = []; //渲染缓冲区对象池 - var renderBufferPool_Filters = []; //滤镜缓冲区对象池 - var CanvasRenderer = (function () { - function CanvasRenderer() { - this.nestLevel = 0; //渲染的嵌套层次,0表示在调用堆栈的最外层。 - this.renderingMask = false; - } - CanvasRenderer.prototype.render = function (displayObject, buffer, matrix, forRenderTexture) { - this.nestLevel++; - var context = buffer.context; - var root = forRenderTexture ? displayObject : null; - //绘制显示对象 - context.transform(matrix.a, matrix.b, matrix.c, matrix.d, 0, 0); - var drawCall = this.drawDisplayObject(displayObject, context, matrix.tx, matrix.ty, true); - var invert = egret.Matrix.create(); - matrix.$invertInto(invert); - context.transform(invert.a, invert.b, invert.c, invert.d, 0, 0); - egret.Matrix.release(invert); - this.nestLevel--; - if (this.nestLevel === 0) { - //最大缓存6个渲染缓冲 - if (renderBufferPool.length > 6) { - renderBufferPool.length = 6; - } - var length_3 = renderBufferPool.length; - for (var i = 0; i < length_3; i++) { - renderBufferPool[i].resize(0, 0); - } - } - return drawCall; - }; - /** - * @private - * 绘制一个显示对象 - */ - CanvasRenderer.prototype.drawDisplayObject = function (displayObject, context, offsetX, offsetY, isStage) { - var drawCalls = 0; - var node; - var displayList = displayObject.$displayList; - if (displayList && !isStage) { - if (displayObject.$cacheDirty || displayObject.$renderDirty || - displayList.$canvasScaleX != egret.sys.DisplayList.$canvasScaleX || - displayList.$canvasScaleY != egret.sys.DisplayList.$canvasScaleY) { - drawCalls += displayList.drawToSurface(); - } - node = displayList.$renderNode; - } - else { - if (displayObject.$renderDirty) { - node = displayObject.$getRenderNode(); - } - else { - node = displayObject.$renderNode; - } - } - displayObject.$cacheDirty = false; - if (node) { - drawCalls++; - context.$offsetX = offsetX; - context.$offsetY = offsetY; - switch (node.type) { - case 1 /* BitmapNode */: - this.renderBitmap(node, context); - break; - case 2 /* TextNode */: - this.renderText(node, context); - break; - case 3 /* GraphicsNode */: - this.renderGraphics(node, context); - break; - case 4 /* GroupNode */: - this.renderGroup(node, context); - break; - case 5 /* MeshNode */: - this.renderMesh(node, context); - break; - case 6 /* NormalBitmapNode */: - this.renderNormalBitmap(node, context); - break; - } - context.$offsetX = 0; - context.$offsetY = 0; - } - if (displayList && !isStage) { - return drawCalls; - } - var children = displayObject.$children; - if (children) { - var length_4 = children.length; - for (var i = 0; i < length_4; i++) { - var child = children[i]; - var offsetX2 = void 0; - var offsetY2 = void 0; - if (child.$useTranslate) { - var m = child.$getMatrix(); - offsetX2 = offsetX + child.$x; - offsetY2 = offsetY + child.$y; - context.save(); - context.transform(m.a, m.b, m.c, m.d, offsetX2, offsetY2); - offsetX2 = -child.$anchorOffsetX; - offsetY2 = -child.$anchorOffsetY; - } - else { - offsetX2 = offsetX + child.$x - child.$anchorOffsetX; - offsetY2 = offsetY + child.$y - child.$anchorOffsetY; - } - var tempAlpha = void 0; - if (child.$alpha != 1) { - tempAlpha = context.globalAlpha; - context.globalAlpha *= child.$alpha; - } - switch (child.$renderMode) { - case 1 /* NONE */: - break; - case 2 /* FILTER */: - drawCalls += this.drawWithFilter(child, context, offsetX2, offsetY2); - break; - case 3 /* CLIP */: - drawCalls += this.drawWithClip(child, context, offsetX2, offsetY2); - break; - case 4 /* SCROLLRECT */: - drawCalls += this.drawWithScrollRect(child, context, offsetX2, offsetY2); - break; - default: - drawCalls += this.drawDisplayObject(child, context, offsetX2, offsetY2); - break; - } - if (child.$useTranslate) { - context.restore(); - } - else if (tempAlpha) { - context.globalAlpha = tempAlpha; - } - } - } - return drawCalls; - }; - CanvasRenderer.prototype.drawWithFilter = function (displayObject, context, offsetX, offsetY) { - if (displayObject.$children && displayObject.$children.length == 0 && (!displayObject.$renderNode || displayObject.$renderNode.$getRenderCount() == 0)) { - return 0; - } - var drawCalls = 0; - var filters = displayObject.$filters; - var filtersLen = filters.length; - var hasBlendMode = (displayObject.$blendMode !== 0); - var compositeOp; - if (hasBlendMode) { - compositeOp = blendModes[displayObject.$blendMode]; - if (!compositeOp) { - compositeOp = defaultCompositeOp; - } - } - var displayBounds = displayObject.$getOriginalBounds(); - var displayBoundsX = displayBounds.x; - var displayBoundsY = displayBounds.y; - var displayBoundsWidth = displayBounds.width; - var displayBoundsHeight = displayBounds.height; - if (displayBoundsWidth <= 0 || displayBoundsHeight <= 0) { - return drawCalls; - } - // 为显示对象创建一个新的buffer - var displayBuffer = this.createRenderBuffer(displayBoundsWidth - displayBoundsX, displayBoundsHeight - displayBoundsY, true); - var displayContext = displayBuffer.context; - if (displayObject.$mask) { - drawCalls += this.drawWithClip(displayObject, displayContext, -displayBoundsX, -displayBoundsY); - } - else if (displayObject.$scrollRect || displayObject.$maskRect) { - drawCalls += this.drawWithScrollRect(displayObject, displayContext, -displayBoundsX, -displayBoundsY); - } - else { - drawCalls += this.drawDisplayObject(displayObject, displayContext, -displayBoundsX, -displayBoundsY); - } - //绘制结果到屏幕 - if (drawCalls > 0) { - if (hasBlendMode) { - context.globalCompositeOperation = compositeOp; - } - drawCalls++; - // 应用滤镜 - var imageData = displayContext.getImageData(0, 0, displayBuffer.surface.width, displayBuffer.surface.height); - for (var i = 0; i < filtersLen; i++) { - var filter = filters[i]; - if (filter.type == "colorTransform") { - colorFilter(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, filter.$matrix); - } - else if (filter.type == "blur") { - blurFilter(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, filter.$blurX, filter.$blurY); - } - else if (filter.type == "glow") { - var r = filter.$red; - var g = filter.$green; - var b = filter.$blue; - var a = filter.$alpha; - if (filter.$inner || filter.$knockout || filter.$hideObject) { - dropShadowFilter2(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, [r / 255, g / 255, b / 255, a], filter.$blurX, filter.$blurY, filter.$angle ? (filter.$angle / 180 * Math.PI) : 0, filter.$distance || 0, filter.$strength, filter.$inner ? 1 : 0, filter.$knockout ? 0 : 1, filter.$hideObject ? 1 : 0); - } - else { - // 如果没有高级效果,使用性能比较高的方式 - dropShadowFilter(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, [r / 255, g / 255, b / 255, a], filter.$blurX, filter.$blurY, filter.$angle ? (filter.$angle / 180 * Math.PI) : 0, filter.$distance || 0, filter.$strength); - } - } - else if (filter.type == "custom") { - // 目前canvas渲染不支持自定义滤镜 - } - } - displayContext.putImageData(imageData, 0, 0); - // 绘制结果的时候,应用滤镜 - context.drawImage(displayBuffer.surface, offsetX + displayBoundsX, offsetY + displayBoundsY); - if (hasBlendMode) { - context.globalCompositeOperation = defaultCompositeOp; - } - } - renderBufferPool_Filters.push(displayBuffer); - return drawCalls; - }; - CanvasRenderer.prototype.drawWithClip = function (displayObject, context, offsetX, offsetY) { - var drawCalls = 0; - var hasBlendMode = (displayObject.$blendMode !== 0); - var compositeOp; - if (hasBlendMode) { - compositeOp = blendModes[displayObject.$blendMode]; - if (!compositeOp) { - compositeOp = defaultCompositeOp; - } - } - var scrollRect = displayObject.$scrollRect ? displayObject.$scrollRect : displayObject.$maskRect; - var mask = displayObject.$mask; - if (mask) { - var maskRenderMatrix = mask.$getMatrix(); - //遮罩scaleX或scaleY为0,放弃绘制 - if ((maskRenderMatrix.a == 0 && maskRenderMatrix.b == 0) || (maskRenderMatrix.c == 0 && maskRenderMatrix.d == 0)) { - return drawCalls; - } - } - //没有遮罩,同时显示对象没有子项 - if (!mask && (!displayObject.$children || displayObject.$children.length == 0)) { - if (scrollRect) { - context.save(); - context.beginPath(); - context.rect(scrollRect.x + offsetX, scrollRect.y + offsetY, scrollRect.width, scrollRect.height); - context.clip(); - } - if (hasBlendMode) { - context.globalCompositeOperation = compositeOp; - } - drawCalls += this.drawDisplayObject(displayObject, context, offsetX, offsetY); - if (hasBlendMode) { - context.globalCompositeOperation = defaultCompositeOp; - } - if (scrollRect) { - context.restore(); - } - return drawCalls; - } - var maskRenderNode = mask.$getRenderNode(); - //遮罩是单纯的填充图形,且alpha为1,性能优化 - if (mask && (!mask.$children || mask.$children.length == 0) && - maskRenderNode && maskRenderNode.type == 3 /* GraphicsNode */ && - maskRenderNode.drawData.length == 1 && - maskRenderNode.drawData[0].type == 1 /* Fill */ && - maskRenderNode.drawData[0].fillAlpha == 1) { - this.renderingMask = true; - context.save(); - var maskMatrix = egret.Matrix.create(); - maskMatrix.copyFrom(mask.$getConcatenatedMatrix()); - mask.$getConcatenatedMatrixAt(displayObject, maskMatrix); - context.transform(maskMatrix.a, maskMatrix.b, maskMatrix.c, maskMatrix.d, maskMatrix.tx, maskMatrix.ty); - var calls = this.drawDisplayObject(mask, context, offsetX, offsetY); - this.renderingMask = false; - maskMatrix.$invertInto(maskMatrix); - context.transform(maskMatrix.a, maskMatrix.b, maskMatrix.c, maskMatrix.d, maskMatrix.tx, maskMatrix.ty); - egret.Matrix.release(maskMatrix); - if (scrollRect) { - context.beginPath(); - context.rect(scrollRect.x + offsetX, scrollRect.y + offsetY, scrollRect.width, scrollRect.height); - context.clip(); - } - calls += this.drawDisplayObject(displayObject, context, offsetX, offsetY); - context.restore(); - return calls; - } - //todo 若显示对象是容器,同时子项有混合模式,则需要先绘制背景到displayBuffer并清除背景区域 - //绘制显示对象自身,若有scrollRect,应用clip - var displayBounds = displayObject.$getOriginalBounds(); - var displayBoundsX = displayBounds.x; - var displayBoundsY = displayBounds.y; - var displayBoundsWidth = displayBounds.width; - var displayBoundsHeight = displayBounds.height; - var displayBuffer = this.createRenderBuffer(displayBoundsWidth, displayBoundsHeight); - var displayContext = displayBuffer.context; - if (!displayContext) { - drawCalls += this.drawDisplayObject(displayObject, context, offsetX, offsetY); - return drawCalls; - } - drawCalls += this.drawDisplayObject(displayObject, displayContext, -displayBoundsX, -displayBoundsY); - //绘制遮罩 - if (mask) { - var maskMatrix = egret.Matrix.create(); - maskMatrix.copyFrom(mask.$getConcatenatedMatrix()); - mask.$getConcatenatedMatrixAt(displayObject, maskMatrix); - maskMatrix.translate(-displayBoundsX, -displayBoundsY); - //如果只有一次绘制或是已经被cache直接绘制到displayContext - if (maskRenderNode && maskRenderNode.$getRenderCount() == 1 || mask.$displayList) { - displayContext.globalCompositeOperation = "destination-in"; - displayContext.save(); - displayContext.setTransform(maskMatrix.a, maskMatrix.b, maskMatrix.c, maskMatrix.d, maskMatrix.tx, maskMatrix.ty); - drawCalls += this.drawDisplayObject(mask, displayContext, 0, 0); - displayContext.restore(); - } - else { - var maskBuffer = this.createRenderBuffer(displayBoundsWidth, displayBoundsHeight); - var maskContext = maskBuffer.context; - maskContext.setTransform(maskMatrix.a, maskMatrix.b, maskMatrix.c, maskMatrix.d, maskMatrix.tx, maskMatrix.ty); - drawCalls += this.drawDisplayObject(mask, maskContext, 0, 0); - displayContext.globalCompositeOperation = "destination-in"; - displayContext.drawImage(maskBuffer.surface, 0, 0); - renderBufferPool.push(maskBuffer); - } - egret.Matrix.release(maskMatrix); - } - //绘制结果到屏幕 - if (drawCalls > 0) { - drawCalls++; - if (hasBlendMode) { - context.globalCompositeOperation = compositeOp; - } - if (scrollRect) { - context.save(); - context.beginPath(); - context.rect(scrollRect.x + offsetX, scrollRect.y + offsetY, scrollRect.width, scrollRect.height); - context.clip(); - } - context.drawImage(displayBuffer.surface, offsetX + displayBoundsX, offsetY + displayBoundsY); - if (scrollRect) { - context.restore(); - } - if (hasBlendMode) { - context.globalCompositeOperation = defaultCompositeOp; - } - } - renderBufferPool.push(displayBuffer); - return drawCalls; - }; - CanvasRenderer.prototype.drawWithScrollRect = function (displayObject, context, offsetX, offsetY) { - var drawCalls = 0; - var scrollRect = displayObject.$scrollRect ? displayObject.$scrollRect : displayObject.$maskRect; - if (scrollRect.isEmpty()) { - return drawCalls; - } - if (displayObject.$scrollRect) { - offsetX -= scrollRect.x; - offsetY -= scrollRect.y; - } - //绘制显示对象自身 - context.save(); - context.beginPath(); - context.rect(scrollRect.x + offsetX, scrollRect.y + offsetY, scrollRect.width, scrollRect.height); - context.clip(); - drawCalls += this.drawDisplayObject(displayObject, context, offsetX, offsetY); - context.restore(); - return drawCalls; - }; - CanvasRenderer.prototype.drawNodeToBuffer = function (node, buffer, matrix, forHitTest) { - var context = buffer.context; - context.setTransform(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty); - this.renderNode(node, context, forHitTest); - }; - /** - * 将一个DisplayObject绘制到渲染缓冲,用于RenderTexture绘制 - * @param displayObject 要绘制的显示对象 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - */ - CanvasRenderer.prototype.drawDisplayToBuffer = function (displayObject, buffer, matrix) { - var context = buffer.context; - if (matrix) { - context.setTransform(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty); - } - var node; - if (displayObject.$renderDirty) { - node = displayObject.$getRenderNode(); - } - else { - node = displayObject.$renderNode; - } - var drawCalls = 0; - if (node) { - drawCalls++; - switch (node.type) { - case 1 /* BitmapNode */: - this.renderBitmap(node, context); - break; - case 2 /* TextNode */: - this.renderText(node, context); - break; - case 3 /* GraphicsNode */: - this.renderGraphics(node, context); - break; - case 4 /* GroupNode */: - this.renderGroup(node, context); - break; - case 5 /* MeshNode */: - this.renderMesh(node, context); - break; - case 6 /* NormalBitmapNode */: - this.renderNormalBitmap(node, context); - break; - } - } - var children = displayObject.$children; - if (children) { - var length_5 = children.length; - for (var i = 0; i < length_5; i++) { - var child = children[i]; - switch (child.$renderMode) { - case 1 /* NONE */: - break; - case 2 /* FILTER */: - drawCalls += this.drawWithFilter(child, context, 0, 0); - break; - case 3 /* CLIP */: - drawCalls += this.drawWithClip(child, context, 0, 0); - break; - case 4 /* SCROLLRECT */: - drawCalls += this.drawWithScrollRect(child, context, 0, 0); - break; - default: - drawCalls += this.drawDisplayObject(child, context, 0, 0); - break; - } - } - } - return drawCalls; - }; - CanvasRenderer.prototype.renderNode = function (node, context, forHitTest) { - var drawCalls = 0; - switch (node.type) { - case 1 /* BitmapNode */: - drawCalls = this.renderBitmap(node, context); - break; - case 2 /* TextNode */: - drawCalls = 1; - this.renderText(node, context); - break; - case 3 /* GraphicsNode */: - drawCalls = this.renderGraphics(node, context, forHitTest); - break; - case 4 /* GroupNode */: - drawCalls = this.renderGroup(node, context); - break; - case 5 /* MeshNode */: - drawCalls = this.renderMesh(node, context); - break; - case 6 /* NormalBitmapNode */: - drawCalls += this.renderNormalBitmap(node, context); - break; - } - return drawCalls; - }; - CanvasRenderer.prototype.renderNormalBitmap = function (node, context) { - var image = node.image; - if (!image || !image.source) { - return 0; - } - if (context.$imageSmoothingEnabled != node.smoothing) { - context.imageSmoothingEnabled = node.smoothing; - context.$imageSmoothingEnabled = node.smoothing; - } - if (node.rotated) { - var sourceX = node.sourceX; - var sourceY = node.sourceY; - var sourceHeight = node.sourceW; - var sourceWidth = node.sourceH; - var offsetX = node.drawX; - var offsetY = node.drawY; - var destHeight = node.drawW; - var destWidth = node.drawH; - context.save(); - context.transform(0, -1, 1, 0, 0, destWidth); - context.drawImage(image.source, sourceX, sourceY, sourceWidth, sourceHeight, offsetX + context.$offsetX, offsetY + context.$offsetY, destWidth, destHeight); - context.restore(); - } - else { - context.drawImage(image.source, node.sourceX, node.sourceY, node.sourceW, node.sourceH, node.drawX + context.$offsetX, node.drawY + context.$offsetY, node.drawW, node.drawH); - } - return 1; - }; - CanvasRenderer.prototype.renderBitmap = function (node, context) { - var image = node.image; - if (!image || !image.source) { - return 0; - } - if (context.$imageSmoothingEnabled != node.smoothing) { - context.imageSmoothingEnabled = node.smoothing; - context.$imageSmoothingEnabled = node.smoothing; - } - var data = node.drawData; - var length = data.length; - var pos = 0; - var m = node.matrix; - var blendMode = node.blendMode; - var alpha = node.alpha; - var saved = false; - var offsetX; - var offsetY; - if (m) { - context.save(); - saved = true; - if (context.$offsetX != 0 || context.$offsetY != 0) { - context.translate(context.$offsetX, context.$offsetY); - offsetX = context.$offsetX; - offsetY = context.$offsetY; - context.$offsetX = context.$offsetY = 0; - } - context.transform(m.a, m.b, m.c, m.d, m.tx, m.ty); - } - //这里不考虑嵌套 - if (blendMode) { - context.globalCompositeOperation = blendModes[blendMode]; - } - var originAlpha; - if (alpha == alpha) { - originAlpha = context.globalAlpha; - context.globalAlpha *= alpha; - } - var drawCalls = 0; - var filter = node.filter; - //todo 暂时只考虑绘制一次的情况 - if (filter && length == 8) { - var sourceX = data[0]; - var sourceY = data[1]; - var sourceWidth = data[2]; - var sourceHeight = data[3]; - var offsetX_1 = data[4]; - var offsetY_1 = data[5]; - var destWidth = data[6]; - var destHeight = data[7]; - if (node.rotated) { - sourceWidth = data[3]; - sourceHeight = data[2]; - destWidth = data[7]; - destHeight = data[6]; - } - var displayBuffer = this.createRenderBuffer(destWidth, destHeight); - var displayContext = displayBuffer.context; - drawCalls++; - if (node.rotated) { - context.transform(0, -1, 1, 0, 0, destWidth); - } - displayContext.drawImage(image.source, sourceX, sourceY, sourceWidth, sourceHeight, 0, 0, destWidth, destHeight); - //绘制结果到屏幕 - drawCalls++; - // 应用滤镜 - var imageData = displayContext.getImageData(0, 0, destWidth, destHeight); - colorFilter(imageData.data, destWidth, destHeight, filter.$matrix); - displayContext.putImageData(imageData, 0, 0); - // 绘制结果的时候,应用滤镜 - context.drawImage(displayBuffer.surface, 0, 0, destWidth, destHeight, offsetX_1 + context.$offsetX, offsetY_1 + context.$offsetY, destWidth, destHeight); - renderBufferPool.push(displayBuffer); - } - else { - while (pos < length) { - drawCalls++; - if (node.rotated) { - var sourceX = data[pos++]; - var sourceY = data[pos++]; - var sourceHeight = data[pos++]; - var sourceWidth = data[pos++]; - var offsetX_2 = data[pos++]; - var offsetY_2 = data[pos++]; - var destHeight = data[pos++]; - var destWidth = data[pos++]; - context.save(); - context.transform(0, -1, 1, 0, 0, destWidth); - context.drawImage(image.source, sourceX, sourceY, sourceWidth, sourceHeight, offsetX_2 + context.$offsetX, offsetY_2 + context.$offsetY, destWidth, destHeight); - context.restore(); - } - else { - context.drawImage(image.source, data[pos++], data[pos++], data[pos++], data[pos++], data[pos++] + context.$offsetX, data[pos++] + context.$offsetY, data[pos++], data[pos++]); - } - } - } - if (saved) { - context.restore(); - } - else { - if (blendMode) { - context.globalCompositeOperation = defaultCompositeOp; - } - if (alpha == alpha) { - context.globalAlpha = originAlpha; - } - } - if (offsetX) { - context.$offsetX = offsetX; - } - if (offsetY) { - context.$offsetY = offsetY; - } - return drawCalls; - }; - CanvasRenderer.prototype.renderMesh = function (node, context) { - return 0; - }; - CanvasRenderer.prototype.renderText = function (node, context) { - context.textAlign = "left"; - context.textBaseline = "middle"; - context.lineJoin = "round"; //确保描边样式是圆角 - var drawData = node.drawData; - var length = drawData.length; - var pos = 0; - while (pos < length) { - var x = drawData[pos++]; - var y = drawData[pos++]; - var text = drawData[pos++]; - var format = drawData[pos++]; - context.font = getFontString(node, format); - var textColor = format.textColor == null ? node.textColor : format.textColor; - var strokeColor = format.strokeColor == null ? node.strokeColor : format.strokeColor; - var stroke = format.stroke == null ? node.stroke : format.stroke; - context.fillStyle = egret.toColorString(textColor); - context.strokeStyle = egret.toColorString(strokeColor); - if (stroke) { - context.lineWidth = stroke * 2; - context.strokeText(text, x + context.$offsetX, y + context.$offsetY); - } - context.fillText(text, x + context.$offsetX, y + context.$offsetY); - } - }; - /** - * @private - */ - CanvasRenderer.prototype.renderGraphics = function (node, context, forHitTest) { - var drawData = node.drawData; - var length = drawData.length; - forHitTest = !!forHitTest; - for (var i = 0; i < length; i++) { - var path = drawData[i]; - switch (path.type) { - case 1 /* Fill */: - var fillPath = path; - context.fillStyle = forHitTest ? BLACK_COLOR : getRGBAString(fillPath.fillColor, fillPath.fillAlpha); - this.renderPath(path, context); - if (this.renderingMask) { - context.clip(); - } - else { - context.fill(); - } - break; - case 2 /* GradientFill */: - var g = path; - context.fillStyle = forHitTest ? BLACK_COLOR : getGradient(context, g.gradientType, g.colors, g.alphas, g.ratios, g.matrix); - context.save(); - var m = g.matrix; - this.renderPath(path, context); - context.transform(m.a, m.b, m.c, m.d, m.tx, m.ty); - context.fill(); - context.restore(); - break; - case 3 /* Stroke */: - var strokeFill = path; - var lineWidth = strokeFill.lineWidth; - context.lineWidth = lineWidth; - context.strokeStyle = forHitTest ? BLACK_COLOR : getRGBAString(strokeFill.lineColor, strokeFill.lineAlpha); - context.lineCap = CAPS_STYLES[strokeFill.caps]; - context.lineJoin = strokeFill.joints; - context.miterLimit = strokeFill.miterLimit; - if (context.setLineDash) { - context.setLineDash(strokeFill.lineDash); - } - //对1像素和3像素特殊处理,向右下角偏移0.5像素,以显示清晰锐利的线条。 - var isSpecialCaseWidth = lineWidth === 1 || lineWidth === 3; - if (isSpecialCaseWidth) { - context.translate(0.5, 0.5); - } - this.renderPath(path, context); - context.stroke(); - if (isSpecialCaseWidth) { - context.translate(-0.5, -0.5); - } - break; - } - } - return length == 0 ? 0 : 1; - }; - CanvasRenderer.prototype.renderPath = function (path, context) { - context.beginPath(); - var data = path.$data; - var commands = path.$commands; - var commandCount = commands.length; - var pos = 0; - for (var commandIndex = 0; commandIndex < commandCount; commandIndex++) { - var command = commands[commandIndex]; - switch (command) { - case 4 /* CubicCurveTo */: - context.bezierCurveTo(data[pos++] + context.$offsetX, data[pos++] + context.$offsetY, data[pos++] + context.$offsetX, data[pos++] + context.$offsetY, data[pos++] + context.$offsetX, data[pos++] + context.$offsetY); - break; - case 3 /* CurveTo */: - context.quadraticCurveTo(data[pos++] + context.$offsetX, data[pos++] + context.$offsetY, data[pos++] + context.$offsetX, data[pos++] + context.$offsetY); - break; - case 2 /* LineTo */: - context.lineTo(data[pos++] + context.$offsetX, data[pos++] + context.$offsetY); - break; - case 1 /* MoveTo */: - context.moveTo(data[pos++] + context.$offsetX, data[pos++] + context.$offsetY); - break; - } - } - }; - CanvasRenderer.prototype.renderGroup = function (groupNode, context) { - var m = groupNode.matrix; - var saved = false; - var offsetX; - var offsetY; - if (m) { - context.save(); - saved = true; - if (context.$offsetX != 0 || context.$offsetY != 0) { - context.translate(context.$offsetX, context.$offsetY); - offsetX = context.$offsetX; - offsetY = context.$offsetY; - context.$offsetX = context.$offsetY = 0; - } - context.transform(m.a, m.b, m.c, m.d, m.tx, m.ty); - } - var drawCalls = 0; - var children = groupNode.drawData; - var length = children.length; - for (var i = 0; i < length; i++) { - var node = children[i]; - drawCalls += this.renderNode(node, context); - } - if (saved) { - context.restore(); - } - if (offsetX) { - context.$offsetX = offsetX; - } - if (offsetY) { - context.$offsetY = offsetY; - } - return drawCalls; - }; - CanvasRenderer.prototype.createRenderBuffer = function (width, height, useForFilters) { - var buffer = useForFilters ? renderBufferPool_Filters.pop() : renderBufferPool.pop(); - if (buffer) { - buffer.resize(width, height, true); - } - else { - buffer = new egret.sys.CanvasRenderBuffer(width, height); - } - return buffer; - }; - return CanvasRenderer; - }()); - egret.CanvasRenderer = CanvasRenderer; - __reflect(CanvasRenderer.prototype, "egret.CanvasRenderer"); - /** - * @private - * 获取字体字符串 - */ - function getFontString(node, format) { - var italic = format.italic == null ? node.italic : format.italic; - var bold = format.bold == null ? node.bold : format.bold; - var size = format.size == null ? node.size : format.size; - var fontFamily = format.fontFamily || node.fontFamily; - var font = italic ? "italic " : "normal "; - font += bold ? "bold " : "normal "; - font += size + "px " + fontFamily; - return font; - } - egret.getFontString = getFontString; - /** - * @private - * 获取RGBA字符串 - */ - function getRGBAString(color, alpha) { - var red = color >> 16; - var green = (color >> 8) & 0xFF; - var blue = color & 0xFF; - return "rgba(" + red + "," + green + "," + blue + "," + alpha + ")"; - } - egret.getRGBAString = getRGBAString; - /** - * @private - * 获取渐变填充样式对象 - */ - function getGradient(context, type, colors, alphas, ratios, matrix) { - var gradient; - if (type == egret.GradientType.LINEAR) { - gradient = context.createLinearGradient(-1, 0, 1, 0); - } - else { - gradient = context.createRadialGradient(0, 0, 0, 0, 0, 1); - } - //todo colors alphas ratios数量不一致情况处理 - var l = colors.length; - for (var i = 0; i < l; i++) { - gradient.addColorStop(ratios[i] / 255, getRGBAString(colors[i], alphas[i])); - } - return gradient; - } - // 判断浏览器是否支持 Uint8ClampedArray - var use8Clamp = false; - try { - use8Clamp = (typeof Uint8ClampedArray !== undefined); - } - catch (e) { } - function setArray(a, b, index) { - if (index === void 0) { index = 0; } - for (var i = 0, l = b.length; i < l; i++) { - a[i + index] = b[i]; - } - } - /** - * @private - */ - function colorFilter(buffer, w, h, matrix) { - var r0 = matrix[0], r1 = matrix[1], r2 = matrix[2], r3 = matrix[3], r4 = matrix[4]; - var g0 = matrix[5], g1 = matrix[6], g2 = matrix[7], g3 = matrix[8], g4 = matrix[9]; - var b0 = matrix[10], b1 = matrix[11], b2 = matrix[12], b3 = matrix[13], b4 = matrix[14]; - var a0 = matrix[15], a1 = matrix[16], a2 = matrix[17], a3 = matrix[18], a4 = matrix[19]; - for (var p = 0, e = w * h * 4; p < e; p += 4) { - var r = buffer[p + 0]; - var g = buffer[p + 1]; - var b = buffer[p + 2]; - var a = buffer[p + 3]; - buffer[p + 0] = r0 * r + r1 * g + r2 * b + r3 * a + r4; - buffer[p + 1] = g0 * r + g1 * g + g2 * b + g3 * a + g4; - buffer[p + 2] = b0 * r + b1 * g + b2 * b + b3 * a + b4; - buffer[p + 3] = a0 * r + a1 * g + a2 * b + a3 * a + a4; - } - } - /** - * @private - */ - function blurFilter(buffer, w, h, blurX, blurY) { - blurFilterH(buffer, w, h, blurX); - blurFilterV(buffer, w, h, blurY); - } - /** - * @private - */ - function blurFilterH(buffer, w, h, blurX) { - var lineBuffer; - if (use8Clamp) { - lineBuffer = new Uint8ClampedArray(w * 4); - } - else { - lineBuffer = new Array(w * 4); - } - var lineSize = w * 4; - var windowLength = (blurX * 2) + 1; - var windowSize = windowLength * 4; - for (var y = 0; y < h; y++) { - var pLineStart = y * lineSize; - var rs = 0, gs = 0, bs = 0, _as = 0, alpha = 0, alpha2 = 0; - // Fill window - for (var ptr = -blurX * 4, end = blurX * 4 + 4; ptr < end; ptr += 4) { - var key = pLineStart + ptr; - if (key < pLineStart || key >= pLineStart + lineSize) { - continue; - } - alpha = buffer[key + 3]; - rs += buffer[key + 0] * alpha; - gs += buffer[key + 1] * alpha; - bs += buffer[key + 2] * alpha; - _as += alpha; - } - // Slide window - for (var ptr = pLineStart, end = pLineStart + lineSize, linePtr = 0, lastPtr = ptr - blurX * 4, nextPtr = ptr + (blurX + 1) * 4; ptr < end; ptr += 4, linePtr += 4, nextPtr += 4, lastPtr += 4) { - if (_as === 0) { - lineBuffer[linePtr + 0] = 0; - lineBuffer[linePtr + 1] = 0; - lineBuffer[linePtr + 2] = 0; - lineBuffer[linePtr + 3] = 0; - } - else { - lineBuffer[linePtr + 0] = rs / _as; - lineBuffer[linePtr + 1] = gs / _as; - lineBuffer[linePtr + 2] = bs / _as; - lineBuffer[linePtr + 3] = _as / windowLength; - } - alpha = buffer[nextPtr + 3]; - alpha2 = buffer[lastPtr + 3]; - if (alpha || alpha == 0) { - if (alpha2 || alpha2 == 0) { - rs += buffer[nextPtr + 0] * alpha - buffer[lastPtr + 0] * alpha2; - gs += buffer[nextPtr + 1] * alpha - buffer[lastPtr + 1] * alpha2; - bs += buffer[nextPtr + 2] * alpha - buffer[lastPtr + 2] * alpha2; - _as += alpha - alpha2; - } - else { - rs += buffer[nextPtr + 0] * alpha; - gs += buffer[nextPtr + 1] * alpha; - bs += buffer[nextPtr + 2] * alpha; - _as += alpha; - } - } - else { - if (alpha2 || alpha2 == 0) { - rs += -buffer[lastPtr + 0] * alpha2; - gs += -buffer[lastPtr + 1] * alpha2; - bs += -buffer[lastPtr + 2] * alpha2; - _as += -alpha2; - } - else { - // do nothing - } - } - } - // Copy line - if (use8Clamp) { - buffer.set(lineBuffer, pLineStart); - } - else { - setArray(buffer, lineBuffer, pLineStart); - } - } - } - /** - * @private - */ - function blurFilterV(buffer, w, h, blurY) { - var columnBuffer; - if (use8Clamp) { - columnBuffer = new Uint8ClampedArray(h * 4); - } - else { - columnBuffer = new Array(h * 4); - } - var stride = w * 4; - var windowLength = (blurY * 2) + 1; - for (var x = 0; x < w; x++) { - var pColumnStart = x * 4; - var rs = 0, gs = 0, bs = 0, _as = 0, alpha = 0, alpha2 = 0; - // Fill window - for (var ptr = -blurY * stride, end = blurY * stride + stride; ptr < end; ptr += stride) { - var key = pColumnStart + ptr; - if (key < pColumnStart || key >= pColumnStart + h * stride) { - continue; - } - alpha = buffer[key + 3]; - rs += buffer[key + 0] * alpha; - gs += buffer[key + 1] * alpha; - bs += buffer[key + 2] * alpha; - _as += alpha; - } - // Slide window - for (var ptr = pColumnStart, end = pColumnStart + h * stride, columnPtr = 0, lastPtr = pColumnStart - blurY * stride, nextPtr = pColumnStart + ((blurY + 1) * stride); ptr < end; ptr += stride, columnPtr += 4, nextPtr += stride, lastPtr += stride) { - if (_as === 0) { - columnBuffer[columnPtr + 0] = 0; - columnBuffer[columnPtr + 1] = 0; - columnBuffer[columnPtr + 2] = 0; - columnBuffer[columnPtr + 3] = 0; - } - else { - columnBuffer[columnPtr + 0] = rs / _as; - columnBuffer[columnPtr + 1] = gs / _as; - columnBuffer[columnPtr + 2] = bs / _as; - columnBuffer[columnPtr + 3] = _as / windowLength; - } - alpha = buffer[nextPtr + 3]; - alpha2 = buffer[lastPtr + 3]; - if (alpha || alpha == 0) { - if (alpha2 || alpha2 == 0) { - rs += buffer[nextPtr + 0] * alpha - buffer[lastPtr + 0] * alpha2; - gs += buffer[nextPtr + 1] * alpha - buffer[lastPtr + 1] * alpha2; - bs += buffer[nextPtr + 2] * alpha - buffer[lastPtr + 2] * alpha2; - _as += alpha - alpha2; - } - else { - rs += buffer[nextPtr + 0] * alpha; - gs += buffer[nextPtr + 1] * alpha; - bs += buffer[nextPtr + 2] * alpha; - _as += alpha; - } - } - else { - if (alpha2 || alpha2 == 0) { - rs += -buffer[lastPtr + 0] * alpha2; - gs += -buffer[lastPtr + 1] * alpha2; - bs += -buffer[lastPtr + 2] * alpha2; - _as += -alpha2; - } - else { - // do nothing - } - } - } - // Copy column - for (var i = x * 4, end = i + h * stride, j = 0; i < end; i += stride, j += 4) { - buffer[i + 0] = columnBuffer[j + 0]; - buffer[i + 1] = columnBuffer[j + 1]; - buffer[i + 2] = columnBuffer[j + 2]; - buffer[i + 3] = columnBuffer[j + 3]; - } - } - } - // function glowFilter(buffer, w, h, color, blurX, blurY, strength) { - // dropShadowFilter(buffer, w, h, color, blurX, blurY, 0, 0, strength) - // } - function dropShadowFilter(buffer, w, h, color, blurX, blurY, angle, distance, strength) { - var tmp = alphaFilter(buffer, color); - panFilter(tmp, w, h, angle, distance); - blurFilter(tmp, w, h, blurX, blurY); - scaleAlphaChannel(tmp, strength); - compositeSourceOver(tmp, buffer); - buffer.set(tmp); - if (use8Clamp) { - buffer.set(tmp); - } - else { - setArray(buffer, tmp); - } - } - function alphaFilter(buffer, color) { - if (!color) { - color = [0, 0, 0, 0]; - } - var plane; - if (use8Clamp) { - plane = new Uint8ClampedArray(buffer); - } - else { - plane = new Array(buffer.length); - setArray(plane, buffer); - } - var colorR = color[0]; - var colorG = color[1]; - var colorB = color[2]; - var colorA = color[3]; - for (var ptr = 0, end = plane.length; ptr < end; ptr += 4) { - var alpha = plane[ptr + 3]; - plane[ptr + 0] = colorR * alpha; - plane[ptr + 1] = colorG * alpha; - plane[ptr + 2] = colorB * alpha; - plane[ptr + 3] = colorA * alpha; - } - return plane; - } - function panFilter(buffer, w, h, angle, distance) { - var dy = (Math.sin(angle) * distance) | 0; - var dx = (Math.cos(angle) * distance) | 0; - var oldBuffer, newBuffer; - if (use8Clamp) { - oldBuffer = new Int32Array(buffer.buffer); - newBuffer = new Int32Array(oldBuffer.length); - for (var oy = 0; oy < h; oy++) { - var ny = oy + dy; - if (ny < 0 || ny > h) { - continue; - } - for (var ox = 0; ox < w; ox++) { - var nx = ox + dx; - if (nx < 0 || nx > w) { - continue; - } - newBuffer[ny * w + nx] = oldBuffer[oy * w + ox]; - } - } - oldBuffer.set(newBuffer); - } - else { - oldBuffer = buffer; - newBuffer = new Array(oldBuffer.length); - for (var oy = 0; oy < h; oy++) { - var ny = oy + dy; - if (ny < 0 || ny > h) { - continue; - } - for (var ox = 0; ox < w; ox++) { - var nx = ox + dx; - if (nx < 0 || nx > w) { - continue; - } - newBuffer[(ny * w + nx) * 4 + 0] = oldBuffer[(oy * w + ox) * 4 + 0]; - newBuffer[(ny * w + nx) * 4 + 1] = oldBuffer[(oy * w + ox) * 4 + 1]; - newBuffer[(ny * w + nx) * 4 + 2] = oldBuffer[(oy * w + ox) * 4 + 2]; - newBuffer[(ny * w + nx) * 4 + 3] = oldBuffer[(oy * w + ox) * 4 + 3]; - } - } - setArray(oldBuffer, newBuffer); - } - } - function scaleAlphaChannel(buffer, value) { - for (var ptr = 0, end = buffer.length; ptr < end; ptr += 4) { - buffer[ptr + 3] *= value; - } - } - function compositeSourceOver(dst, src) { - for (var ptr = 0, end = dst.length; ptr < end; ptr += 4) { - var Dr = dst[ptr + 0]; - var Dg = dst[ptr + 1]; - var Db = dst[ptr + 2]; - var Da = dst[ptr + 3] / 255; - var Sr = src[ptr + 0]; - var Sg = src[ptr + 1]; - var Sb = src[ptr + 2]; - var Sa = src[ptr + 3] / 255; - dst[ptr + 0] = Sr + Dr * (1 - Sa); - dst[ptr + 1] = Sg + Dg * (1 - Sa); - dst[ptr + 2] = Sb + Db * (1 - Sa); - dst[ptr + 3] = (Sa + Da * (1 - Sa)) * 255; - } - } - function getPixelKey(w, x, y) { - return y * w * 4 + x * 4; - } - function mix(v1, v2, rate) { - return v1 * (1 - rate) + v2 * rate; - } - // dropShadowFilter2 - // 模拟shader中的算法,可以实现内发光,挖空等高级效果 - function dropShadowFilter2(buffer, w, h, color, blurX, blurY, angle, distance, strength, inner, knockout, hideObject) { - var plane; - if (use8Clamp) { - plane = new Uint8ClampedArray(buffer.length); - } - else { - plane = new Array(buffer.length); - } - var alpha = color[3]; - var curDistanceX = 0; - var curDistanceY = 0; - var offsetX = distance * Math.cos(angle); - var offsetY = distance * Math.sin(angle); - var linearSamplingTimes = 7.0; - var circleSamplingTimes = 12.0; - var PI = 3.14159265358979323846264; - var cosAngle; - var sinAngle; - var stepX = blurX / linearSamplingTimes; - var stepY = blurY / linearSamplingTimes; - // 遍历像素 - for (var u = 0; u < w; u++) { - for (var v = 0; v < h; v++) { - // 此处为了避免毛刺可以添加一个随机值 - var offset = 0; - // 处理单个像素 - var key = v * w * 4 + u * 4; - var totalAlpha = 0; - var maxTotalAlpha = 0; - // 采样出来的色值 - var _r = buffer[key + 0] / 255; - var _g = buffer[key + 1] / 255; - var _b = buffer[key + 2] / 255; - var _a = buffer[key + 3] / 255; - for (var a = 0; a <= PI * 2; a += PI * 2 / circleSamplingTimes) { - cosAngle = Math.cos(a + offset); - sinAngle = Math.sin(a + offset); - for (var i = 0; i < linearSamplingTimes; i++) { - curDistanceX = i * stepX * cosAngle; - curDistanceY = i * stepY * sinAngle; - var _u = Math.round(u + curDistanceX - offsetX); - var _v = Math.round(v + curDistanceY - offsetY); - var __a = 0; - if (_u >= w || _u < 0 || _v < 0 || _v >= h) { - __a = 0; - } - else { - var _key = _v * w * 4 + _u * 4; - __a = buffer[_key + 3] / 255; - } - totalAlpha += (linearSamplingTimes - i) * __a; - maxTotalAlpha += (linearSamplingTimes - i); - } - } - _a = Math.max(_a, 0.0001); - // 'ownColor.rgb = ownColor.rgb / ownColor.a;', - var outerGlowAlpha = (totalAlpha / maxTotalAlpha) * strength * alpha * (1. - inner) * Math.max(Math.min(hideObject, knockout), 1. - _a); - var innerGlowAlpha = ((maxTotalAlpha - totalAlpha) / maxTotalAlpha) * strength * alpha * inner * _a; - _a = Math.max(_a * knockout * (1 - hideObject), 0.0001); - var rate1 = innerGlowAlpha / (innerGlowAlpha + _a); - var r1 = mix(_r, color[0], rate1); - var g1 = mix(_g, color[1], rate1); - var b1 = mix(_b, color[2], rate1); - var rate2 = outerGlowAlpha / (innerGlowAlpha + _a + outerGlowAlpha); - var r2 = mix(r1, color[0], rate2); - var g2 = mix(g1, color[1], rate2); - var b2 = mix(b1, color[2], rate2); - var resultAlpha = Math.min(_a + outerGlowAlpha + innerGlowAlpha, 1); - // 赋值颜色 - plane[key + 0] = r2 * 255; - plane[key + 1] = g2 * 255; - plane[key + 2] = b2 * 255; - plane[key + 3] = resultAlpha * 255; - } - } - if (use8Clamp) { - buffer.set(plane); - } - else { - setArray(buffer, plane); - } - } -})(egret || (egret = {})); -var egret; -(function (egret) { - /** - * @copy egret.Orientation - */ - egret.DeviceOrientation = null; -})(egret || (egret = {})); -var egret; -(function (egret) { -})(egret || (egret = {})); -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Type of operation. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 运行类型的类型。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var RuntimeType; - (function (RuntimeType) { - /** - * Running on Web - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 运行在Web上 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - RuntimeType.WEB = "web"; - /** - * Running on NATIVE - * @version Egret 2.4 - * @deprecated - * @platform Web,Native - * @language en_US - */ - /** - * 运行在NATIVE上 - * @version Egret 2.4 - * @deprecated - * @platform Web,Native - * @language zh_CN - */ - RuntimeType.NATIVE = "native"; - /** - * Running on Runtime2.0 - * @version Egret 5.1.5 - * @platform Web,Native - * @language en_US - */ - /** - * 运行在Runtime2.0上 - * @version Egret 5.1.5 - * @platform Web,Native - * @language zh_CN - */ - RuntimeType.RUNTIME2 = "runtime2"; - /** - * Running on WeChat mini game - * @version Egret 5.1.5 - * @platform All - * @language en_US - */ - /** - * 运行在微信小游戏上 - * @version Egret 5.1.5 - * @platform All - * @language zh_CN - */ - RuntimeType.WXGAME = "wxgame"; - })(RuntimeType = egret.RuntimeType || (egret.RuntimeType = {})); - /** - * The Capabilities class provides properties that describe the system and runtime that are hosting the application. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/system/Capabilities.ts - * @language en_US - */ - /** - * Capabilities 类提供一些属性,这些属性描述了承载应用程序的系统和运行时。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/system/Capabilities.ts - * @language zh_CN - */ - var Capabilities = (function () { - function Capabilities() { - } - /** - * Specifies the language code of the system on which the content is running. The language is specified as a lowercase - * two-letter language code from ISO 639-1. For Chinese, an additional uppercase two-letter country code from ISO 3166 - * distinguishes between Simplified and Traditional Chinese.
    - * The following table lists the possible values,but not limited to them: - *
      - *
    • Simplified Chinese zh-CN
    • - *
    • Traditional Chinese zh-TW
    • - *
    • English en
    • - *
    • Japanese ja
    • - *
    • Korean ko
    • - *
    - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示运行内容的系统的语言代码。语言指定为 ISO 639-1 中的小写双字母语言代码。 - * 对于中文,另外使用 ISO 3166 中的大写双字母国家/地区代码,以区分简体中文和繁体中文。
    - * 以下是可能但不限于的语言和值: - *
      - *
    • 简体中文 zh-CN
    • - *
    • 繁体中文 zh-TW
    • - *
    • 英语 en
    • - *
    • 日语 ja
    • - *
    • 韩语 ko
    • - *
    - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Capabilities.language = "zh-CN"; - /** - * Specifies the current operating system. The os property can return the following strings: - *
      - *
    • iPhone "iOS"
    • - *
    • Android Phone "Android"
    • - *
    • Windows Phone "Windows Phone"
    • - *
    • Windows Desktop "Windows PC"
    • - *
    • Mac Desktop "Mac OS"
    • - *
    • Unknown OS "Unknown"
    • - *
    - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指示当前的操作系统。os 属性返回下列字符串: - *
      - *
    • 苹果手机操作系统 "iOS"
    • - *
    • 安卓手机操作系统 "Android"
    • - *
    • 微软手机操作系统 "Windows Phone"
    • - *
    • 微软桌面操作系统 "Windows PC"
    • - *
    • 苹果桌面操作系统 "Mac OS"
    • - *
    • 未知操作系统 "Unknown"
    • - *
    - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Capabilities.os = "Unknown"; - /** - * It indicates the current type of operation. runtimeType property returns the following string: - *
      - *
    • Run on Web egret.RuntimeType.WEB
    • - *
    • Run on Runtime2.0 egret.RuntimeType.RUNTIME2
    • - *
    • Run on WeChat mini game egret.RuntimeType.WXGAME
    • - *
    - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指示当前的运行类型。runtimeType 属性返回下列字符串: - *
      - *
    • 运行在Web上 egret.RuntimeType.WEB
    • - *
    • 运行在Runtime2.0上 egret.RuntimeType.RUNTIME2
    • - *
    • 运行在微信小游戏上 egret.RuntimeType.WXGAME
    • - *
    - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Capabilities.runtimeType = egret.RuntimeType.WEB; - /*** - * version of Egret. - * @type {string} - * @version Egret 3.2.0 - * @platform Web,Native - * @language en_US - */ - /*** - * Egret 的版本号。 - * @type {string} - * @version Egret 3.2.0 - * @platform Web,Native - * @language zh_CN - */ - Capabilities.engineVersion = "5.2.5"; - /*** - * current render mode. - * @type {string} - * @version Egret 3.0.7 - * @platform Web,Native - * @language en_US - */ - /*** - * 当前渲染模式。 - * @type {string} - * @version Egret 3.0.7 - * @platform Web,Native - * @language zh_CN - */ - Capabilities.renderMode = "Unknown"; - /*** - * Clients border width. - * The value before the document class initialization is always 0. - * This value will change after the distribution Event.RESIZE and StageOrientationEvent.ORIENTATION_CHANGE. - * @version Egret 3.1.3 - * @platform Web,Native - * @language en_US - */ - /*** - * 客户端边界宽度。 - * 该值在文档类初始化之前始终是0。 - * 该值在派发 Event.RESIZE 以及 StageOrientationEvent.ORIENTATION_CHANGE 之后会发生改变。 - * @version Egret 3.1.3 - * @platform Web,Native - * @language zh_CN - */ - Capabilities.boundingClientWidth = 0; - /*** - * Clients border height. - * The value before the document class initialization is always 0. - * This value will change after the distribution Event.RESIZE and StageOrientationEvent.ORIENTATION_CHANGE. - * @version Egret 3.1.3 - * @platform Web,Native - * @language en_US - */ - /*** - * 客户端边界高度。 - * 该值在文档类初始化之前始终是0。 - * 该值在派发 Event.RESIZE 以及 StageOrientationEvent.ORIENTATION_CHANGE 之后会发生改变。 - * @version Egret 3.1.3 - * @platform Web,Native - * @language zh_CN - */ - Capabilities.boundingClientHeight = 0; - return Capabilities; - }()); - egret.Capabilities = Capabilities; - __reflect(Capabilities.prototype, "egret.Capabilities"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * This class is used to create lightweight shapes using the drawing application program interface (API). The Shape - * class includes a graphics property, which lets you access methods from the Graphics class. - * @see egret.Graphics - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Shape.ts - * @language en_US - */ - /** - * 此类用于使用绘图应用程序编程接口 (API) 创建简单形状。Shape 类含有 graphics 属性,通过该属性您可以访问各种矢量绘图方法。 - * @see egret.Graphics - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Shape.ts - * @language zh_CN - */ - var Shape = (function (_super) { - __extends(Shape, _super); - /** - * Creates a new Shape object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Shape 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Shape() { - var _this = _super.call(this) || this; - _this.$graphics = new egret.Graphics(); - _this.$graphics.$setTarget(_this); - return _this; - } - Shape.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(8 /* GRAPHICS */); - }; - Object.defineProperty(Shape.prototype, "graphics", { - /** - * Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取 Shape 中的 Graphics 对象。可通过此对象执行矢量绘图命令。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$graphics; - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - Shape.prototype.$measureContentBounds = function (bounds) { - this.$graphics.$measureContentBounds(bounds); - }; - Shape.prototype.$hitTest = function (stageX, stageY) { - var target = _super.prototype.$hitTest.call(this, stageX, stageY); - if (target == this) { - target = this.$graphics.$hitTest(stageX, stageY); - } - return target; - }; - /** - * @private - */ - Shape.prototype.$onRemoveFromStage = function () { - _super.prototype.$onRemoveFromStage.call(this); - if (this.$graphics) { - this.$graphics.$onRemoveFromStage(); - } - }; - return Shape; - }(egret.DisplayObject)); - egret.Shape = Shape; - __reflect(Shape.prototype, "egret.Shape"); -})(egret || (egret = {})); -var egret; -(function (egret) { - /** - * @private - */ - var implMap = {}; - /** - * Adds an interface-name-to-implementation-class mapping to the registry. - * @param interfaceName the interface name to register. For example:"eui.IAssetAdapter","eui.Theme" - * @param instance the instance to register. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 注册一个接口实现。 - * @param interfaceName 注入的接口名称。例如:"eui.IAssetAdapter","eui.Theme" - * @param instance 实现此接口的实例。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - function registerImplementation(interfaceName, instance) { - implMap[interfaceName] = instance; - } - egret.registerImplementation = registerImplementation; - /** - * Returns the singleton instance of the implementation class that was registered for the specified interface. - * This method is usually called by egret framework. - * @param interfaceName The interface name to identify. For example:"eui.IAssetAdapter","eui.Theme" - * @returns the singleton instance of the implementation class - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 获取一个接口实现。此方法通常由框架内部调用。获取项目注入的自定义实现实例。 - * @param interfaceName 要获取的接口名称。例如:"eui.IAssetAdapter","eui.Theme" - * @returns 返回实现此接口的实例。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - function getImplementation(interfaceName) { - return implMap[interfaceName]; - } - egret.getImplementation = getImplementation; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The Sprite class is a basic display list building block: a display list node that can contain children. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Sprite.ts - * @language en_US - */ - /** - * Sprite 类是基本显示列表构造块:一个可包含子项的显示列表节点。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Sprite.ts - * @language zh_CN - */ - var Sprite = (function (_super) { - __extends(Sprite, _super); - /** - * Creates a new Sprite instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 实例化一个容器 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Sprite() { - var _this = _super.call(this) || this; - _this.$graphics = new egret.Graphics(); - _this.$graphics.$setTarget(_this); - return _this; - } - Sprite.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(9 /* SPRITE */); - }; - Object.defineProperty(Sprite.prototype, "graphics", { - /** - * Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取 Shape 中的 Graphics 对象。可通过此对象执行矢量绘图命令。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$graphics; - }, - enumerable: true, - configurable: true - }); - Sprite.prototype.$hitTest = function (stageX, stageY) { - if (!this.$visible) { - return null; - } - var m = this.$getInvertedConcatenatedMatrix(); - var localX = m.a * stageX + m.c * stageY + m.tx; - var localY = m.b * stageX + m.d * stageY + m.ty; - var rect = this.$scrollRect ? this.$scrollRect : this.$maskRect; - if (rect && !rect.contains(localX, localY)) { - return null; - } - if (this.$mask && !this.$mask.$hitTest(stageX, stageY)) { - return null; - } - var children = this.$children; - var found = false; - var target = null; - for (var i = children.length - 1; i >= 0; i--) { - var child = children[i]; - if (child.$maskedObject) { - continue; - } - target = child.$hitTest(stageX, stageY); - if (target) { - found = true; - if (target.$touchEnabled) { - break; - } - else { - target = null; - } - } - } - if (target) { - if (this.$touchChildren) { - return target; - } - return this; - } - if (found) { - return this; - } - target = egret.DisplayObject.prototype.$hitTest.call(this, stageX, stageY); - if (target) { - target = this.$graphics.$hitTest(stageX, stageY); - } - return target; - }; - /** - * @private - */ - Sprite.prototype.$measureContentBounds = function (bounds) { - this.$graphics.$measureContentBounds(bounds); - }; - /** - * @private - */ - Sprite.prototype.$onRemoveFromStage = function () { - _super.prototype.$onRemoveFromStage.call(this); - if (this.$graphics) { - this.$graphics.$onRemoveFromStage(); - } - }; - return Sprite; - }(egret.DisplayObjectContainer)); - egret.Sprite = Sprite; - __reflect(Sprite.prototype, "egret.Sprite"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Bitmap font, texture set of a font. It is generally used as the value of the BitmapText.font attribute. - * @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger - * @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 Text(Containing the specific usage of the bitmap font ) - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapFont.ts - * @language en_US - */ - /** - * 位图字体,是一个字体的纹理集,通常作为BitmapText.font属性的值。 - * @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger - * @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 文本(含位图字体具体用法) - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapFont.ts - * @language zh_CN - */ - var BitmapFont = (function (_super) { - __extends(BitmapFont, _super); - /** - * Create an egret.BitmapFont object - * @param texture {egret.Texture} Texture set that use TextureMerger create - * @param config {any} Configure data that use TextureMerger create - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.BitmapFont 对象 - * @param texture {egret.Texture} 使用TextureMerger生成的纹理集 - * @param config {any} 使用TextureMerger生成的配置数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function BitmapFont(texture, config) { - var _this = _super.call(this, texture) || this; - /** - * @private - */ - _this.firstCharHeight = 0; - if (typeof (config) == "string") { - _this.charList = _this.parseConfig(config); - } - else if (config && config.hasOwnProperty("frames")) { - _this.charList = config.frames; - } - else { - _this.charList = {}; - } - return _this; - } - /** - * Obtain corresponding texture through the name attribute - * @param name {string} name Attribute - * @returns {egret.Texture} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 通过 name 属性获取对应纹理 - * @param name {string} name属性 - * @returns {egret.Texture} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - BitmapFont.prototype.getTexture = function (name) { - var texture = this._textureMap[name]; - if (!texture) { - var c = this.charList[name]; - if (!c) { - return null; - } - texture = this.createTexture(name, c.x, c.y, c.w, c.h, c.offX, c.offY, c.sourceW, c.sourceH); - this._textureMap[name] = texture; - } - return texture; - }; - /** - * @private - */ - BitmapFont.prototype.getConfig = function (name, key) { - if (!this.charList[name]) { - return 0; - } - return this.charList[name][key]; - }; - /** - * @private - * - * @returns - */ - BitmapFont.prototype._getFirstCharHeight = function () { - if (this.firstCharHeight == 0) { - for (var str in this.charList) { - var c = this.charList[str]; - if (c) { - var sourceH = c.sourceH; - if (sourceH === undefined) { - var h = c.h; - if (h === undefined) { - h = 0; - } - var offY = c.offY; - if (offY === undefined) { - offY = 0; - } - sourceH = h + offY; - } - if (sourceH <= 0) { - continue; - } - this.firstCharHeight = sourceH; - break; - } - } - } - return this.firstCharHeight; - }; - /** - * @private - * - * @param fntText - * @returns - */ - BitmapFont.prototype.parseConfig = function (fntText) { - fntText = fntText.split("\r\n").join("\n"); - var lines = fntText.split("\n"); - var charsCount = this.getConfigByKey(lines[3], "count"); - var chars = {}; - for (var i = 4; i < 4 + charsCount; i++) { - var charText = lines[i]; - var letter = String.fromCharCode(this.getConfigByKey(charText, "id")); - var c = {}; - chars[letter] = c; - c["x"] = this.getConfigByKey(charText, "x"); - c["y"] = this.getConfigByKey(charText, "y"); - c["w"] = this.getConfigByKey(charText, "width"); - c["h"] = this.getConfigByKey(charText, "height"); - c["offX"] = this.getConfigByKey(charText, "xoffset"); - c["offY"] = this.getConfigByKey(charText, "yoffset"); - c["xadvance"] = this.getConfigByKey(charText, "xadvance"); - } - return chars; - }; - /** - * @private - * - * @param configText - * @param key - * @returns - */ - BitmapFont.prototype.getConfigByKey = function (configText, key) { - var itemConfigTextList = configText.split(" "); - for (var i = 0, length_6 = itemConfigTextList.length; i < length_6; i++) { - var itemConfigText = itemConfigTextList[i]; - if (key == itemConfigText.substring(0, key.length)) { - var value = itemConfigText.substring(key.length + 1); - return parseInt(value); - } - } - return 0; - }; - return BitmapFont; - }(egret.SpriteSheet)); - egret.BitmapFont = BitmapFont; - __reflect(BitmapFont.prototype, "egret.BitmapFont"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Bitmap font adopts the Bitmap+SpriteSheet mode to render text. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapText.ts - * @language en_US - */ - /** - * 位图字体采用了Bitmap+SpriteSheet的方式来渲染文字。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapText.ts - * @language zh_CN - */ - var BitmapText = (function (_super) { - __extends(BitmapText, _super); - /** - * Create an egret.BitmapText object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.BitmapText 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function BitmapText() { - var _this = _super.call(this) || this; - _this.$smoothing = egret.Bitmap.defaultSmoothing; - _this.$text = ""; - _this.$textFieldWidth = NaN; - _this.$textLinesChanged = false; - _this.$textFieldHeight = NaN; - _this.$font = null; - _this.$fontStringChanged = false; - _this.$lineSpacing = 0; - _this.$letterSpacing = 0; - _this.$textAlign = egret.HorizontalAlign.LEFT; - _this.$verticalAlign = egret.VerticalAlign.TOP; - _this.$textWidth = NaN; - _this.$textHeight = NaN; - /** - * @private - */ - _this.$textOffsetX = 0; - /** - * @private - */ - _this.$textOffsetY = 0; - /** - * @private - */ - _this.$textStartX = 0; - /** - * @private - */ - _this.$textStartY = 0; - /** - * @private - */ - _this.textLines = []; - /** - * @private - */ - _this.$lineHeights = []; - if (!egret.nativeRender) { - _this.$renderNode = new egret.sys.BitmapNode(); - } - return _this; - } - BitmapText.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(11 /* BITMAP_TEXT */); - }; - Object.defineProperty(BitmapText.prototype, "smoothing", { - /** - * Whether or not is smoothed when scaled. - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否进行平滑处理。 - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$smoothing; - }, - set: function (value) { - var self = this; - if (value == self.$smoothing) { - return; - } - self.$smoothing = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(BitmapText.prototype, "text", { - /** - * A string to display in the text field. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要显示的文本内容 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$text; - }, - set: function (value) { - this.$setText(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - BitmapText.prototype.$setText = function (value) { - if (value == null) { - value = ""; - } - else { - value = String(value); - } - var self = this; - if (value == self.$text) - return false; - self.$text = value; - self.$invalidateContentBounds(); - return true; - }; - /** - * @private - */ - BitmapText.prototype.$getWidth = function () { - var self = this; - var w = self.$textFieldWidth; - return isNaN(w) ? self.$getContentBounds().width : w; - }; - /** - * @private - */ - BitmapText.prototype.$setWidth = function (value) { - var self = this; - if (value < 0 || value == self.$textFieldWidth) { - return false; - } - self.$textFieldWidth = value; - self.$invalidateContentBounds(); - return true; - }; - /** - * @private - */ - BitmapText.prototype.$invalidateContentBounds = function () { - this.$renderDirty = true; - this.$textLinesChanged = true; - //todo lcj - this.$updateRenderNode(); - }; - /** - * @private - */ - BitmapText.prototype.$getHeight = function () { - var self = this; - var h = self.$textFieldHeight; - return isNaN(h) ? self.$getContentBounds().height : h; - }; - /** - * @private - */ - BitmapText.prototype.$setHeight = function (value) { - var self = this; - if (value < 0 || value == self.$textFieldHeight) { - return false; - } - self.$textFieldHeight = value; - self.$invalidateContentBounds(); - return true; - }; - Object.defineProperty(BitmapText.prototype, "font", { - /** - * The name of the font to use, or a comma-separated list of font names, the type of value must be BitmapFont. - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要使用的字体的名称或用逗号分隔的字体名称列表,类型必须是 BitmapFont。 - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$font; - }, - set: function (value) { - this.$setFont(value); - }, - enumerable: true, - configurable: true - }); - BitmapText.prototype.$setFont = function (value) { - var self = this; - if (self.$font == value) { - return false; - } - self.$font = value; - self.$fontStringChanged = true; - this.$invalidateContentBounds(); - return true; - }; - Object.defineProperty(BitmapText.prototype, "lineSpacing", { - /** - /** - * An integer representing the amount of vertical space between lines. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个整数,表示行与行之间的垂直间距量 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$lineSpacing; - }, - set: function (value) { - this.$setLineSpacing(value); - }, - enumerable: true, - configurable: true - }); - BitmapText.prototype.$setLineSpacing = function (value) { - var self = this; - if (self.$lineSpacing == value) - return false; - self.$lineSpacing = value; - self.$invalidateContentBounds(); - return true; - }; - Object.defineProperty(BitmapText.prototype, "letterSpacing", { - /** - * An integer representing the amount of distance between characters. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个整数,表示字符之间的距离。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$letterSpacing; - }, - set: function (value) { - this.$setLetterSpacing(value); - }, - enumerable: true, - configurable: true - }); - BitmapText.prototype.$setLetterSpacing = function (value) { - var self = this; - if (self.$letterSpacing == value) { - return false; - } - self.$letterSpacing = value; - self.$invalidateContentBounds(); - return true; - }; - Object.defineProperty(BitmapText.prototype, "textAlign", { - /** - * Horizontal alignment of text. - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.5.6 - * @platform Web,Native - * @language en_US - */ - /** - * 文本的水平对齐方式。 - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.5.6 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$textAlign; - }, - set: function (value) { - this.$setTextAlign(value); - }, - enumerable: true, - configurable: true - }); - BitmapText.prototype.$setTextAlign = function (value) { - var self = this; - if (self.$textAlign == value) { - return false; - } - self.$textAlign = value; - self.$invalidateContentBounds(); - return true; - }; - Object.defineProperty(BitmapText.prototype, "verticalAlign", { - /** - * Vertical alignment of text. - * @default:egret.VerticalAlign.TOP - * @version Egret 2.5.6 - * @platform Web,Native - * @language en_US - */ - /** - * 文字的垂直对齐方式。 - * @default:egret.VerticalAlign.TOP - * @version Egret 2.5.6 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$verticalAlign; - }, - set: function (value) { - this.$setVerticalAlign(value); - }, - enumerable: true, - configurable: true - }); - BitmapText.prototype.$setVerticalAlign = function (value) { - var self = this; - if (self.$verticalAlign == value) { - return false; - } - self.$verticalAlign = value; - self.$invalidateContentBounds(); - return true; - }; - /** - * @private - */ - BitmapText.prototype.$updateRenderNode = function () { - var self = this; - var textLines = this.$getTextLines(); - var length = textLines.length; - if (length == 0) { - return; - } - var drawArr = []; - var textLinesWidth = this.$textLinesWidth; - var bitmapFont = self.$font; - var node; - if (!egret.nativeRender) { - node = this.$renderNode; - if (bitmapFont.$texture) { - node.image = bitmapFont.$texture.$bitmapData; - } - node.smoothing = self.$smoothing; - } - var emptyHeight = bitmapFont._getFirstCharHeight(); - var emptyWidth = Math.ceil(emptyHeight * BitmapText.EMPTY_FACTOR); - var hasSetHeight = !isNaN(self.$textFieldHeight); - var textWidth = self.$textWidth; - var textFieldWidth = self.$textFieldWidth; - var textFieldHeight = self.$textFieldHeight; - var align = self.$textAlign; - var yPos = this.$textOffsetY + this.$textStartY; - var lineHeights = this.$lineHeights; - for (var i = 0; i < length; i++) { - var lineHeight = lineHeights[i]; - if (hasSetHeight && i > 0 && yPos + lineHeight > textFieldHeight) { - break; - } - var line = textLines[i]; - var len = line.length; - var xPos = this.$textOffsetX; - if (align != egret.HorizontalAlign.LEFT) { - var countWidth = textFieldWidth > textWidth ? textFieldWidth : textWidth; - if (align == egret.HorizontalAlign.RIGHT) { - xPos += countWidth - textLinesWidth[i]; - } - else if (align == egret.HorizontalAlign.CENTER) { - xPos += Math.floor((countWidth - textLinesWidth[i]) / 2); - } - } - for (var j = 0; j < len; j++) { - var character = line.charAt(j); - var texture = bitmapFont.getTexture(character); - if (!texture) { - if (character == " ") { - xPos += emptyWidth; - } - else { - egret.$warn(1046, character); - } - continue; - } - var bitmapWidth = texture.$bitmapWidth; - var bitmapHeight = texture.$bitmapHeight; - if (egret.nativeRender) { - drawArr.push(texture.$bitmapX, texture.$bitmapY, bitmapWidth, bitmapHeight, xPos + texture.$offsetX, yPos + texture.$offsetY, texture.$getScaleBitmapWidth(), texture.$getScaleBitmapHeight(), texture.$sourceWidth, texture.$sourceHeight); - } - else { - node.imageWidth = texture.$sourceWidth; - node.imageHeight = texture.$sourceHeight; - node.drawImage(texture.$bitmapX, texture.$bitmapY, bitmapWidth, bitmapHeight, xPos + texture.$offsetX, yPos + texture.$offsetY, texture.$getScaleBitmapWidth(), texture.$getScaleBitmapHeight()); - } - xPos += (bitmapFont.getConfig(character, "xadvance") || texture.$getTextureWidth()) + self.$letterSpacing; - } - yPos += lineHeight + self.$lineSpacing; - } - if (egret.nativeRender) { - self.$nativeDisplayObject.setDataToBitmapNode(self.$nativeDisplayObject.id, bitmapFont.$texture, drawArr); - var bounds = self.$getContentBounds(); - self.$nativeDisplayObject.setWidth(bounds.width); - self.$nativeDisplayObject.setHeight(bounds.height); - } - }; - /** - * @private - */ - BitmapText.prototype.$measureContentBounds = function (bounds) { - var lines = this.$getTextLines(); - if (lines.length == 0) { - bounds.setEmpty(); - } - else { - bounds.setTo(this.$textOffsetX + this.$textStartX, this.$textOffsetY + this.$textStartY, this.$textWidth - this.$textOffsetX, this.$textHeight - this.$textOffsetY); - } - }; - Object.defineProperty(BitmapText.prototype, "textWidth", { - /** - * Get the BitmapText measured width - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位图文本测量宽度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - this.$getTextLines(); - return this.$textWidth; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(BitmapText.prototype, "textHeight", { - /** - * Get Text BitmapText height - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位图文本测量高度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - this.$getTextLines(); - return this.$textHeight; - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @returns - */ - BitmapText.prototype.$getTextLines = function () { - var self = this; - if (!self.$textLinesChanged) { - return self.textLines; - } - var textLines = []; - self.textLines = textLines; - var textLinesWidth = []; - self.$textLinesWidth = textLinesWidth; - self.$textLinesChanged = false; - var lineHeights = []; - self.$lineHeights = lineHeights; - if (!self.$text || !self.$font) { - self.$textWidth = 0; - self.$textHeight = 0; - return textLines; - } - var lineSpacing = self.$lineSpacing; - var letterSpacing = self.$letterSpacing; - var textWidth = 0; - var textHeight = 0; - var textOffsetX = 0; - var textOffsetY = 0; - var hasWidthSet = !isNaN(self.$textFieldWidth); - var textFieldWidth = self.$textFieldWidth; - var textFieldHeight = self.$textFieldHeight; - var bitmapFont = self.$font; - var emptyHeight = bitmapFont._getFirstCharHeight(); - var emptyWidth = Math.ceil(emptyHeight * BitmapText.EMPTY_FACTOR); - var text = self.$text; - var textArr = text.split(/(?:\r\n|\r|\n)/); - var length = textArr.length; - var isFirstLine = true; - var isFirstChar; - var isLastChar; - var lineHeight; - var xPos; - for (var i = 0; i < length; i++) { - var line = textArr[i]; - var len = line.length; - lineHeight = 0; - xPos = 0; - isFirstChar = true; - isLastChar = false; - for (var j = 0; j < len; j++) { - if (!isFirstChar) { - xPos += letterSpacing; - } - var character = line.charAt(j); - var texureWidth = void 0; - var textureHeight = void 0; - var offsetX = 0; - var offsetY = 0; - var texture = bitmapFont.getTexture(character); - if (!texture) { - if (character == " ") { - texureWidth = emptyWidth; - textureHeight = emptyHeight; - } - else { - egret.$warn(1046, character); - if (isFirstChar) { - isFirstChar = false; - } - continue; - } - } - else { - texureWidth = texture.$getTextureWidth(); - textureHeight = texture.$getTextureHeight(); - offsetX = texture.$offsetX; - offsetY = texture.$offsetY; - } - if (isFirstChar) { - isFirstChar = false; - textOffsetX = Math.min(offsetX, textOffsetX); - } - if (isFirstLine) { - isFirstLine = false; - textOffsetY = Math.min(offsetY, textOffsetY); - } - if (hasWidthSet && j > 0 && xPos + texureWidth > textFieldWidth) { - if (!setLineData(line.substring(0, j))) - break; - line = line.substring(j); - len = line.length; - j = 0; - //最后一个字符要计算纹理宽度,而不是xadvance - if (j == len - 1) { - xPos = texureWidth; - } - else { - xPos = bitmapFont.getConfig(character, "xadvance") || texureWidth; - } - lineHeight = textureHeight; - continue; - } - //最后一个字符要计算纹理宽度,而不是xadvance - if (j == len - 1) { - xPos += texureWidth; - } - else { - xPos += bitmapFont.getConfig(character, "xadvance") || texureWidth; - } - lineHeight = Math.max(textureHeight, lineHeight); - } - if (textFieldHeight && i > 0 && textHeight > textFieldHeight) { - break; - } - isLastChar = true; - if (!setLineData(line)) - break; - } - function setLineData(str) { - if (textFieldHeight && textLines.length > 0 && textHeight > textFieldHeight) { - return false; - } - textHeight += lineHeight + lineSpacing; - if (!isFirstChar && !isLastChar) { - xPos -= letterSpacing; - } - textLines.push(str); - lineHeights.push(lineHeight); - textLinesWidth.push(xPos); - textWidth = Math.max(xPos, textWidth); - return true; - } - textHeight -= lineSpacing; - self.$textWidth = textWidth; - self.$textHeight = textHeight; - this.$textOffsetX = textOffsetX; - this.$textOffsetY = textOffsetY; - this.$textStartX = 0; - this.$textStartY = 0; - var alignType; - if (textFieldWidth > textWidth) { - alignType = self.$textAlign; - if (alignType == egret.HorizontalAlign.RIGHT) { - this.$textStartX = textFieldWidth - textWidth; - } - else if (alignType == egret.HorizontalAlign.CENTER) { - this.$textStartX = Math.floor((textFieldWidth - textWidth) / 2); - } - } - if (textFieldHeight > textHeight) { - alignType = self.$verticalAlign; - if (alignType == egret.VerticalAlign.BOTTOM) { - this.$textStartY = textFieldHeight - textHeight; - } - else if (alignType == egret.VerticalAlign.MIDDLE) { - this.$textStartY = Math.floor((textFieldHeight - textHeight) / 2); - } - } - return textLines; - }; - /** - * A ratio of the width of the space character. This value is multiplied by the height of the first character is the space character width. - * @default 0.33 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个空格字符的宽度比例。这个数值乘以第一个字符的高度即为空格字符的宽。 - * @default 0.33 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - BitmapText.EMPTY_FACTOR = 0.33; - return BitmapText; - }(egret.DisplayObject)); - egret.BitmapText = BitmapText; - __reflect(BitmapText.prototype, "egret.BitmapText"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The HorizontalAlign class defines the possible values for the horizontal alignment. - * @see egret.TextField#textAlign - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HorizontalAlign 类为水平对齐方式定义可能的值。 - * @see egret.TextField#textAlign - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var HorizontalAlign = (function () { - function HorizontalAlign() { - } - /** - * Horizontally align content to the left of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的左侧对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HorizontalAlign.LEFT = "left"; - /** - * Horizontally align content to the right of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的右侧对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HorizontalAlign.RIGHT = "right"; - /** - * Horizontally align content in the center of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在容器的水平中心对齐内容。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HorizontalAlign.CENTER = "center"; - /** - * Horizontal alignment with both edges. - * Note: TextFiled does not support this alignment method. - * @constant egret.HorizontalAlign.JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 水平两端对齐。 - * 注意:TextFiled不支持此对齐方式。 - * @constant egret.HorizontalAlign.JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HorizontalAlign.JUSTIFY = "justify"; - /** - * Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Width \" of the container \". - * The Content Width \" of the container \" is the size of the max. child item. If the size of all child items are less than the width of the container, they will be adjusted to the width of the container. - * Note: TextFiled does not support this alignment method. - * @constant egret.HorizontalAlign.CONTENT_JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的"内容宽度"。 - * 容器的"内容宽度"是最大子项的大小,如果所有子项都小于容器的宽度,则会将所有子项的大小调整为容器的宽度。 - * 注意:TextFiled不支持此对齐方式。 - * @constant egret.HorizontalAlign.CONTENT_JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HorizontalAlign.CONTENT_JUSTIFY = "contentJustify"; - return HorizontalAlign; - }()); - egret.HorizontalAlign = HorizontalAlign; - __reflect(HorizontalAlign.prototype, "egret.HorizontalAlign"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property - * @see http://edn.egret.com/cn/docs/page/146 Text mixed in a variety of style - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/HtmlTextParser.ts - * @language en_US - */ - /** - * 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象 - * @see http://edn.egret.com/cn/docs/page/146 多种样式文本混合 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/HtmlTextParser.ts - * @language zh_CN - */ - var HtmlTextParser = (function () { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - function HtmlTextParser() { - this.replaceArr = []; - /** - * @private - */ - this.resutlArr = []; - this.initReplaceArr(); - } - HtmlTextParser.prototype.initReplaceArr = function () { - this.replaceArr = []; - this.replaceArr.push([/</g, "<"]); - this.replaceArr.push([/>/g, ">"]); - this.replaceArr.push([/&/g, "&"]); - this.replaceArr.push([/"/g, "\""]); - this.replaceArr.push([/'/g, "\'"]); - }; - /** - * @private - * - * @param value - * @returns - */ - HtmlTextParser.prototype.replaceSpecial = function (value) { - for (var i = 0; i < this.replaceArr.length; i++) { - var k = this.replaceArr[i][0]; - var v = this.replaceArr[i][1]; - value = value.replace(k, v); - } - return value; - }; - /** - * Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property - * @param htmltext {string} Text in html - * @returns {Array} 可赋值给 egret.TextField#textFlow Object that can be assigned to the egret.TextField#textFlow property - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象 - * @param htmltext {string} html文本 - * @returns {Array} 可赋值给 egret.TextField#textFlow 属性的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HtmlTextParser.prototype.parse = function (htmltext) { - this.stackArray = []; - this.resutlArr = []; - var firstIdx = 0; //文本段开始位置 - var length = htmltext.length; - while (firstIdx < length) { - var starIdx = htmltext.indexOf("<", firstIdx); - if (starIdx < 0) { - this.addToResultArr(htmltext.substring(firstIdx)); - firstIdx = length; - } - else { - this.addToResultArr(htmltext.substring(firstIdx, starIdx)); - var fontEnd = htmltext.indexOf(">", starIdx); - if (fontEnd == -1) { - egret.$error(1038); - fontEnd = starIdx; - } - else if (htmltext.charAt(starIdx + 1) == "\/") { - this.stackArray.pop(); - } - else { - this.addToArray(htmltext.substring(starIdx + 1, fontEnd)); - } - firstIdx = fontEnd + 1; - } - } - return this.resutlArr; - }; - HtmlTextParser.prototype.parser = function (htmltext) { - return this.parse(htmltext); - }; - /** - * @private - * - * @param value - */ - HtmlTextParser.prototype.addToResultArr = function (value) { - if (value == "") { - return; - } - value = this.replaceSpecial(value); - if (this.stackArray.length > 0) { - this.resutlArr.push({ text: value, style: this.stackArray[this.stackArray.length - 1] }); - } - else { - this.resutlArr.push({ text: value }); - } - }; - //将字符数据转成Json数据 - HtmlTextParser.prototype.changeStringToObject = function (str) { - str = str.trim(); - var info = {}; - var header = []; - if (str.charAt(0) == "i" || str.charAt(0) == "b" || str.charAt(0) == "u") { - this.addProperty(info, str, "true"); - } - else if (header = str.match(/^(font|a)\s/)) { - str = str.substring(header[0].length).trim(); - var next = 0; - var titles = void 0; - while (titles = str.match(this.getHeadReg())) { - var title = titles[0]; - var value = ""; - str = str.substring(title.length).trim(); - if (str.charAt(0) == "\"") { - next = str.indexOf("\"", 1); - value = str.substring(1, next); - next += 1; - } - else if (str.charAt(0) == "\'") { - next = str.indexOf("\'", 1); - value = str.substring(1, next); - next += 1; - } - else { - value = str.match(/(\S)+/)[0]; - next = value.length; - } - this.addProperty(info, title.substring(0, title.length - 1).trim(), value.trim()); - str = str.substring(next).trim(); - } - } - return info; - }; - /** - * @private - * - * @returns - */ - HtmlTextParser.prototype.getHeadReg = function () { - return /^(color|textcolor|strokecolor|stroke|b|bold|i|italic|u|size|fontfamily|href|target)(\s)*=/; - }; - /** - * @private - * - * @param info - * @param head - * @param value - */ - HtmlTextParser.prototype.addProperty = function (info, head, value) { - switch (head.toLowerCase()) { - case "color": - case "textcolor": - value = value.replace(/#/, "0x"); - info.textColor = parseInt(value); - break; - case "strokecolor": - value = value.replace(/#/, "0x"); - info.strokeColor = parseInt(value); - break; - case "stroke": - info.stroke = parseInt(value); - break; - case "b": - case "bold": - info.bold = value == "true"; - break; - case "u": - info.underline = value == "true"; - break; - case "i": - case "italic": - info.italic = value == "true"; - break; - case "size": - info.size = parseInt(value); - break; - case "fontfamily": - info.fontFamily = value; - break; - case "href": - info.href = this.replaceSpecial(value); - break; - case "target": - info.target = this.replaceSpecial(value); - break; - } - }; - /** - * @private - * - * @param infoStr - */ - HtmlTextParser.prototype.addToArray = function (infoStr) { - var info = this.changeStringToObject(infoStr); - if (this.stackArray.length == 0) { - this.stackArray.push(info); - } - else { - var lastInfo = this.stackArray[this.stackArray.length - 1]; - for (var key in lastInfo) { - if (info[key] == null) { - info[key] = lastInfo[key]; - } - } - this.stackArray.push(info); - } - }; - return HtmlTextParser; - }()); - egret.HtmlTextParser = HtmlTextParser; - __reflect(HtmlTextParser.prototype, "egret.HtmlTextParser"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - var InputController = (function (_super) { - __extends(InputController, _super); - /** - * @version Egret 2.4 - * @platform Web,Native - */ - function InputController() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.stageTextAdded = false; - /** - * @private - */ - _this._text = null; - /** - * @private - */ - _this._isFocus = false; - return _this; - } - /** - * - * @param text - * @version Egret 2.4 - * @platform Web,Native - */ - InputController.prototype.init = function (text) { - this._text = text; - this.stageText = new egret.StageText(); - this.stageText.$setTextField(this._text); - }; - /** - * @private - * - */ - InputController.prototype._addStageText = function () { - if (this.stageTextAdded) { - return; - } - if (!this._text.$inputEnabled) { - this._text.$touchEnabled = true; - } - this.tempStage = this._text.stage; - this.stageText.$addToStage(); - this.stageText.addEventListener("updateText", this.updateTextHandler, this); - this._text.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onMouseDownHandler, this); - this.stageText.addEventListener("blur", this.blurHandler, this); - this.stageText.addEventListener("focus", this.focusHandler, this); - this.stageTextAdded = true; - }; - /** - * @private - * - */ - InputController.prototype._removeStageText = function () { - if (!this.stageTextAdded) { - return; - } - if (!this._text.$inputEnabled) { - this._text.$touchEnabled = false; - } - this.stageText.$removeFromStage(); - this.stageText.removeEventListener("updateText", this.updateTextHandler, this); - this._text.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onMouseDownHandler, this); - this.tempStage.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onStageDownHandler, this); - this.stageText.removeEventListener("blur", this.blurHandler, this); - this.stageText.removeEventListener("focus", this.focusHandler, this); - this.stageTextAdded = false; - }; - /** - * @private - * - * @returns - */ - InputController.prototype._getText = function () { - return this.stageText.$getText(); - }; - /** - * @private - * - * @param value - */ - InputController.prototype._setText = function (value) { - this.stageText.$setText(value); - }; - /** - * @private - */ - InputController.prototype._setColor = function (value) { - this.stageText.$setColor(value); - }; - /** - * @private - * - * @param event - */ - InputController.prototype.focusHandler = function (event) { - //不再显示竖线,并且输入框显示最开始 - if (!this._isFocus) { - this._isFocus = true; - if (!event["showing"]) { - this._text.$setIsTyping(true); - } - this._text.dispatchEvent(new egret.FocusEvent(egret.FocusEvent.FOCUS_IN, true)); - } - }; - /** - * @private - * - * @param event - */ - InputController.prototype.blurHandler = function (event) { - if (this._isFocus) { - //不再显示竖线,并且输入框显示最开始 - this._isFocus = false; - this.tempStage.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onStageDownHandler, this); - this._text.$setIsTyping(false); - //失去焦点后调用 - this.stageText.$onBlur(); - this._text.dispatchEvent(new egret.FocusEvent(egret.FocusEvent.FOCUS_OUT, true)); - } - }; - //点中文本 - InputController.prototype.onMouseDownHandler = function (event) { - this.$onFocus(); - }; - InputController.prototype.$onFocus = function () { - var _this = this; - var self = this; - if (!this._text.visible) { - return; - } - if (this._isFocus) { - return; - } - this.tempStage.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onStageDownHandler, this); - egret.callLater(function () { - _this.tempStage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, _this.onStageDownHandler, _this); - }, this); - if (egret.nativeRender) { - this.stageText.$setText(this._text.$TextField[13 /* text */]); - } - //强制更新输入框位置 - this.stageText.$show(); - }; - //未点中文本 - InputController.prototype.onStageDownHandler = function (event) { - if (event.$target != this._text) { - this.stageText.$hide(); - } - }; - /** - * @private - * - * @param event - */ - InputController.prototype.updateTextHandler = function (event) { - var values = this._text.$TextField; - var textValue = this.stageText.$getText(); - var isChanged = false; - var reg; - var result; - if (values[35 /* restrictAnd */] != null) { - reg = new RegExp("[" + values[35 /* restrictAnd */] + "]", "g"); - result = textValue.match(reg); - if (result) { - textValue = result.join(""); - } - else { - textValue = ""; - } - isChanged = true; - } - if (values[36 /* restrictNot */] != null) { - reg = new RegExp("[^" + values[36 /* restrictNot */] + "]", "g"); - result = textValue.match(reg); - if (result) { - textValue = result.join(""); - } - else { - textValue = ""; - } - isChanged = true; - } - if (isChanged && this.stageText.$getText() != textValue) { - this.stageText.$setText(textValue); - } - this.resetText(); - //抛出change事件 - this._text.dispatchEvent(new egret.Event(egret.Event.CHANGE, true)); - }; - /** - * @private - * - */ - InputController.prototype.resetText = function () { - this._text.$setBaseText(this.stageText.$getText()); - }; - /** - * @private - * - */ - InputController.prototype._hideInput = function () { - this.stageText.$removeFromStage(); - }; - /** - * @private - * - */ - InputController.prototype.updateInput = function () { - if (!this._text.$visible && this.stageText) { - this._hideInput(); - } - }; - /** - * @private - * - */ - InputController.prototype._updateProperties = function () { - if (this._isFocus) { - //整体修改 - this.stageText.$resetStageText(); - this.updateInput(); - return; - } - this.stageText.$setText(this._text.$TextField[13 /* text */]); - //整体修改 - this.stageText.$resetStageText(); - this.updateInput(); - }; - return InputController; - }(egret.HashObject)); - egret.InputController = InputController; - __reflect(InputController.prototype, "egret.InputController"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var SplitRegex = new RegExp("(?=[\\u00BF-\\u1FFF\\u2C00-\\uD7FF]|\\b|\\s)(?![。,!、》…))}”】\\.\\,\\!\\?\\]\\:])"); - /** - * @private - * 根据样式测量文本宽度 - */ - function measureTextWidth(text, values, style) { - style = style || {}; - var italic = style.italic == null ? values[16 /* italic */] : style.italic; - var bold = style.bold == null ? values[15 /* bold */] : style.bold; - var size = style.size == null ? values[0 /* fontSize */] : style.size; - var fontFamily = style.fontFamily || values[8 /* fontFamily */] || TextField.default_fontFamily; - return egret.sys.measureText(text, fontFamily, size, bold, italic); - } - /** - * TextField is the text rendering class of egret. It conducts rendering by using the browser / device API. Due to different ways of font rendering in different browsers / devices, there may be differences in the rendering - * If developers expect no differences among all platforms, please use BitmapText - * @see http://edn.egret.com/cn/docs/page/141 Create Text - * - * @event egret.Event.CHANGE Dispatched when entering text user input。 - * @event egret.FocusEvent.FOCUS_IN Dispatched after the focus to enter text. - * @event egret.FocusEvent.FOCUS_OUT Enter the text loses focus after dispatch. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/TextField.ts - * @language en_US - */ - /** - * TextField是egret的文本渲染类,采用浏览器/设备的API进行渲染,在不同的浏览器/设备中由于字体渲染方式不一,可能会有渲染差异 - * 如果开发者希望所有平台完全无差异,请使用BitmapText - * @see http://edn.egret.com/cn/docs/page/141 创建文本 - * - * @event egret.Event.CHANGE 输入文本有用户输入时调度。 - * @event egret.FocusEvent.FOCUS_IN 聚焦输入文本后调度。 - * @event egret.FocusEvent.FOCUS_OUT 输入文本失去焦点后调度。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/TextField.ts - * @language zh_CN - */ - var TextField = (function (_super) { - __extends(TextField, _super); - /** - * @version Egret 2.4 - * @platform Web,Native - */ - function TextField() { - var _this = _super.call(this) || this; - _this.$inputEnabled = false; - /** - * @private - */ - _this.inputUtils = null; - /** - * @private - */ - _this.$graphicsNode = null; - /** - * @private - */ - _this.isFlow = false; - /** - * @private - */ - _this.textArr = []; - /** - * @private - */ - _this.linesArr = []; - /** - * @private - */ - _this.$isTyping = false; - var textNode = new egret.sys.TextNode(); - textNode.fontFamily = TextField.default_fontFamily; - _this.textNode = textNode; - _this.$renderNode = textNode; - _this.$TextField = { - 0: TextField.default_size, - 1: 0, - 2: TextField.default_textColor, - 3: NaN, - 4: NaN, - 5: 0, - 6: 0, - 7: 0, - 8: TextField.default_fontFamily, - 9: "left", - 10: "top", - 11: "#ffffff", - 12: "", - 13: "", - 14: [], - 15: false, - 16: false, - 17: true, - 18: false, - 19: false, - 20: false, - 21: 0, - 22: 0, - 23: 0, - 24: egret.TextFieldType.DYNAMIC, - 25: 0x000000, - 26: "#000000", - 27: 0, - 28: -1, - 29: 0, - 30: false, - 31: false, - 32: 0x000000, - 33: false, - 34: 0xffffff, - 35: null, - 36: null, - 37: egret.TextFieldInputType.TEXT, - 38: false //textLinesChangedForNativeRender - }; - return _this; - } - TextField.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(7 /* TEXT */); - }; - /** - * @private - */ - TextField.prototype.isInput = function () { - return this.$TextField[24 /* type */] == egret.TextFieldType.INPUT; - }; - TextField.prototype.$setTouchEnabled = function (value) { - _super.prototype.$setTouchEnabled.call(this, value); - if (this.isInput()) { - this.$inputEnabled = true; - } - }; - Object.defineProperty(TextField.prototype, "fontFamily", { - /** - * The name of the font to use, or a comma-separated list of font names. - * @default "Arial" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要使用的字体的名称或用逗号分隔的字体名称列表。 - * @default "Arial" - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$TextField[8 /* fontFamily */]; - }, - set: function (value) { - this.$setFontFamily(value); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.$setFontFamily = function (value) { - var values = this.$TextField; - if (values[8 /* fontFamily */] == value) { - return false; - } - values[8 /* fontFamily */] = value; - this.invalidateFontString(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setFontFamily(value); - } - return true; - }; - Object.defineProperty(TextField.prototype, "size", { - /** - * The size in pixels of text - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本的字号大小。 - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$TextField[0 /* fontSize */]; - }, - set: function (value) { - this.$setSize(value); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.$setSize = function (value) { - var values = this.$TextField; - if (values[0 /* fontSize */] == value) { - return false; - } - values[0 /* fontSize */] = value; - this.invalidateFontString(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setFontSize(value); - } - return true; - }; - Object.defineProperty(TextField.prototype, "bold", { - /** - * Specifies whether the text is boldface. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否显示为粗体。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$TextField[15 /* bold */]; - }, - set: function (value) { - this.$setBold(value); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.$setBold = function (value) { - var values = this.$TextField; - if (value == values[15 /* bold */]) { - return false; - } - values[15 /* bold */] = value; - this.invalidateFontString(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setBold(value); - } - return true; - }; - Object.defineProperty(TextField.prototype, "italic", { - /** - * Determines whether the text is italic font. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否显示为斜体。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$TextField[16 /* italic */]; - }, - set: function (value) { - this.$setItalic(value); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.$setItalic = function (value) { - var values = this.$TextField; - if (value == values[16 /* italic */]) { - return false; - } - values[16 /* italic */] = value; - this.invalidateFontString(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setItalic(value); - } - return true; - }; - /** - * @private - * - */ - TextField.prototype.invalidateFontString = function () { - this.$TextField[17 /* fontStringChanged */] = true; - this.$invalidateTextField(); - }; - Object.defineProperty(TextField.prototype, "textAlign", { - /** - * Horizontal alignment of text. - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本的水平对齐方式。 - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$TextField[9 /* textAlign */]; - }, - set: function (value) { - this.$setTextAlign(value); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.$setTextAlign = function (value) { - var values = this.$TextField; - if (values[9 /* textAlign */] == value) { - return false; - } - values[9 /* textAlign */] = value; - this.$invalidateTextField(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setTextAlign(value); - } - return true; - }; - Object.defineProperty(TextField.prototype, "verticalAlign", { - /** - * Vertical alignment of text. - * @default:egret.VerticalAlign.TOP - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文字的垂直对齐方式。 - * @default:egret.VerticalAlign.TOP - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$TextField[10 /* verticalAlign */]; - }, - set: function (value) { - this.$setVerticalAlign(value); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.$setVerticalAlign = function (value) { - var values = this.$TextField; - if (values[10 /* verticalAlign */] == value) { - return false; - } - values[10 /* verticalAlign */] = value; - this.$invalidateTextField(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setVerticalAlign(value); - } - return true; - }; - Object.defineProperty(TextField.prototype, "lineSpacing", { - /** - * An integer representing the amount of vertical space between lines. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个整数,表示行与行之间的垂直间距量 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$TextField[1 /* lineSpacing */]; - }, - set: function (value) { - this.$setLineSpacing(value); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.$setLineSpacing = function (value) { - var values = this.$TextField; - if (values[1 /* lineSpacing */] == value) - return false; - values[1 /* lineSpacing */] = value; - this.$invalidateTextField(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setLineSpacing(value); - } - return true; - }; - Object.defineProperty(TextField.prototype, "textColor", { - /** - * Color of the text. - * @default 0x000000 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本颜色 - * @default 0x000000 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$TextField[2 /* textColor */]; - }, - set: function (value) { - this.$setTextColor(value); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.$setTextColor = function (value) { - var values = this.$TextField; - if (values[2 /* textColor */] == value) { - return false; - } - values[2 /* textColor */] = value; - if (this.inputUtils) { - this.inputUtils._setColor(this.$TextField[2 /* textColor */]); - } - this.$invalidateTextField(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setTextColor(value); - } - return true; - }; - Object.defineProperty(TextField.prototype, "wordWrap", { - /** - * A Boolean value that indicates whether the text field word wrap. If the value is true, then the text field by word wrap; - * if the value is false, the text field by newline characters. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个布尔值,表示文本字段是否按单词换行。如果值为 true,则该文本字段按单词换行; - * 如果值为 false,则该文本字段按字符换行。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$TextField[19 /* wordWrap */]; - }, - set: function (value) { - this.$setWordWrap(value); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.$setWordWrap = function (value) { - var values = this.$TextField; - if (value == values[19 /* wordWrap */]) { - return; - } - if (values[20 /* displayAsPassword */]) { - return; - } - values[19 /* wordWrap */] = value; - this.$invalidateTextField(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setWordWrap(value); - } - }; - Object.defineProperty(TextField.prototype, "type", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$TextField[24 /* type */]; - }, - /** - * Type of the text field. - * Any one of the following TextFieldType constants: TextFieldType.DYNAMIC (specifies the dynamic text field that users can not edit), or TextFieldType.INPUT (specifies the dynamic text field that users can edit). - * @default egret.TextFieldType.DYNAMIC - * @language en_US - */ - /** - * 文本字段的类型。 - * 以下 TextFieldType 常量中的任一个:TextFieldType.DYNAMIC(指定用户无法编辑的动态文本字段),或 TextFieldType.INPUT(指定用户可以编辑的输入文本字段)。 - * @default egret.TextFieldType.DYNAMIC - * @language zh_CN - */ - set: function (value) { - this.$setType(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - TextField.prototype.$setType = function (value) { - var values = this.$TextField; - if (values[24 /* type */] != value) { - values[24 /* type */] = value; - if (egret.nativeRender) { - this.$nativeDisplayObject.setType(value); - } - if (value == egret.TextFieldType.INPUT) { - if (isNaN(values[3 /* textFieldWidth */])) { - this.$setWidth(100); - } - if (isNaN(values[4 /* textFieldHeight */])) { - this.$setHeight(30); - } - this.$setTouchEnabled(true); - //创建stageText - if (this.inputUtils == null) { - this.inputUtils = new egret.InputController(); - } - this.inputUtils.init(this); - this.$invalidateTextField(); - if (this.$stage) { - this.inputUtils._addStageText(); - } - } - else { - if (this.inputUtils) { - this.inputUtils._removeStageText(); - this.inputUtils = null; - } - this.$setTouchEnabled(false); - } - return true; - } - return false; - }; - Object.defineProperty(TextField.prototype, "inputType", { - /** - * @version Egret 3.1.2 - * @platform Web,Native - */ - get: function () { - return this.$TextField[37 /* inputType */]; - }, - /** - * Pop-up keyboard type. - * Any of a TextFieldInputType constants. - * @language en_US - */ - /** - * 弹出键盘的类型。 - * TextFieldInputType 常量中的任一个。 - * @language zh_CN - */ - set: function (value) { - this.$TextField[37 /* inputType */] = value; - if (egret.nativeRender) { - this.$nativeDisplayObject.setInputType(value); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "text", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$getText(); - }, - /** - * Serve as a string of the current text field in the text - * @language en_US - */ - /** - * 作为文本字段中当前文本的字符串 - * @language zh_CN - */ - set: function (value) { - this.$setText(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @returns - */ - TextField.prototype.$getText = function () { - if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { - return this.inputUtils._getText(); - } - return this.$TextField[13 /* text */]; - }; - /** - * @private - * - * @param value - */ - TextField.prototype.$setBaseText = function (value) { - if (value == null) { - value = ""; - } - else { - value = value.toString(); - } - this.isFlow = false; - var values = this.$TextField; - if (values[13 /* text */] != value) { - this.$invalidateTextField(); - values[13 /* text */] = value; - var text = ""; - if (values[20 /* displayAsPassword */]) { - text = this.changeToPassText(value); - } - else { - text = value; - } - if (egret.nativeRender) { - this.$nativeDisplayObject.setText(text); - } - this.setMiddleStyle([{ text: text }]); - return true; - } - return false; - }; - /** - * @private - * - * @param value - */ - TextField.prototype.$setText = function (value) { - if (value == null) { - value = ""; - } - var result = this.$setBaseText(value); - if (this.inputUtils) { - this.inputUtils._setText(this.$TextField[13 /* text */]); - } - return result; - }; - Object.defineProperty(TextField.prototype, "displayAsPassword", { - /** - * Specify whether the text field is a password text field. - * If the value of this property is true, the text field is treated as a password text field and hides the input characters using asterisks instead of the actual characters. If false, the text field is not treated as a password text field. - * @default false - * @language en_US - */ - /** - * 指定文本字段是否是密码文本字段。 - * 如果此属性的值为 true,则文本字段被视为密码文本字段,并使用星号而不是实际字符来隐藏输入的字符。如果为 false,则不会将文本字段视为密码文本字段。 - * @default false - * @language zh_CN - */ - get: function () { - return this.$TextField[20 /* displayAsPassword */]; - }, - set: function (value) { - this.$setDisplayAsPassword(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - TextField.prototype.$setDisplayAsPassword = function (value) { - var values = this.$TextField; - if (values[20 /* displayAsPassword */] != value) { - values[20 /* displayAsPassword */] = value; - this.$invalidateTextField(); - var text = ""; - if (value) { - text = this.changeToPassText(values[13 /* text */]); - } - else { - text = values[13 /* text */]; - } - if (egret.nativeRender) { - this.$nativeDisplayObject.setText(text); - } - this.setMiddleStyle([{ text: text }]); - return true; - } - return false; - }; - Object.defineProperty(TextField.prototype, "strokeColor", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$TextField[25 /* strokeColor */]; - }, - /** - * Represent the stroke color of the text. - * Contain three 8-bit numbers with RGB color components; for example, 0xFF0000 is red, 0x00FF00 is green. - * @default 0x000000 - * @language en_US - */ - /** - * 表示文本的描边颜色。 - * 包含三个 8 位 RGB 颜色成分的数字;例如,0xFF0000 为红色,0x00FF00 为绿色。 - * @default 0x000000 - * @language zh_CN - */ - set: function (value) { - this.$setStrokeColor(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - TextField.prototype.$setStrokeColor = function (value) { - var values = this.$TextField; - if (values[25 /* strokeColor */] != value) { - this.$invalidateTextField(); - values[25 /* strokeColor */] = value; - if (egret.nativeRender) { - this.$nativeDisplayObject.setStrokeColor(value); - } - values[26 /* strokeColorString */] = egret.toColorString(value); - return true; - } - return false; - }; - Object.defineProperty(TextField.prototype, "stroke", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$TextField[27 /* stroke */]; - }, - /** - * Indicate the stroke width. - * 0 means no stroke. - * @default 0 - * @language en_US - */ - /** - * 表示描边宽度。 - * 0为没有描边。 - * @default 0 - * @language zh_CN - */ - set: function (value) { - this.$setStroke(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - TextField.prototype.$setStroke = function (value) { - if (this.$TextField[27 /* stroke */] != value) { - this.$invalidateTextField(); - this.$TextField[27 /* stroke */] = value; - if (egret.nativeRender) { - this.$nativeDisplayObject.setStroke(value); - } - return true; - } - return false; - }; - Object.defineProperty(TextField.prototype, "maxChars", { - /** - * The maximum number of characters that the text field can contain, as entered by a user. \n A script can insert more text than maxChars allows; the maxChars property indicates only how much text a user can enter. If the value of this property is 0, a user can enter an unlimited amount of text. - * The default value is 0. - * @default 0 - * @language en_US - */ - /** - * 文本字段中最多可包含的字符数(即用户输入的字符数)。 - * 脚本可以插入比 maxChars 允许的字符数更多的文本;maxChars 属性仅表示用户可以输入多少文本。如果此属性的值为 0,则用户可以输入无限数量的文本。 - * @default 0 - * @language zh_CN - */ - get: function () { - return this.$TextField[21 /* maxChars */]; - }, - set: function (value) { - this.$setMaxChars(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - TextField.prototype.$setMaxChars = function (value) { - if (this.$TextField[21 /* maxChars */] != value) { - this.$TextField[21 /* maxChars */] = value; - if (egret.nativeRender) { - this.$nativeDisplayObject.setMaxChars(value); - } - return true; - } - return false; - }; - Object.defineProperty(TextField.prototype, "scrollV", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return Math.min(Math.max(this.$TextField[28 /* scrollV */], 1), this.maxScrollV); - }, - /** - * Vertical position of text in a text field. scrollV property helps users locate specific passages in a long article, and create scrolling text fields. - * Vertically scrolling units are lines, and horizontal scrolling unit is pixels. - * If the first displayed line is the first line in the text field, scrollV is set to 1 (instead of 0). - * @language en_US - */ - /** - * 文本在文本字段中的垂直位置。scrollV 属性可帮助用户定位到长篇文章的特定段落,还可用于创建滚动文本字段。 - * 垂直滚动的单位是行,而水平滚动的单位是像素。 - * 如果显示的第一行是文本字段中的第一行,则 scrollV 设置为 1(而非 0)。 - * @language zh_CN - */ - set: function (value) { - this.$TextField[28 /* scrollV */] = Math.max(value, 1); - if (egret.nativeRender) { - this.$nativeDisplayObject.setScrollV(value); - } - this.$invalidateTextField(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "maxScrollV", { - /** - * The maximum value of scrollV - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * scrollV 的最大值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - this.$getLinesArr(); - return Math.max(this.$TextField[29 /* numLines */] - egret.TextFieldUtils.$getScrollNum(this) + 1, 1); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "selectionBeginIndex", { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "selectionEndIndex", { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "caretIndex", { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param beginIndex - * @param endIndex - */ - TextField.prototype.$setSelection = function (beginIndex, endIndex) { - return false; - }; - /** - * @private - * - * @returns - */ - TextField.prototype.$getLineHeight = function () { - return this.$TextField[1 /* lineSpacing */] + this.$TextField[0 /* fontSize */]; - }; - Object.defineProperty(TextField.prototype, "numLines", { - /** - * Number of lines of text. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本行数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - this.$getLinesArr(); - return this.$TextField[29 /* numLines */]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "multiline", { - get: function () { - return this.$TextField[30 /* multiline */]; - }, - /** - * Indicate whether field is a multiline text field. Note that this property is valid only when the type is TextFieldType.INPUT. - * If the value is true, the text field is multiline; if the value is false, the text field is a single-line text field. In a field of type TextFieldType.INPUT, the multiline value determines whether the Enter key creates a new line (a value of false, and the Enter key is ignored). - * @default false - * @language en_US - */ - /** - * 表示字段是否为多行文本字段。注意,此属性仅在type为TextFieldType.INPUT时才有效。 - * 如果值为 true,则文本字段为多行文本字段;如果值为 false,则文本字段为单行文本字段。在类型为 TextFieldType.INPUT 的字段中,multiline 值将确定 Enter 键是否创建新行(如果值为 false,则将忽略 Enter 键)。 - * @default false - * @language zh_CN - */ - set: function (value) { - this.$setMultiline(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - TextField.prototype.$setMultiline = function (value) { - this.$TextField[30 /* multiline */] = value; - this.$invalidateTextField(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setMultiline(value); - } - return true; - }; - Object.defineProperty(TextField.prototype, "restrict", { - get: function () { - var values = this.$TextField; - var str = null; - if (values[35 /* restrictAnd */] != null) { - str = values[35 /* restrictAnd */]; - } - if (values[36 /* restrictNot */] != null) { - if (str == null) { - str = ""; - } - str += "^" + values[36 /* restrictNot */]; - } - return str; - }, - /** - * Indicates a user can enter into the text field character set. If you restrict property is null, you can enter any character. If you restrict property is an empty string, you can not enter any character. If you restrict property is a string of characters, you can enter only characters in the string in the text field. The string is scanned from left to right. You can use a hyphen (-) to specify a range. Only restricts user interaction; a script may put any text into the text field.
    - * If the string of characters caret (^) at the beginning, all characters are initially accepted, then the string are excluded from receiving ^ character. If the string does not begin with a caret (^) to, any characters are initially accepted and then a string of characters included in the set of accepted characters.
    - * The following example allows only uppercase characters, spaces, and numbers in the text field:
    - * My_txt.restrict = "A-Z 0-9";
    - * The following example includes all characters except lowercase letters:
    - * My_txt.restrict = "^ a-z";
    - * If you need to enter characters \ ^, use two backslash "\\ -" "\\ ^":
    - * Can be used anywhere in the string ^ to rule out including characters and switch between characters, but can only be used to exclude a ^. The following code includes only uppercase letters except uppercase Q:
    - * My_txt.restrict = "A-Z ^ Q";
    - * @version Egret 2.4 - * @platform Web,Native - * @default null - * @language en_US - */ - /** - * 表示用户可输入到文本字段中的字符集。如果 restrict 属性的值为 null,则可以输入任何字符。如果 restrict 属性的值为空字符串,则不能输入任何字符。如果 restrict 属性的值为一串字符,则只能在文本字段中输入该字符串中的字符。从左向右扫描该字符串。可以使用连字符 (-) 指定一个范围。只限制用户交互;脚本可将任何文本放入文本字段中。
    - * 如果字符串以尖号 (^) 开头,则先接受所有字符,然后从接受字符集中排除字符串中 ^ 之后的字符。如果字符串不以尖号 (^) 开头,则最初不接受任何字符,然后将字符串中的字符包括在接受字符集中。
    - * 下例仅允许在文本字段中输入大写字符、空格和数字:
    - * my_txt.restrict = "A-Z 0-9";
    - * 下例包含除小写字母之外的所有字符:
    - * my_txt.restrict = "^a-z";
    - * 如果需要输入字符 \ ^,请使用2个反斜杠 "\\-" "\\^" :
    - * 可在字符串中的任何位置使用 ^,以在包含字符与排除字符之间进行切换,但是最多只能有一个 ^ 用来排除。下面的代码只包含除大写字母 Q 之外的大写字母:
    - * my_txt.restrict = "A-Z^Q";
    - * @version Egret 2.4 - * @platform Web,Native - * @default null - * @language zh_CN - */ - set: function (value) { - var values = this.$TextField; - if (value == null) { - values[35 /* restrictAnd */] = null; - values[36 /* restrictNot */] = null; - } - else { - var index = -1; - while (index < value.length) { - index = value.indexOf("^", index); - if (index == 0) { - break; - } - else if (index > 0) { - if (value.charAt(index - 1) != "\\") { - break; - } - index++; - } - else { - break; - } - } - if (index == 0) { - values[35 /* restrictAnd */] = null; - values[36 /* restrictNot */] = value.substring(index + 1); - } - else if (index > 0) { - values[35 /* restrictAnd */] = value.substring(0, index); - values[36 /* restrictNot */] = value.substring(index + 1); - } - else { - values[35 /* restrictAnd */] = value; - values[36 /* restrictNot */] = null; - } - } - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - TextField.prototype.$setWidth = function (value) { - if (egret.nativeRender) { - this.$nativeDisplayObject.setTextFieldWidth(value); - } - var values = this.$TextField; - if (isNaN(value)) { - if (isNaN(values[3 /* textFieldWidth */])) { - return false; - } - values[3 /* textFieldWidth */] = NaN; - } - else { - if (values[3 /* textFieldWidth */] == value) { - return false; - } - values[3 /* textFieldWidth */] = value; - } - value = +value; - if (value < 0) { - return false; - } - this.$invalidateTextField(); - return true; - }; - /** - * @private - * - * @param value - */ - TextField.prototype.$setHeight = function (value) { - if (egret.nativeRender) { - this.$nativeDisplayObject.setTextFieldHeight(value); - } - var values = this.$TextField; - if (isNaN(value)) { - if (isNaN(values[4 /* textFieldHeight */])) { - return false; - } - values[4 /* textFieldHeight */] = NaN; - } - else { - if (values[4 /* textFieldHeight */] == value) { - return false; - } - values[4 /* textFieldHeight */] = value; - } - value = +value; - if (value < 0) { - return false; - } - this.$invalidateTextField(); - return true; - }; - /** - * @private - * 获取显示宽度 - */ - TextField.prototype.$getWidth = function () { - var values = this.$TextField; - return isNaN(values[3 /* textFieldWidth */]) ? this.$getContentBounds().width : values[3 /* textFieldWidth */]; - }; - /** - * @private - * 获取显示宽度 - */ - TextField.prototype.$getHeight = function () { - var values = this.$TextField; - return isNaN(values[4 /* textFieldHeight */]) ? this.$getContentBounds().height : values[4 /* textFieldHeight */]; - }; - Object.defineProperty(TextField.prototype, "border", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$TextField[31 /* border */]; - }, - /** - * Specifies whether the text field has a border. - * If true, the text field has a border. If false, the text field has no border. - * Use borderColor property to set the border color. - * @default false - * @language en_US - */ - /** - * 指定文本字段是否具有边框。 - * 如果为 true,则文本字段具有边框。如果为 false,则文本字段没有边框。 - * 使用 borderColor 属性来设置边框颜色。 - * @default false - * @language zh_CN - */ - set: function (value) { - this.$setBorder(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - TextField.prototype.$setBorder = function (value) { - value = !!value; - this.$TextField[31 /* border */] = value; - if (egret.nativeRender) { - this.$nativeDisplayObject.setBorder(value); - } - }; - Object.defineProperty(TextField.prototype, "borderColor", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$TextField[32 /* borderColor */]; - }, - /** - * The color of the text field border. - * Even currently is no border can be retrieved or set this property, but only if the text field has the border property is set to true, the color is visible. - * @default 0x000000 - * @language en_US - */ - /** - * 文本字段边框的颜色。 - * 即使当前没有边框,也可检索或设置此属性,但只有当文本字段已将 border 属性设置为 true 时,才可以看到颜色。 - * @default 0x000000 - * @language zh_CN - */ - set: function (value) { - this.$setBorderColor(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - TextField.prototype.$setBorderColor = function (value) { - value = +value || 0; - this.$TextField[32 /* borderColor */] = value; - if (egret.nativeRender) { - this.$nativeDisplayObject.setBorderColor(value); - } - }; - Object.defineProperty(TextField.prototype, "background", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$TextField[33 /* background */]; - }, - /** - * Specifies whether the text field has a background fill. - * If true, the text field has a background fill. If false, the text field has no background fill. - * Use the backgroundColor property to set the background color of the text field. - * @default false - * @language en_US - */ - /** - * 指定文本字段是否具有背景填充。 - * 如果为 true,则文本字段具有背景填充。如果为 false,则文本字段没有背景填充。 - * 使用 backgroundColor 属性来设置文本字段的背景颜色。 - * @default false - * @language zh_CN - */ - set: function (value) { - this.$setBackground(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - TextField.prototype.$setBackground = function (value) { - this.$TextField[33 /* background */] = value; - if (egret.nativeRender) { - this.$nativeDisplayObject.setBackground(value); - } - }; - Object.defineProperty(TextField.prototype, "backgroundColor", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$TextField[34 /* backgroundColor */]; - }, - /** - * Color of the text field background. - * Even currently is no background, can be retrieved or set this property, but only if the text field has the background property set to true, the color is visible. - * @default 0xFFFFFF - * @language en_US - */ - /** - * 文本字段背景的颜色。 - * 即使当前没有背景,也可检索或设置此属性,但只有当文本字段已将 background 属性设置为 true 时,才可以看到颜色。 - * @default 0xFFFFFF - * @language zh_CN - */ - set: function (value) { - this.$setBackgroundColor(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - TextField.prototype.$setBackgroundColor = function (value) { - this.$TextField[34 /* backgroundColor */] = value; - if (egret.nativeRender) { - this.$nativeDisplayObject.setBackgroundColor(value); - } - }; - /** - * @private - * - */ - TextField.prototype.fillBackground = function (lines) { - var graphics = this.$graphicsNode; - if (graphics) { - graphics.clear(); - } - var values = this.$TextField; - if (values[33 /* background */] || values[31 /* border */] || (lines && lines.length > 0)) { - if (!graphics) { - graphics = this.$graphicsNode = new egret.sys.GraphicsNode(); - if (!egret.nativeRender) { - var groupNode = new egret.sys.GroupNode(); - groupNode.addNode(graphics); - groupNode.addNode(this.textNode); - this.$renderNode = groupNode; - } - else { - this.$renderNode = this.textNode; - } - } - var fillPath = void 0; - var strokePath = void 0; - //渲染背景 - if (values[33 /* background */]) { - fillPath = graphics.beginFill(values[34 /* backgroundColor */]); - fillPath.drawRect(0, 0, this.$getWidth(), this.$getHeight()); - } - //渲染边框 - if (values[31 /* border */]) { - strokePath = graphics.lineStyle(1, values[32 /* borderColor */]); - //1像素和3像素线条宽度的情况,会向右下角偏移0.5像素绘制。少画一像素宽度,正好能不超出文本测量边界。 - strokePath.drawRect(0, 0, this.$getWidth() - 1, this.$getHeight() - 1); - } - //渲染下划线 - if (lines && lines.length > 0) { - var textColor = values[2 /* textColor */]; - var lastColor = -1; - var length_7 = lines.length; - for (var i = 0; i < length_7; i += 4) { - var x = lines[i]; - var y = lines[i + 1]; - var w = lines[i + 2]; - var color = lines[i + 3] || textColor; - if (lastColor < 0 || lastColor != color) { - lastColor = color; - strokePath = graphics.lineStyle(2, color, 1, egret.CapsStyle.NONE); - } - strokePath.moveTo(x, y); - strokePath.lineTo(x + w, y); - } - } - } - if (graphics) { - var bounds = this.$getRenderBounds(); - graphics.x = bounds.x; - graphics.y = bounds.y; - graphics.width = bounds.width; - graphics.height = bounds.height; - egret.Rectangle.release(bounds); - } - }; - /** - * Enter the text automatically entered into the input state, the input type is text only and may only be invoked in the user interaction. - * @version Egret 3.0.8 - * @platform Web,Native - * @language en_US - */ - /** - * 输入文本自动进入到输入状态,仅在类型是输入文本并且是在用户交互下才可以调用。 - * @version Egret 3.0.8 - * @platform Web,Native - * @language zh_CN - */ - TextField.prototype.setFocus = function () { - if (this.type == egret.TextFieldType.INPUT && this.$stage) { - this.inputUtils.$onFocus(); - } - }; - /** - * @private - * - */ - TextField.prototype.$onRemoveFromStage = function () { - _super.prototype.$onRemoveFromStage.call(this); - this.removeEvent(); - if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { - this.inputUtils._removeStageText(); - } - if (this.textNode) { - this.textNode.clean(); - if (egret.nativeRender) { - egret_native.NativeDisplayObject.disposeTextData(this); - } - } - }; - /** - * @private - * - * @param stage - * @param nestLevel - */ - TextField.prototype.$onAddToStage = function (stage, nestLevel) { - _super.prototype.$onAddToStage.call(this, stage, nestLevel); - this.addEvent(); - if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { - this.inputUtils._addStageText(); - } - }; - TextField.prototype.$invalidateTextField = function () { - var self = this; - self.$renderDirty = true; - self.$TextField[18 /* textLinesChanged */] = true; - self.$TextField[38 /* textLinesChangedForNativeRender */] = true; - if (egret.nativeRender) { - // egret_native.dirtyTextField(this); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - TextField.prototype.$getRenderBounds = function () { - var bounds = this.$getContentBounds(); - var tmpBounds = egret.Rectangle.create(); - tmpBounds.copyFrom(bounds); - if (this.$TextField[31 /* border */]) { - tmpBounds.width += 2; - tmpBounds.height += 2; - } - var _strokeDouble = this.$TextField[27 /* stroke */] * 2; - if (_strokeDouble > 0) { - tmpBounds.width += _strokeDouble * 2; - tmpBounds.height += _strokeDouble * 2; - } - tmpBounds.x -= _strokeDouble + 2; //+2和+4 是为了webgl纹理太小导致裁切问题 - tmpBounds.y -= _strokeDouble + 2; - tmpBounds.width = Math.ceil(tmpBounds.width) + 4; - tmpBounds.height = Math.ceil(tmpBounds.height) + 4; - return tmpBounds; - }; - /** - * @private - */ - TextField.prototype.$measureContentBounds = function (bounds) { - this.$getLinesArr(); - var w = 0; - var h = 0; - if (egret.nativeRender) { - w = egret_native.nrGetTextFieldWidth(this.$nativeDisplayObject.id); - h = egret_native.nrGetTextFieldHeight(this.$nativeDisplayObject.id); - } - else { - w = !isNaN(this.$TextField[3 /* textFieldWidth */]) ? this.$TextField[3 /* textFieldWidth */] : this.$TextField[5 /* textWidth */]; - h = !isNaN(this.$TextField[4 /* textFieldHeight */]) ? this.$TextField[4 /* textFieldHeight */] : egret.TextFieldUtils.$getTextHeight(this); - } - bounds.setTo(0, 0, w, h); - }; - TextField.prototype.$updateRenderNode = function () { - if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { - this.inputUtils._updateProperties(); - if (this.$isTyping) { - this.fillBackground(); - return; - } - } - else if (this.$TextField[3 /* textFieldWidth */] == 0) { - var graphics = this.$graphicsNode; - if (graphics) { - graphics.clear(); - } - return; - } - var underLines = this.drawText(); - this.fillBackground(underLines); - //tudo 宽高很小的情况下webgl模式绘制异常 - var bounds = this.$getRenderBounds(); - var node = this.textNode; - node.x = bounds.x; - node.y = bounds.y; - node.width = Math.ceil(bounds.width); - node.height = Math.ceil(bounds.height); - egret.Rectangle.release(bounds); - }; - Object.defineProperty(TextField.prototype, "textFlow", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.textArr; - }, - /** - * Set rich text - * @language en_US - */ - /** - * 设置富文本 - * @see http://edn.egret.com/cn/index.php/article/index/id/146 - * @language zh_CN - */ - set: function (textArr) { - this.isFlow = true; - var text = ""; - if (textArr == null) - textArr = []; - for (var i = 0; i < textArr.length; i++) { - var element = textArr[i]; - text += element.text; - } - if (this.$TextField[20 /* displayAsPassword */]) { - this.$setBaseText(text); - } - else { - this.$TextField[13 /* text */] = text; - this.setMiddleStyle(textArr); - if (egret.nativeRender) { - this.$nativeDisplayObject.setTextFlow(textArr); - } - } - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param text - * @returns - */ - TextField.prototype.changeToPassText = function (text) { - if (this.$TextField[20 /* displayAsPassword */]) { - var passText = ""; - for (var i = 0, num = text.length; i < num; i++) { - switch (text.charAt(i)) { - case '\n': - passText += "\n"; - break; - case '\r': - break; - default: - passText += '*'; - } - } - return passText; - } - return text; - }; - /** - * @private - * - * @param textArr - */ - TextField.prototype.setMiddleStyle = function (textArr) { - this.$TextField[18 /* textLinesChanged */] = true; - this.$TextField[38 /* textLinesChangedForNativeRender */] = true; - this.textArr = textArr; - this.$invalidateTextField(); - }; - Object.defineProperty(TextField.prototype, "textWidth", { - /** - * Get the text measured width - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取文本测量宽度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - this.$getLinesArr(); - if (egret.nativeRender) { - return egret_native.nrGetTextWidth(this.$nativeDisplayObject.id); - } - return this.$TextField[5 /* textWidth */]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "textHeight", { - /** - * Get Text measuring height - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取文本测量高度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - this.$getLinesArr(); - if (egret.nativeRender) { - return egret_native.nrGetTextHeight(this.$nativeDisplayObject.id); - } - return egret.TextFieldUtils.$getTextHeight(this); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * @param text - * @version Egret 2.4 - * @platform Web,Native - */ - TextField.prototype.appendText = function (text) { - this.appendElement({ text: text }); - }; - /** - * @private - * @param element - * @version Egret 2.4 - * @platform Web,Native - */ - TextField.prototype.appendElement = function (element) { - var text = this.$TextField[13 /* text */] + element.text; - if (egret.nativeRender) { - this.textArr.push(element); - this.$TextField[13 /* text */] = text; - this.$TextField[18 /* textLinesChanged */] = true; - this.$TextField[38 /* textLinesChangedForNativeRender */] = true; - this.$nativeDisplayObject.setTextFlow(this.textArr); - return; - } - if (this.$TextField[20 /* displayAsPassword */]) { - this.$setBaseText(text); - } - else { - this.$TextField[13 /* text */] = text; - this.textArr.push(element); - this.setMiddleStyle(this.textArr); - } - }; - TextField.prototype.$getLinesArr = function () { - var values = this.$TextField; - if (egret.nativeRender && values[38 /* textLinesChangedForNativeRender */]) { - egret_native.updateNativeRender(); - values[38 /* textLinesChangedForNativeRender */] = false; - return; - } - else { - return this.$getLinesArr2(); - } - }; - /** - * @private - * - * @returns - */ - TextField.prototype.$getLinesArr2 = function () { - var values = this.$TextField; - if (!values[18 /* textLinesChanged */]) { - return this.linesArr; - } - values[18 /* textLinesChanged */] = false; - var text2Arr = this.textArr; - this.linesArr.length = 0; - values[6 /* textHeight */] = 0; - values[5 /* textWidth */] = 0; - var textFieldWidth = values[3 /* textFieldWidth */]; - //宽度被设置为0 - if (!isNaN(textFieldWidth) && textFieldWidth == 0) { - values[29 /* numLines */] = 0; - return [{ width: 0, height: 0, charNum: 0, elements: [], hasNextLine: false }]; - } - var linesArr = this.linesArr; - var lineW = 0; - var lineCharNum = 0; - var lineH = 0; - var lineCount = 0; - var lineElement; - for (var i = 0, text2ArrLength = text2Arr.length; i < text2ArrLength; i++) { - var element = text2Arr[i]; - //可能设置为没有文本,忽略绘制 - if (!element.text) { - if (lineElement) { - lineElement.width = lineW; - lineElement.height = lineH; - lineElement.charNum = lineCharNum; - values[5 /* textWidth */] = Math.max(values[5 /* textWidth */], lineW); - values[6 /* textHeight */] += lineH; - } - continue; - } - element.style = element.style || {}; - var text = element.text.toString(); - var textArr = text.split(/(?:\r\n|\r|\n)/); - for (var j = 0, textArrLength = textArr.length; j < textArrLength; j++) { - if (linesArr[lineCount] == null) { - lineElement = { width: 0, height: 0, elements: [], charNum: 0, hasNextLine: false }; - linesArr[lineCount] = lineElement; - lineW = 0; - lineH = 0; - lineCharNum = 0; - } - if (values[24 /* type */] == egret.TextFieldType.INPUT) { - lineH = values[0 /* fontSize */]; - } - else { - lineH = Math.max(lineH, element.style.size || values[0 /* fontSize */]); - } - var isNextLine = true; - if (textArr[j] == "") { - if (j == textArrLength - 1) { - isNextLine = false; - } - } - else { - var w = measureTextWidth(textArr[j], values, element.style); - if (isNaN(textFieldWidth)) { - lineW += w; - lineCharNum += textArr[j].length; - lineElement.elements.push({ - width: w, - text: textArr[j], - style: element.style - }); - if (j == textArrLength - 1) { - isNextLine = false; - } - } - else { - if (lineW + w <= textFieldWidth) { - lineElement.elements.push({ - width: w, - text: textArr[j], - style: element.style - }); - lineW += w; - lineCharNum += textArr[j].length; - if (j == textArrLength - 1) { - isNextLine = false; - } - } - else { - var k = 0; - var ww = 0; - var word = textArr[j]; - var words = void 0; - if (values[19 /* wordWrap */]) { - words = word.split(SplitRegex); - } - else { - words = word.match(/./g); - } - var wl = words.length; - var charNum = 0; - for (; k < wl; k++) { - // detect 4 bytes unicode, refer https://mths.be/punycode - var codeLen = words[k].length; - var has4BytesUnicode = false; - if (codeLen == 1 && k < wl - 1) { - var charCodeHigh = words[k].charCodeAt(0); - var charCodeLow = words[k + 1].charCodeAt(0); - if (charCodeHigh >= 0xD800 && charCodeHigh <= 0xDBFF && (charCodeLow & 0xFC00) == 0xDC00) { - var realWord = words[k] + words[k + 1]; - codeLen = 2; - has4BytesUnicode = true; - w = measureTextWidth(realWord, values, element.style); - } - else { - w = measureTextWidth(words[k], values, element.style); - } - } - else { - w = measureTextWidth(words[k], values, element.style); - } - // w = measureTextWidth(words[k], values, element.style); - if (lineW != 0 && lineW + w > textFieldWidth && lineW + k != 0) { - break; - } - if (ww + w > textFieldWidth) { - var words2 = words[k].match(/./g); - for (var k2 = 0, wl2 = words2.length; k2 < wl2; k2++) { - // detect 4 bytes unicode, refer https://mths.be/punycode - var codeLen = words2[k2].length; - var has4BytesUnicode2 = false; - if (codeLen == 1 && k2 < wl2 - 1) { - var charCodeHigh = words2[k2].charCodeAt(0); - var charCodeLow = words2[k2 + 1].charCodeAt(0); - if (charCodeHigh >= 0xD800 && charCodeHigh <= 0xDBFF && (charCodeLow & 0xFC00) == 0xDC00) { - var realWord = words2[k2] + words2[k2 + 1]; - codeLen = 2; - has4BytesUnicode2 = true; - w = measureTextWidth(realWord, values, element.style); - } - else { - w = measureTextWidth(words2[k2], values, element.style); - } - } - else { - w = measureTextWidth(words2[k2], values, element.style); - } - // w = measureTextWidth(words2[k2], values, element.style); - if (k2 > 0 && lineW + w > textFieldWidth) { - break; - } - // charNum += words2[k2].length; - charNum += codeLen; - ww += w; - lineW += w; - lineCharNum += charNum; - if (has4BytesUnicode2) { - k2++; - } - } - } - else { - // charNum += words[k].length; - charNum += codeLen; - ww += w; - lineW += w; - lineCharNum += charNum; - } - if (has4BytesUnicode) { - k++; - } - } - if (k > 0) { - lineElement.elements.push({ - width: ww, - text: word.substring(0, charNum), - style: element.style - }); - var leftWord = word.substring(charNum); - var m = void 0; - var lwleng = leftWord.length; - for (m = 0; m < lwleng; m++) { - if (leftWord.charAt(m) != " ") { - break; - } - } - textArr[j] = leftWord.substring(m); - } - if (textArr[j] != "") { - j--; - isNextLine = false; - } - } - } - } - if (isNextLine) { - lineCharNum++; - lineElement.hasNextLine = true; - } - if (j < textArr.length - 1) { - lineElement.width = lineW; - lineElement.height = lineH; - lineElement.charNum = lineCharNum; - values[5 /* textWidth */] = Math.max(values[5 /* textWidth */], lineW); - values[6 /* textHeight */] += lineH; - //if (this._type == TextFieldType.INPUT && !this._multiline) { - // this._numLines = linesArr.length; - // return linesArr; - //} - lineCount++; - } - } - if (i == text2Arr.length - 1 && lineElement) { - lineElement.width = lineW; - lineElement.height = lineH; - lineElement.charNum = lineCharNum; - values[5 /* textWidth */] = Math.max(values[5 /* textWidth */], lineW); - values[6 /* textHeight */] += lineH; - } - } - values[29 /* numLines */] = linesArr.length; - return linesArr; - }; - /** - * @private - */ - TextField.prototype.$setIsTyping = function (value) { - this.$isTyping = value; - this.$invalidateTextField(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setIsTyping(value); - } - }; - /** - * @private - * 返回要绘制的下划线列表 - */ - TextField.prototype.drawText = function () { - var node = this.textNode; - var values = this.$TextField; - //更新文本样式 - node.bold = values[15 /* bold */]; - node.fontFamily = values[8 /* fontFamily */] || TextField.default_fontFamily; - node.italic = values[16 /* italic */]; - node.size = values[0 /* fontSize */]; - node.stroke = values[27 /* stroke */]; - node.strokeColor = values[25 /* strokeColor */]; - node.textColor = values[2 /* textColor */]; - //先算出需要的数值 - var lines = this.$getLinesArr(); - if (values[5 /* textWidth */] == 0) { - return []; - } - var maxWidth = !isNaN(values[3 /* textFieldWidth */]) ? values[3 /* textFieldWidth */] : values[5 /* textWidth */]; - var textHeight = egret.TextFieldUtils.$getTextHeight(this); - var drawY = 0; - var startLine = egret.TextFieldUtils.$getStartLine(this); - var textFieldHeight = values[4 /* textFieldHeight */]; - if (!isNaN(textFieldHeight) && textFieldHeight > textHeight) { - var vAlign = egret.TextFieldUtils.$getValign(this); - drawY += vAlign * (textFieldHeight - textHeight); - } - drawY = Math.round(drawY); - var hAlign = egret.TextFieldUtils.$getHalign(this); - var drawX = 0; - var underLineData = []; - for (var i = startLine, numLinesLength = values[29 /* numLines */]; i < numLinesLength; i++) { - var line = lines[i]; - var h = line.height; - drawY += h / 2; - if (i != startLine) { - if (values[24 /* type */] == egret.TextFieldType.INPUT && !values[30 /* multiline */]) { - break; - } - if (!isNaN(textFieldHeight) && drawY > textFieldHeight) { - break; - } - } - drawX = Math.round((maxWidth - line.width) * hAlign); - for (var j = 0, elementsLength = line.elements.length; j < elementsLength; j++) { - var element = line.elements[j]; - var size = element.style.size || values[0 /* fontSize */]; - node.drawText(drawX, drawY + (h - size) / 2, element.text, element.style); - if (element.style.underline) { - underLineData.push(drawX, drawY + (h) / 2, element.width, element.style.textColor); - } - drawX += element.width; - } - drawY += h / 2 + values[1 /* lineSpacing */]; - } - return underLineData; - }; - //增加点击事件 - TextField.prototype.addEvent = function () { - this.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTapHandler, this); - }; - //释放点击事件 - TextField.prototype.removeEvent = function () { - this.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTapHandler, this); - }; - //处理富文本中有href的 - TextField.prototype.onTapHandler = function (e) { - if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { - return; - } - var ele = egret.TextFieldUtils.$getTextElement(this, e.localX, e.localY); - if (ele == null) { - return; - } - var style = ele.style; - if (style && style.href) { - if (style.href.match(/^event:/)) { - var type = style.href.match(/^event:/)[0]; - egret.TextEvent.dispatchTextEvent(this, egret.TextEvent.LINK, style.href.substring(type.length)); - } - else { - open(style.href, style.target || "_blank"); - } - } - }; - /** - * default fontFamily - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本字体 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TextField.default_fontFamily = "Arial"; - /** - * default size in pixels of text - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本字号大小 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - TextField.default_size = 30; - /** - * default color of the text. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本颜色 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - TextField.default_textColor = 0xffffff; - return TextField; - }(egret.DisplayObject)); - egret.TextField = TextField; - __reflect(TextField.prototype, "egret.TextField"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * TextFieldInputType class is an enumeration of constant value used in setting the inputType property of the TextField class. - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * TextFieldInputType 类是在设置 TextField 类的 inputType 属性时使用的常数值的枚举。 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - var TextFieldInputType = (function () { - function TextFieldInputType() { - } - /** - * The default - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * 默认 input 类型 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - TextFieldInputType.TEXT = "text"; - /** - * Telephone Number Inputs - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * 电话号码 input 类型 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - TextFieldInputType.TEL = "tel"; - /** - * Password Inputs - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * password 类型 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - TextFieldInputType.PASSWORD = "password"; - return TextFieldInputType; - }()); - egret.TextFieldInputType = TextFieldInputType; - __reflect(TextFieldInputType.prototype, "egret.TextFieldInputType"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * TextFieldType class is an enumeration of constant value used in setting the type property of the TextField class. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * TextFieldType 类是在设置 TextField 类的 type 属性时使用的常数值的枚举。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var TextFieldType = (function () { - function TextFieldType() { - } - /** - * Used to specify dynamic text - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定动态文本 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TextFieldType.DYNAMIC = "dynamic"; - /** - * Used to specify the input text - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定输入文本 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TextFieldType.INPUT = "input"; - return TextFieldType; - }()); - egret.TextFieldType = TextFieldType; - __reflect(TextFieldType.prototype, "egret.TextFieldType"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - var TextFieldUtils = (function () { - function TextFieldUtils() { - } - /** - * 获取第一个绘制的行数 - * @param textfield 文本 - * @returns {number} 行数,从0开始 - * @private - */ - TextFieldUtils.$getStartLine = function (textfield) { - var values = textfield.$TextField; - var textHeight = TextFieldUtils.$getTextHeight(textfield); - var startLine = 0; - var textFieldHeight = values[4 /* textFieldHeight */]; - if (!isNaN(textFieldHeight)) { - if (textHeight < textFieldHeight) { - } - else if (textHeight > textFieldHeight) { - startLine = Math.max(values[28 /* scrollV */] - 1, 0); - startLine = Math.min(values[29 /* numLines */] - 1, startLine); - } - if (!values[30 /* multiline */]) { - startLine = Math.max(values[28 /* scrollV */] - 1, 0); - if (values[29 /* numLines */] > 0) { - startLine = Math.min(values[29 /* numLines */] - 1, startLine); - } - } - } - return startLine; - }; - /** - * 获取水平比例 - * @param textfield 文本 - * @returns {number} 水平比例 - * @private - */ - TextFieldUtils.$getHalign = function (textfield) { - var lineArr = textfield.$getLinesArr2(); - var halign = 0; - if (textfield.$TextField[9 /* textAlign */] == egret.HorizontalAlign.CENTER) { - halign = 0.5; - } - else if (textfield.$TextField[9 /* textAlign */] == egret.HorizontalAlign.RIGHT) { - halign = 1; - } - if (textfield.$TextField[24 /* type */] == egret.TextFieldType.INPUT && !textfield.$TextField[30 /* multiline */] && lineArr.length > 1) { - halign = 0; - } - return halign; - }; - /** - * @private - * - * @param textfield - * @returns - */ - TextFieldUtils.$getTextHeight = function (textfield) { - var textHeight = (egret.TextFieldType.INPUT == textfield.$TextField[24 /* type */] - && !textfield.$TextField[30 /* multiline */]) ? textfield.$TextField[0 /* fontSize */] : (textfield.$TextField[6 /* textHeight */] + (textfield.$TextField[29 /* numLines */] - 1) * textfield.$TextField[1 /* lineSpacing */]); - return textHeight; - }; - /** - * 获取垂直比例 - * @param textfield 文本 - * @returns {number} 垂直比例 - * @private - */ - TextFieldUtils.$getValign = function (textfield) { - var textHeight = TextFieldUtils.$getTextHeight(textfield); - //if (textfield.$TextField[sys.TextKeys.type] == egret.TextFieldType.INPUT) { - // if (textfield.$TextField[sys.TextKeys.multiline]) { - //return 0; - //} - //return 0.5; - //} - var textFieldHeight = textfield.$TextField[4 /* textFieldHeight */]; - if (!isNaN(textFieldHeight)) { - if (textHeight < textFieldHeight) { - var valign = 0; - if (textfield.$TextField[10 /* verticalAlign */] == egret.VerticalAlign.MIDDLE) - valign = 0.5; - else if (textfield.$TextField[10 /* verticalAlign */] == egret.VerticalAlign.BOTTOM) - valign = 1; - return valign; - } - } - return 0; - }; - /** - * 根据x、y获取文本项 - * @param textfield 文本 - * @param x x坐标值 - * @param y y坐标值 - * @returns 文本单项 - * @private - */ - TextFieldUtils.$getTextElement = function (textfield, x, y) { - var hitTextEle = TextFieldUtils.$getHit(textfield, x, y); - var lineArr = textfield.$getLinesArr2(); - if (hitTextEle && lineArr[hitTextEle.lineIndex] && lineArr[hitTextEle.lineIndex].elements[hitTextEle.textElementIndex]) { - return lineArr[hitTextEle.lineIndex].elements[hitTextEle.textElementIndex]; - } - return null; - }; - /** - * 获取文本点击块 - * @param textfield 文本 - * @param x x坐标值 - * @param y y坐标值 - * @returns 文本点击块 - * @private - */ - TextFieldUtils.$getHit = function (textfield, x, y) { - var lineArr = textfield.$getLinesArr2(); - if (textfield.$TextField[3 /* textFieldWidth */] == 0) { - return null; - } - var line = 0; - var textHeight = TextFieldUtils.$getTextHeight(textfield); - var startY = 0; - var textFieldHeight = textfield.$TextField[4 /* textFieldHeight */]; - if (!isNaN(textFieldHeight) && textFieldHeight > textHeight) { - var valign = TextFieldUtils.$getValign(textfield); - startY = valign * (textFieldHeight - textHeight); - if (startY != 0) { - y -= startY; - } - } - var startLine = TextFieldUtils.$getStartLine(textfield); - var lineH = 0; - for (var i = startLine; i < lineArr.length; i++) { - var lineEle = lineArr[i]; - if (lineH + lineEle.height >= y) { - if (lineH < y) { - line = i + 1; - } - break; - } - else { - lineH += lineEle.height; - } - if (lineH + textfield.$TextField[1 /* lineSpacing */] > y) { - return null; - } - lineH += textfield.$TextField[1 /* lineSpacing */]; - } - if (line == 0) { - return null; - } - var lineElement = lineArr[line - 1]; - var textFieldWidth = textfield.$TextField[3 /* textFieldWidth */]; - if (isNaN(textFieldWidth)) { - textFieldWidth = textfield.textWidth; - } - var halign = TextFieldUtils.$getHalign(textfield); - x -= halign * (textFieldWidth - lineElement.width); - var lineW = 0; - for (var i = 0; i < lineElement.elements.length; i++) { - var iwTE = lineElement.elements[i]; - if (lineW + iwTE.width <= x) { - lineW += iwTE.width; - } - else if (lineW < x) { - return { "lineIndex": line - 1, "textElementIndex": i }; - } - } - return null; - }; - /** - * 获取当前显示多少行 - * @param textfield 文本 - * @returns {number} 显示的行数 - * @private - */ - TextFieldUtils.$getScrollNum = function (textfield) { - var scrollNum = 1; - if (textfield.$TextField[30 /* multiline */]) { - var height = textfield.height; - var size = textfield.size; - var lineSpacing = textfield.lineSpacing; - scrollNum = Math.floor(height / (size + lineSpacing)); - var leftH = height - (size + lineSpacing) * scrollNum; - if (leftH > size / 2) { - scrollNum++; - } - } - return scrollNum; - }; - return TextFieldUtils; - }()); - egret.TextFieldUtils = TextFieldUtils; - __reflect(TextFieldUtils.prototype, "egret.TextFieldUtils"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/** - * @private - */ -var egret; -(function (egret) { - var sys; - (function (sys) { - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The VerticalAlign class defines the possible values for the vertical alignment. - * @see egret.TextField#verticalAlign - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * VerticalAlign 类为垂直对齐方式定义可能的值。 - * @see egret.TextField#verticalAlign - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var VerticalAlign = (function () { - function VerticalAlign() { - } - /** - * Vertically align content to the top of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的顶部对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - VerticalAlign.TOP = "top"; - /** - * Vertically align content to the bottom of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的底部对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - VerticalAlign.BOTTOM = "bottom"; - /** - * Vertically align content in the middle of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在容器的垂直中心对齐内容。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - VerticalAlign.MIDDLE = "middle"; - /** - * Vertical alignment with both edges - * Note: TextFiled does not support this alignment method." - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 垂直两端对齐 - * 注意:TextFiled不支持此对齐方式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - VerticalAlign.JUSTIFY = "justify"; - /** - * Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Height \" of the container \". - * The Content Height \" of the container \" is the size of the max. child item. If the size of all child items are less than the height of the container, they will be adjusted to the height of the container. - * Note: TextFiled does not support this alignment method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的"内容高度"。 - * 容器的"内容高度"是最大子项的大小,如果所有子项都小于容器的高度,则会将所有子项的大小调整为容器的高度。 - * 注意:TextFiled不支持此对齐方式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - VerticalAlign.CONTENT_JUSTIFY = "contentJustify"; - return VerticalAlign; - }()); - egret.VerticalAlign = VerticalAlign; - __reflect(VerticalAlign.prototype, "egret.VerticalAlign"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @language en_US - * The Base64Util class provides methods for encoding and decoding base64. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Base64Util.ts - */ - /** - * @language zh_CN - * Base64Util 类提供用于编解码base64的方法。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Base64Util.ts - */ - var Base64Util = (function () { - function Base64Util() { - } - /** - * @language en_US - * encode base64. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 编码base64。 - * @version Egret 2.4 - * @platform Web,Native - */ - Base64Util.encode = function (arraybuffer) { - var bytes = new Uint8Array(arraybuffer); - var len = bytes.length; - var base64 = ''; - for (var i = 0; i < len; i += 3) { - base64 += chars[bytes[i] >> 2]; - base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)]; - base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)]; - base64 += chars[bytes[i + 2] & 63]; - } - if ((len % 3) === 2) { - base64 = base64.substring(0, base64.length - 1) + '='; - } - else if (len % 3 === 1) { - base64 = base64.substring(0, base64.length - 2) + '=='; - } - return base64; - }; - /** - * @language en_US - * decode base64. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 解码base64。 - * @version Egret 2.4 - * @platform Web,Native - */ - Base64Util.decode = function (base64) { - var bufferLength = base64.length * 0.75; - var len = base64.length; - var p = 0; - var encoded1 = 0; - var encoded2 = 0; - var encoded3 = 0; - var encoded4 = 0; - if (base64[base64.length - 1] === '=') { - bufferLength--; - if (base64[base64.length - 2] === '=') { - bufferLength--; - } - } - var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer); - for (var i = 0; i < len; i += 4) { - encoded1 = lookup[base64.charCodeAt(i)]; - encoded2 = lookup[base64.charCodeAt(i + 1)]; - encoded3 = lookup[base64.charCodeAt(i + 2)]; - encoded4 = lookup[base64.charCodeAt(i + 3)]; - bytes[p++] = (encoded1 << 2) | (encoded2 >> 4); - bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2); - bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63); - } - return arraybuffer; - }; - return Base64Util; - }()); - egret.Base64Util = Base64Util; - __reflect(Base64Util.prototype, "egret.Base64Util"); -})(egret || (egret = {})); -/** - * @private - */ -var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -/** - * @private - */ -var lookup = new Uint8Array(256); -for (var i = 0; i < chars.length; i++) { - lookup[chars.charCodeAt(i)] = i; -} -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The Endian class contains values that denote the byte order used to represent multibyte numbers. - * The byte order is either bigEndian (most significant byte first) or littleEndian (least significant byte first). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Endian 类中包含一些值,它们表示用于表示多字节数字的字节顺序。 - * 字节顺序为 bigEndian(最高有效字节位于最前)或 littleEndian(最低有效字节位于最前)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var Endian = (function () { - function Endian() { - } - /** - * Indicates the least significant byte of the multibyte number appears first in the sequence of bytes. - * The hexadecimal number 0x12345678 has 4 bytes (2 hexadecimal digits per byte). The most significant byte is 0x12. The least significant byte is 0x78. (For the equivalent decimal number, 305419896, the most significant digit is 3, and the least significant digit is 6). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示多字节数字的最低有效字节位于字节序列的最前面。 - * 十六进制数字 0x12345678 包含 4 个字节(每个字节包含 2 个十六进制数字)。最高有效字节为 0x12。最低有效字节为 0x78。(对于等效的十进制数字 305419896,最高有效数字是 3,最低有效数字是 6)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Endian.LITTLE_ENDIAN = "littleEndian"; - /** - * Indicates the most significant byte of the multibyte number appears first in the sequence of bytes. - * The hexadecimal number 0x12345678 has 4 bytes (2 hexadecimal digits per byte). The most significant byte is 0x12. The least significant byte is 0x78. (For the equivalent decimal number, 305419896, the most significant digit is 3, and the least significant digit is 6). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示多字节数字的最高有效字节位于字节序列的最前面。 - * 十六进制数字 0x12345678 包含 4 个字节(每个字节包含 2 个十六进制数字)。最高有效字节为 0x12。最低有效字节为 0x78。(对于等效的十进制数字 305419896,最高有效数字是 3,最低有效数字是 6)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Endian.BIG_ENDIAN = "bigEndian"; - return Endian; - }()); - egret.Endian = Endian; - __reflect(Endian.prototype, "egret.Endian"); - /** - * The ByteArray class provides methods and attributes for optimized reading and writing as well as dealing with binary data. - * Note: The ByteArray class is applied to the advanced developers who need to access data at the byte layer. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/ByteArray.ts - * @language en_US - */ - /** - * ByteArray 类提供用于优化读取、写入以及处理二进制数据的方法和属性。 - * 注意:ByteArray 类适用于需要在字节层访问数据的高级开发人员。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/ByteArray.ts - * @language zh_CN - */ - var ByteArray = (function () { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - function ByteArray(buffer, bufferExtSize) { - if (bufferExtSize === void 0) { bufferExtSize = 0; } - /** - * @private - */ - this.bufferExtSize = 0; //Buffer expansion size - /** - * @private - */ - this.EOF_byte = -1; - /** - * @private - */ - this.EOF_code_point = -1; - if (bufferExtSize < 0) { - bufferExtSize = 0; - } - this.bufferExtSize = bufferExtSize; - var bytes, wpos = 0; - if (buffer) { - var uint8 = void 0; - if (buffer instanceof Uint8Array) { - uint8 = buffer; - wpos = buffer.length; - } - else { - wpos = buffer.byteLength; - uint8 = new Uint8Array(buffer); - } - if (bufferExtSize == 0) { - bytes = new Uint8Array(wpos); - } - else { - var multi = (wpos / bufferExtSize | 0) + 1; - bytes = new Uint8Array(multi * bufferExtSize); - } - bytes.set(uint8); - } - else { - bytes = new Uint8Array(bufferExtSize); - } - this.write_position = wpos; - this._position = 0; - this._bytes = bytes; - this.data = new DataView(bytes.buffer); - this.endian = Endian.BIG_ENDIAN; - } - Object.defineProperty(ByteArray.prototype, "endian", { - /** - * Changes or reads the byte order; egret.EndianConst.BIG_ENDIAN or egret.EndianConst.LITTLE_EndianConst. - * @default egret.EndianConst.BIG_ENDIAN - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 更改或读取数据的字节顺序;egret.EndianConst.BIG_ENDIAN 或 egret.EndianConst.LITTLE_ENDIAN。 - * @default egret.EndianConst.BIG_ENDIAN - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$endian == 0 /* LITTLE_ENDIAN */ ? Endian.LITTLE_ENDIAN : Endian.BIG_ENDIAN; - }, - set: function (value) { - this.$endian = value == Endian.LITTLE_ENDIAN ? 0 /* LITTLE_ENDIAN */ : 1 /* BIG_ENDIAN */; - }, - enumerable: true, - configurable: true - }); - /** - * @deprecated - * @version Egret 2.4 - * @platform Web,Native - */ - ByteArray.prototype.setArrayBuffer = function (buffer) { - }; - Object.defineProperty(ByteArray.prototype, "readAvailable", { - /** - * 可读的剩余字节数 - * - * @returns - * - * @memberOf ByteArray - */ - get: function () { - return this.write_position - this._position; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ByteArray.prototype, "buffer", { - get: function () { - return this.data.buffer.slice(0, this.write_position); - }, - /** - * @private - */ - set: function (value) { - var wpos = value.byteLength; - var uint8 = new Uint8Array(value); - var bufferExtSize = this.bufferExtSize; - var bytes; - if (bufferExtSize == 0) { - bytes = new Uint8Array(wpos); - } - else { - var multi = (wpos / bufferExtSize | 0) + 1; - bytes = new Uint8Array(multi * bufferExtSize); - } - bytes.set(uint8); - this.write_position = wpos; - this._bytes = bytes; - this.data = new DataView(bytes.buffer); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ByteArray.prototype, "rawBuffer", { - get: function () { - return this.data.buffer; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ByteArray.prototype, "bytes", { - get: function () { - return this._bytes; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ByteArray.prototype, "dataView", { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.data; - }, - /** - * @private - */ - set: function (value) { - this.buffer = value.buffer; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ByteArray.prototype, "bufferOffset", { - /** - * @private - */ - get: function () { - return this.data.byteOffset; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ByteArray.prototype, "position", { - /** - * The current position of the file pointer (in bytes) to move or return to the ByteArray object. The next time you start reading reading method call in this position, or will start writing in this position next time call a write method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将文件指针的当前位置(以字节为单位)移动或返回到 ByteArray 对象中。下一次调用读取方法时将在此位置开始读取,或者下一次调用写入方法时将在此位置开始写入。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._position; - }, - set: function (value) { - this._position = value; - if (value > this.write_position) { - this.write_position = value; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ByteArray.prototype, "length", { - /** - * The length of the ByteArray object (in bytes). - * If the length is set to be larger than the current length, the right-side zero padding byte array. - * If the length is set smaller than the current length, the byte array is truncated. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * ByteArray 对象的长度(以字节为单位)。 - * 如果将长度设置为大于当前长度的值,则用零填充字节数组的右侧。 - * 如果将长度设置为小于当前长度的值,将会截断该字节数组。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.write_position; - }, - set: function (value) { - this.write_position = value; - if (this.data.byteLength > value) { - this._position = value; - } - this._validateBuffer(value); - }, - enumerable: true, - configurable: true - }); - ByteArray.prototype._validateBuffer = function (value) { - if (this.data.byteLength < value) { - var be = this.bufferExtSize; - var tmp = void 0; - if (be == 0) { - tmp = new Uint8Array(value); - } - else { - var nLen = ((value / be >> 0) + 1) * be; - tmp = new Uint8Array(nLen); - } - tmp.set(this._bytes); - this._bytes = tmp; - this.data = new DataView(tmp.buffer); - } - }; - Object.defineProperty(ByteArray.prototype, "bytesAvailable", { - /** - * The number of bytes that can be read from the current position of the byte array to the end of the array data. - * When you access a ByteArray object, the bytesAvailable property in conjunction with the read methods each use to make sure you are reading valid data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 可从字节数组的当前位置到数组末尾读取的数据的字节数。 - * 每次访问 ByteArray 对象时,将 bytesAvailable 属性与读取方法结合使用,以确保读取有效的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.data.byteLength - this._position; - }, - enumerable: true, - configurable: true - }); - /** - * Clears the contents of the byte array and resets the length and position properties to 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 清除字节数组的内容,并将 length 和 position 属性重置为 0。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.clear = function () { - var buffer = new ArrayBuffer(this.bufferExtSize); - this.data = new DataView(buffer); - this._bytes = new Uint8Array(buffer); - this._position = 0; - this.write_position = 0; - }; - /** - * Read a Boolean value from the byte stream. Read a simple byte. If the byte is non-zero, it returns true; otherwise, it returns false. - * @return If the byte is non-zero, it returns true; otherwise, it returns false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取布尔值。读取单个字节,如果字节非零,则返回 true,否则返回 false - * @return 如果字节不为零,则返回 true,否则返回 false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readBoolean = function () { - if (this.validate(1 /* SIZE_OF_BOOLEAN */)) - return !!this._bytes[this.position++]; - }; - /** - * Read signed bytes from the byte stream. - * @return An integer ranging from -128 to 127 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取带符号的字节 - * @return 介于 -128 和 127 之间的整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readByte = function () { - if (this.validate(1 /* SIZE_OF_INT8 */)) - return this.data.getInt8(this.position++); - }; - /** - * Read data byte number specified by the length parameter from the byte stream. Starting from the position specified by offset, read bytes into the ByteArray object specified by the bytes parameter, and write bytes into the target ByteArray - * @param bytes ByteArray object that data is read into - * @param offset Offset (position) in bytes. Read data should be written from this position - * @param length Byte number to be read Default value 0 indicates reading all available data - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取 length 参数指定的数据字节数。从 offset 指定的位置开始,将字节读入 bytes 参数指定的 ByteArray 对象中,并将字节写入目标 ByteArray 中 - * @param bytes 要将数据读入的 ByteArray 对象 - * @param offset bytes 中的偏移(位置),应从该位置写入读取的数据 - * @param length 要读取的字节数。默认值 0 导致读取所有可用的数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readBytes = function (bytes, offset, length) { - if (offset === void 0) { offset = 0; } - if (length === void 0) { length = 0; } - if (!bytes) { - return; - } - var pos = this._position; - var available = this.write_position - pos; - if (available < 0) { - egret.$error(1025); - return; - } - if (length == 0) { - length = available; - } - else if (length > available) { - egret.$error(1025); - return; - } - var position = bytes._position; - bytes._position = 0; - bytes.validateBuffer(offset + length); - bytes._position = position; - bytes._bytes.set(this._bytes.subarray(pos, pos + length), offset); - this.position += length; - }; - /** - * Read an IEEE 754 double-precision (64 bit) floating point number from the byte stream - * @return Double-precision (64 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个 IEEE 754 双精度(64 位)浮点数 - * @return 双精度(64 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readDouble = function () { - if (this.validate(8 /* SIZE_OF_FLOAT64 */)) { - var value = this.data.getFloat64(this._position, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 8 /* SIZE_OF_FLOAT64 */; - return value; - } - }; - /** - * Read an IEEE 754 single-precision (32 bit) floating point number from the byte stream - * @return Single-precision (32 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个 IEEE 754 单精度(32 位)浮点数 - * @return 单精度(32 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readFloat = function () { - if (this.validate(4 /* SIZE_OF_FLOAT32 */)) { - var value = this.data.getFloat32(this._position, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 4 /* SIZE_OF_FLOAT32 */; - return value; - } - }; - /** - * Read a 32-bit signed integer from the byte stream. - * @return A 32-bit signed integer ranging from -2147483648 to 2147483647 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个带符号的 32 位整数 - * @return 介于 -2147483648 和 2147483647 之间的 32 位带符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readInt = function () { - if (this.validate(4 /* SIZE_OF_INT32 */)) { - var value = this.data.getInt32(this._position, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 4 /* SIZE_OF_INT32 */; - return value; - } - }; - /** - * Read a 16-bit signed integer from the byte stream. - * @return A 16-bit signed integer ranging from -32768 to 32767 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个带符号的 16 位整数 - * @return 介于 -32768 和 32767 之间的 16 位带符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readShort = function () { - if (this.validate(2 /* SIZE_OF_INT16 */)) { - var value = this.data.getInt16(this._position, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 2 /* SIZE_OF_INT16 */; - return value; - } - }; - /** - * Read unsigned bytes from the byte stream. - * @return A unsigned integer ranging from 0 to 255 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取无符号的字节 - * @return 介于 0 和 255 之间的无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readUnsignedByte = function () { - if (this.validate(1 /* SIZE_OF_UINT8 */)) - return this._bytes[this.position++]; - }; - /** - * Read a 32-bit unsigned integer from the byte stream. - * @return A 32-bit unsigned integer ranging from 0 to 4294967295 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个无符号的 32 位整数 - * @return 介于 0 和 4294967295 之间的 32 位无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readUnsignedInt = function () { - if (this.validate(4 /* SIZE_OF_UINT32 */)) { - var value = this.data.getUint32(this._position, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 4 /* SIZE_OF_UINT32 */; - return value; - } - }; - /** - * Read a 16-bit unsigned integer from the byte stream. - * @return A 16-bit unsigned integer ranging from 0 to 65535 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个无符号的 16 位整数 - * @return 介于 0 和 65535 之间的 16 位无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readUnsignedShort = function () { - if (this.validate(2 /* SIZE_OF_UINT16 */)) { - var value = this.data.getUint16(this._position, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 2 /* SIZE_OF_UINT16 */; - return value; - } - }; - /** - * Read a UTF-8 character string from the byte stream Assume that the prefix of the character string is a short unsigned integer (use byte to express length) - * @return UTF-8 character string - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个 UTF-8 字符串。假定字符串的前缀是无符号的短整型(以字节表示长度) - * @return UTF-8 编码的字符串 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readUTF = function () { - var length = this.readUnsignedShort(); - if (length > 0) { - return this.readUTFBytes(length); - } - else { - return ""; - } - }; - /** - * Read a UTF-8 byte sequence specified by the length parameter from the byte stream, and then return a character string - * @param Specify a short unsigned integer of the UTF-8 byte length - * @return A character string consists of UTF-8 bytes of the specified length - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个由 length 参数指定的 UTF-8 字节序列,并返回一个字符串 - * @param length 指明 UTF-8 字节长度的无符号短整型数 - * @return 由指定长度的 UTF-8 字节组成的字符串 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readUTFBytes = function (length) { - if (!this.validate(length)) { - return; - } - var data = this.data; - var bytes = new Uint8Array(data.buffer, data.byteOffset + this._position, length); - this.position += length; - return this.decodeUTF8(bytes); - }; - /** - * Write a Boolean value. A single byte is written according to the value parameter. If the value is true, write 1; if the value is false, write 0. - * @param value A Boolean value determining which byte is written. If the value is true, write 1; if the value is false, write 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 写入布尔值。根据 value 参数写入单个字节。如果为 true,则写入 1,如果为 false,则写入 0 - * @param value 确定写入哪个字节的布尔值。如果该参数为 true,则该方法写入 1;如果该参数为 false,则该方法写入 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeBoolean = function (value) { - this.validateBuffer(1 /* SIZE_OF_BOOLEAN */); - this._bytes[this.position++] = +value; - }; - /** - * Write a byte into the byte stream - * The low 8 bits of the parameter are used. The high 24 bits are ignored. - * @param value A 32-bit integer. The low 8 bits will be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个字节 - * 使用参数的低 8 位。忽略高 24 位 - * @param value 一个 32 位整数。低 8 位将被写入字节流 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeByte = function (value) { - this.validateBuffer(1 /* SIZE_OF_INT8 */); - this._bytes[this.position++] = value & 0xff; - }; - /** - * Write the byte sequence that includes length bytes in the specified byte array, bytes, (starting at the byte specified by offset, using a zero-based index), into the byte stream - * If the length parameter is omitted, the default length value 0 is used and the entire buffer starting at offset is written. If the offset parameter is also omitted, the entire buffer is written - * If the offset or length parameter is out of range, they are clamped to the beginning and end of the bytes array. - * @param bytes ByteArray Object - * @param offset A zero-based index specifying the position into the array to begin writing - * @param length An unsigned integer specifying how far into the buffer to write - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定字节数组 bytes(起始偏移量为 offset,从零开始的索引)中包含 length 个字节的字节序列写入字节流 - * 如果省略 length 参数,则使用默认长度 0;该方法将从 offset 开始写入整个缓冲区。如果还省略了 offset 参数,则写入整个缓冲区 - * 如果 offset 或 length 超出范围,它们将被锁定到 bytes 数组的开头和结尾 - * @param bytes ByteArray 对象 - * @param offset 从 0 开始的索引,表示在数组中开始写入的位置 - * @param length 一个无符号整数,表示在缓冲区中的写入范围 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeBytes = function (bytes, offset, length) { - if (offset === void 0) { offset = 0; } - if (length === void 0) { length = 0; } - var writeLength; - if (offset < 0) { - return; - } - if (length < 0) { - return; - } - else if (length == 0) { - writeLength = bytes.length - offset; - } - else { - writeLength = Math.min(bytes.length - offset, length); - } - if (writeLength > 0) { - this.validateBuffer(writeLength); - this._bytes.set(bytes._bytes.subarray(offset, offset + writeLength), this._position); - this.position = this._position + writeLength; - } - }; - /** - * Write an IEEE 754 double-precision (64 bit) floating point number into the byte stream - * @param value Double-precision (64 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个 IEEE 754 双精度(64 位)浮点数 - * @param value 双精度(64 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeDouble = function (value) { - this.validateBuffer(8 /* SIZE_OF_FLOAT64 */); - this.data.setFloat64(this._position, value, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 8 /* SIZE_OF_FLOAT64 */; - }; - /** - * Write an IEEE 754 single-precision (32 bit) floating point number into the byte stream - * @param value Single-precision (32 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个 IEEE 754 单精度(32 位)浮点数 - * @param value 单精度(32 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeFloat = function (value) { - this.validateBuffer(4 /* SIZE_OF_FLOAT32 */); - this.data.setFloat32(this._position, value, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 4 /* SIZE_OF_FLOAT32 */; - }; - /** - * Write a 32-bit signed integer into the byte stream - * @param value An integer to be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个带符号的 32 位整数 - * @param value 要写入字节流的整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeInt = function (value) { - this.validateBuffer(4 /* SIZE_OF_INT32 */); - this.data.setInt32(this._position, value, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 4 /* SIZE_OF_INT32 */; - }; - /** - * Write a 16-bit integer into the byte stream. The low 16 bits of the parameter are used. The high 16 bits are ignored. - * @param value A 32-bit integer. Its low 16 bits will be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个 16 位整数。使用参数的低 16 位。忽略高 16 位 - * @param value 32 位整数,该整数的低 16 位将被写入字节流 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeShort = function (value) { - this.validateBuffer(2 /* SIZE_OF_INT16 */); - this.data.setInt16(this._position, value, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 2 /* SIZE_OF_INT16 */; - }; - /** - * Write a 32-bit unsigned integer into the byte stream - * @param value An unsigned integer to be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个无符号的 32 位整数 - * @param value 要写入字节流的无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeUnsignedInt = function (value) { - this.validateBuffer(4 /* SIZE_OF_UINT32 */); - this.data.setUint32(this._position, value, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 4 /* SIZE_OF_UINT32 */; - }; - /** - * Write a 16-bit unsigned integer into the byte stream - * @param value An unsigned integer to be written into the byte stream - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个无符号的 16 位整数 - * @param value 要写入字节流的无符号整数 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeUnsignedShort = function (value) { - this.validateBuffer(2 /* SIZE_OF_UINT16 */); - this.data.setUint16(this._position, value, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 2 /* SIZE_OF_UINT16 */; - }; - /** - * Write a UTF-8 string into the byte stream. The length of the UTF-8 string in bytes is written first, as a 16-bit integer, followed by the bytes representing the characters of the string - * @param value Character string value to be written - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 UTF-8 字符串写入字节流。先写入以字节表示的 UTF-8 字符串长度(作为 16 位整数),然后写入表示字符串字符的字节 - * @param value 要写入的字符串值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeUTF = function (value) { - var utf8bytes = this.encodeUTF8(value); - var length = utf8bytes.length; - this.validateBuffer(2 /* SIZE_OF_UINT16 */ + length); - this.data.setUint16(this._position, length, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 2 /* SIZE_OF_UINT16 */; - this._writeUint8Array(utf8bytes, false); - }; - /** - * Write a UTF-8 string into the byte stream. Similar to the writeUTF() method, but the writeUTFBytes() method does not prefix the string with a 16-bit length word - * @param value Character string value to be written - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 UTF-8 字符串写入字节流。类似于 writeUTF() 方法,但 writeUTFBytes() 不使用 16 位长度的词为字符串添加前缀 - * @param value 要写入的字符串值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeUTFBytes = function (value) { - this._writeUint8Array(this.encodeUTF8(value)); - }; - /** - * - * @returns - * @version Egret 2.4 - * @platform Web,Native - */ - ByteArray.prototype.toString = function () { - return "[ByteArray] length:" + this.length + ", bytesAvailable:" + this.bytesAvailable; - }; - /** - * @private - * 将 Uint8Array 写入字节流 - * @param bytes 要写入的Uint8Array - * @param validateBuffer - */ - ByteArray.prototype._writeUint8Array = function (bytes, validateBuffer) { - if (validateBuffer === void 0) { validateBuffer = true; } - var pos = this._position; - var npos = pos + bytes.length; - if (validateBuffer) { - this.validateBuffer(npos); - } - this.bytes.set(bytes, pos); - this.position = npos; - }; - /** - * @param len - * @returns - * @version Egret 2.4 - * @platform Web,Native - * @private - */ - ByteArray.prototype.validate = function (len) { - var bl = this._bytes.length; - if (bl > 0 && this._position + len <= bl) { - return true; - } - else { - egret.$error(1025); - } - }; - /**********************/ - /* PRIVATE METHODS */ - /**********************/ - /** - * @private - * @param len - * @param needReplace - */ - ByteArray.prototype.validateBuffer = function (len) { - this.write_position = len > this.write_position ? len : this.write_position; - len += this._position; - this._validateBuffer(len); - }; - /** - * @private - * UTF-8 Encoding/Decoding - */ - ByteArray.prototype.encodeUTF8 = function (str) { - var pos = 0; - var codePoints = this.stringToCodePoints(str); - var outputBytes = []; - while (codePoints.length > pos) { - var code_point = codePoints[pos++]; - if (this.inRange(code_point, 0xD800, 0xDFFF)) { - this.encoderError(code_point); - } - else if (this.inRange(code_point, 0x0000, 0x007f)) { - outputBytes.push(code_point); - } - else { - var count = void 0, offset = void 0; - if (this.inRange(code_point, 0x0080, 0x07FF)) { - count = 1; - offset = 0xC0; - } - else if (this.inRange(code_point, 0x0800, 0xFFFF)) { - count = 2; - offset = 0xE0; - } - else if (this.inRange(code_point, 0x10000, 0x10FFFF)) { - count = 3; - offset = 0xF0; - } - outputBytes.push(this.div(code_point, Math.pow(64, count)) + offset); - while (count > 0) { - var temp = this.div(code_point, Math.pow(64, count - 1)); - outputBytes.push(0x80 + (temp % 64)); - count -= 1; - } - } - } - return new Uint8Array(outputBytes); - }; - /** - * @private - * - * @param data - * @returns - */ - ByteArray.prototype.decodeUTF8 = function (data) { - var fatal = false; - var pos = 0; - var result = ""; - var code_point; - var utf8_code_point = 0; - var utf8_bytes_needed = 0; - var utf8_bytes_seen = 0; - var utf8_lower_boundary = 0; - while (data.length > pos) { - var _byte = data[pos++]; - if (_byte == this.EOF_byte) { - if (utf8_bytes_needed != 0) { - code_point = this.decoderError(fatal); - } - else { - code_point = this.EOF_code_point; - } - } - else { - if (utf8_bytes_needed == 0) { - if (this.inRange(_byte, 0x00, 0x7F)) { - code_point = _byte; - } - else { - if (this.inRange(_byte, 0xC2, 0xDF)) { - utf8_bytes_needed = 1; - utf8_lower_boundary = 0x80; - utf8_code_point = _byte - 0xC0; - } - else if (this.inRange(_byte, 0xE0, 0xEF)) { - utf8_bytes_needed = 2; - utf8_lower_boundary = 0x800; - utf8_code_point = _byte - 0xE0; - } - else if (this.inRange(_byte, 0xF0, 0xF4)) { - utf8_bytes_needed = 3; - utf8_lower_boundary = 0x10000; - utf8_code_point = _byte - 0xF0; - } - else { - this.decoderError(fatal); - } - utf8_code_point = utf8_code_point * Math.pow(64, utf8_bytes_needed); - code_point = null; - } - } - else if (!this.inRange(_byte, 0x80, 0xBF)) { - utf8_code_point = 0; - utf8_bytes_needed = 0; - utf8_bytes_seen = 0; - utf8_lower_boundary = 0; - pos--; - code_point = this.decoderError(fatal, _byte); - } - else { - utf8_bytes_seen += 1; - utf8_code_point = utf8_code_point + (_byte - 0x80) * Math.pow(64, utf8_bytes_needed - utf8_bytes_seen); - if (utf8_bytes_seen !== utf8_bytes_needed) { - code_point = null; - } - else { - var cp = utf8_code_point; - var lower_boundary = utf8_lower_boundary; - utf8_code_point = 0; - utf8_bytes_needed = 0; - utf8_bytes_seen = 0; - utf8_lower_boundary = 0; - if (this.inRange(cp, lower_boundary, 0x10FFFF) && !this.inRange(cp, 0xD800, 0xDFFF)) { - code_point = cp; - } - else { - code_point = this.decoderError(fatal, _byte); - } - } - } - } - //Decode string - if (code_point !== null && code_point !== this.EOF_code_point) { - if (code_point <= 0xFFFF) { - if (code_point > 0) - result += String.fromCharCode(code_point); - } - else { - code_point -= 0x10000; - result += String.fromCharCode(0xD800 + ((code_point >> 10) & 0x3ff)); - result += String.fromCharCode(0xDC00 + (code_point & 0x3ff)); - } - } - } - return result; - }; - /** - * @private - * - * @param code_point - */ - ByteArray.prototype.encoderError = function (code_point) { - egret.$error(1026, code_point); - }; - /** - * @private - * - * @param fatal - * @param opt_code_point - * @returns - */ - ByteArray.prototype.decoderError = function (fatal, opt_code_point) { - if (fatal) { - egret.$error(1027); - } - return opt_code_point || 0xFFFD; - }; - /** - * @private - * - * @param a - * @param min - * @param max - */ - ByteArray.prototype.inRange = function (a, min, max) { - return min <= a && a <= max; - }; - /** - * @private - * - * @param n - * @param d - */ - ByteArray.prototype.div = function (n, d) { - return Math.floor(n / d); - }; - /** - * @private - * - * @param string - */ - ByteArray.prototype.stringToCodePoints = function (string) { - /** @type {Array.} */ - var cps = []; - // Based on http://www.w3.org/TR/WebIDL/#idl-DOMString - var i = 0, n = string.length; - while (i < string.length) { - var c = string.charCodeAt(i); - if (!this.inRange(c, 0xD800, 0xDFFF)) { - cps.push(c); - } - else if (this.inRange(c, 0xDC00, 0xDFFF)) { - cps.push(0xFFFD); - } - else { - if (i == n - 1) { - cps.push(0xFFFD); - } - else { - var d = string.charCodeAt(i + 1); - if (this.inRange(d, 0xDC00, 0xDFFF)) { - var a = c & 0x3FF; - var b = d & 0x3FF; - i += 1; - cps.push(0x10000 + (a << 10) + b); - } - else { - cps.push(0xFFFD); - } - } - } - i += 1; - } - return cps; - }; - return ByteArray; - }()); - egret.ByteArray = ByteArray; - __reflect(ByteArray.prototype, "egret.ByteArray"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The BitmapFillMode class defines the image fill mode of Bitmap. - * The BitmapFillMode class defines a pattern enumeration for adjusting size. These patterns determine how Bitmap fill the size designated by the layout system. - * @see http://edn.egret.com/cn/docs/page/134 Texture filling way - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BitmapFillMode.ts - * @language en_US - */ - /** - * BitmapFillMode 类定义Bitmap的图像填充方式。 - * BitmapFillMode 类定义了调整大小模式的一个枚举,这些模式确定 Bitmap 如何填充由布局系统指定的尺寸。 - * @see http://edn.egret.com/cn/docs/page/134 纹理的填充方式 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BitmapFillMode.ts - * @language zh_CN - */ - egret.BitmapFillMode = { - /** - * Repeat the bitmap to fill area. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 重复位图以填充区域。 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - REPEAT: "repeat", - /** - * Scale bitmap fill to fill area. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 位图填充拉伸以填充区域。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - SCALE: "scale", - /** - * The bitmap ends at the edge of the region. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在区域的边缘处截断不显示位图。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - CLIP: "clip" - }; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Registers the runtime class information for a class.This method adds some strings which represent the class name or - * some interface names to the class definition. After the registration,you can use egret.is() method to do the type checking - * for the instance of this class.
    - * Note:If you use the TypeScript programming language, the egret command line tool will automatically generate the registration code line. - * You don't need to manually call this method. - * - * @example the following code shows how to register the runtime class information for the EventDispatcher class and do the type checking: - *
    -     *      egret.registerClass(egret.EventDispatcher,"egret.EventDispatcher",["egret.IEventDispatcher"]);
    -     *      let dispatcher = new egret.EventDispatcher();
    -     *      egret.log(egret.is(dispatcher, "egret.IEventDispatcher"));  //true。
    -     *      egret.log(egret.is(dispatcher, "egret.EventDispatcher"));   //true。
    -     *      egret.log(egret.is(dispatcher, "egret.Bitmap"));   //false。
    -     * 
    - * @param classDefinition the class definition to be registered. - * @param className a unique identification string of the specific class - * @param interfaceNames a list of unique identification string of the specific interfaces. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 为一个类定义注册运行时类信息,用此方法往类定义上注册它自身以及所有接口对应的字符串。 - * 在运行时,这个类的实例将可以使用 egret.is() 方法传入一个字符串来判断实例类型。 - * @example 以下代码演示了如何为EventDispatcher类注册运行时类信息并判断类型: - *
    -     *      //为egret.EventDispatcher类注册运行时类信息,由于它实现了IEventDispatcher接口,这里应同时传入接口名对应的字符串。
    -     *      egret.registerClass(egret.EventDispatcher,"egret.EventDispatcher",["egret.IEventDispatcher"]);
    -     *      let dispatcher = new egret.EventDispatcher();
    -     *      egret.log(egret.is(dispatcher, "egret.IEventDispatcher"));  //true。
    -     *      egret.log(egret.is(dispatcher, "egret.EventDispatcher"));   //true。
    -     *      egret.log(egret.is(dispatcher, "egret.Bitmap"));   //false。
    -     * 
    - * 注意:若您使用 TypeScript 来编写程序,egret 命令行会自动帮您生成类信息注册代码行到最终的 Javascript 文件中。因此您不需要手动调用此方法。 - * - * @param classDefinition 要注册的类定义。 - * @param className 要注册的类名。 - * @param interfaceNames 要注册的类所实现的接口名列表。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function registerClass(classDefinition, className, interfaceNames) { - if (true) { - if (!classDefinition) { - egret.$error(1003, "classDefinition"); - } - if (!classDefinition.prototype) { - egret.$error(1012, "classDefinition"); - } - if (className === void 0) { - egret.$error(1003, "className"); - } - } - var prototype = classDefinition.prototype; - prototype.__class__ = className; - var types = [className]; - if (interfaceNames) { - types = types.concat(interfaceNames); - } - var superTypes = prototype.__types__; - if (prototype.__types__) { - var length_8 = superTypes.length; - for (var i = 0; i < length_8; i++) { - var name_1 = superTypes[i]; - if (types.indexOf(name_1) == -1) { - types.push(name_1); - } - } - } - prototype.__types__ = types; - } - egret.registerClass = registerClass; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The Stage class represents the main drawing area.The Stage object is not globally accessible. You need to access - * it through the stage property of a DisplayObject instance.
    - * The Stage class has several ancestor classes — Sprite, DisplayObject, and EventDispatcher — from which it inherits - * properties and methods. Many of these properties and methods are inapplicable to Stage objects. - * @event egret.Event.RESIZE Dispatched when the stageWidth or stageHeight property of the Stage object is changed. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Stage.ts - * @language en_US - */ - /** - * Stage 类代表主绘图区。 - * 可以利用 DisplayObject 实例的 stage 属性进行访问。
    - * Stage 类具有多个祖代类: Sprite、DisplayObject 和 EventDispatcher,属性和方法便是从这些类继承而来的。 - * 从这些继承的许多属性和方法不适用于 Stage 对象。 - * @event egret.Event.RESIZE 当stageWidth或stageHeight属性发生改变时调度 - * @event egret.Event.DEACTIVATE 当stage失去焦点后调度 - * @event egret.Event.ACTIVATE 当stage获得焦点后调度 - * - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Stage.ts - * @language zh_CN - */ - var Stage = (function (_super) { - __extends(Stage, _super); - /** - * @private - * Stage不许允许自行实例化 - * @version Egret 2.4 - * @platform Web,Native - */ - function Stage() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.$stageWidth = 0; - /** - * @private - */ - _this.$stageHeight = 0; - _this.$scaleMode = egret.StageScaleMode.SHOW_ALL; - _this.$orientation = egret.OrientationMode.AUTO; - _this.$maxTouches = 99; - _this.$stage = _this; - _this.$nestLevel = 1; - return _this; - } - Stage.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(13 /* STAGE */); - }; - Object.defineProperty(Stage.prototype, "frameRate", { - /** - * Gets and sets the frame rate of the stage. The frame rate is defined as frames per second. Valid range for the - * frame rate is from 0.01 to 1000 frames per second.
    - * Note: setting the frameRate property of one Stage object changes the frame rate for all Stage objects - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取并设置舞台的帧速率。帧速率是指每秒显示的帧数。帧速率的有效范围为每秒 0.01 到 60 个帧。
    - * 注意: 修改任何一个Stage的frameRate属性都会同步修改其他Stage的帧率。 - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return egret.ticker.$frameRate; - }, - set: function (value) { - egret.ticker.$setFrameRate(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Stage.prototype, "stageWidth", { - /** - * Indicates the width of the stage, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 舞台的当前宽度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$stageWidth; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Stage.prototype, "stageHeight", { - /** - * Indicates the height of the stage, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 舞台的当前高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$stageHeight; - }, - enumerable: true, - configurable: true - }); - /** - * After you call the invalidate() method, when the display list is next rendered, the Egret runtime sends a render - * event to each display object that has registered to listen for the render event. You must call the invalidate() - * method each time you want the Egret runtime to send render events. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 调用 invalidate() 方法后,在显示列表下次呈现时,Egret 会向每个已注册侦听 Event.RENDER 事件的显示对象发送一个 Event.RENDER 事件。 - * 每次您希望 Egret 发送 Event.RENDER 事件时,都必须调用 invalidate() 方法。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Stage.prototype.invalidate = function () { - egret.sys.$invalidateRenderFlag = true; - }; - /** - * @deprecated - */ - Stage.prototype.registerImplementation = function (interfaceName, instance) { - egret.registerImplementation(interfaceName, instance); - }; - /** - * @deprecated - */ - Stage.prototype.getImplementation = function (interfaceName) { - return egret.getImplementation(interfaceName); - }; - Object.defineProperty(Stage.prototype, "scaleMode", { - /** - * A StageScaleMode class that specifies which scale mode to use. The following are valid values:
    - *
      - *
    • StageScaleMode.EXACT_FIT -- The entire application be visible in the specified area without trying to preserve the original aspect ratio. Distortion can occur, the application may be stretched or compressed.
    • - *
    • StageScaleMode.SHOW_ALL -- The entire application is visible in the specified area without distortion while maintaining the application of the original aspect ratio. Applications may display border.
    • - *
    • StageScaleMode.NO_SCALE -- The size of the entire application is fixed, so that even if the size of the player window changes, it remains unchanged. If the player window is smaller than the content, it may do some trimming.
    • - *
    • StageScaleMode.NO_BORDER -- Keep the original aspect ratio scaling application content, after scaling a narrow direction of application content to fill the viewport players on both sides in the other direction may exceed the viewport and the player is cut.
    • - *
    • StageScaleMode.FIXED_WIDTH -- Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant width, height may change.
    • - *
    • StageScaleMode.FIXED_HEIGHT -- Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant height, width may change.
    • - *
    - * @default egret.StageScaleMode.SHOW_ALL - * @language en_US - */ - /** - * 一个 StageScaleMode 类中指定要使用哪种缩放模式的值。以下是有效值:
    - *
      - *
    • StageScaleMode.EXACT_FIT -- 整个应用程序在指定区域中可见,但不尝试保持原始高宽比。可能会发生扭曲,应用程序可能会拉伸或压缩显示。
    • - *
    • StageScaleMode.SHOW_ALL -- 整个应用程序在指定区域中可见,且不发生扭曲,同时保持应用程序的原始高宽比。应用程序的可能会显示边框。
    • - *
    • StageScaleMode.NO_SCALE -- 整个应用程序的大小固定,因此,即使播放器窗口的大小更改,它也会保持不变。如果播放器窗口比内容小,则可能进行一些裁切。
    • - *
    • StageScaleMode.NO_BORDER -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较窄方向填满播放器视口,另一个方向的两侧可能会超出播放器视口而被裁切。
    • - *
    • StageScaleMode.FIXED_WIDTH -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始宽度不变,高度可能会改变。
    • - *
    • StageScaleMode.FIXED_HEIGHT -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始高度不变,宽度可能会改变。
    • - *
    - * @default egret.StageScaleMode.SHOW_ALL - * @language zh_CN - */ - get: function () { - return this.$scaleMode; - }, - set: function (value) { - if (this.$scaleMode == value) { - return; - } - this.$scaleMode = value; - this.$screen.updateScreenSize(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Stage.prototype, "orientation", { - /** - * Horizontal and vertical screen display screen, can only be set under the current Native in the configuration file. A egret.OrientationMode class that specifies which display mode to use. The following are valid values:
    - *
      - *
    • egret.OrientationMode.AUTO -- Always follow the direction of application display screen, always guaranteed by the look down.
    • - *
    • egret.OrientationMode.PORTRAIT -- Applications remain portrait mode, namely horizontal screen look, the screen from left to right.
    • - *
    • egret.OrientationMode.LANDSCAPE -- Applications remain horizontal screen mode, namely vertical screen, the screen from right to left.
    • - *
    • egret.OrientationMode.LANDSCAPE_FLIPPED -- Applications remain horizontal screen mode, namely vertical screen, the screen from left to right.
    • - *
    - * @platform Web - * @version 2.4 - * @language en_US - */ - /** - * 屏幕横竖屏显示方式,目前 Native 下只能在配置文件里设置。一个 egret.OrientationMode 类中指定要使用哪种显示方式。以下是有效值:
    - *
      - *
    • egret.OrientationMode.AUTO -- 应用始终跟随屏幕的方向显示,始终保证由上往下看。
    • - *
    • egret.OrientationMode.PORTRAIT -- 应用始终保持竖屏模式,即横屏看时,屏幕由左往右看。
    • - *
    • egret.OrientationMode.LANDSCAPE -- 应用始终保持横屏模式,即竖屏看时,屏幕显示由右往左。
    • - *
    • egret.OrientationMode.LANDSCAPE_FLIPPED -- 应用始终保持横屏模式,即竖屏看时,屏幕显示由左往右。
    • - *
    - * @platform Web - * @version 2.4 - * @language zh_CN - */ - get: function () { - return this.$orientation; - }, - set: function (value) { - if (this.$orientation == value) { - return; - } - this.$orientation = value; - this.$screen.updateScreenSize(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Stage.prototype, "textureScaleFactor", { - /** - * Draw texture zoom ratio - * @default 1 - * @language en_US - */ - /** - * 绘制纹理的缩放比率,默认值为1 - * @default 1 - * @language zh_CN - */ - get: function () { - return egret.$TextureScaleFactor; - }, - set: function (value) { - egret.$TextureScaleFactor = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Stage.prototype, "maxTouches", { - /** - * Set the number of screens can simultaneously touch. Above this amount will not be triggered in response. - * @default 99 - * @language en_US - */ - /** - * 设置屏幕同时可以触摸的数量。高于这个数量将不会被触发响应。 - * @default 99 - * @language zh_CN - */ - get: function () { - return this.$maxTouches; - }, - set: function (value) { - if (this.$maxTouches == value) { - return; - } - this.$maxTouches = value; - this.$screen.updateMaxTouches(); - }, - enumerable: true, - configurable: true - }); - /** - * Set resolution size - * @param width width - * @param height height - * @version Egret 2.5.5 - * @platform Web,Native - * @language en_US - */ - /** - * 设置分辨率尺寸 - * @param width 宽度 - * @param height 高度 - * @version Egret 2.5.5 - * @platform Web,Native - * @language zh_CN - */ - Stage.prototype.setContentSize = function (width, height) { - this.$screen.setContentSize(width, height); - }; - return Stage; - }(egret.DisplayObjectContainer)); - egret.Stage = Stage; - __reflect(Stage.prototype, "egret.Stage"); - if (true) { - egret.$markCannotUse(Stage, "alpha", 1); - egret.$markCannotUse(Stage, "visible", true); - egret.$markCannotUse(Stage, "x", 0); - egret.$markCannotUse(Stage, "y", 0); - egret.$markCannotUse(Stage, "scaleX", 1); - egret.$markCannotUse(Stage, "scaleY", 1); - egret.$markCannotUse(Stage, "rotation", 0); - egret.$markCannotUse(Stage, "cacheAsBitmap", false); - egret.$markCannotUse(Stage, "scrollRect", null); - egret.$markCannotUse(Stage, "filters", null); - egret.$markCannotUse(Stage, "blendMode", null); - egret.$markCannotUse(Stage, "touchEnabled", true); - egret.$markCannotUse(Stage, "matrix", null); - } -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Logger is an entrance for the log processing namespace of the engine - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Logger是引擎的日志处理模块入口 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var Logger = (function () { - function Logger() { - } - Object.defineProperty(Logger, "logLevel", { - /** - * Set the current need to open the log level. Grade level are: ALL - * This feature is only in DEBUG mode to take effect.
    - *
      - *
    • Logger.ALL - all levels of log can be printed out. - *
    • Logger.DEBUG - print debug, info, log, warn, error. - *
    • Logger.INFO - print info, log, warn, error. - *
    • Logger.WARN - can print warn, error. - *
    • Logger.ERROR - You can print error. - *
    • Logger.OFF - all closed. - * - *param LogType from this level to start printing. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置当前需要开启的log级别。级别等级分别为:ALL < DEBUG < INFO < WARN < ERROR < OFF
      - * 此功能只在 DEBUG 模式下才生效。
      - *
        - *
      • Logger.ALL -- 所有等级的log都可以打印出来。
      • - *
      • Logger.DEBUG -- 可以打印debug、info、log、warn、error。
      • - *
      • Logger.INFO -- 可以打印info、log、warn、error。
      • - *
      • Logger.WARN -- 可以打印warn、error。
      • - *
      • Logger.ERROR -- 可以打印error。
      • - *
      • Logger.OFF -- 全部关闭。
      • - *
      - * @param logType 从这个等级开始打印。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - set: function (logType) { - }, - enumerable: true, - configurable: true - }); - /** - * open all - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 全开 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Logger.ALL = "all"; - /** - * level: DEBUG - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 DEBUG - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Logger.DEBUG = "debug"; - /** - * level: INFO - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 INFO - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Logger.INFO = "info"; - /** - * level: WARN - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 WARN - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Logger.WARN = "warn"; - /** - * level: ERROR - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 ERROR - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Logger.ERROR = "error"; - /** - * close all - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 全关 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Logger.OFF = "off"; - return Logger; - }()); - egret.Logger = Logger; - __reflect(Logger.prototype, "egret.Logger"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - var NumberUtils = (function () { - function NumberUtils() { - } - /** - * Judge whether it is a numerical value - * @param value Parameter that needs to be judged - * @returns - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 判断是否是数值 - * @param value 需要判断的参数 - * @returns - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - NumberUtils.isNumber = function (value) { - return typeof (value) === "number" && !isNaN(value); - }; - /** - * Obtain the approximate sin value of the corresponding angle value - * @param value {number} Angle value - * @returns {number} sin value - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 得到对应角度值的sin近似值 - * @param value {number} 角度值 - * @returns {number} sin值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - NumberUtils.sin = function (value) { - var valueFloor = Math.floor(value); - var valueCeil = valueFloor + 1; - var resultFloor = NumberUtils.sinInt(valueFloor); - if (valueFloor == value) { - return resultFloor; - } - var resultCeil = NumberUtils.sinInt(valueCeil); - return (value - valueFloor) * resultCeil + (valueCeil - value) * resultFloor; - }; - /** - * @private - * - * @param value - * @returns - */ - NumberUtils.sinInt = function (value) { - value = value % 360; - if (value < 0) { - value += 360; - } - return egret_sin_map[value]; - }; - /** - * Obtain the approximate cos value of the corresponding angle value - * @param value {number} Angle value - * @returns {number} cos value - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 得到对应角度值的cos近似值 - * @param value {number} 角度值 - * @returns {number} cos值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - NumberUtils.cos = function (value) { - var valueFloor = Math.floor(value); - var valueCeil = valueFloor + 1; - var resultFloor = NumberUtils.cosInt(valueFloor); - if (valueFloor == value) { - return resultFloor; - } - var resultCeil = NumberUtils.cosInt(valueCeil); - return (value - valueFloor) * resultCeil + (valueCeil - value) * resultFloor; - }; - /** - * @private - * - * @param value - * @returns - */ - NumberUtils.cosInt = function (value) { - value = value % 360; - if (value < 0) { - value += 360; - } - return egret_cos_map[value]; - }; - return NumberUtils; - }()); - egret.NumberUtils = NumberUtils; - __reflect(NumberUtils.prototype, "egret.NumberUtils"); -})(egret || (egret = {})); -/** - * @private - */ -var egret_sin_map = {}; -/** - * @private - */ -var egret_cos_map = {}; -/** - * @private - */ -var DEG_TO_RAD = Math.PI / 180; -for (var NumberUtils_i = 0; NumberUtils_i < 360; NumberUtils_i++) { - egret_sin_map[NumberUtils_i] = Math.sin(NumberUtils_i * DEG_TO_RAD); - egret_cos_map[NumberUtils_i] = Math.cos(NumberUtils_i * DEG_TO_RAD); -} -egret_sin_map[90] = 1; -egret_cos_map[90] = 0; -egret_sin_map[180] = 0; -egret_cos_map[180] = -1; -egret_sin_map[270] = -1; -egret_cos_map[270] = 0; -//对未提供bind的浏览器实现bind机制 -if (!Function.prototype.bind) { - Function.prototype.bind = function (oThis) { - if (typeof this !== "function") { - // closest thing possible to the ECMAScript 5 internal IsCallable function - egret.$error(1029); - } - var aArgs = Array.prototype.slice.call(arguments, 1), fToBind = this, fNOP = function () { - }, fBound = function () { - return fToBind.apply(this instanceof fNOP && oThis - ? this - : oThis, aArgs.concat(Array.prototype.slice.call(arguments))); - }; - fNOP.prototype = this.prototype; - fBound.prototype = new fNOP(); - return fBound; - }; -} -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The Timer class is the interface to timers, which let you run code on a specified time sequence. Use the start() - * method to start a timer. Add an event listener for the timer event to set up code to be run on the timer interval.
      - * You can create Timer objects to run once or repeat at specified intervals to execute code on a schedule. Depending - * on the framerate or the runtime environment (available memory and other factors), the runtime may dispatchEvent events at - * slightly offset intervals. - * @see egret.TimerEvent - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Timer.ts - * @language en_US - */ - /** - * Timer 类是计时器的接口,它使您能按指定的时间序列运行代码。 - * 使用 start() 方法来启动计时器。为 timer 事件添加事件侦听器,以便将代码设置为按计时器间隔运行。 - * 可以创建 Timer 对象以运行一次或按指定间隔重复运行,从而按计划执行代码。 - * 根据 Egret 的帧速率或运行时环境(可用内存和其他因素),运行时调度事件的间隔可能稍有不同。 - * @see egret.TimerEvent - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Timer.ts - * @language zh_CN - */ - var Timer = (function (_super) { - __extends(Timer, _super); - /** - * Constructs a new Timer object with the specified delay and repeatCount states. - * @param delay The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended. - * Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems. - * @param repeatCount Specifies the number of repetitions. If zero, the timer repeats indefinitely.If nonzero, - * the timer runs the specified number of times and then stops. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的 delay 和 repeatCount 状态构造新的 Timer 对象。 - * @param delay 计时器事件间的延迟(以毫秒为单位)。建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。 - * @param repeatCount 指定重复次数。如果为零,则计时器将持续不断重复运行。如果不为 0,则将运行计时器,运行次数为指定的次数,然后停止。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Timer(delay, repeatCount) { - if (repeatCount === void 0) { repeatCount = 0; } - var _this = _super.call(this) || this; - /** - * @private - */ - _this._delay = 0; - /** - * @private - */ - _this._currentCount = 0; - /** - * @private - */ - _this._running = false; - /** - * @private - */ - _this.updateInterval = 1000; - /** - * @private - */ - _this.lastCount = 1000; - /** - * @private - */ - _this.lastTimeStamp = 0; - _this.delay = delay; - _this.repeatCount = +repeatCount | 0; - return _this; - } - Object.defineProperty(Timer.prototype, "delay", { - /** - * The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended.
      - * Note: Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计时器事件间的延迟(以毫秒为单位)。如果在计时器正在运行时设置延迟间隔,则计时器将按相同的 repeatCount 迭代重新启动。
      - * 注意:建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._delay; - }, - set: function (value) { - if (value < 1) { - value = 1; - } - if (this._delay == value) { - return; - } - this._delay = value; - this.lastCount = this.updateInterval = Math.round(60 * value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Timer.prototype, "currentCount", { - /** - * The total number of times the timer has fired since it started at zero. If the timer has been reset, only the fires since the reset are counted. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计时器从 0 开始后触发的总次数。如果已重置了计时器,则只会计入重置后的触发次数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._currentCount; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Timer.prototype, "running", { - /** - * The timer's current state; true if the timer is running, otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计时器的当前状态;如果计时器正在运行,则为 true,否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._running; - }, - enumerable: true, - configurable: true - }); - /** - * Stops the timer, if it is running, and sets the currentCount property back to 0, like the reset button of a stopwatch. - * Then, when start() is called, the timer instance runs for the specified number of repetitions, as set by the repeatCount value. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果计时器正在运行,则停止计时器,并将 currentCount 属性设回为 0,这类似于秒表的重置按钮。然后,在调用 start() 后,将运行计时器实例,运行次数为指定的重复次数(由 repeatCount 值设置)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Timer.prototype.reset = function () { - this.stop(); - this._currentCount = 0; - }; - /** - * Starts the timer, if it is not already running. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果计时器尚未运行,则启动计时器。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Timer.prototype.start = function () { - if (this._running) - return; - this.lastCount = this.updateInterval; - this.lastTimeStamp = egret.getTimer(); - egret.ticker.$startTick(this.$update, this); - this._running = true; - }; - /** - * Stops the timer. When start() is called after stop(), the timer instance runs for the remaining number of - * repetitions, as set by the repeatCount property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 停止计时器。如果在调用 stop() 后调用 start(),则将继续运行计时器实例,运行次数为剩余的 重复次数(由 repeatCount 属性设置)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Timer.prototype.stop = function () { - if (!this._running) - return; - egret.stopTick(this.$update, this); - this._running = false; - }; - /** - * @private - * Ticker以60FPS频率刷新此方法 - */ - Timer.prototype.$update = function (timeStamp) { - var deltaTime = timeStamp - this.lastTimeStamp; - if (deltaTime >= this._delay) { - this.lastCount = this.updateInterval; - } - else { - this.lastCount -= 1000; - if (this.lastCount > 0) { - return false; - } - this.lastCount += this.updateInterval; - } - this.lastTimeStamp = timeStamp; - this._currentCount++; - var complete = (this.repeatCount > 0 && this._currentCount >= this.repeatCount); - egret.TimerEvent.dispatchTimerEvent(this, egret.TimerEvent.TIMER); - if (complete) { - this.stop(); - egret.TimerEvent.dispatchTimerEvent(this, egret.TimerEvent.TIMER_COMPLETE); - } - return false; - }; - return Timer; - }(egret.EventDispatcher)); - egret.Timer = Timer; - __reflect(Timer.prototype, "egret.Timer"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - */ - egret.$callLaterFunctionList = []; - /** - * @private - */ - egret.$callLaterThisList = []; - /** - * @private - */ - egret.$callLaterArgsList = []; - /** - * Delay the function to run unless screen is redrawn. - * @param method {Function} The function to be delayed to run - * @param thisObject {any} this reference of callback function - * @param ...args {any} Function parameter list - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/callLater.ts - * @language en_US - */ - /** - * 延迟函数到屏幕重绘前执行。 - * @param method {Function} 要延迟执行的函数 - * @param thisObject {any} 回调函数的this引用 - * @param ...args {any} 函数参数列表 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/callLater.ts - * @language zh_CN - */ - function callLater(method, thisObject) { - var args = []; - for (var _i = 2; _i < arguments.length; _i++) { - args[_i - 2] = arguments[_i]; - } - egret.$callLaterFunctionList.push(method); - egret.$callLaterThisList.push(thisObject); - egret.$callLaterArgsList.push(args); - } - egret.callLater = callLater; - /** - * @private - */ - egret.$callAsyncFunctionList = []; - /** - * @private - */ - egret.$callAsyncThisList = []; - /** - * @private - */ - egret.$callAsyncArgsList = []; - /** - * 异步调用函数 - * @param method {Function} 要异步调用的函数 - * @param thisObject {any} 函数的this引用 - * @param ...args {any} 函数参数列表 - * @private - */ - function $callAsync(method, thisObject) { - var args = []; - for (var _i = 2; _i < arguments.length; _i++) { - args[_i - 2] = arguments[_i]; - } - egret.$callAsyncFunctionList.push(method); - egret.$callAsyncThisList.push(thisObject); - egret.$callAsyncArgsList.push(args); - } - egret.$callAsync = $callAsync; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -//function __extends(d, b) { -// for (let p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; -// function __() { -// this.constructor = d; -// } -// -// __.prototype = b.prototype; -// d.prototype = new __(); -//} -var egret; -(function (egret) { - /** - * Call setter properties of the parent class, instead of the other writing languages, such as super.alpha = 1; - * @param currentClass The current class class name, non-string - * @param thisObj The current object. Always this - * @param type Setter property names need to call - * @param values Value passed to the parent class - * - * @exmaple egret.superSetter(egret.Sprite, this, "alpha", 1); - * @language en_US - */ - /** - * 调用父类的setter属性,代替其他语言的写法,如 super.alpha = 1; - * @param currentClass 当前 class 类名,非字符串 - * @param thisObj 当前对象。永远都this - * @param type 需要调用的setter属性名称 - * @param values 传给父类的值 - * - * @exmaple egret.superSetter(egret.Sprite, this, "alpha", 1); - * @language zh_CN - */ - function superSetter(currentClass, thisObj, type) { - var values = []; - for (var _i = 3; _i < arguments.length; _i++) { - values[_i - 3] = arguments[_i]; - } - var cla = currentClass.prototype; - var seters; - if (!currentClass.hasOwnProperty("__sets__")) { - Object.defineProperty(currentClass, "__sets__", { "value": {} }); - } - seters = currentClass["__sets__"]; - var setF = seters[type]; - if (setF) { - return setF.apply(thisObj, values); - } - var d = Object.getPrototypeOf(cla); - if (d == null) { - return; - } - while (!d.hasOwnProperty(type)) { - d = Object.getPrototypeOf(d); - if (d == null) { - return; - } - } - setF = Object.getOwnPropertyDescriptor(d, type).set; - seters[type] = setF; - setF.apply(thisObj, values); - } - egret.superSetter = superSetter; - /** - * Get getter property value of the parent class. Instead of writing in other languages, such as super.alpha; - * @param currentClass The current class class name, non-string - * @param thisObj The current object. Always this - * @param type Setter property names need to call - * @returns {any} The value returned by the parent - * - * @exmaple egret.superGetter(egret.Sprite, this, "alpha"); - * @language en_US - */ - /** - * 获取父类的getter属性值。代替其他语言的写法,如 super.alpha; - * @param currentClass 当前 class 类名,非字符串 - * @param thisObj 当前对象。永远都this - * @param type 需要调用的getter属性名称 - * @returns {any} 父类返回的值 - * - * @exmaple egret.superGetter(egret.Sprite, this, "alpha"); - * @language zh_CN - */ - function superGetter(currentClass, thisObj, type) { - var cla = currentClass.prototype; - var geters; - if (!currentClass.hasOwnProperty("__gets__")) { - Object.defineProperty(currentClass, "__gets__", { "value": {} }); - } - geters = currentClass["__gets__"]; - var getF = geters[type]; - if (getF) { - return getF.call(thisObj); - } - var d = Object.getPrototypeOf(cla); - if (d == null) { - return; - } - while (!d.hasOwnProperty(type)) { - d = Object.getPrototypeOf(d); - if (d == null) { - return; - } - } - getF = Object.getOwnPropertyDescriptor(d, type).get; - geters[type] = getF; - return getF.call(thisObj); - } - egret.superGetter = superGetter; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - */ - var getDefinitionByNameCache = {}; - /** - * Returns a reference to the class object of the class specified by the name parameter. - * @param name The name of a class. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getDefinitionByName.ts - * @language en_US - */ - /** - * 返回 name 参数指定的类的类对象引用。 - * @param name 类的名称。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getDefinitionByName.ts - * @language zh_CN - */ - function getDefinitionByName(name) { - if (!name) - return null; - var definition = getDefinitionByNameCache[name]; - if (definition) { - return definition; - } - var paths = name.split("."); - var length = paths.length; - definition = global; - for (var i = 0; i < length; i++) { - var path = paths[i]; - definition = definition[path]; - if (!definition) { - return null; - } - } - getDefinitionByNameCache[name] = definition; - return definition; - } - egret.getDefinitionByName = getDefinitionByName; - if (true) { - egret["cleanCache"] = function () { - getDefinitionByNameCache = {}; - }; - } -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Return the fully qualified class name of an object - * @param value The object for which a fully qualified class name is desired. Any JavaScript value may be passed to - * this method including all available JavaScript types, object instances, primitive types such as number, and class objects. - * @returns A string containing the fully qualified class name. - * @example - *
      -     *  egret.getQualifiedClassName(egret.DisplayObject) //return "egret.DisplayObject"
      -     * 
      - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedClassName.ts - * @language en_US - */ - /** - * 返回对象的完全限定类名。 - * @param value 需要完全限定类名称的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型 - * (如number)和类对象 - * @returns 包含完全限定类名称的字符串。 - * @example - *
      -     *  egret.getQualifiedClassName(egret.DisplayObject) //返回 "egret.DisplayObject"
      -     * 
      - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedClassName.ts - * @language zh_CN - */ - function getQualifiedClassName(value) { - var type = typeof value; - if (!value || (type != "object" && !value.prototype)) { - return type; - } - var prototype = value.prototype ? value.prototype : Object.getPrototypeOf(value); - if (prototype.hasOwnProperty("__class__")) { - return prototype["__class__"]; - } - var constructorString = prototype.constructor.toString().trim(); - var index = constructorString.indexOf("("); - var className = constructorString.substring(9, index); - Object.defineProperty(prototype, "__class__", { - value: className, - enumerable: false, - writable: true - }); - return className; - } - egret.getQualifiedClassName = getQualifiedClassName; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Returns the fully qualified class name of the base class of the object specified by the value parameter. - * @param value The object for which a parent class is desired. Any JavaScript value may be passed to this method including - * all available JavaScript types, object instances, primitive types such as number, and class objects. - * @returns A fully qualified base class name, or null if none exists. - * @example - *
      -     *  egret.getQualifiedSuperclassName(egret.Bitmap) //return "egret.DisplayObject"
      -     * 
      - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedSuperclassName.ts - * @language en_US - */ - /** - * 返回 value 参数指定的对象的基类的完全限定类名。 - * @param value 需要取得父类的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型(如number)和类对象 - * @returns 完全限定的基类名称,或 null(如果不存在基类名称)。 - * @example - *
      -     *  egret.getQualifiedSuperclassName(egret.Sprite) //返回 "egret.DisplayObject"
      -     * 
      - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedSuperclassName.ts - * @language zh_CN - */ - function getQualifiedSuperclassName(value) { - if (!value || (typeof value != "object" && !value.prototype)) { - return null; - } - var prototype = value.prototype ? value.prototype : Object.getPrototypeOf(value); - var superProto = Object.getPrototypeOf(prototype); - if (!superProto) { - return null; - } - var superClass = egret.getQualifiedClassName(superProto.constructor); - if (!superClass) { - return null; - } - return superClass; - } - egret.getQualifiedSuperclassName = getQualifiedSuperclassName; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Used to compute relative time.this method returns the number of milliseconds since the Egret framework was initialized - * @returns The number of milliseconds since the Egret framework was initialized - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getTimer.ts - * @language en_US - */ - /** - * 用于计算相对时间。此方法返回自启动 Egret 框架以来经过的毫秒数。 - * @returns 启动 Egret 框架以来经过的毫秒数。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getTimer.ts - * @language zh_CN - */ - function getTimer() { - return Date.now() - egret.sys.$START_TIME; - } - egret.getTimer = getTimer; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Check whether a public definition exists in the specified application domain. The definition can be that of a class, a naming space or a function. - * @param name {string} Name of the definition. - * @returns {boolean} Whether the public definition exists - * @example - * egret.hasDefinition("egret.DisplayObject") //return true - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/hasDefinition.ts - * @language en_US - */ - /** - * 检查指定的应用程序域之内是否存在一个公共定义。该定义可以是一个类、一个命名空间或一个函数的定义。 - * @param name {string} 定义的名称。 - * @returns {boolean} 公共定义是否存在 - * @example - * egret.hasDefinition("egret.DisplayObject") //返回 true - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/hasDefinition.ts - * @language zh_CN - */ - function hasDefinition(name) { - var definition = egret.getDefinitionByName(name); - return definition ? true : false; - } - egret.hasDefinition = hasDefinition; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Indicates whether an object is a instance of the class or interface specified as the parameter.This method has better performance - * compared width the instanceOf operator,and it can indicate whether an object is a instance of the specific interface. - * @param instance the instance to be checked. - * @param typeName the string value representing a specific class or interface. - * @returns A value of true if the object is a instance of the class or interface specified as the parameter. - * @example - *
      -     *     let instance = new egret.Sprite();
      -     *     egret.log(egret.is(instance,"egret.Sprite"))  //true
      -     *     egret.log(egret.is(instance,"egret.DisplayObjectContainer"))  //true
      -     *     egret.log(egret.is(instance,"egret.Bitmap"))  //false
      -     * 
      - * @see egret.registerClass() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查指定对象是否为 Egret 框架内指定接口或类或其子类的实例。此方法与使用 instanceOf 关键字相比具有更高的性能,并且能判断接口的实现。 - * @param instance 要判断的实例。 - * @param typeName 类或接口的完全名称. - * @returns 返回true表示当前对象是指定类或接口的实例。 - * @example - *
      -     *     let instance = new egret.Sprite();
      -     *     egret.log(egret.is(instance,"egret.Sprite"))  //true
      -     *     egret.log(egret.is(instance,"egret.DisplayObjectContainer"))  //true
      -     *     egret.log(egret.is(instance,"egret.Bitmap"))  //false
      -     * 
      - * @see egret.registerClass() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function is(instance, typeName) { - if (!instance || typeof instance != "object") { - return false; - } - var prototype = Object.getPrototypeOf(instance); - var types = prototype ? prototype.__types__ : null; - if (!types) { - return false; - } - return (types.indexOf(typeName) !== -1); - } - egret.is = is; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Register and start a timer,which will notify the callback method at a rate of 60 FPS ,and pass the current time stamp as parameters.
      - * Note: After the registration,it will notify the callback method continuously,you can call the stopTick () method to stop it. - * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds - * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime - * to render after processing of this method completes. - * @param thisObject the call back method's "this" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 注册并启动一个计时器,通常会以60FPS的速率触发回调方法,并传入当前时间戳。注意:注册后将会持续触发回调方法,若要停止回调,需要手动调用stopTick()方法。 - * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。 - * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。 - * @param thisObject 回调方法的this对象引用。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function startTick(callBack, thisObject) { - if (true && !callBack) { - egret.$error(1003, "callBack"); - } - egret.ticker.$startTick(callBack, thisObject); - } - egret.startTick = startTick; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Stops the timer started by the egret.startTick() method. - * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds - * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime - * to render after processing of this method completes. - * @param thisObject the call back method's "this" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 停止之前用 startTick() 方法启动的计时器。 - * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。 - * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。 - * @param thisObject 回调方法的this对象引用。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function stopTick(callBack, thisObject) { - if (true && !callBack) { - egret.$error(1003, "callBack"); - } - egret.ticker.$stopTick(callBack, thisObject); - } - egret.stopTick = stopTick; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Transfer number to color character string - * @param value {number} color value ,such as 0xffffff - * @returns {string} Color character string, for example, #ffffff. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/toColorString.ts - * @language en_US - */ - /** - * 转换数字为颜色字符串 - * @param value {number} 颜色值,例如 0xffffff - * @returns {string} 颜色字符串,例如"#ffffff"。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/toColorString.ts - * @language zh_CN - */ - function toColorString(value) { - if (value < 0) - value = 0; - if (value > 16777215) - value = 16777215; - var color = value.toString(16).toUpperCase(); - while (color.length > 6) { - color = color.slice(1, color.length); - } - while (color.length < 6) { - color = "0" + color; - } - return "#" + color; - } - egret.toColorString = toColorString; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); diff --git a/helloworld/libs/modules/egret/egret.min.js b/helloworld/libs/modules/egret/egret.min.js deleted file mode 100644 index 97541a8..0000000 --- a/helloworld/libs/modules/egret/egret.min.js +++ /dev/null @@ -1,6 +0,0 @@ -var __reflect=this&&this.__reflect||function(t,e,i){t.__class__=e,i?i.push(e):i=[e],t.__types__=t.__types__?i.concat(t.__types__):i},__extends=this&&this.__extends||function(t,e){function i(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);i.prototype=e.prototype,t.prototype=new i};if("undefined"==typeof global)var global=window;if("undefined"==typeof __global)var __global=global;var __define=this&&this.__define||function(t,e,i,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get:i,set:r})},egret;!function(t){t.$hashCount=1;var e=function(){function e(){this.$hashCode=t.$hashCount++}return Object.defineProperty(e.prototype,"hashCode",{get:function(){return this.$hashCode},enumerable:!0,configurable:!0}),e}();t.HashObject=e,__reflect(e.prototype,"egret.HashObject",["egret.IHashObject"])}(egret||(egret={}));var egret;!function(t){var e=[],i=function(i){function r(t){void 0===t&&(t=null);var e=i.call(this)||this;return e.$EventDispatcher={0:t?t:e,1:{},2:{},3:0},e}return __extends(r,i),r.prototype.$getEventMap=function(t){var e=this.$EventDispatcher,i=t?e[2]:e[1];return i},r.prototype.addEventListener=function(t,e,i,r,n){this.$addListener(t,e,i,r,n)},r.prototype.once=function(t,e,i,r,n){this.$addListener(t,e,i,r,n,!0)},r.prototype.$addListener=function(t,e,i,r,n,a){var o=this.$EventDispatcher,s=r?o[2]:o[1],h=s[t];h?0!==o[3]&&(s[t]=h=h.concat()):h=s[t]=[],this.$insertEventBin(h,t,e,i,r,n,a)},r.prototype.$insertEventBin=function(t,e,i,r,n,a,o){a=0|+a;for(var s=-1,h=t.length,c=0;h>c;c++){var l=t[c];if(l.listener==i&&l.thisObject==r&&l.target==this)return!1;-1==s&&l.priorityn;n++){var a=t[n];if(a.listener==e&&a.thisObject==i&&a.target==this)return t.splice(n,1),!0}return!1},r.prototype.hasEventListener=function(t){var e=this.$EventDispatcher;return!(!e[1][t]&&!e[2][t])},r.prototype.willTrigger=function(t){return this.hasEventListener(t)},r.prototype.dispatchEvent=function(t){return t.$currentTarget=this.$EventDispatcher[0],t.$setTarget(t.$currentTarget),this.$notifyListener(t,!1)},r.prototype.$notifyListener=function(t,i){var r=this.$EventDispatcher,n=i?r[2]:r[1],a=n[t.$type];if(!a)return!0;var o=a.length;if(0==o)return!0;var s=e;r[3]++;for(var h=0;o>h;h++){var c=a[h];if(c.listener.call(c.thisObject,t),c.dispatchOnce&&s.push(c),t.$isPropagationImmediateStopped)break}for(r[3]--;s.length;){var c=s.pop();c.target.removeEventListener(c.type,c.listener,c.thisObject,c.useCapture)}return!t.$isDefaultPrevented},r.prototype.dispatchEventWith=function(e,i,r,n){if(i||this.hasEventListener(e)){var a=t.Event.create(t.Event,e,i,n);a.data=r;var o=this.dispatchEvent(a);return t.Event.release(a),o}return!0},r}(t.HashObject);t.EventDispatcher=i,__reflect(i.prototype,"egret.EventDispatcher",["egret.IEventDispatcher"])}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){var i=e.call(this)||this;return i.type=null,i.$id=null,i.paddingTop=0,i.paddingBottom=0,i.paddingLeft=0,i.paddingRight=0,i.$uniforms={},t.nativeRender&&egret_native.NativeDisplayObject.createFilter(i),i}return __extends(i,e),i.prototype.$toJson=function(){return""},i.prototype.updatePadding=function(){},i.prototype.onPropertyChange=function(){var e=this;e.updatePadding(),t.nativeRender&&(egret_native.NativeDisplayObject.setFilterPadding(e.$id,e.paddingTop,e.paddingBottom,e.paddingLeft,e.paddingRight),egret_native.NativeDisplayObject.setDataToFilter(e))},i}(t.HashObject);t.Filter=e,__reflect(e.prototype,"egret.Filter")}(egret||(egret={}));var egret;!function(t){function e(t){return t%=360,t>180?t-=360:-180>t&&(t+=360),t}var i=function(i){function r(){var e=i.call(this)||this;return e.$children=null,e.$name="",e.$parent=null,e.$stage=null,e.$nestLevel=0,e.$useTranslate=!1,e.$matrix=new t.Matrix,e.$matrixDirty=!1,e.$x=0,e.$y=0,e.$scaleX=1,e.$scaleY=1,e.$rotation=0,e.$skewX=0,e.$skewXdeg=0,e.$skewY=0,e.$skewYdeg=0,e.$explicitWidth=0/0,e.$explicitHeight=0/0,e.$anchorOffsetX=0,e.$anchorOffsetY=0,e.$visible=!0,e.$displayList=null,e.$cacheAsBitmap=!1,e.$cacheDirty=!1,e.$alpha=1,e.$touchEnabled=r.defaultTouchEnabled,e.$scrollRect=null,e.$blendMode=0,e.$maskedObject=null,e.$mask=null,e.$maskRect=null,e.$parentDisplayList=null,e.$renderNode=null,e.$renderDirty=!1,e.$renderMode=null,t.nativeRender&&e.createNativeDisplayObject(),e}return __extends(r,i),r.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(0)},Object.defineProperty(r.prototype,"name",{get:function(){return this.$name},set:function(t){this.$name=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"parent",{get:function(){return this.$parent},enumerable:!0,configurable:!0}),r.prototype.$setParent=function(t){this.$parent=t},r.prototype.$onAddToStage=function(e,i){var r=this;r.$stage=e,r.$nestLevel=i,r.$hasAddToStage=!0,t.Sprite.$EVENT_ADD_TO_STAGE_LIST.push(r)},r.prototype.$onRemoveFromStage=function(){var e=this;e.$nestLevel=0,t.Sprite.$EVENT_REMOVE_FROM_STAGE_LIST.push(e)},r.prototype.$updateUseTransform=function(){var t=this;1==t.$scaleX&&1==t.$scaleY&&0==t.$skewX&&0==t.$skewY?t.$useTranslate=!1:t.$useTranslate=!0},Object.defineProperty(r.prototype,"stage",{get:function(){return this.$stage},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"matrix",{get:function(){return this.$getMatrix().clone()},set:function(t){this.$setMatrix(t)},enumerable:!0,configurable:!0}),r.prototype.$getMatrix=function(){var t=this;return t.$matrixDirty&&(t.$matrixDirty=!1,t.$matrix.$updateScaleAndRotation(t.$scaleX,t.$scaleY,t.$skewX,t.$skewY)),t.$matrix.tx=t.$x,t.$matrix.ty=t.$y,t.$matrix},r.prototype.$setMatrix=function(i,r){void 0===r&&(r=!0);var n=this,a=n.$matrix;a.a=i.a,a.b=i.b,a.c=i.c,a.d=i.d,n.$x=i.tx,n.$y=i.ty,n.$matrixDirty=!1,1==a.a&&0==a.b&&0==a.c&&1==a.d?n.$useTranslate=!1:n.$useTranslate=!0,r&&(n.$scaleX=a.$getScaleX(),n.$scaleY=a.$getScaleY(),n.$skewX=i.$getSkewX(),n.$skewY=i.$getSkewY(),n.$skewXdeg=e(180*n.$skewX/Math.PI),n.$skewYdeg=e(180*n.$skewY/Math.PI),n.$rotation=e(180*n.$skewY/Math.PI)),t.nativeRender&&n.$nativeDisplayObject.setMatrix(i.a,i.b,i.c,i.d,i.tx,i.ty)},r.prototype.$getConcatenatedMatrix=function(){var e=this,i=e.$concatenatedMatrix;i||(i=e.$concatenatedMatrix=new t.Matrix),e.$parent?e.$parent.$getConcatenatedMatrix().$preMultiplyInto(e.$getMatrix(),i):i.copyFrom(e.$getMatrix());var r=e.$anchorOffsetX,n=e.$anchorOffsetY,a=e.$scrollRect;return a?i.$preMultiplyInto(t.$TempMatrix.setTo(1,0,0,1,-a.x-r,-a.y-n),i):(0!=r||0!=n)&&i.$preMultiplyInto(t.$TempMatrix.setTo(1,0,0,1,-r,-n),i),e.$concatenatedMatrix},r.prototype.$getInvertedConcatenatedMatrix=function(){var e=this;return e.$invertedConcatenatedMatrix||(e.$invertedConcatenatedMatrix=new t.Matrix),e.$getConcatenatedMatrix().$invertInto(e.$invertedConcatenatedMatrix),e.$invertedConcatenatedMatrix},Object.defineProperty(r.prototype,"x",{get:function(){return this.$getX()},set:function(t){this.$setX(t)},enumerable:!0,configurable:!0}),r.prototype.$getX=function(){return this.$x},r.prototype.$setX=function(e){var i=this;if(i.$x==e)return!1;if(i.$x=e,t.nativeRender)i.$nativeDisplayObject.setX(e);else{var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}return!0},Object.defineProperty(r.prototype,"y",{get:function(){return this.$getY()},set:function(t){this.$setY(t)},enumerable:!0,configurable:!0}),r.prototype.$getY=function(){return this.$y},r.prototype.$setY=function(e){var i=this;if(i.$y==e)return!1;if(i.$y=e,t.nativeRender)i.$nativeDisplayObject.setY(e);else{var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}return!0},Object.defineProperty(r.prototype,"scaleX",{get:function(){return this.$getScaleX()},set:function(t){this.$setScaleX(t)},enumerable:!0,configurable:!0}),r.prototype.$getScaleX=function(){return this.$scaleX},r.prototype.$setScaleX=function(e){var i=this;if(i.$scaleX=e,i.$matrixDirty=!0,i.$updateUseTransform(),t.nativeRender)i.$nativeDisplayObject.setScaleX(e);else{var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},Object.defineProperty(r.prototype,"scaleY",{get:function(){return this.$getScaleY()},set:function(t){this.$setScaleY(t)},enumerable:!0,configurable:!0}),r.prototype.$getScaleY=function(){return this.$scaleY},r.prototype.$setScaleY=function(e){var i=this;if(i.$scaleY=e,i.$matrixDirty=!0,i.$updateUseTransform(),t.nativeRender)i.$nativeDisplayObject.setScaleY(e);else{var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},Object.defineProperty(r.prototype,"rotation",{get:function(){return this.$getRotation()},set:function(t){this.$setRotation(t)},enumerable:!0,configurable:!0}),r.prototype.$getRotation=function(){return this.$rotation},r.prototype.$setRotation=function(i){i=e(i);var r=this;if(i!=r.$rotation){var n=i-r.$rotation,a=n/180*Math.PI;if(r.$skewX+=a,r.$skewY+=a,r.$rotation=i,r.$matrixDirty=!0,r.$updateUseTransform(),t.nativeRender)r.$nativeDisplayObject.setRotation(i);else{var o=r.$parent;o&&!o.$cacheDirty&&(o.$cacheDirty=!0,o.$cacheDirtyUp());var s=r.$maskedObject;s&&!s.$cacheDirty&&(s.$cacheDirty=!0,s.$cacheDirtyUp())}}},Object.defineProperty(r.prototype,"skewX",{get:function(){return this.$skewXdeg},set:function(t){this.$setSkewX(t)},enumerable:!0,configurable:!0}),r.prototype.$setSkewX=function(i){var r=this;if(i!=r.$skewXdeg)if(r.$skewXdeg=i,i=e(i),i=i/180*Math.PI,r.$skewX=i,r.$matrixDirty=!0,r.$updateUseTransform(),t.nativeRender)r.$nativeDisplayObject.setSkewX(r.$skewXdeg);else{var n=r.$parent;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp());var a=r.$maskedObject;a&&!a.$cacheDirty&&(a.$cacheDirty=!0,a.$cacheDirtyUp())}},Object.defineProperty(r.prototype,"skewY",{get:function(){return this.$skewYdeg},set:function(t){this.$setSkewY(t)},enumerable:!0,configurable:!0}),r.prototype.$setSkewY=function(i){var r=this;if(i!=r.$skewYdeg)if(r.$skewYdeg=i,i=e(i),i=i/180*Math.PI,r.$skewY=i,r.$matrixDirty=!0,r.$updateUseTransform(),t.nativeRender)r.$nativeDisplayObject.setSkewY(r.$skewYdeg);else{var n=r.$parent;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp());var a=r.$maskedObject;a&&!a.$cacheDirty&&(a.$cacheDirty=!0,a.$cacheDirtyUp())}},Object.defineProperty(r.prototype,"width",{get:function(){return this.$getWidth()},set:function(t){this.$setWidth(t)},enumerable:!0,configurable:!0}),r.prototype.$getWidth=function(){var t=this;return isNaN(t.$explicitWidth)?t.$getOriginalBounds().width:t.$explicitWidth},r.prototype.$setWidth=function(t){this.$explicitWidth=isNaN(t)?0/0:t},Object.defineProperty(r.prototype,"height",{get:function(){return this.$getHeight()},set:function(t){this.$setHeight(t)},enumerable:!0,configurable:!0}),r.prototype.$getHeight=function(){var t=this;return isNaN(t.$explicitHeight)?t.$getOriginalBounds().height:t.$explicitHeight},r.prototype.$setHeight=function(t){this.$explicitHeight=isNaN(t)?0/0:t},Object.defineProperty(r.prototype,"measuredWidth",{get:function(){return this.$getOriginalBounds().width},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"measuredHeight",{get:function(){return this.$getOriginalBounds().height},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"anchorOffsetX",{get:function(){return this.$anchorOffsetX},set:function(t){this.$setAnchorOffsetX(t)},enumerable:!0,configurable:!0}),r.prototype.$setAnchorOffsetX=function(e){var i=this;i.$anchorOffsetX=e,t.nativeRender&&i.$nativeDisplayObject.setAnchorOffsetX(e)},Object.defineProperty(r.prototype,"anchorOffsetY",{get:function(){return this.$anchorOffsetY},set:function(t){this.$setAnchorOffsetY(t)},enumerable:!0,configurable:!0}),r.prototype.$setAnchorOffsetY=function(e){var i=this;i.$anchorOffsetY=e,t.nativeRender&&i.$nativeDisplayObject.setAnchorOffsetY(e)},Object.defineProperty(r.prototype,"visible",{get:function(){return this.$visible},set:function(t){this.$setVisible(t)},enumerable:!0,configurable:!0}),r.prototype.$setVisible=function(e){var i=this;if(i.$visible=e,t.nativeRender)i.$nativeDisplayObject.setVisible(e);else{i.$updateRenderMode();var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},Object.defineProperty(r.prototype,"cacheAsBitmap",{get:function(){return this.$cacheAsBitmap},set:function(e){var i=this;i.$cacheAsBitmap=e,t.nativeRender?i.$nativeDisplayObject.setCacheAsBitmap(e):i.$setHasDisplayList(e)},enumerable:!0,configurable:!0}),r.prototype.$setHasDisplayList=function(e){var i=this,r=!!i.$displayList;if(r!=e)if(e){var n=t.sys.DisplayList.create(i);n&&(i.$displayList=n,i.$cacheDirty=!0)}else i.$displayList=null},r.prototype.$cacheDirtyUp=function(){var t=this.$parent;t&&!t.$cacheDirty&&(t.$cacheDirty=!0,t.$cacheDirtyUp())},Object.defineProperty(r.prototype,"alpha",{get:function(){return this.$alpha},set:function(t){this.$setAlpha(t)},enumerable:!0,configurable:!0}),r.prototype.$setAlpha=function(e){var i=this;if(i.$alpha=e,t.nativeRender)i.$nativeDisplayObject.setAlpha(e);else{i.$updateRenderMode();var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},Object.defineProperty(r.prototype,"touchEnabled",{get:function(){return this.$getTouchEnabled()},set:function(t){this.$setTouchEnabled(t)},enumerable:!0,configurable:!0}),r.prototype.$getTouchEnabled=function(){return this.$touchEnabled},r.prototype.$setTouchEnabled=function(t){this.$touchEnabled=t},Object.defineProperty(r.prototype,"scrollRect",{get:function(){return this.$scrollRect},set:function(t){this.$setScrollRect(t)},enumerable:!0,configurable:!0}),r.prototype.$setScrollRect=function(e){var i=this;return e||i.$scrollRect?(e?(i.$scrollRect||(i.$scrollRect=new t.Rectangle),i.$scrollRect.copyFrom(e),t.nativeRender&&i.$nativeDisplayObject.setScrollRect(e.x,e.y,e.width,e.height)):(i.$scrollRect=null,t.nativeRender&&i.$nativeDisplayObject.setScrollRect(0,0,0,0)),void(t.nativeRender||i.$updateRenderMode())):void i.$updateRenderMode()},Object.defineProperty(r.prototype,"blendMode",{get:function(){return t.sys.numberToBlendMode(this.$blendMode)},set:function(e){var i=this,r=t.sys.blendModeToNumber(e);if(i.$blendMode=r,t.nativeRender)i.$nativeDisplayObject.setBlendMode(r);else{i.$updateRenderMode();var n=i.$parent;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp());var a=i.$maskedObject;a&&!a.$cacheDirty&&(a.$cacheDirty=!0,a.$cacheDirtyUp())}},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"mask",{get:function(){var t=this;return t.$mask?t.$mask:t.$maskRect},set:function(e){var i=this;if(e!==i){if(e)if(e instanceof r){if(e==i.$mask)return;e.$maskedObject&&(e.$maskedObject.mask=null),e.$maskedObject=i,i.$mask=e,t.nativeRender||e.$updateRenderMode(),i.$maskRect&&(t.nativeRender&&i.$nativeDisplayObject.setMaskRect(0,0,0,0),i.$maskRect=null),t.nativeRender&&i.$nativeDisplayObject.setMask(e.$nativeDisplayObject.id)}else i.$maskRect||(i.$maskRect=new t.Rectangle),i.$maskRect.copyFrom(e),t.nativeRender&&i.$nativeDisplayObject.setMaskRect(e.x,e.y,e.width,e.height),i.$mask&&(i.$mask.$maskedObject=null,t.nativeRender||i.$mask.$updateRenderMode()),i.mask&&(t.nativeRender&&i.$nativeDisplayObject.setMask(-1),i.$mask=null);else i.$mask&&(i.$mask.$maskedObject=null,t.nativeRender||i.$mask.$updateRenderMode()),i.mask&&(t.nativeRender&&i.$nativeDisplayObject.setMask(-1),i.$mask=null),i.$maskRect&&(t.nativeRender&&i.$nativeDisplayObject.setMaskRect(0,0,0,0),i.$maskRect=null);t.nativeRender||i.$updateRenderMode()}},enumerable:!0,configurable:!0}),r.prototype.$setMaskRect=function(e){var i=this;(e||i.$maskRect)&&(e?(i.$maskRect||(i.$maskRect=new t.Rectangle),i.$maskRect.copyFrom(e)):i.$maskRect=null)},Object.defineProperty(r.prototype,"filters",{get:function(){return this.$filters},set:function(e){var i=this,r=i.$filters;if(r||e){if(e&&e.length?(e=e.concat(),i.$filters=e,t.nativeRender&&i.$nativeDisplayObject.setFilters(e)):(i.$filters=e,t.nativeRender&&i.$nativeDisplayObject.setFilters(null)),!t.nativeRender){i.$updateRenderMode();var n=i.$parent;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp());var a=i.$maskedObject;a&&!a.$cacheDirty&&(a.$cacheDirty=!0,a.$cacheDirtyUp())}}else if(i.$filters=e,t.nativeRender)i.$nativeDisplayObject.setFilters(null);else{i.$updateRenderMode();var n=i.$parent;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp());var a=i.$maskedObject;a&&!a.$cacheDirty&&(a.$cacheDirty=!0,a.$cacheDirtyUp())}},enumerable:!0,configurable:!0}),r.prototype.getTransformedBounds=function(t,e){return t=t||this,this.$getTransformedBounds(t,e)},r.prototype.getBounds=function(t,e){void 0===e&&(e=!0);var i=this;return t=i.$getTransformedBounds(i,t),e&&(0!=i.$anchorOffsetX&&(t.x-=i.$anchorOffsetX),0!=i.$anchorOffsetY&&(t.y-=i.$anchorOffsetY)),t},r.prototype.$getTransformedBounds=function(e,i){var r=this,n=r.$getOriginalBounds();if(i||(i=new t.Rectangle),i.copyFrom(n),e==r)return i;var a;if(e){a=t.$TempMatrix;var o=e.$getInvertedConcatenatedMatrix();o.$preMultiplyInto(r.$getConcatenatedMatrix(),a)}else a=r.$getConcatenatedMatrix();return a.$transformBounds(i),i},r.prototype.globalToLocal=function(e,i,r){if(void 0===e&&(e=0),void 0===i&&(i=0),t.nativeRender){egret_native.updateNativeRender();var n=egret_native.nrGlobalToLocal(this.$nativeDisplayObject.id,e,i),a=n.split(","),o=parseFloat(a[0]),s=parseFloat(a[1]);return r?r.setTo(o,s):r=new t.Point(o,s),r}var h=this.$getInvertedConcatenatedMatrix();return h.transformPoint(e,i,r)},r.prototype.localToGlobal=function(e,i,r){if(void 0===e&&(e=0),void 0===i&&(i=0),t.nativeRender){egret_native.updateNativeRender();var n=egret_native.nrLocalToGlobal(this.$nativeDisplayObject.id,e,i),a=n.split(","),o=parseFloat(a[0]),s=parseFloat(a[1]);return r?r.setTo(o,s):r=new t.Point(o,s),r}var h=this.$getConcatenatedMatrix();return h.transformPoint(e,i,r)},r.prototype.$getOriginalBounds=function(){var t=this,e=t.$getContentBounds();t.$measureChildBounds(e);var i=t.$measureFiltersOffset(!1);return i&&(e.x+=i.minX,e.y+=i.minY,e.width+=-i.minX+i.maxX,e.height+=-i.minY+i.maxY),e},r.prototype.$measureChildBounds=function(t){},r.prototype.$getContentBounds=function(){var e=t.$TempRectangle;return e.setEmpty(),this.$measureContentBounds(e),e},r.prototype.$measureContentBounds=function(t){},r.prototype.$getRenderNode=function(){var t=this,e=t.$renderNode;return e?(t.$renderDirty&&(e.cleanBeforeRender(),t.$updateRenderNode(),t.$renderDirty=!1,e=t.$renderNode),e):null},r.prototype.$updateRenderMode=function(){var t=this;!t.$visible||t.$alpha<=0||t.$maskedObject?t.$renderMode=1:t.filters&&t.filters.length>0?t.$renderMode=2:0!==t.$blendMode||t.$mask&&t.$mask.$stage?t.$renderMode=3:t.$scrollRect||t.$maskRect?t.$renderMode=4:t.$renderMode=null},r.prototype.$measureFiltersOffset=function(e){for(var i=this,r=0,n=0,a=0,o=0;i;){var s=i.$filters;if(s&&s.length)for(var h=s.length,c=0;h>c;c++){var l=s[c];if("blur"==l.type){var u=l.blurX,p=l.blurY;r-=u,n-=p,a+=u,o+=p}else if("glow"==l.type){var u=l.blurX,p=l.blurY;r-=u,n-=p,a+=u,o+=p;var d=l.distance||0,f=l.angle||0,g=0,$=0;0!=d&&(g=d*t.NumberUtils.cos(f),g=g>0?Math.ceil(g):Math.floor(g),$=d*t.NumberUtils.sin(f),$=$>0?Math.ceil($):Math.floor($),r+=g,a+=g,n+=$,o+=$)}else if("custom"==l.type){var y=l.padding;r-=y,n-=y,a+=y,o+=y}}i=e?i.$parent:null}return r=Math.min(r,0),n=Math.min(n,0),a=Math.max(a,0),o=Math.max(o,0),{minX:r,minY:n,maxX:a,maxY:o}},r.prototype.$getConcatenatedMatrixAt=function(e,i){var r=e.$getInvertedConcatenatedMatrix();if(0===r.a||0===r.d){var n=this,a=e.$nestLevel;for(i.identity();n.$nestLevel>a;){var o=n.$scrollRect;o&&i.concat(t.$TempMatrix.setTo(1,0,0,1,-o.x,-o.y)),i.concat(n.$getMatrix()),n=n.$parent}}else r.$preMultiplyInto(i,i)},r.prototype.$updateRenderNode=function(){},r.prototype.$hitTest=function(t,e){var i=this;if(!i.$renderNode||!i.$visible||0==i.$scaleX||0==i.$scaleY)return null;var r=i.$getInvertedConcatenatedMatrix();if(0==r.a&&0==r.b&&0==r.c&&0==r.d)return null;var n=i.$getContentBounds(),a=r.a*t+r.c*e+r.tx,o=r.b*t+r.d*e+r.ty;if(n.contains(a,o)){if(!i.$children){var s=i.$scrollRect?i.$scrollRect:i.$maskRect;if(s&&!s.contains(a,o))return null;if(i.$mask&&!i.$mask.$hitTest(t,e))return null}return i}return null},r.prototype.hitTestPoint=function(e,i,r){var n=this;if(r){var a=n.$getInvertedConcatenatedMatrix(),o=a.a*e+a.c*i+a.tx,s=a.b*e+a.d*i+a.ty,h=void 0;if(t.nativeRender){var c=t.sys.customHitTestBuffer;c.resize(3,3),egret_native.forHitTest=!0,egret_native.activateBuffer(c),egret_native.updateNativeRender(),egret_native.nrRenderDisplayObject2(n.$nativeDisplayObject.id,1-o,1-s,!0);try{h=new Uint8Array(4),egret_native.nrGetPixels(1,1,1,1,h)}catch(l){throw new Error(t.sys.tr(1039))}return egret_native.activateBuffer(null),egret_native.forHitTest=!1,0===h[3]?!1:!0}var u=n.$displayList;if(u){var c=u.renderBuffer;try{h=c.getPixels(o-u.offsetX,s-u.offsetY)}catch(l){throw new Error(t.sys.tr(1039))}}else{var c=t.sys.customHitTestBuffer;c.resize(3,3);var p=t.Matrix.create();p.identity(),p.translate(1-o,1-s),t.sys.systemRenderer.render(this,c,p,!0),t.Matrix.release(p);try{h=c.getPixels(1,1)}catch(l){throw new Error(t.sys.tr(1039))}}return 0===h[3]?!1:!0}if(0==n.$scaleX||0==n.$scaleY)return!1;var a=n.$getInvertedConcatenatedMatrix(),d=n.getBounds(null,!1),o=a.a*e+a.c*i+a.tx,s=a.b*e+a.d*i+a.ty;if(d.contains(o,s)){var f=n.$scrollRect?n.$scrollRect:n.$maskRect;return f&&!f.contains(o,s)?!1:!0}return!1},r.prototype.$addListener=function(e,n,a,o,s,h){i.prototype.$addListener.call(this,e,n,a,o,s,h);var c=e==t.Event.ENTER_FRAME;if(c||e==t.Event.RENDER){var l=c?r.$enterFrameCallBackList:r.$renderCallBackList;-1==l.indexOf(this)&&l.push(this)}},r.prototype.removeEventListener=function(e,n,a,o){i.prototype.removeEventListener.call(this,e,n,a,o);var s=e==t.Event.ENTER_FRAME;if((s||e==t.Event.RENDER)&&!this.hasEventListener(e)){var h=s?r.$enterFrameCallBackList:r.$renderCallBackList,c=h.indexOf(this);-1!==c&&h.splice(c,1)}},r.prototype.dispatchEvent=function(t){if(!t.$bubbles)return i.prototype.dispatchEvent.call(this,t);var e=this.$getPropagationList(this),r=.5*e.length;return t.$setTarget(this),this.$dispatchPropagationEvent(t,e,r),!t.$isDefaultPrevented},r.prototype.$getPropagationList=function(t){for(var e=[];t;)e.push(t),t=t.$parent;var i=e.concat();return i.reverse(),e=i.concat(e)},r.prototype.$dispatchPropagationEvent=function(t,e,i){for(var r=e.length,n=i-1,a=0;r>a;a++){var o=e[a];if(t.$currentTarget=o,n>a?t.$eventPhase=1:a==i||a==n?t.$eventPhase=2:t.$eventPhase=3,o.$notifyListener(t,i>a),t.$isPropagationStopped||t.$isPropagationImmediateStopped)return}},r.prototype.willTrigger=function(t){for(var e=this;e;){if(e.hasEventListener(t))return!0;e=e.$parent}return!1},r.defaultTouchEnabled=!1,r.$enterFrameCallBackList=[],r.$renderCallBackList=[],r}(t.EventDispatcher);t.DisplayObject=i,__reflect(i.prototype,"egret.DisplayObject")}(egret||(egret={}));var egret;!function(t){t.$TextureScaleFactor=1;var e=function(e){function i(){var t=e.call(this)||this;return t.disposeBitmapData=!0,t.$bitmapX=0,t.$bitmapY=0,t.$bitmapWidth=0,t.$bitmapHeight=0,t.$offsetX=0,t.$offsetY=0,t.$textureWidth=0,t.$textureHeight=0,t.$sourceWidth=0,t.$sourceHeight=0,t.$bitmapData=null,t.$rotated=!1,t}return __extends(i,e),Object.defineProperty(i.prototype,"textureWidth",{get:function(){return this.$getTextureWidth()},enumerable:!0,configurable:!0}),i.prototype.$getTextureWidth=function(){return this.$textureWidth},Object.defineProperty(i.prototype,"textureHeight",{get:function(){return this.$getTextureHeight()},enumerable:!0,configurable:!0}),i.prototype.$getTextureHeight=function(){return this.$textureHeight},i.prototype.$getScaleBitmapWidth=function(){return this.$bitmapWidth*t.$TextureScaleFactor},i.prototype.$getScaleBitmapHeight=function(){return this.$bitmapHeight*t.$TextureScaleFactor},Object.defineProperty(i.prototype,"bitmapData",{get:function(){return this.$bitmapData},set:function(t){this._setBitmapData(t)},enumerable:!0,configurable:!0}),i.prototype._setBitmapData=function(e){this.$bitmapData=e;var i=t.$TextureScaleFactor,r=e.width*i,n=e.height*i;this.$initData(0,0,r,n,0,0,r,n,e.width,e.height)},i.prototype.$initData=function(e,i,r,n,a,o,s,h,c,l,u){void 0===u&&(u=!1);var p=t.$TextureScaleFactor;this.$bitmapX=e/p,this.$bitmapY=i/p,this.$bitmapWidth=r/p,this.$bitmapHeight=n/p,this.$offsetX=a,this.$offsetY=o,this.$textureWidth=s,this.$textureHeight=h,this.$sourceWidth=c,this.$sourceHeight=l,this.$rotated=u,t.BitmapData.$invalidate(this.$bitmapData)},i.prototype.getPixel32=function(t,e){throw new Error},i.prototype.getPixels=function(t,e,i,r){throw void 0===i&&(i=1),void 0===r&&(r=1),new Error},i.prototype.toDataURL=function(t,e,i){throw new Error},i.prototype.saveToFile=function(t,e,i){throw new Error},i.prototype.dispose=function(){this.$bitmapData&&(this.disposeBitmapData&&this.$bitmapData.$dispose(),this.$bitmapData=null),t.nativeRender&&egret_native.NativeDisplayObject.disposeTexture(this)},i}(t.HashObject);t.Texture=e,__reflect(e.prototype,"egret.Texture")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e,i,r,n){var a=t.call(this)||this;return a.$eventPhase=2,a.$currentTarget=null,a.$target=null,a.$isDefaultPrevented=!1,a.$isPropagationStopped=!1,a.$isPropagationImmediateStopped=!1,a.$type=e,a.$bubbles=!!i,a.$cancelable=!!r,a.data=n,a}return __extends(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return this.$type},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bubbles",{get:function(){return this.$bubbles},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cancelable",{get:function(){return this.$cancelable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"eventPhase",{get:function(){return this.$eventPhase},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentTarget",{get:function(){return this.$currentTarget},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this.$target},enumerable:!0,configurable:!0}),e.prototype.$setTarget=function(t){return this.$target=t,!0},e.prototype.isDefaultPrevented=function(){return this.$isDefaultPrevented},e.prototype.preventDefault=function(){this.$cancelable&&(this.$isDefaultPrevented=!0)},e.prototype.stopPropagation=function(){this.$bubbles&&(this.$isPropagationStopped=!0)},e.prototype.stopImmediatePropagation=function(){this.$bubbles&&(this.$isPropagationImmediateStopped=!0)},e.prototype.clean=function(){this.data=this.$currentTarget=null,this.$setTarget(null)},e.dispatchEvent=function(t,i,r,n){void 0===r&&(r=!1);var a=e.create(e,i,r),o=e._getPropertyData(e);void 0!=n&&(o.data=n);var s=t.dispatchEvent(a);return e.release(a),s},e._getPropertyData=function(t){var e=t._props;return e||(e=t._props={}),e},e.create=function(t,e,i,r){var n=t.eventPool;if(n||(n=t.eventPool=[]),n.length){var a=n.pop();return a.$type=e,a.$bubbles=!!i,a.$cancelable=!!r,a.$isDefaultPrevented=!1,a.$isPropagationStopped=!1,a.$isPropagationImmediateStopped=!1,a.$eventPhase=2,a}return new t(e,i,r)},e.release=function(t){t.clean();var e=Object.getPrototypeOf(t).constructor;e.eventPool.push(t)},e.ADDED_TO_STAGE="addedToStage",e.REMOVED_FROM_STAGE="removedFromStage",e.ADDED="added",e.REMOVED="removed",e.ENTER_FRAME="enterFrame",e.RENDER="render",e.RESIZE="resize",e.CHANGE="change",e.CHANGING="changing",e.COMPLETE="complete",e.LOOP_COMPLETE="loopComplete",e.FOCUS_IN="focusIn",e.FOCUS_OUT="focusOut",e.ENDED="ended",e.ACTIVATE="activate",e.DEACTIVATE="deactivate",e.CLOSE="close",e.CONNECT="connect",e.LEAVE_STAGE="leaveStage",e.SOUND_COMPLETE="soundComplete",e}(t.HashObject);t.Event=e,__reflect(e.prototype,"egret.Event")}(egret||(egret={}));var egret;!function(t){function e(){return""}function i(t){throw new Error("#"+t)}function r(){}function n(){}t.getString=e,t.$error=i,t.$warn=r,t.$markCannotUse=n}(egret||(egret={}));var egret;!function(t){var e=[],i=Math.PI/180,r=function(r){function n(t,e){void 0===t&&(t=0),void 0===e&&(e=0);var i=r.call(this)||this;return i.x=t,i.y=e,i}return __extends(n,r),n.release=function(t){t&&e.push(t)},n.create=function(t,i){var r=e.pop();return r||(r=new n),r.setTo(t,i)},Object.defineProperty(n.prototype,"length",{get:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},enumerable:!0,configurable:!0}),n.prototype.setTo=function(t,e){return this.x=t,this.y=e,this},n.prototype.clone=function(){return new n(this.x,this.y)},n.prototype.equals=function(t){return this.x==t.x&&this.y==t.y},n.distance=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},n.prototype.copyFrom=function(t){this.x=t.x,this.y=t.y},n.prototype.add=function(t){return new n(this.x+t.x,this.y+t.y)},n.interpolate=function(t,e,i){var r=1-i;return new n(t.x*i+e.x*r,t.y*i+e.y*r)},n.prototype.normalize=function(t){if(0!=this.x||0!=this.y){var e=t/this.length;this.x*=e,this.y*=e}},n.prototype.offset=function(t,e){this.x+=t,this.y+=e},n.polar=function(e,r){return new n(e*t.NumberUtils.cos(r/i),e*t.NumberUtils.sin(r/i))},n.prototype.subtract=function(t){return new n(this.x-t.x,this.y-t.y)},n.prototype.toString=function(){return"(x="+this.x+", y="+this.y+")"},n}(t.HashObject);t.Point=r,__reflect(r.prototype,"egret.Point"),t.$TempPoint=new r}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){var t=e.call(this)||this;return t.$touchChildren=!0,t.$children=[],t}return __extends(i,e),Object.defineProperty(i.prototype,"numChildren",{get:function(){return this.$children.length},enumerable:!0,configurable:!0}),i.prototype.addChild=function(t){var e=this.$children.length;return t.$parent==this&&e--,this.$doAddChild(t,e)},i.prototype.addChildAt=function(t,e){return e=0|+e,(0>e||e>=this.$children.length)&&(e=this.$children.length,t.$parent==this&&e--),this.$doAddChild(t,e)},i.prototype.$doAddChild=function(e,r,n){void 0===n&&(n=!0);var a=this,o=e.$parent;if(o==a)return a.doSetChildIndex(e,r),e;o&&o.removeChild(e),a.$children.splice(r,0,e),e.$setParent(a);var s=a.$stage;if(s&&e.$onAddToStage(s,a.$nestLevel+1),n&&e.dispatchEventWith(t.Event.ADDED,!0),s)for(var h=i.$EVENT_ADD_TO_STAGE_LIST;h.length;){var c=h.shift();c.$stage&&n&&c.dispatchEventWith(t.Event.ADDED_TO_STAGE)}if(t.nativeRender)a.$nativeDisplayObject.addChildAt(e.$nativeDisplayObject.id,r);else if(e.$maskedObject&&e.$maskedObject.$updateRenderMode(),!a.$cacheDirty){a.$cacheDirty=!0;var l=a.$parent;l&&!l.$cacheDirty&&(l.$cacheDirty=!0,l.$cacheDirtyUp());var u=a.$maskedObject;u&&!u.$cacheDirty&&(u.$cacheDirty=!0,u.$cacheDirtyUp())}return this.$childAdded(e,r),e},i.prototype.contains=function(t){for(;t;){if(t==this)return!0;t=t.$parent}return!1},i.prototype.getChildAt=function(t){return t=0|+t,t>=0&&tn;n++)if(e=i[n],e.name==t)return e;return null},i.prototype.removeChild=function(t){var e=this.$children.indexOf(t);return e>=0?this.$doRemoveChild(e):null},i.prototype.removeChildAt=function(t){return t=0|+t,t>=0&&t0;){var h=s.shift();r&&h.$hasAddToStage&&(h.$hasAddToStage=!1,h.dispatchEventWith(t.Event.REMOVED_FROM_STAGE)),h.$hasAddToStage=!1,h.$stage=null}}this.$displayList||this.$parentDisplayList;o.$setParent(null);var c=a.indexOf(o);if(-1!=c&&a.splice(c,1),t.nativeRender)n.$nativeDisplayObject.removeChild(o.$nativeDisplayObject.id);else if(o.$maskedObject&&o.$maskedObject.$updateRenderMode(),!n.$cacheDirty){n.$cacheDirty=!0;var l=n.$parent;l&&!l.$cacheDirty&&(l.$cacheDirty=!0,l.$cacheDirtyUp());var u=n.$maskedObject;u&&!u.$cacheDirty&&(u.$cacheDirty=!0,u.$cacheDirtyUp())}return o},i.prototype.setChildIndex=function(t,e){e=0|+e,(0>e||e>=this.$children.length)&&(e=this.$children.length-1),this.doSetChildIndex(t,e)},i.prototype.doSetChildIndex=function(e,i){var r=this,n=this.$children.indexOf(e);if(n!=i)if(this.$childRemoved(e,n),this.$children.splice(n,1),this.$children.splice(i,0,e),this.$childAdded(e,i),t.nativeRender)this.$nativeDisplayObject.removeChild(e.$nativeDisplayObject.id),this.$nativeDisplayObject.addChildAt(e.$nativeDisplayObject.id,i);else if(!r.$cacheDirty){r.$cacheDirty=!0;var a=r.$parent;a&&!a.$cacheDirty&&(a.$cacheDirty=!0,a.$cacheDirtyUp());var o=r.$maskedObject;o&&!o.$cacheDirty&&(o.$cacheDirty=!0,o.$cacheDirtyUp())}},i.prototype.swapChildrenAt=function(t,e){t=0|+t,e=0|+e,t>=0&&t=0&&ei){var n=i;i=e,e=n}else if(e==i)return;var a=this.$children,o=a[e],s=a[i];if(this.$childRemoved(o,e),this.$childRemoved(s,i),a[e]=s,a[i]=o,this.$childAdded(s,e),this.$childAdded(o,i),t.nativeRender)this.$nativeDisplayObject.swapChild(e,i);else if(!r.$cacheDirty){r.$cacheDirty=!0;var h=r.$parent;h&&!h.$cacheDirty&&(h.$cacheDirty=!0,h.$cacheDirtyUp());var c=r.$maskedObject;c&&!c.$cacheDirty&&(c.$cacheDirty=!0,c.$cacheDirtyUp())}},i.prototype.removeChildren=function(){for(var t=this.$children,e=t.length-1;e>=0;e--)this.$doRemoveChild(e)},i.prototype.$childAdded=function(t,e){},i.prototype.$childRemoved=function(t,e){},i.prototype.$onAddToStage=function(t,i){e.prototype.$onAddToStage.call(this,t,i);var r=this.$children,n=r.length;i++;for(var a=0;n>a;a++){var o=this.$children[a];o.$onAddToStage(t,i),o.$maskedObject&&o.$maskedObject.$updateRenderMode()}},i.prototype.$onRemoveFromStage=function(){e.prototype.$onRemoveFromStage.call(this);for(var t=this.$children,i=t.length,r=0;i>r;r++){var n=t[r];n.$onRemoveFromStage()}},i.prototype.$measureChildBounds=function(e){var i=this.$children,r=i.length;if(0!=r){for(var n=0,a=0,o=0,s=0,h=!1,c=-1;r>c;c++){var l=void 0;-1==c?l=e:(i[c].getBounds(t.$TempRectangle),i[c].$getMatrix().$transformBounds(t.$TempRectangle),l=t.$TempRectangle),l.isEmpty()||(h?(n=Math.min(n,l.x),a=Math.max(a,l.x+l.width),o=Math.min(o,l.y),s=Math.max(s,l.y+l.height)):(h=!0,n=l.x,a=n+l.width,o=l.y,s=o+l.height))}e.setTo(n,o,a-n,s-o)}},Object.defineProperty(i.prototype,"touchChildren",{get:function(){return this.$getTouchChildren()},set:function(t){this.$setTouchChildren(!!t)},enumerable:!0,configurable:!0}),i.prototype.$getTouchChildren=function(){return this.$touchChildren},i.prototype.$setTouchChildren=function(t){return this.$touchChildren==t?!1:(this.$touchChildren=t,!0)},i.prototype.$hitTest=function(t,i){if(!this.$visible)return null;var r=this.$getInvertedConcatenatedMatrix(),n=r.a*t+r.c*i+r.tx,a=r.b*t+r.d*i+r.ty,o=this.$scrollRect?this.$scrollRect:this.$maskRect;if(o&&!o.contains(n,a))return null;if(this.$mask&&!this.$mask.$hitTest(t,i))return null;for(var s=this.$children,h=!1,c=null,l=s.length-1;l>=0;l--){var u=s[l];if(!u.$maskedObject&&(c=u.$hitTest(t,i))){if(h=!0,c.$touchEnabled)break;c=null}}return c?this.$touchChildren?c:this:h?this:e.prototype.$hitTest.call(this,t,i)},i.$EVENT_ADD_TO_STAGE_LIST=[],i.$EVENT_REMOVE_FROM_STAGE_LIST=[],i}(t.DisplayObject);t.DisplayObjectContainer=e,__reflect(e.prototype,"egret.DisplayObjectContainer")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(i){var r=e.call(this)||this;return r._bitmapX=0,r._bitmapY=0,r._textureMap=t.createMap(),r.$texture=i,r._bitmapX=i.$bitmapX-i.$offsetX,r._bitmapY=i.$bitmapY-i.$offsetY,r}return __extends(i,e),i.prototype.getTexture=function(t){return this._textureMap[t]},i.prototype.createTexture=function(e,i,r,n,a,o,s,h,c){void 0===o&&(o=0),void 0===s&&(s=0),void 0===h&&(h=o+n),void 0===c&&(c=s+a);var l=new t.Texture;return l.disposeBitmapData=!1,l.$bitmapData=this.$texture.$bitmapData,l.$initData(this._bitmapX+i,this._bitmapY+r,n,a,o,s,h,c,this.$texture.$sourceWidth,this.$texture.$sourceHeight),this._textureMap[e]=l,l},i.prototype.dispose=function(){this.$texture&&this.$texture.dispose()},i}(t.HashObject);t.SpriteSheet=e,__reflect(e.prototype,"egret.SpriteSheet")}(egret||(egret={}));var egret;!function(t){t.$locale_strings=t.$locale_strings||{},t.$language="en_US"}(egret||(egret={})),function(t){var e;!function(e){function i(e){for(var i=[],r=1;ro;o++)n=n.replace("{"+o+"}",i[o]);return n}e.tr=i}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(r){var n=e.call(this)||this;return n.$texture=null,n.$bitmapData=null,n.$bitmapX=0,n.$bitmapY=0,n.$bitmapWidth=0,n.$bitmapHeight=0,n.$offsetX=0,n.$offsetY=0,n.$textureWidth=0,n.$textureHeight=0,n.$sourceWidth=0,n.$sourceHeight=0,n.$smoothing=i.defaultSmoothing,n.$explicitBitmapWidth=0/0,n.$explicitBitmapHeight=0/0,n.$scale9Grid=null,n.$fillMode="scale",n._pixelHitTest=!1,n.$renderNode=new t.sys.NormalBitmapNode,n.$setTexture(r),r&&(n.$renderNode.rotated=r.$rotated),n}return __extends(i,e),i.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(1)},i.prototype.$onAddToStage=function(i,r){e.prototype.$onAddToStage.call(this,i,r);var n=this.$texture;n&&n.$bitmapData&&t.BitmapData.$addDisplayObject(this,n.$bitmapData)},i.prototype.$onRemoveFromStage=function(){e.prototype.$onRemoveFromStage.call(this);var i=this.$texture;i&&t.BitmapData.$removeDisplayObject(this,i.$bitmapData)},Object.defineProperty(i.prototype,"texture",{get:function(){return this.$texture},set:function(t){var e=this;e.$setTexture(t),t&&e.$renderNode&&(e.$renderNode.rotated=t.$rotated)},enumerable:!0,configurable:!0}),i.prototype.$setTexture=function(e){var i=this,r=i.$texture;if(e==r)return!1;if(i.$texture=e,!e){r&&t.BitmapData.$removeDisplayObject(i,r.$bitmapData),i.setImageData(null,0,0,0,0,0,0,0,0,0,0),i.$renderDirty=!0;var n=i.$parent;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp());var a=i.$maskedObject;return a&&!a.$cacheDirty&&(a.$cacheDirty=!0,a.$cacheDirtyUp()),t.nativeRender&&this.setBitmapDataToWasm(null),!0}if(i.$refreshImageData(),i.$stage){if(r&&r.$bitmapData){var o=r.$bitmapData.hashCode,s=e.$bitmapData?e.$bitmapData.hashCode:-1;if(o==s){i.$renderDirty=!0;var h=i.$parent;h&&!h.$cacheDirty&&(h.$cacheDirty=!0,h.$cacheDirtyUp());var c=i.$maskedObject;return c&&!c.$cacheDirty&&(c.$cacheDirty=!0,c.$cacheDirtyUp()),!0}t.BitmapData.$removeDisplayObject(i,r.$bitmapData)}t.BitmapData.$addDisplayObject(i,e.$bitmapData)}i.$renderDirty=!0;var l=i.$parent;l&&!l.$cacheDirty&&(l.$cacheDirty=!0,l.$cacheDirtyUp());var u=i.$maskedObject;return u&&!u.$cacheDirty&&(u.$cacheDirty=!0,u.$cacheDirtyUp()),!0},i.prototype.$setBitmapData=function(t){this.$setTexture(t)},i.prototype.setBitmapDataToWasm=function(t){this.$nativeDisplayObject.setBitmapData(t)},i.prototype.$refreshImageData=function(){var e=this.$texture;e?(t.nativeRender&&this.setBitmapDataToWasm(e),this.setImageData(e.$bitmapData,e.$bitmapX,e.$bitmapY,e.$bitmapWidth,e.$bitmapHeight,e.$offsetX,e.$offsetY,e.$getTextureWidth(),e.$getTextureHeight(),e.$sourceWidth,e.$sourceHeight)):t.nativeRender&&this.setBitmapDataToWasm(null)},i.prototype.setImageData=function(t,e,i,r,n,a,o,s,h,c,l){this.$bitmapData=t,this.$bitmapX=e,this.$bitmapY=i,this.$bitmapWidth=r,this.$bitmapHeight=n,this.$offsetX=a,this.$offsetY=o,this.$textureWidth=s,this.$textureHeight=h,this.$sourceWidth=c,this.$sourceHeight=l},Object.defineProperty(i.prototype,"scale9Grid",{get:function(){return this.$scale9Grid},set:function(t){this.$setScale9Grid(t)},enumerable:!0,configurable:!0}),i.prototype.$setScale9Grid=function(e){var i=this;if(i.$scale9Grid=e,i.$renderDirty=!0,t.nativeRender)e?i.$nativeDisplayObject.setScale9Grid(e.x,e.y,e.width,e.height):i.$nativeDisplayObject.setScale9Grid(0,0,-1,-1);else{var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},Object.defineProperty(i.prototype,"fillMode",{get:function(){return this.$fillMode},set:function(t){this.$setFillMode(t)},enumerable:!0,configurable:!0}),i.prototype.$setFillMode=function(e){return e==this.$fillMode?!1:(this.$fillMode=e,t.nativeRender&&this.$nativeDisplayObject.setBitmapFillMode(this.$fillMode),!0)},Object.defineProperty(i.prototype,"smoothing",{get:function(){return this.$smoothing},set:function(t){t!=this.$smoothing&&(this.$smoothing=t,this.$renderNode.smoothing=t)},enumerable:!0,configurable:!0}),i.prototype.$setWidth=function(e){var i=this;if(0>e||e==i.$explicitBitmapWidth)return!1;if(i.$explicitBitmapWidth=e,i.$renderDirty=!0,t.nativeRender)i.$nativeDisplayObject.setWidth(e);else{var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}return!0},i.prototype.$setHeight=function(e){var i=this;if(0>e||e==i.$explicitBitmapHeight)return!1;if(i.$explicitBitmapHeight=e,i.$renderDirty=!0,t.nativeRender)i.$nativeDisplayObject.setHeight(e);else{var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}return!0},i.prototype.$getWidth=function(){return isNaN(this.$explicitBitmapWidth)?this.$getContentBounds().width:this.$explicitBitmapWidth},i.prototype.$getHeight=function(){return isNaN(this.$explicitBitmapHeight)?this.$getContentBounds().height:this.$explicitBitmapHeight},i.prototype.$measureContentBounds=function(t){if(this.$bitmapData){var e=isNaN(this.$explicitBitmapWidth)?this.$textureWidth:this.$explicitBitmapWidth,i=isNaN(this.$explicitBitmapHeight)?this.$textureHeight:this.$explicitBitmapHeight;t.setTo(0,0,e,i)}else{var e=isNaN(this.$explicitBitmapWidth)?0:this.$explicitBitmapWidth,i=isNaN(this.$explicitBitmapHeight)?0:this.$explicitBitmapHeight;t.setTo(0,0,e,i)}},i.prototype.$updateRenderNode=function(){if(this.$texture){var e=isNaN(this.$explicitBitmapWidth)?this.$textureWidth:this.$explicitBitmapWidth,i=isNaN(this.$explicitBitmapHeight)?this.$textureHeight:this.$explicitBitmapHeight,r=this.scale9Grid||this.$texture.scale9Grid;r?(this.$renderNode instanceof t.sys.NormalBitmapNode&&(this.$renderNode=new t.sys.BitmapNode),t.sys.BitmapNode.$updateTextureDataWithScale9Grid(this.$renderNode,this.$bitmapData,r,this.$bitmapX,this.$bitmapY,this.$bitmapWidth,this.$bitmapHeight,this.$offsetX,this.$offsetY,this.$textureWidth,this.$textureHeight,e,i,this.$sourceWidth,this.$sourceHeight,this.$smoothing)):(this.fillMode==t.BitmapFillMode.REPEAT&&this.$renderNode instanceof t.sys.NormalBitmapNode&&(this.$renderNode=new t.sys.BitmapNode),t.sys.BitmapNode.$updateTextureData(this.$renderNode,this.$bitmapData,this.$bitmapX,this.$bitmapY,this.$bitmapWidth,this.$bitmapHeight,this.$offsetX,this.$offsetY,this.$textureWidth,this.$textureHeight,e,i,this.$sourceWidth,this.$sourceHeight,this.$fillMode,this.$smoothing))}},Object.defineProperty(i.prototype,"pixelHitTest",{get:function(){return this._pixelHitTest},set:function(t){this._pixelHitTest=!!t},enumerable:!0,configurable:!0}),i.prototype.$hitTest=function(t,i){var r=e.prototype.$hitTest.call(this,t,i);if(r&&this._pixelHitTest){var n=this.hitTestPoint(t,i,!0);n||(r=null)}return r},i.defaultSmoothing=!0,i}(t.DisplayObject);t.Bitmap=e,__reflect(e.prototype,"egret.Bitmap")}(egret||(egret={}));var egret;!function(t){var e;!function(t){var e=function(){function t(){this.type=0,this.drawData=[],this.renderCount=0}return t.prototype.cleanBeforeRender=function(){this.drawData.length=0,this.renderCount=0},t.prototype.$getRenderCount=function(){return this.renderCount},t}();t.RenderNode=e,__reflect(e.prototype,"egret.sys.RenderNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(t){var e=function(){function t(){this.type=0,this.$commands=[],this.$data=[],this.commandPosition=0,this.dataPosition=0,this.$lastX=0,this.$lastY=0}return t.prototype.moveTo=function(t,e){this.$commands[this.commandPosition++]=1;var i=this.dataPosition;this.$data[i++]=t,this.$data[i++]=e,this.dataPosition=i},t.prototype.lineTo=function(t,e){this.$commands[this.commandPosition++]=2;var i=this.dataPosition;this.$data[i++]=t,this.$data[i++]=e,this.dataPosition=i},t.prototype.curveTo=function(t,e,i,r){this.$commands[this.commandPosition++]=3;var n=this.dataPosition;this.$data[n++]=t,this.$data[n++]=e,this.$data[n++]=i,this.$data[n++]=r,this.dataPosition=n},t.prototype.cubicCurveTo=function(t,e,i,r,n,a){this.$commands[this.commandPosition++]=4;var o=this.dataPosition;this.$data[o++]=t,this.$data[o++]=e,this.$data[o++]=i,this.$data[o++]=r,this.$data[o++]=n,this.$data[o++]=a,this.dataPosition=o},t.prototype.drawRect=function(t,e,i,r){var n=t+i,a=e+r;this.moveTo(t,e),this.lineTo(n,e),this.lineTo(n,a),this.lineTo(t,a),this.lineTo(t,e)},t.prototype.drawRoundRect=function(t,e,i,r,n,a){var o=.5*n|0,s=a?.5*a|0:o;if(!o||!s)return void this.drawRect(t,e,i,r);var h=.5*i,c=.5*r;if(o>h&&(o=h),s>c&&(s=c),h===o&&c===s)return void(o===s?this.drawCircle(t+o,e+s,o):this.drawEllipse(t,e,2*o,2*s));var l=t+i,u=e+r,p=t+o,d=l-o,f=e+s,g=u-s;this.moveTo(l,g),this.curveTo(l,u,d,u),this.lineTo(p,u),this.curveTo(t,u,t,g),this.lineTo(t,f),this.curveTo(t,e,p,e),this.lineTo(d,e),this.curveTo(l,e,l,f),this.lineTo(l,g)},t.prototype.drawCircle=function(t,e,i){this.arcToBezier(t,e,i,i,0,2*Math.PI)},t.prototype.drawEllipse=function(t,e,i,r){var n=.5*i,a=.5*r;t+=n,e+=a,this.arcToBezier(t,e,n,a,0,2*Math.PI)},t.prototype.drawArc=function(t,e,i,r,n,a){a?n>=r&&(n-=2*Math.PI):r>=n&&(n+=2*Math.PI),this.arcToBezier(t,e,i,i,r,n,a)},t.prototype.arcToBezier=function(t,e,i,r,n,a,o){var s=.5*Math.PI,h=n,c=h;o?(c+=-s-h%s,a>c&&(c=a)):(c+=s-h%s,c>a&&(c=a));var l=t+Math.cos(h)*i,u=e+Math.sin(h)*r;(this.$lastX!=l||this.$lastY!=u)&&this.moveTo(l,u);for(var p=Math.cos(h),d=Math.sin(h),f=0;4>f;f++){var g=c-h,$=4*Math.tan(g/4)/3,y=l-d*$*i,v=u+p*$*r;p=Math.cos(c),d=Math.sin(c),l=t+p*i,u=e+d*r;var b=l+d*$*i,m=u-p*$*r;if(this.cubicCurveTo(y,v,b,m,l,u),c===a)break;h=c,o?(c=h-s,a>c&&(c=a)):(c=h+s,c>a&&(c=a))}},t}();t.Path2D=e,__reflect(e.prototype,"egret.sys.Path2D")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){t.fontMapping={}}(egret||(egret={}));var egret;!function(t){function e(){var t=Object.create(null);return t.__v8__=void 0,delete t.__v8__,t}t.createMap=e}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e,i,r,n,a,o,s,h){void 0===e&&(e=16711680),void 0===i&&(i=1),void 0===r&&(r=6),void 0===n&&(n=6),void 0===a&&(a=2),void 0===o&&(o=1),void 0===s&&(s=!1),void 0===h&&(h=!1);var c=t.call(this)||this,l=c;return l.type="glow",l.$color=e,l.$blue=255&e,l.$green=(65280&e)>>8,l.$red=e>>16,l.$alpha=i,l.$blurX=r,l.$blurY=n,l.$strength=a,l.$quality=o,l.$inner=s,l.$knockout=h,l.$uniforms.color={x:c.$red/255,y:c.$green/255,z:c.$blue/255,w:1},l.$uniforms.alpha=i,l.$uniforms.blurX=r,l.$uniforms.blurY=n,l.$uniforms.strength=a,l.$uniforms.inner=s?1:0,l.$uniforms.knockout=h?0:1,l.$uniforms.dist=0,l.$uniforms.angle=0,l.$uniforms.hideObject=0,l.onPropertyChange(),c}return __extends(e,t),Object.defineProperty(e.prototype,"color",{get:function(){return this.$color},set:function(t){this.$color!=t&&(this.$color=t,this.$blue=255&t,this.$green=(65280&t)>>8,this.$red=t>>16,this.$uniforms.color.x=this.$red/255,this.$uniforms.color.y=this.$green/255,this.$uniforms.color.z=this.$blue/255)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alpha",{get:function(){return this.$alpha},set:function(t){this.$alpha!=t&&(this.$alpha=t,this.$uniforms.alpha=t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blurX",{get:function(){return this.$blurX},set:function(t){var e=this;e.$blurX!=t&&(e.$blurX=t,e.$uniforms.blurX=t,e.onPropertyChange())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blurY",{get:function(){return this.$blurY},set:function(t){var e=this;e.$blurY!=t&&(e.$blurY=t,e.$uniforms.blurY=t,e.onPropertyChange())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"strength",{get:function(){return this.$strength},set:function(t){this.$strength!=t&&(this.$strength=t,this.$uniforms.strength=t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"quality",{get:function(){return this.$quality},set:function(t){this.$quality!=t&&(this.$quality=t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inner",{get:function(){return this.$inner},set:function(t){this.$inner!=t&&(this.$inner=t,this.$uniforms.inner=t?1:0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"knockout",{get:function(){return this.$knockout},set:function(t){this.$knockout!=t&&(this.$knockout=t,this.$uniforms.knockout=t?0:1)},enumerable:!0,configurable:!0}),e.prototype.$toJson=function(){return'{"color": '+this.$color+', "red": '+this.$red+', "green": '+this.$green+', "blue": '+this.$blue+', "alpha": '+this.$alpha+', "blurX": '+this.$blurX+', "blurY": '+this.blurY+', "strength": '+this.$strength+', "quality": '+this.$quality+', "inner": '+this.$inner+', "knockout": '+this.$knockout+"}"},e.prototype.updatePadding=function(){var t=this;t.paddingLeft=t.blurX,t.paddingRight=t.blurX,t.paddingTop=t.blurY,t.paddingBottom=t.blurY},e}(t.Filter);t.GlowFilter=e,__reflect(e.prototype,"egret.GlowFilter")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.NORMAL="normal",t.ADD="add",t.ERASE="erase",t}();t.BlendMode=e,__reflect(e.prototype,"egret.BlendMode")}(egret||(egret={})),function(t){var e;!function(t){function e(t){var e=n[t];return void 0===e?0:e}function i(t){var e=r[t];return void 0===e?"normal":e}for(var r=["normal","add","erase"],n={},a=r.length,o=0;a>o;o++){var s=r[o];n[s]=o}t.blendModeToNumber=e,t.numberToBlendMode=i}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){t.CapsStyle={NONE:"none",ROUND:"round",SQUARE:"square"}}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){}return e.compileProgram=function(i,r,n){var a=e.compileFragmentShader(i,n),o=e.compileVertexShader(i,r),s=i.createProgram();return i.attachShader(s,o),i.attachShader(s,a),i.linkProgram(s),i.getProgramParameter(s,i.LINK_STATUS)||t.$warn(1020),s},e.compileFragmentShader=function(t,i){return e._compileShader(t,i,t.FRAGMENT_SHADER)},e.compileVertexShader=function(t,i){return e._compileShader(t,i,t.VERTEX_SHADER)},e._compileShader=function(t,e,i){var r=t.createShader(i);return t.shaderSource(r,e),t.compileShader(r),t.getShaderParameter(r,t.COMPILE_STATUS)?r:null},e.checkCanUseWebGL=function(){if(void 0==e.canUseWebGL)try{var t=document.createElement("canvas");e.canUseWebGL=!(!window.WebGLRenderingContext||!t.getContext("webgl")&&!t.getContext("experimental-webgl"))}catch(i){e.canUseWebGL=!1}return e.canUseWebGL},e.deleteWebGLTexture=function(t){if(t){var e=t.glContext;e&&e.deleteTexture(t)}},e}();t.WebGLUtils=e,__reflect(e.prototype,"egret.WebGLUtils")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e,i,r){return void 0===i&&(i=!1),void 0===r&&(r=!1),t.call(this,e,i,r)||this}return __extends(e,t),e.FOCUS_IN="focusIn",e.FOCUS_OUT="focusOut",e}(t.Event);t.FocusEvent=e,__reflect(e.prototype,"egret.FocusEvent")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.PERMISSION_DENIED="permissionDenied",e.UNAVAILABLE="unavailable",e}(t.Event);t.GeolocationEvent=e,__reflect(e.prototype,"egret.GeolocationEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,r){void 0===i&&(i=!1),void 0===r&&(r=!1);var n=e.call(this,t,i,r)||this;return n._status=0,n}return __extends(i,e),Object.defineProperty(i.prototype,"status",{get:function(){return this._status},enumerable:!0,configurable:!0}),i.dispatchHTTPStatusEvent=function(e,r){var n=t.Event.create(i,i.HTTP_STATUS);n._status=r;var a=e.dispatchEvent(n);return t.Event.release(n),a},i.HTTP_STATUS="httpStatus",i}(t.Event);t.HTTPStatusEvent=e,__reflect(e.prototype,"egret.HTTPStatusEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,r){return void 0===i&&(i=!1),void 0===r&&(r=!1),e.call(this,t,i,r)||this}return __extends(i,e),i.dispatchIOErrorEvent=function(e){var r=t.Event.create(i,i.IO_ERROR),n=e.dispatchEvent(r);return t.Event.release(r),n},i.IO_ERROR="ioError",i}(t.Event);t.IOErrorEvent=e,__reflect(e.prototype,"egret.IOErrorEvent")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(t.Event);t.MotionEvent=e,__reflect(e.prototype,"egret.MotionEvent")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(t.Event);t.OrientationEvent=e,__reflect(e.prototype,"egret.OrientationEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,r,n,a){void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===n&&(n=0),void 0===a&&(a=0);var o=e.call(this,t,i,r)||this;return o.bytesLoaded=0,o.bytesTotal=0,o.bytesLoaded=n,o.bytesTotal=a,o}return __extends(i,e),i.dispatchProgressEvent=function(e,r,n,a){void 0===n&&(n=0),void 0===a&&(a=0);var o=t.Event.create(i,r);o.bytesLoaded=n,o.bytesTotal=a;var s=e.dispatchEvent(o);return t.Event.release(o),s},i.PROGRESS="progress",i.SOCKET_DATA="socketData",i}(t.Event);t.ProgressEvent=e,__reflect(e.prototype,"egret.ProgressEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,r){return void 0===i&&(i=!1),void 0===r&&(r=!1),e.call(this,t,i,r)||this}return __extends(i,e),i.dispatchStageOrientationEvent=function(e,r){var n=t.Event.create(i,r),a=e.dispatchEvent(n);return t.Event.release(n),a},i.ORIENTATION_CHANGE="orientationChange",i}(t.Event);t.StageOrientationEvent=e,__reflect(e.prototype,"egret.StageOrientationEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,r,n){void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===n&&(n="");var a=e.call(this,t,i,r)||this;return a.text=n,a}return __extends(i,e),i.dispatchTextEvent=function(e,r,n){var a=t.Event.create(i,r);a.text=n;var o=e.dispatchEvent(a);return t.Event.release(a),o},i.LINK="link",i}(t.Event);t.TextEvent=e,__reflect(e.prototype,"egret.TextEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,r){return e.call(this,t,i,r)||this}return __extends(i,e),i.prototype.updateAfterEvent=function(){t.sys.$requestRenderingFlag=!0},i.dispatchTimerEvent=function(e,r,n,a){var o=t.Event.create(i,r,n,a),s=e.dispatchEvent(o);return t.Event.release(o),s},i.TIMER="timer",i.TIMER_COMPLETE="timerComplete",i}(t.Event);t.TimerEvent=e,__reflect(e.prototype,"egret.TimerEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t){var i=e.call(this)||this;return i.format="image",i.$deleteSource=!0,i.source=t,i.width=t.width,i.height=t.height,i}return __extends(i,e),i.create=function(e,r,n){var a="";a="arraybuffer"===e?t.Base64Util.encode(r):r;var o="image/png";"/"===a.charAt(0)?o="image/jpeg":"R"===a.charAt(0)?o="image/gif":"i"===a.charAt(0)&&(o="image/png");var s=new Image;s.src="data:"+o+";base64,"+a,s.crossOrigin="*";var h=new i(s);return s.onload=function(){s.onload=void 0,h.source=s,h.height=s.height,h.width=s.width,n&&n(h)},h},i.prototype.$dispose=function(){"webgl"==t.Capabilities.renderMode&&this.webGLTexture&&(t.WebGLUtils.deleteWebGLTexture(this.webGLTexture),this.webGLTexture=null),this.source&&this.source.dispose&&this.source.dispose(),this.source=null,i.$dispose(this)},i.$addDisplayObject=function(t,e){if(e){var r=e.hashCode;if(r){if(!i._displayList[r])return void(i._displayList[r]=[t]);var n=i._displayList[r];n.indexOf(t)<0&&n.push(t)}}},i.$removeDisplayObject=function(t,e){if(e){var r=e.hashCode;if(r&&i._displayList[r]){var n=i._displayList[r],a=n.indexOf(t);a>=0&&n.splice(a,1)}}},i.$invalidate=function(e){if(e){var r=e.hashCode;if(r&&i._displayList[r])for(var n=i._displayList[r],a=0;at;t++)this.matrix2[t]=this.$matrix[t];return this.matrix2},set:function(t){this.setMatrix(t)},enumerable:!0,configurable:!0}),e.prototype.setMatrix=function(t){if(t)for(var e=0;20>e;e++)this.$matrix[e]=t[e];else for(var e=0;20>e;e++)this.$matrix[e]=0==e||6==e||12==e||18==e?1:0;for(var i=this.$matrix,r=this.$uniforms.matrix,n=this.$uniforms.colorAdd,e=0,a=0;et;t++)8===t||13===t||18===t||23===t?n[t]="-":14===t?n[t]="4":(2>=a&&(a=33554432+16777216*Math.random()|0),e=15&a,a>>=4,n[t]=r[19===t?3&e|8:e]);return n.join("")},s=function(e){function r(t,r,n){void 0===n&&(n={});var a=e.call(this)||this;a.$padding=0,a.$vertexSrc=t,a.$fragmentSrc=r;var s=t+r;return i[s]||(i[s]=o()),a.$shaderKey=i[s],a.$uniforms=n,a.type="custom",a}return __extends(r,e),Object.defineProperty(r.prototype,"padding",{get:function(){return this.$padding},set:function(t){var e=this;e.$padding!=t&&(e.$padding=t,e.onPropertyChange())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"uniforms",{get:function(){return this.$uniforms},enumerable:!0,configurable:!0}),r.prototype.onPropertyChange=function(){if(t.nativeRender){var e=this;egret_native.NativeDisplayObject.setFilterPadding(e.$id,e.$padding,e.$padding,e.$padding,e.$padding),egret_native.NativeDisplayObject.setDataToFilter(e)}},r}(t.Filter);t.CustomFilter=s,__reflect(s.prototype,"egret.CustomFilter")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,r,n,a,o,s,h,c,l,u){void 0===t&&(t=4),void 0===i&&(i=45),void 0===r&&(r=0),void 0===n&&(n=1),void 0===a&&(a=4),void 0===o&&(o=4),void 0===s&&(s=1),void 0===h&&(h=1),void 0===c&&(c=!1),void 0===l&&(l=!1),void 0===u&&(u=!1); -var p=e.call(this,r,n,a,o,s,h,c,l)||this,d=p;return d.$distance=t,d.$angle=i,d.$hideObject=u,d.$uniforms.dist=t,d.$uniforms.angle=i/180*Math.PI,d.$uniforms.hideObject=u?1:0,d.onPropertyChange(),p}return __extends(i,e),Object.defineProperty(i.prototype,"distance",{get:function(){return this.$distance},set:function(t){var e=this;e.$distance!=t&&(e.$distance=t,e.$uniforms.dist=t,e.onPropertyChange())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"angle",{get:function(){return this.$angle},set:function(t){var e=this;e.$angle!=t&&(e.$angle=t,e.$uniforms.angle=t/180*Math.PI,e.onPropertyChange())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"hideObject",{get:function(){return this.$hideObject},set:function(t){this.$hideObject!=t&&(this.$hideObject=t,this.$uniforms.hideObject=t?1:0)},enumerable:!0,configurable:!0}),i.prototype.$toJson=function(){return'{"distance": '+this.$distance+', "angle": '+this.$angle+', "color": '+this.$color+', "red": '+this.$red+', "green": '+this.$green+', "blue": '+this.$blue+', "alpha": '+this.$alpha+', "blurX": '+this.$blurX+', "blurY": '+this.blurY+', "strength": '+this.$strength+', "quality": '+this.$quality+', "inner": '+this.$inner+', "knockout": '+this.$knockout+', "hideObject": '+this.$hideObject+"}"},i.prototype.updatePadding=function(){var e=this;e.paddingLeft=e.blurX,e.paddingRight=e.blurX,e.paddingTop=e.blurY,e.paddingBottom=e.blurY;var i=e.distance||0,r=e.angle||0,n=0,a=0;0!=i&&(n=i*t.NumberUtils.cos(r),n=n>0?Math.ceil(n):Math.floor(n),a=i*t.NumberUtils.sin(r),a=a>0?Math.ceil(a):Math.floor(a),e.paddingLeft+=n,e.paddingRight+=n,e.paddingTop+=a,e.paddingBottom+=a)},i}(t.GlowFilter);t.DropShadowFilter=e,__reflect(e.prototype,"egret.DropShadowFilter")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.LINEAR="linear",t.RADIAL="radial",t}();t.GradientType=e,__reflect(e.prototype,"egret.GradientType")}(egret||(egret={}));var egret;!function(t){function e(t){return t%=2*Math.PI,0>t&&(t+=2*Math.PI),t}function i(t,e){for(var i=[],n=0;e>n;n++){var a=r(t,n/e);a&&i.push(a)}return i}function r(e,i){var r=0,o=0,s=0,h=e.length;if(h/2==3){var c=e[r++],l=e[r++],u=e[r++],p=e[r++],d=e[r++],f=e[r++];o=n(c,u,d,i),s=n(l,p,f,i)}else if(h/2==4){var c=e[r++],l=e[r++],u=e[r++],p=e[r++],d=e[r++],f=e[r++],g=e[r++],$=e[r++];o=a(c,u,d,g,i),s=a(l,p,f,$,i)}return t.Point.create(o,s)}function n(t,e,i,r){var n=Math.pow(1-r,2)*t+2*r*(1-r)*e+Math.pow(r,2)*i;return n}function a(t,e,i,r,n){var a=Math.pow(1-n,3)*t+3*n*Math.pow(1-n,2)*e+3*(1-n)*Math.pow(n,2)*i+Math.pow(n,3)*r;return a}var o=function(r){function n(){var e=r.call(this)||this;return e.lastX=0,e.lastY=0,e.fillPath=null,e.strokePath=null,e.topLeftStrokeWidth=0,e.bottomRightStrokeWidth=0,e.minX=1/0,e.minY=1/0,e.maxX=-(1/0),e.maxY=-(1/0),e.includeLastPosition=!0,e.$renderNode=new t.sys.GraphicsNode,e}return __extends(n,r),n.prototype.$setTarget=function(e){this.$targetDisplay&&(this.$targetDisplay.$renderNode=null),e.$renderNode=this.$renderNode,this.$targetDisplay=e,this.$targetIsSprite=e instanceof t.Sprite},n.prototype.setStrokeWidth=function(t){switch(t){case 1:this.topLeftStrokeWidth=0,this.bottomRightStrokeWidth=1;break;case 3:this.topLeftStrokeWidth=1,this.bottomRightStrokeWidth=2;break;default:var e=0|Math.ceil(.5*t);this.topLeftStrokeWidth=e,this.bottomRightStrokeWidth=e}},n.prototype.beginFill=function(e,i){void 0===i&&(i=1),e=+e||0,i=+i||0,t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setBeginFill(e,i),this.fillPath=this.$renderNode.beginFill(e,i,this.strokePath),this.$renderNode.drawData.length>1&&this.fillPath.moveTo(this.lastX,this.lastY)},n.prototype.beginGradientFill=function(e,i,r,n,a){void 0===a&&(a=null),t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setBeginGradientFill(e,i,r,n,a),this.fillPath=this.$renderNode.beginGradientFill(e,i,r,n,a,this.strokePath),this.$renderNode.drawData.length>1&&this.fillPath.moveTo(this.lastX,this.lastY)},n.prototype.endFill=function(){t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setEndFill(),this.fillPath=null},n.prototype.lineStyle=function(e,i,r,n,a,o,s,h,c){void 0===e&&(e=0/0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=!1),void 0===a&&(a="normal"),void 0===o&&(o=null),void 0===s&&(s=null),void 0===h&&(h=3),e=+e||0,i=+i||0,r=+r||0,h=+h||0,t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setLineStyle(e,i,r,n,a,o,s,h),0>=e?(this.strokePath=null,this.setStrokeWidth(0)):(this.setStrokeWidth(e),this.strokePath=this.$renderNode.lineStyle(e,i,r,o,s,h,c),this.$renderNode.drawData.length>1&&this.strokePath.moveTo(this.lastX,this.lastY))},n.prototype.drawRect=function(e,i,r,n){e=+e||0,i=+i||0,r=+r||0,n=+n||0,t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setDrawRect(e,i,r,n);var a=this.fillPath,o=this.strokePath;a&&a.drawRect(e,i,r,n),o&&o.drawRect(e,i,r,n),this.extendBoundsByPoint(e+r,i+n),this.updatePosition(e,i),this.dirty()},n.prototype.drawRoundRect=function(e,i,r,n,a,o){e=+e||0,i=+i||0,r=+r||0,n=+n||0,a=+a||0,o=+o||0,t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setDrawRoundRect(e,i,r,n,a,o);var s=this.fillPath,h=this.strokePath;s&&s.drawRoundRect(e,i,r,n,a,o),h&&h.drawRoundRect(e,i,r,n,a,o);var c=.5*a|0,l=o?.5*o|0:c,u=e+r,p=i+n,d=p-l;this.extendBoundsByPoint(e,i),this.extendBoundsByPoint(u,p),this.updatePosition(u,d),this.dirty()},n.prototype.drawCircle=function(e,i,r){e=+e||0,i=+i||0,r=+r||0,t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setDrawCircle(e,i,r);var n=this.fillPath,a=this.strokePath;n&&n.drawCircle(e,i,r),a&&a.drawCircle(e,i,r),this.extendBoundsByPoint(e-r-1,i-r-1),this.extendBoundsByPoint(e+r+2,i+r+2),this.updatePosition(e+r,i),this.dirty()},n.prototype.drawEllipse=function(e,i,r,n){e=+e||0,i=+i||0,r=+r||0,n=+n||0,t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setDrawEllipse(e,i,r,n);var a=this.fillPath,o=this.strokePath;a&&a.drawEllipse(e,i,r,n),o&&o.drawEllipse(e,i,r,n),this.extendBoundsByPoint(e-1,i-1),this.extendBoundsByPoint(e+r+2,i+n+2),this.updatePosition(e+r,i+.5*n),this.dirty()},n.prototype.moveTo=function(e,i){e=+e||0,i=+i||0,t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setMoveTo(e,i);var r=this.fillPath,n=this.strokePath;r&&r.moveTo(e,i),n&&n.moveTo(e,i),this.includeLastPosition=!1,this.lastX=e,this.lastY=i,this.dirty()},n.prototype.lineTo=function(e,i){e=+e||0,i=+i||0,t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setLineTo(e,i);var r=this.fillPath,n=this.strokePath;r&&r.lineTo(e,i),n&&n.lineTo(e,i),this.updatePosition(e,i),this.dirty()},n.prototype.curveTo=function(e,r,n,a){e=+e||0,r=+r||0,n=+n||0,a=+a||0,t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setCurveTo(e,r,n,a);var o=this.fillPath,s=this.strokePath;o&&o.curveTo(e,r,n,a),s&&s.curveTo(e,r,n,a);for(var h=this.lastX||0,c=this.lastY||0,l=i([h,c,e,r,n,a],50),u=0;un||a===o)){i=+i||0,r=+r||0,n=+n||0,a=+a||0,o=+o||0,s=!!s,a=e(a),o=e(o),t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setDrawArc(i,r,n,a,o,s);var h=this.fillPath,c=this.strokePath;h&&(h.$lastX=this.lastX,h.$lastY=this.lastY,h.drawArc(i,r,n,a,o,s)),c&&(c.$lastX=this.lastX,c.$lastY=this.lastY,c.drawArc(i,r,n,a,o,s)),s?this.arcBounds(i,r,n,o,a):this.arcBounds(i,r,n,a,o);var l=i+Math.cos(o)*n,u=r+Math.sin(o)*n;this.updatePosition(l,u),this.dirty()}},n.prototype.dirty=function(){var e=this;if(e.$renderNode.dirtyRender=!0,!t.nativeRender){var i=e.$targetDisplay;i.$cacheDirty=!0;var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},n.prototype.arcBounds=function(t,e,i,r,n){var a=Math.PI;if(Math.abs(r-n)<.01)return this.extendBoundsByPoint(t-i,e-i),void this.extendBoundsByPoint(t+i,e+i);r>n&&(n+=2*a);for(var o=Math.cos(r)*i,s=Math.cos(n)*i,h=Math.min(o,s),c=Math.max(o,s),l=Math.sin(r)*i,u=Math.sin(n)*i,p=Math.min(l,u),d=Math.max(l,u),f=r/(.5*a),g=n/(.5*a),$=Math.ceil(f);g>=$;$++)switch($%4){case 0:c=i;break;case 1:d=i;break;case 2:h=-i;break;case 3:p=-i}h=Math.floor(h),p=Math.floor(p),c=Math.ceil(c),d=Math.ceil(d),this.extendBoundsByPoint(h+t,p+e),this.extendBoundsByPoint(c+t,d+e)},n.prototype.clear=function(){t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setGraphicsClear(),this.$renderNode.clear(),this.updatePosition(0,0),this.minX=1/0,this.minY=1/0,this.maxX=-(1/0),this.maxY=-(1/0),this.dirty()},n.prototype.extendBoundsByPoint=function(t,e){this.extendBoundsByX(t),this.extendBoundsByY(e)},n.prototype.extendBoundsByX=function(t){this.minX=Math.min(this.minX,t-this.topLeftStrokeWidth),this.maxX=Math.max(this.maxX,t+this.bottomRightStrokeWidth),this.updateNodeBounds()},n.prototype.extendBoundsByY=function(t){this.minY=Math.min(this.minY,t-this.topLeftStrokeWidth),this.maxY=Math.max(this.maxY,t+this.bottomRightStrokeWidth),this.updateNodeBounds()},n.prototype.updateNodeBounds=function(){var t=this.$renderNode;t.x=this.minX,t.y=this.minY,t.width=Math.ceil(this.maxX-this.minX),t.height=Math.ceil(this.maxY-this.minY)},n.prototype.updatePosition=function(t,e){this.includeLastPosition||(this.extendBoundsByPoint(this.lastX,this.lastY),this.includeLastPosition=!0),this.lastX=t,this.lastY=e,this.extendBoundsByPoint(t,e)},n.prototype.$measureContentBounds=function(t){this.minX===1/0?t.setEmpty():t.setTo(this.minX,this.minY,this.maxX-this.minX,this.maxY-this.minY)},n.prototype.$hitTest=function(e,i){var r=this.$targetDisplay,n=r.$getInvertedConcatenatedMatrix(),a=n.a*e+n.c*i+n.tx,o=n.b*e+n.d*i+n.ty,s=t.sys.canvasHitTestBuffer;s.resize(3,3);var h=this.$renderNode,c=t.Matrix.create();c.identity(),c.translate(1-a,1-o),t.sys.canvasRenderer.drawNodeToBuffer(h,s,c,!0),t.Matrix.release(c);try{var l=s.getPixels(1,1);if(0===l[3])return null}catch(u){throw new Error(t.sys.tr(1039))}return r},n.prototype.$onRemoveFromStage=function(){this.$renderNode&&this.$renderNode.clean(),t.nativeRender&&egret_native.NativeDisplayObject.disposeGraphicData(this)},n}(t.HashObject);t.Graphics=o,__reflect(o.prototype,"egret.Graphics")}(egret||(egret={}));var egret;!function(t){var e=Math.PI,i=2*e,r=e/180,n=[],a=function(a){function o(t,e,i,r,n,o){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=0),void 0===o&&(o=0);var s=a.call(this)||this;return s.a=t,s.b=e,s.c=i,s.d=r,s.tx=n,s.ty=o,s}return __extends(o,a),o.release=function(t){t&&n.push(t)},o.create=function(){var t=n.pop();return t||(t=new o),t},o.prototype.clone=function(){return new o(this.a,this.b,this.c,this.d,this.tx,this.ty)},o.prototype.concat=function(t){var e=this.a*t.a,i=0,r=0,n=this.d*t.d,a=this.tx*t.a+t.tx,o=this.ty*t.d+t.ty;(0!==this.b||0!==this.c||0!==t.b||0!==t.c)&&(e+=this.b*t.c,n+=this.c*t.b,i+=this.a*t.b+this.b*t.d,r+=this.c*t.a+this.d*t.c,a+=this.ty*t.c,o+=this.tx*t.b),this.a=e,this.b=i,this.c=r,this.d=n,this.tx=a,this.ty=o},o.prototype.copyFrom=function(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this},o.prototype.identity=function(){this.a=this.d=1,this.b=this.c=this.tx=this.ty=0},o.prototype.invert=function(){this.$invertInto(this)},o.prototype.$invertInto=function(t){var e=this.a,i=this.b,r=this.c,n=this.d,a=this.tx,o=this.ty;if(0==i&&0==r)return t.b=t.c=0,void(0==e||0==n?t.a=t.d=t.tx=t.ty=0:(e=t.a=1/e,n=t.d=1/n,t.tx=-e*a,t.ty=-n*o));var s=e*n-i*r;if(0==s)return void t.identity();s=1/s;var h=t.a=n*s;i=t.b=-i*s,r=t.c=-r*s,n=t.d=e*s,t.tx=-(h*a+r*o),t.ty=-(i*a+n*o)},o.prototype.rotate=function(e){if(e=+e,0!==e){e/=r;var i=t.NumberUtils.cos(e),n=t.NumberUtils.sin(e),a=this.a,o=this.b,s=this.c,h=this.d,c=this.tx,l=this.ty;this.a=a*i-o*n,this.b=a*n+o*i,this.c=s*i-h*n,this.d=s*n+h*i,this.tx=c*i-l*n,this.ty=c*n+l*i}},o.prototype.scale=function(t,e){1!==t&&(this.a*=t,this.c*=t,this.tx*=t),1!==e&&(this.b*=e,this.d*=e,this.ty*=e)},o.prototype.setTo=function(t,e,i,r,n,a){return this.a=t,this.b=e,this.c=i,this.d=r,this.tx=n,this.ty=a,this},o.prototype.transformPoint=function(e,i,r){var n=this.a*e+this.c*i+this.tx,a=this.b*e+this.d*i+this.ty;return r?(r.setTo(n,a),r):new t.Point(n,a)},o.prototype.translate=function(t,e){this.tx+=t,this.ty+=e},o.prototype.equals=function(t){return this.a==t.a&&this.b==t.b&&this.c==t.c&&this.d==t.d&&this.tx==t.tx&&this.ty==t.ty},o.prototype.prepend=function(t,e,i,r,n,a){var o=this.tx;if(1!=t||0!=e||0!=i||1!=r){var s=this.a,h=this.c;this.a=s*t+this.b*i,this.b=s*e+this.b*r,this.c=h*t+this.d*i,this.d=h*e+this.d*r}return this.tx=o*t+this.ty*i+n,this.ty=o*e+this.ty*r+a,this},o.prototype.append=function(t,e,i,r,n,a){var o=this.a,s=this.b,h=this.c,c=this.d;return(1!=t||0!=e||0!=i||1!=r)&&(this.a=t*o+e*h,this.b=t*s+e*c,this.c=i*o+r*h,this.d=i*s+r*c),this.tx=n*o+a*h+this.tx,this.ty=n*s+a*c+this.ty,this},o.prototype.deltaTransformPoint=function(e){var i=this,r=i.a*e.x+i.c*e.y,n=i.b*e.x+i.d*e.y;return new t.Point(r,n)},o.prototype.toString=function(){return"(a="+this.a+", b="+this.b+", c="+this.c+", d="+this.d+", tx="+this.tx+", ty="+this.ty+")"},o.prototype.createBox=function(e,i,n,a,o){void 0===n&&(n=0),void 0===a&&(a=0),void 0===o&&(o=0);var s=this;if(0!==n){n/=r;var h=t.NumberUtils.cos(n),c=t.NumberUtils.sin(n);s.a=h*e,s.b=c*i,s.c=-c*e,s.d=h*i}else s.a=e,s.b=0,s.c=0,s.d=i;s.tx=a,s.ty=o},o.prototype.createGradientBox=function(t,e,i,r,n){void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=0),this.createBox(t/1638.4,e/1638.4,i,r+t/2,n+e/2)},o.prototype.$transformBounds=function(t){var e=this.a,i=this.b,r=this.c,n=this.d,a=this.tx,o=this.ty,s=t.x,h=t.y,c=s+t.width,l=h+t.height,u=e*s+r*h+a,p=i*s+n*h+o,d=e*c+r*h+a,f=i*c+n*h+o,g=e*c+r*l+a,$=i*c+n*l+o,y=e*s+r*l+a,v=i*s+n*l+o,b=0;u>d&&(b=u,u=d,d=b),g>y&&(b=g,g=y,y=b),t.x=Math.floor(g>u?u:g),t.width=Math.ceil((d>y?d:y)-t.x),p>f&&(b=p,p=f,f=b),$>v&&(b=$,$=v,v=b),t.y=Math.floor($>p?p:$),t.height=Math.ceil((f>v?f:v)-t.y)},o.prototype.getDeterminant=function(){return this.a*this.d-this.b*this.c},o.prototype.$getScaleX=function(){var t=this;if(0==t.b)return t.a;var e=Math.sqrt(t.a*t.a+t.b*t.b);return this.getDeterminant()<0?-e:e},o.prototype.$getScaleY=function(){var t=this;if(0==t.c)return t.d;var e=Math.sqrt(t.c*t.c+t.d*t.d);return this.getDeterminant()<0?-e:e},o.prototype.$getSkewX=function(){return this.d<0?Math.atan2(this.d,this.c)+e/2:Math.atan2(this.d,this.c)-e/2},o.prototype.$getSkewY=function(){return this.a<0?Math.atan2(this.b,this.a)-e:Math.atan2(this.b,this.a)},o.prototype.$updateScaleAndRotation=function(e,n,a,o){if(!(0!=a&&a!=i||0!=o&&o!=i))return this.a=e,this.b=this.c=0,void(this.d=n);a/=r,o/=r;var s=t.NumberUtils.cos(a),h=t.NumberUtils.sin(a);a==o?(this.a=s*e,this.b=h*e):(this.a=t.NumberUtils.cos(o)*e,this.b=t.NumberUtils.sin(o)*e),this.c=-h*n,this.d=s*n},o.prototype.$preMultiplyInto=function(t,e){var i=t.a*this.a,r=0,n=0,a=t.d*this.d,o=t.tx*this.a+this.tx,s=t.ty*this.d+this.ty;(0!==t.b||0!==t.c||0!==this.b||0!==this.c)&&(i+=t.b*this.c,a+=t.c*this.b,r+=t.a*this.b+t.b*this.d,n+=t.c*this.a+t.d*this.c,o+=t.ty*this.c,s+=t.tx*this.b),e.a=i,e.b=r,e.c=n,e.d=a,e.tx=o,e.ty=s},o}(t.HashObject);t.Matrix=a,__reflect(a.prototype,"egret.Matrix"),t.$TempMatrix=new a}(egret||(egret={}));var egret;!function(t){var e=[],i=function(i){function r(t,e,r,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===r&&(r=0),void 0===n&&(n=0);var a=i.call(this)||this;return a.x=t,a.y=e,a.width=r,a.height=n,a}return __extends(r,i),r.release=function(t){t&&e.push(t)},r.create=function(){var t=e.pop();return t||(t=new r),t},Object.defineProperty(r.prototype,"right",{get:function(){return this.x+this.width},set:function(t){this.width=t-this.x},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"bottom",{get:function(){return this.y+this.height},set:function(t){this.height=t-this.y},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"left",{get:function(){return this.x},set:function(t){this.width+=this.x-t,this.x=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"top",{get:function(){return this.y},set:function(t){this.height+=this.y-t,this.y=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"topLeft",{get:function(){return new t.Point(this.left,this.top)},set:function(t){this.top=t.y,this.left=t.x},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"bottomRight",{get:function(){return new t.Point(this.right,this.bottom)},set:function(t){this.bottom=t.y,this.right=t.x},enumerable:!0,configurable:!0}),r.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this},r.prototype.setTo=function(t,e,i,r){return this.x=t,this.y=e,this.width=i,this.height=r,this},r.prototype.contains=function(t,e){return this.x<=t&&this.x+this.width>=t&&this.y<=e&&this.y+this.height>=e},r.prototype.intersection=function(t){return this.clone().$intersectInPlace(t)},r.prototype.inflate=function(t,e){this.x-=t,this.width+=2*t,this.y-=e,this.height+=2*e},r.prototype.$intersectInPlace=function(t){var e=this.x,i=this.y,r=t.x,n=t.y,a=Math.max(e,r),o=Math.min(e+this.width,r+t.width);if(o>=a){var s=Math.max(i,n),h=Math.min(i+this.height,n+t.height);if(h>=s)return this.setTo(a,s,o-a,h-s),this}return this.setEmpty(),this},r.prototype.intersects=function(t){return Math.max(this.x,t.x)<=Math.min(this.right,t.right)&&Math.max(this.y,t.y)<=Math.min(this.bottom,t.bottom)},r.prototype.isEmpty=function(){return this.width<=0||this.height<=0},r.prototype.setEmpty=function(){this.x=0,this.y=0,this.width=0,this.height=0},r.prototype.clone=function(){return new r(this.x,this.y,this.width,this.height)},r.prototype.containsPoint=function(t){return this.x<=t.x&&this.x+this.width>t.x&&this.y<=t.y&&this.y+this.height>t.y?!0:!1},r.prototype.containsRect=function(t){var e=t.x+t.width,i=t.y+t.height,r=this.x+this.width,n=this.y+this.height;return t.x>=this.x&&t.x=this.y&&t.ythis.x&&r>=e&&i>this.y&&n>=i},r.prototype.equals=function(t){return this===t?!0:this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height},r.prototype.inflatePoint=function(t){this.inflate(t.x,t.y)},r.prototype.offset=function(t,e){this.x+=t,this.y+=e},r.prototype.offsetPoint=function(t){this.offset(t.x,t.y)},r.prototype.toString=function(){return"(x="+this.x+", y="+this.y+", width="+this.width+", height="+this.height+")"},r.prototype.union=function(t){var e=this.clone();if(t.isEmpty())return e;if(e.isEmpty())return e.copyFrom(t),e;var i=Math.min(e.x,t.x),r=Math.min(e.y,t.y);return e.setTo(i,r,Math.max(e.right,t.right)-i,Math.max(e.bottom,t.bottom)-r),e},r.prototype.$getBaseWidth=function(t){var e=Math.abs(Math.cos(t)),i=Math.abs(Math.sin(t));return e*this.width+i*this.height},r.prototype.$getBaseHeight=function(t){var e=Math.abs(Math.cos(t)),i=Math.abs(Math.sin(t));return i*this.width+e*this.height},r}(t.HashObject);t.Rectangle=i,__reflect(i.prototype,"egret.Rectangle"),t.$TempRectangle=new i}(egret||(egret={}));var egret;!function(t){t.$locale_strings=t.$locale_strings||{},t.$locale_strings.en_US=t.$locale_strings.en_US||{};var e=t.$locale_strings.en_US;e[1001]="Could not find Egret entry class: {0}。",e[1002]="Egret entry class '{0}' must inherit from egret.DisplayObject.",e[1003]="Parameter {0} must be non-null.",e[1004]="An object cannot be added as a child to one of it's children (or children's children, etc.).",e[1005]="An object cannot be added as a child of itself.",e[1006]="The supplied DisplayObject must be a child of the caller.",e[1007]="An index specified for a parameter was out of range.",e[1008]="Instantiate singleton error,singleton class {0} can not create multiple instances.",e[1009]='the Class {0} cannot use the property "{1}"',e[1010]='the property "{1}" of the Class "{0}" is readonly',e[1011]="Stream Error. URL: {0}",e[1012]="The type of parameter {0} must be Class.",e[1013]="Variable assignment is NaN, please see the code!",e[1014]='the constant "{1}" of the Class "{0}" is read-only',e[1015]="xml not found!",e[1016]="{0}has been obsoleted",e[1017]="The format of JSON file is incorrect: {0}\ndata: {1}",e[1018]="the scale9Grid is not correct",e[1019]="Network ab:{0}",e[1020]="Cannot initialize Shader",e[1021]="Current browser does not support webgl",e[1022]="{0} ArgumentError",e[1023]="This method is not available in the ScrollView!",e[1025]="end of the file",e[1026]="! EncodingError The code point {0} could not be encoded.",e[1027]="DecodingError",e[1028]=". called injection is not configured rule: {0}, please specify configuration during its initial years of injection rule, and then call the corresponding single case.",e[1029]="Function.prototype.bind - what is trying to be bound is not callable",e[1033]="Photos can not be used across domains toDataURL to convert base64",e[1034]='Music file decoding failed: "{0}", please use the standard conversion tool reconversion under mp3.',e[1035]="Native does not support this feature!",e[1036]="Sound has stopped, please recall Sound.play () to play the sound!",e[1037]="Non-load the correct blob!",e[1038]="XML format error!",e[1039]="Cross domains pictures can not get pixel information!",e[1040]="hitTestPoint can not detect crossOrigin images! Please check if the display object has crossOrigin elements.",e[1041]="{0} is deprecated, please use {1} replace",e[1042]="The parameters passed in the region needs is an integer in drawToTexture method. Otherwise, some browsers will draw abnormal.",e[1043]="Compile errors in {0}, the attribute name: {1}, the attribute value: {2}.",e[1044]="The current version of the Runtime does not support video playback, please use the latest version",e[1045]="The resource url is not found",e[1046]="BitmapText no corresponding characters: {0}, please check the configuration file",e[1047]="egret.localStorage.setItem save failed,key={0}&value={1}",e[1048]="Video loading failed",e[1049]="In the absence of sound is not allowed to play after loading",e[1050]="ExternalInterface calls the method without js registration: {0}",e[3e3]="Theme configuration file failed to load: {0}",e[3001]="Cannot find the skin name which is configured in Theme: {0}",e[3002]='Index:"{0}" is out of the collection element index range',e[3003]="Cannot be available in this component. If this component is container, please continue to use",e[3004]="addChild(){0}addElement() replace",e[3005]="addChildAt(){0}addElementAt() replace",e[3006]="removeChild(){0}removeElement() replace",e[3007]="removeChildAt(){0}removeElementAt() replace",e[3008]="setChildIndex(){0}setElementIndex() replace",e[3009]="swapChildren(){0}swapElements() replace",e[3010]="swapChildrenAt(){0}swapElementsAt() replace",e[3011]='Index:"{0}" is out of the visual element index range',e[3012]="This method is not available in Scroller component!",e[3013]="UIStage is GUI root container, and only one such instant is in the display list!",e[3014]="set fullscreen error",e[3100]="Current browser does not support WebSocket",e[3101]="Please connect Socket firstly",e[3102]="Please set the type of binary type",e[4e3]="An Bone cannot be added as a child to itself or one of its children (or children's children, etc.)",e[4001]="Abstract class can not be instantiated!",e[4002]="Unnamed data!",e[4003]="Nonsupport version!"}(egret||(egret={}));var egret;!function(t){t.JointStyle={BEVEL:"bevel",MITER:"miter",ROUND:"round"}}(egret||(egret={}));var egret;!function(t){t.$locale_strings=t.$locale_strings||{},t.$locale_strings.zh_CN=t.$locale_strings.zh_CN||{};var e=t.$locale_strings.zh_CN;e[1001]="找不到Egret入口类: {0}。",e[1002]="Egret入口类 {0} 必须继承自egret.DisplayObject。",e[1003]="参数 {0} 不能为 null。",e[1004]="无法将对象添加为它的一个子对象(或子对象的子对象等)的子对象。",e[1005]="不能将对象添加为其自身的子对象。",e[1006]="提供的 DisplayObject 必须是调用者的子级。",e[1007]="为参数指定的索引不在范围内。",e[1008]="实例化单例出错,不允许实例化多个 {0} 对象。",e[1009]="类 {0} 不可以使用属性 {1}",e[1010]="类 {0} 属性 {1} 是只读的",e[1011]="流错误。URL: {0}",e[1012]="参数 {0} 的类型必须为 Class。",e[1013]="变量赋值为NaN,请查看代码!",e[1014]="类 {0} 常量 {1} 是只读的",e[1015]="xml not found!",e[1016]="{0}已经废弃",e[1017]="JSON文件格式不正确: {0}\ndata: {1}",e[1018]="9宫格设置错误",e[1019]="网络异常:{0}",e[1020]="无法初始化着色器",e[1021]="当前浏览器不支持webgl",e[1022]="{0} ArgumentError",e[1023]="此方法在ScrollView内不可用!",e[1025]="遇到文件尾",e[1026]="EncodingError! The code point {0} could not be encoded.",e[1027]="DecodingError",e[1028]="调用了未配置的注入规则:{0}。 请先在项目初始化里配置指定的注入规则,再调用对应单例。",e[1029]="Function.prototype.bind - what is trying to be bound is not callable",e[1033]="跨域图片不可以使用toDataURL来转换成base64",e[1034]='音乐文件解码失败:"{0}",请使用标准的转换工具重新转换下mp3。',e[1035]="Native 下暂未实现此功能!",e[1036]="声音已停止,请重新调用 Sound.play() 来播放声音!",e[1037]="非正确的blob加载!",e[1038]="XML 格式错误!",e[1039]="跨域图片不能获取像素信息!",e[1040]="hitTestPoint 不能对跨域图片进行检测! 请检查该显示对象内是否含有跨域元素",e[1041]="{0} 已废弃,请使用 {1} 代替",e[1042]="drawToTexture方法传入的区域各个参数需要为整数,否则某些浏览器绘制会出现异常",e[1043]="{0} 中存在编译错误,属性名 : {1},属性值 : {2}",e[1044]="当前的 runtime 版本不支持视频播放,请使用最新的版本",e[1045]="没有设置要加载的资源地址",e[1046]="BitmapText 找不到对应字符:{0},请检查配置文件",e[1047]="egret.localStorage.setItem保存失败,key={0}&value={1}",e[1048]="视频加载失败",e[1049]="声音在没有加载完之前不允许播放",e[1050]="ExternalInterface调用了js没有注册的方法: {0}",e[3e3]="主题配置文件加载失败: {0}",e[3001]="找不到主题中所配置的皮肤类名: {0}",e[3002]='索引:"{0}"超出集合元素索引范围',e[3003]="在此组件中不可用,若此组件为容器类,请使用",e[3004]="addChild(){0}addElement()代替",e[3005]="addChildAt(){0}addElementAt()代替",e[3006]="removeChild(){0}removeElement()代替",e[3007]="removeChildAt(){0}removeElementAt()代替",e[3008]="setChildIndex(){0}setElementIndex()代替",e[3009]="swapChildren(){0}swapElements()代替",e[3010]="swapChildrenAt(){0}swapElementsAt()代替",e[3011]='索引:"{0}"超出可视元素索引范围',e[3012]="此方法在Scroller组件内不可用!",e[3013]="UIStage是GUI根容器,只能有一个此实例在显示列表中!",e[3014]="设置全屏模式失败",e[3100]="当前浏览器不支持WebSocket",e[3101]="请先连接WebSocket",e[3102]="请先设置type为二进制类型",e[4e3]="An Bone cannot be added as a child to itself or one of its children (or children's children, etc.)",e[4001]="Abstract class can not be instantiated!",e[4002]="Unnamed data!",e[4003]="Nonsupport version!"}(egret||(egret={}));var egret;!function(t){var e;!function(t){}(e=t.localStorage||(t.localStorage={}))}(egret||(egret={}));var egret;!function(t){var e;!function(t){function e(t){r.indexOf(t)<0&&r.push(t)}function i(t){var e=r.indexOf(t);return e>=0?(r.splice(e,1),!0):!1}var r=[];t.$pushSoundChannel=e,t.$popSoundChannel=i}(e=t.sys||(t.sys={}))}(egret||(egret={})),function(t){}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e;!function(t){t.GET="GET",t.POST="POST"}(e=t.HttpMethod||(t.HttpMethod={}))}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.TEXT="text",t.ARRAY_BUFFER="arraybuffer",t}();t.HttpResponseType=e,__reflect(e.prototype,"egret.HttpResponseType")}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(i){function r(r){var n=i.call(this)||this;return n.isStage=!1,n.$renderNode=new e.BitmapNode,n.renderBuffer=null,n.offsetX=0,n.offsetY=0,n.offsetMatrix=new t.Matrix,n.$canvasScaleX=1,n.$canvasScaleY=1,n.root=r,n.isStage=r instanceof t.Stage,n}return __extends(r,i),r.create=function(i){var r=new t.sys.DisplayList(i);try{var n=new e.RenderBuffer;r.renderBuffer=n}catch(a){return null}return r.root=i,r},r.prototype.$getRenderNode=function(){return this.$renderNode},r.prototype.setClipRect=function(t,e){t*=r.$canvasScaleX,e*=r.$canvasScaleY,this.renderBuffer.resize(t,e)},r.prototype.drawToSurface=function(){var i=0;this.$canvasScaleX=this.offsetMatrix.a=r.$canvasScaleX,this.$canvasScaleY=this.offsetMatrix.d=r.$canvasScaleY,this.isStage||this.changeSurfaceSize();var n=this.renderBuffer;if(n.clear(),i=e.systemRenderer.render(this.root,n,this.offsetMatrix),!this.isStage){var a=n.surface,o=this.$renderNode;o.drawData.length=0;var s=a.width,h=a.height;this.bitmapData?(this.bitmapData.source=a,this.bitmapData.width=s,this.bitmapData.height=h):this.bitmapData=new t.BitmapData(a),o.image=this.bitmapData,o.imageWidth=s,o.imageHeight=h,o.drawImage(0,0,s,h,-this.offsetX,-this.offsetY,s/this.$canvasScaleX,h/this.$canvasScaleY)}return i},r.prototype.changeSurfaceSize=function(){var t=(this.root,this.offsetX),e=this.offsetY,i=this.root.$getOriginalBounds(),r=this.$canvasScaleX,n=this.$canvasScaleY;this.offsetX=-i.x,this.offsetY=-i.y,this.offsetMatrix.setTo(this.offsetMatrix.a,0,0,this.offsetMatrix.d,this.offsetX,this.offsetY);var a=this.renderBuffer,o=Math.max(257,i.width*r),s=Math.max(257,i.height*n);(this.offsetX!=t||this.offsetY!=e||a.surface.width!=o||a.surface.height!=s)&&a.resize(o,s)},r.$setCanvasScale=function(e,i){r.$canvasScaleX=e,r.$canvasScaleY=i,t.nativeRender&&egret_native.nrSetCanvasScaleFactor(r.$canvasScaleFactor,e,i)},r.$canvasScaleFactor=1,r.$canvasScaleX=1,r.$canvasScaleY=1,r}(t.HashObject);e.DisplayList=i,__reflect(i.prototype,"egret.sys.DisplayList")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e;!function(e){function i(t){for(var e=[],i=0;in;n++)r+=arguments[n]+" ";e.$logToFPS(r),console.log.apply(console,i(arguments))},t.warn=function(){for(var t=arguments.length,r="",n=0;t>n;n++)r+=arguments[n]+" ";e.$warnToFPS(r),console.warn.apply(console,i(arguments))},t.error=function(){for(var t=arguments.length,r="",n=0;t>n;n++)r+=arguments[n]+" ";e.$errorToFPS(r),console.error.apply(console,i(arguments))}),this.showFPS=!!r,this.showLog=h,!n){n=new FPS(this.stage,r,h,c,l);for(var u=a.length,p=0;u>p;p++)n.updateInfo(a[p]);a=null;for(var d=o.length,p=0;d>p;p++)n.updateWarn(o[p]);o=null;for(var f=s.length,p=0;f>p;p++)n.updateError(s[p]);s=null}},h}(t.HashObject);e.Player=r,__reflect(r.prototype,"egret.sys.Player");var n,a=[],o=[],s=[];e.$logToFPS=function(t){return n?void n.updateInfo(t):void a.push(t)},e.$warnToFPS=function(t){return n?void n.updateWarn(t):void o.push(t)},e.$errorToFPS=function(t){return n?void n.updateError(t):void s.push(t) -};var h=function(){function e(e,i,r,n,a){this.showFPS=i,this.showLog=r,this.logFilter=n,this.styles=a,this.infoLines=[],this.totalTime=0,this.totalTick=0,this.lastTime=0,this.drawCalls=0,this.costRender=0,this.costTicker=0,this.infoLines=[],this.totalTime=0,this.totalTick=0,this.lastTime=0,this.drawCalls=0,this.costRender=0,this.costTicker=0,this._stage=e,this.showFPS=i,this.showLog=r,this.logFilter=n,this.styles=a,this.fpsDisplay=new t.FPSDisplay(e,i,r,n,a);var o;try{o=n?new RegExp(n):null}catch(s){t.log(s)}this.filter=function(t){return o?o.test(t):!n||0==t.indexOf(n)}}return e.prototype.update=function(e,i,r){var n=t.getTimer();if(this.totalTime+=n-this.lastTime,this.lastTime=n,this.totalTick++,this.drawCalls+=e,this.costRender+=i,this.costTicker+=r,this.totalTime>=1e3){var a=Math.min(Math.ceil(1e3*this.totalTick/this.totalTime),t.ticker.$frameRate),o=Math.round(this.drawCalls/this.totalTick),s=Math.round(this.costRender/this.totalTick),h=Math.round(this.costTicker/this.totalTick);this.fpsDisplay.update({fps:a,draw:o,costTicker:h,costRender:s}),this.totalTick=0,this.totalTime=this.totalTime%1e3,this.drawCalls=0,this.costRender=0,this.costTicker=0}},e.prototype.updateInfo=function(t){t&&this.showLog&&this.filter(t)&&this.fpsDisplay.updateInfo(t)},e.prototype.updateWarn=function(t){t&&this.showLog&&this.filter(t)&&(this.fpsDisplay.updateWarn?this.fpsDisplay.updateWarn(t):this.fpsDisplay.updateInfo("[Warning]"+t))},e.prototype.updateError=function(t){t&&this.showLog&&this.filter(t)&&(this.fpsDisplay.updateError?this.fpsDisplay.updateError(t):this.fpsDisplay.updateInfo("[Error]"+t))},e}();__reflect(h.prototype,"FPSImpl"),__global.FPS=h,t.warn=function(){console.warn.apply(console,i(arguments))},t.error=function(){console.error.apply(console,i(arguments))},t.assert=function(){console.assert.apply(console,i(arguments))},t.log=function(){console.log.apply(console,i(arguments))}}(e=t.sys||(t.sys={}))}(egret||(egret={})),function(t){if(t.nativeRender=__global.nativeRender,t.nativeRender){var e=egret_native.nrABIVersion,i=egret_native.nrMinEgretVersion,r=4;if(r>e){t.nativeRender=!1;var n="需要升级微端版本到 0.1.8 才可以开启原生渲染加速";t.sys.$warnToFPS(n),t.warn(n)}else if(e>r){t.nativeRender=!1;var n="需要升级引擎版本到 "+i+" 才可以开启原生渲染加速";t.sys.$warnToFPS(n),t.warn(n)}}}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(i){var r=e.call(this,i)||this;return r._verticesDirty=!0,r._bounds=new t.Rectangle,r.$renderNode=new t.sys.MeshNode,r}return __extends(i,e),i.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(12)},i.prototype.setBitmapDataToWasm=function(t){this.$nativeDisplayObject.setBitmapDataToMesh(t)},i.prototype.$updateRenderNode=function(){var e=this.$bitmapData;if(e){var i=(t.$TextureScaleFactor,this.$renderNode);i.smoothing=this.$smoothing,i.image=e,i.imageWidth=this.$sourceWidth,i.imageHeight=this.$sourceHeight;var r=isNaN(this.$explicitBitmapWidth)?this.$textureWidth:this.$explicitBitmapWidth,n=isNaN(this.$explicitBitmapHeight)?this.$textureHeight:this.$explicitBitmapHeight,a=r/this.$textureWidth,o=n/this.$textureHeight,s=this.$bitmapWidth,h=this.$bitmapHeight;i.drawMesh(this.$bitmapX,this.$bitmapY,s,h,this.$offsetX*a,this.$offsetY*o,a*s,o*h)}},i.prototype.$updateVertices=function(){var e=this;if(e._verticesDirty=!0,e.$renderDirty=!0,t.nativeRender){var i=this.$renderNode;this.$nativeDisplayObject.setDataToMesh(i.vertices,i.indices,i.uvs)}else{var r=e.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=e.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},i.prototype.$measureContentBounds=function(t){if(this._verticesDirty){this._verticesDirty=!1;var e=this.$renderNode,i=e.vertices;if(i.length){this._bounds.setTo(Number.MAX_VALUE,Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var r=0,n=i.length;n>r;r+=2){var a=i[r],o=i[r+1];this._bounds.x>a&&(this._bounds.x=a),this._bounds.widtho&&(this._bounds.y=o),this._bounds.heightu?s=Math.round(c*l):o=Math.round(h*u);break;case t.StageScaleMode.SHOW_ALL:l>u?o=Math.round(h*u):s=Math.round(c*l);break;case t.StageScaleMode.FIXED_NARROW:l>u?h=Math.round(i/u):c=Math.round(r/l);break;case t.StageScaleMode.FIXED_WIDE:l>u?c=Math.round(r/l):h=Math.round(i/u);break;default:h=i,c=r}return h%2!=0&&(h+=1),c%2!=0&&(c+=1),o%2!=0&&(o+=1),s%2!=0&&(s+=1),{stageWidth:h,stageHeight:c,displayWidth:o,displayHeight:s}},i}(t.HashObject);e.DefaultScreenAdapter=i,__reflect(i.prototype,"egret.sys.DefaultScreenAdapter",["egret.sys.IScreenAdapter"])}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.NO_SCALE="noScale",t.SHOW_ALL="showAll",t.NO_BORDER="noBorder",t.EXACT_FIT="exactFit",t.FIXED_WIDTH="fixedWidth",t.FIXED_HEIGHT="fixedHeight",t.FIXED_NARROW="fixedNarrow",t.FIXED_WIDE="fixedWide",t}();t.StageScaleMode=e,__reflect(e.prototype,"egret.StageScaleMode")}(egret||(egret={}));var egret;!function(t){var e;!function(t){}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){e.$START_TIME=0,e.$invalidateRenderFlag=!1,e.$requestRenderingFlag=!1;var i=function(){function i(){this.playerList=[],this.callBackList=[],this.thisObjectList=[],this.$frameRate=30,this.lastTimeStamp=0,this.costEnterFrame=0,this.isPaused=!1,e.$START_TIME=Date.now(),this.frameDeltaTime=1e3/this.$frameRate,this.lastCount=this.frameInterval=Math.round(6e4/this.$frameRate)}return i.prototype.$addPlayer=function(t){-1==this.playerList.indexOf(t)&&(this.playerList=this.playerList.concat(),this.playerList.push(t))},i.prototype.$removePlayer=function(t){var e=this.playerList.indexOf(t);if(-1!==e){this.playerList=this.playerList.concat(),this.playerList.splice(e,1)}},i.prototype.$startTick=function(t,e){var i=this.getTickIndex(t,e);-1==i&&(this.concatTick(),this.callBackList.push(t),this.thisObjectList.push(e))},i.prototype.$stopTick=function(t,e){var i=this.getTickIndex(t,e);-1!=i&&(this.concatTick(),this.callBackList.splice(i,1),this.thisObjectList.splice(i,1))},i.prototype.getTickIndex=function(t,e){for(var i=this.callBackList,r=this.thisObjectList,n=i.length-1;n>=0;n--)if(i[n]==t&&r[n]==e)return n;return-1},i.prototype.concatTick=function(){this.callBackList=this.callBackList.concat(),this.thisObjectList=this.thisObjectList.concat()},i.prototype.$setFrameRate=function(t){return 0>=t?!1:this.$frameRate==t?!1:(this.$frameRate=t,t>60&&(t=60),this.frameDeltaTime=1e3/t,this.lastCount=this.frameInterval=Math.round(6e4/t),!0)},i.prototype.pause=function(){this.isPaused=!0},i.prototype.resume=function(){this.isPaused=!1},i.prototype.update=function(){for(var i=t.getTimer(),r=this.callBackList,n=this.thisObjectList,a=r.length,o=e.$requestRenderingFlag,s=t.getTimer(),h=t.lifecycle.contexts,c=0,l=h;cp;p++)r[p].call(n[p],s)&&(o=!0);var d=t.getTimer(),f=s-this.lastTimeStamp;if(this.lastTimeStamp=s,f>=this.frameDeltaTime)this.lastCount=this.frameInterval;else{if(this.lastCount-=1e3,this.lastCount>0)return void(o&&this.render(!1,this.costEnterFrame+d-i));this.lastCount+=this.frameInterval}this.render(!0,this.costEnterFrame+d-i);var g=t.getTimer();this.broadcastEnterFrame();var $=t.getTimer();this.costEnterFrame=$-g},i.prototype.render=function(t,i){var r=this.playerList,n=r.length;if(0!=n){this.callLaters(),e.$invalidateRenderFlag&&(this.broadcastRender(),e.$invalidateRenderFlag=!1);for(var a=0;n>a;a++)r[a].$render(t,i);e.$requestRenderingFlag=!1}},i.prototype.broadcastEnterFrame=function(){var e=t.DisplayObject.$enterFrameCallBackList,i=e.length;if(0!=i){e=e.concat();for(var r=0;i>r;r++)e[r].dispatchEventWith(t.Event.ENTER_FRAME)}},i.prototype.broadcastRender=function(){var e=t.DisplayObject.$renderCallBackList,i=e.length;if(0!=i){e=e.concat();for(var r=0;i>r;r++)e[r].dispatchEventWith(t.Event.RENDER)}},i.prototype.callLaters=function(){var e,i,r;if(t.$callLaterFunctionList.length>0&&(e=t.$callLaterFunctionList,t.$callLaterFunctionList=[],i=t.$callLaterThisList,t.$callLaterThisList=[],r=t.$callLaterArgsList,t.$callLaterArgsList=[]),e)for(var n=e.length,a=0;n>a;a++){var o=e[a];null!=o&&o.apply(i[a],r[a])}},i.prototype.callLaterAsyncs=function(){if(t.$callAsyncFunctionList.length>0){var e=t.$callAsyncFunctionList,i=t.$callAsyncThisList,r=t.$callAsyncArgsList;t.$callAsyncFunctionList=[],t.$callAsyncThisList=[],t.$callAsyncArgsList=[];for(var n=0;n=this.maxTouches)){this.lastTouchX=e,this.lastTouchY=i;var n=this.findTarget(e,i);null==this.touchDownTarget[r]&&(this.touchDownTarget[r]=n,this.useTouchesCount++),t.TouchEvent.dispatchTouchEvent(n,t.TouchEvent.TOUCH_BEGIN,!0,!0,e,i,r,!0)}},i.prototype.onTouchMove=function(e,i,r){if(null!=this.touchDownTarget[r]&&(this.lastTouchX!=e||this.lastTouchY!=i)){this.lastTouchX=e,this.lastTouchY=i;var n=this.findTarget(e,i);t.TouchEvent.dispatchTouchEvent(n,t.TouchEvent.TOUCH_MOVE,!0,!0,e,i,r,!0)}},i.prototype.onTouchEnd=function(e,i,r){if(null!=this.touchDownTarget[r]){var n=this.findTarget(e,i),a=this.touchDownTarget[r];delete this.touchDownTarget[r],this.useTouchesCount--,t.TouchEvent.dispatchTouchEvent(n,t.TouchEvent.TOUCH_END,!0,!0,e,i,r,!1),a==n?t.TouchEvent.dispatchTouchEvent(n,t.TouchEvent.TOUCH_TAP,!0,!0,e,i,r,!1):t.TouchEvent.dispatchTouchEvent(a,t.TouchEvent.TOUCH_RELEASE_OUTSIDE,!0,!0,e,i,r,!1)}},i.prototype.findTarget=function(t,e){var i=this.stage.$hitTest(t,e);return i||(i=this.stage),i},i}(t.HashObject);e.TouchHandler=i,__reflect(i.prototype,"egret.sys.TouchHandler")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(e){function i(){var t=e.call(this)||this;return t.image=null,t.smoothing=!0,t.blendMode=null,t.alpha=0/0,t.filter=null,t.rotated=!1,t.type=1,t}return __extends(i,e),i.prototype.drawImage=function(t,e,i,r,n,a,o,s){this.drawData.push(t,e,i,r,n,a,o,s),this.renderCount++},i.prototype.cleanBeforeRender=function(){e.prototype.cleanBeforeRender.call(this),this.image=null,this.matrix=null,this.blendMode=null,this.alpha=0/0,this.filter=null},i.$updateTextureData=function(e,r,n,a,o,s,h,c,l,u,p,d,f,g,$,y){if(r){var v=t.$TextureScaleFactor;if(e.smoothing=y,e.image=r,e.imageWidth=f,e.imageHeight=g,$==t.BitmapFillMode.SCALE){var b=p/l*v,m=d/u*v;e.drawImage(n,a,o,s,b*h,m*c,b*o,m*s)}else if($==t.BitmapFillMode.CLIP){var x=Math.min(l,p),T=Math.min(u,d),_=o*v,D=s*v;i.drawClipImage(e,v,n,a,_,D,h,c,x,T)}else for(var _=o*v,D=s*v,O=0;p>O;O+=l)for(var w=0;d>w;w+=u){var x=Math.min(p-O,l),T=Math.min(d-w,u);i.drawClipImage(e,v,n,a,_,D,h,c,x,T,O,w)}}},i.$updateTextureDataWithScale9Grid=function(e,i,r,n,a,o,s,h,c,l,u,p,d,f,g,$){e.smoothing=$,e.image=i,e.imageWidth=f,e.imageHeight=g;var y=o,v=s;p-=l-o*t.$TextureScaleFactor,d-=u-s*t.$TextureScaleFactor;var b=r.x-h,m=r.y-c,x=b/t.$TextureScaleFactor,T=m/t.$TextureScaleFactor,_=r.width/t.$TextureScaleFactor,D=r.height/t.$TextureScaleFactor;0==D&&(D=1,T>=v&&T--),0==_&&(_=1,x>=y&&x--);var O=n,w=O+x,E=w+_,R=y-x-_,S=a,F=S+T,P=F+D,C=v-T-D,M=R*t.$TextureScaleFactor,j=C*t.$TextureScaleFactor;if((x+R)*t.$TextureScaleFactor>p||(T+C)*t.$TextureScaleFactor>d)return void e.drawImage(n,a,o,s,h,c,p,d);var A=h,B=A+b,N=A+(p-M),k=p-b-M,L=c,I=L+m,U=L+d-j,X=d-m-j;T>0&&(x>0&&e.drawImage(O,S,x,T,A,L,b,m),_>0&&e.drawImage(w,S,_,T,B,L,k,m),R>0&&e.drawImage(E,S,R,T,N,L,M,m)),D>0&&(x>0&&e.drawImage(O,F,x,D,A,I,b,X),_>0&&e.drawImage(w,F,_,D,B,I,k,X),R>0&&e.drawImage(E,F,R,D,N,I,M,X)),C>0&&(x>0&&e.drawImage(O,P,x,C,A,U,b,j),_>0&&e.drawImage(w,P,_,C,B,U,k,j),R>0&&e.drawImage(E,P,R,C,N,U,M,j))},i.drawClipImage=function(t,e,i,r,n,a,o,s,h,c,l,u){void 0===l&&(l=0),void 0===u&&(u=0);var p=o+n-h;p>0&&(n-=p),p=s+a-c,p>0&&(a-=p),t.drawImage(i,r,n/e,a/e,l+o,u+s,n,a)},i}(e.RenderNode);e.BitmapNode=i,__reflect(i.prototype,"egret.sys.BitmapNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=["none","round","square"],r=["bevel","miter","round"],n=function(n){function a(){var t=n.call(this)||this;return t.dirtyRender=!0,t.type=3,t}return __extends(a,n),a.prototype.beginFill=function(t,i,r){void 0===i&&(i=1);var n=new e.FillPath;if(n.fillColor=t,n.fillAlpha=i,r){var a=this.drawData.lastIndexOf(r);this.drawData.splice(a,0,n)}else this.drawData.push(n);return this.renderCount++,n},a.prototype.beginGradientFill=function(i,r,n,a,o,s){var h=new t.Matrix;o?(h.a=819.2*o.a,h.b=819.2*o.b,h.c=819.2*o.c,h.d=819.2*o.d,h.tx=o.tx,h.ty=o.ty):(h.a=100,h.d=100);var c=new e.GradientFillPath;if(c.gradientType=i,c.colors=r,c.alphas=n,c.ratios=a,c.matrix=h,s){var l=this.drawData.lastIndexOf(s);this.drawData.splice(l,0,c)}else this.drawData.push(c);return this.renderCount++,c},a.prototype.lineStyle=function(n,a,o,s,h,c,l){void 0===o&&(o=1),void 0===c&&(c=3),void 0===l&&(l=[]),-1==i.indexOf(s)&&(s="round"),-1==r.indexOf(h)&&(h="round");var u=new e.StrokePath;return u.lineWidth=n,u.lineColor=a,u.lineAlpha=o,u.caps=s||t.CapsStyle.ROUND,u.joints=h,u.miterLimit=c,u.lineDash=l,this.drawData.push(u),this.renderCount++,u},a.prototype.clear=function(){this.drawData.length=0,this.dirtyRender=!0,this.renderCount=0},a.prototype.cleanBeforeRender=function(){},a.prototype.clean=function(){this.$texture&&(t.WebGLUtils.deleteWebGLTexture(this.$texture),this.$texture=null,this.dirtyRender=!0)},a}(e.RenderNode);e.GraphicsNode=n,__reflect(n.prototype,"egret.sys.GraphicsNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(t){var e=function(t){function e(){var e=t.call(this)||this;return e.type=4,e}return __extends(e,t),e.prototype.addNode=function(t){this.drawData.push(t)},e.prototype.cleanBeforeRender=function(){for(var t=this.drawData,e=t.length-1;e>=0;e--)t[e].cleanBeforeRender()},e.prototype.$getRenderCount=function(){for(var t=0,e=this.drawData,i=e.length-1;i>=0;i--)t+=e[i].$getRenderCount();return t},e}(t.RenderNode);t.GroupNode=e,__reflect(e.prototype,"egret.sys.GroupNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(e){function i(){var i=e.call(this)||this;return i.image=null,i.smoothing=!0,i.bounds=new t.Rectangle,i.blendMode=null,i.alpha=0/0,i.filter=null,i.rotated=!1,i.type=5,i.vertices=[],i.uvs=[],i.indices=[],i}return __extends(i,e),i.prototype.drawMesh=function(t,e,i,r,n,a,o,s){this.drawData.push(t,e,i,r,n,a,o,s),this.renderCount++},i.prototype.cleanBeforeRender=function(){e.prototype.cleanBeforeRender.call(this),this.image=null,this.matrix=null},i}(e.RenderNode);e.MeshNode=i,__reflect(i.prototype,"egret.sys.MeshNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(t){var e=function(t){function e(){var e=t.call(this)||this;return e.image=null,e.smoothing=!0,e.rotated=!1,e.type=6,e}return __extends(e,t),e.prototype.drawImage=function(t,e,i,r,n,a,o,s){var h=this;h.sourceX=t,h.sourceY=e,h.sourceW=i,h.sourceH=r,h.drawX=n,h.drawY=a,h.drawW=o,h.drawH=s,h.renderCount=1},e.prototype.cleanBeforeRender=function(){t.prototype.cleanBeforeRender.call(this),this.image=null},e}(t.RenderNode);t.NormalBitmapNode=e,__reflect(e.prototype,"egret.sys.NormalBitmapNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){t.OrientationMode={AUTO:"auto",PORTRAIT:"portrait",LANDSCAPE:"landscape",LANDSCAPE_FLIPPED:"landscapeFlipped"}}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(e){function i(){var t=e.call(this)||this;return t.textColor=16777215,t.strokeColor=0,t.size=30,t.stroke=0,t.bold=!1,t.italic=!1,t.fontFamily="Arial",t.dirtyRender=!0,t.type=2,t}return __extends(i,e),i.prototype.drawText=function(t,e,i,r){this.drawData.push(t,e,i,r),this.renderCount++,this.dirtyRender=!0},i.prototype.clean=function(){this.$texture&&(t.WebGLUtils.deleteWebGLTexture(this.$texture),this.$texture=null,this.dirtyRender=!0)},i.prototype.cleanBeforeRender=function(){e.prototype.cleanBeforeRender.call(this),this.dirtyRender=!0},i}(e.RenderNode);e.TextNode=i,__reflect(i.prototype,"egret.sys.TextNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(t){var e=function(t){function e(){var e=t.call(this)||this;return e.type=1,e}return __extends(e,t),e}(t.Path2D);t.FillPath=e,__reflect(e.prototype,"egret.sys.FillPath")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(t){var e=function(t){function e(){var e=t.call(this)||this;return e.type=2,e}return __extends(e,t),e}(t.Path2D);t.GradientFillPath=e,__reflect(e.prototype,"egret.sys.GradientFillPath")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){var i=e.call(this)||this;i.$renderBuffer=new t.sys.RenderBuffer;var r=new t.BitmapData(i.$renderBuffer.surface);return r.$deleteSource=!1,i._setBitmapData(r),i}return __extends(i,e),i.prototype.drawToTexture=function(e,i,r){if(void 0===r&&(r=1),i&&(0==i.width||0==i.height))return!1;var n=i||e.$getOriginalBounds();if(0==n.width||0==n.height)return!1;r/=t.$TextureScaleFactor;var a=(n.x+n.width)*r,o=(n.y+n.height)*r;i&&(a=n.width*r,o=n.height*r);var s=this.$renderBuffer;if(!s)return!1;if(s.resize(a,o),this.$bitmapData.width=a,this.$bitmapData.height=o,t.nativeRender){egret_native.activateBuffer(this.$renderBuffer);var h=!1,c=0,l=0,u=0,p=0;i&&(h=!0,c=i.x,l=i.y,u=i.width,p=i.height),egret_native.updateNativeRender(),egret_native.nrRenderDisplayObject(e.$nativeDisplayObject.id,r,h,c,l,u,p),egret_native.activateBuffer(null)}else{var d=t.Matrix.create();d.identity(),d.scale(r,r),i&&d.translate(-i.x,-i.y),t.sys.systemRenderer.render(e,s,d,!0),t.Matrix.release(d)}return this.$initData(0,0,a,o,0,0,a,o,a,o),!0},i.prototype.getPixel32=function(e,i){var r;if(this.$renderBuffer){var n=t.$TextureScaleFactor;e=Math.round(e/n),i=Math.round(i/n),r=this.$renderBuffer.getPixels(e,i,1,1)}return r},i.prototype.dispose=function(){e.prototype.dispose.call(this),this.$renderBuffer=null},i}(t.Texture);t.RenderTexture=e,__reflect(e.prototype,"egret.RenderTexture")}(egret||(egret={}));var egret;!function(t){var e;!function(t){var e=function(t){function e(){var e=t.call(this)||this;return e.type=3,e}return __extends(e,t),e}(t.Path2D);t.StrokePath=e,__reflect(e.prototype,"egret.sys.StrokePath")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){function e(t,e){var i=null==e.italic?t.italic:e.italic,r=null==e.bold?t.bold:e.bold,n=null==e.size?t.size:e.size,a=e.fontFamily||t.fontFamily,o=i?"italic ":"normal ";return o+=r?"bold ":"normal ",o+=n+"px "+a}function i(t,e){var i=t>>16,r=t>>8&255,n=255&t;return"rgba("+i+","+r+","+n+","+e+")"}function r(e,r,n,a,o,s){var h;h=r==t.GradientType.LINEAR?e.createLinearGradient(-1,0,1,0):e.createRadialGradient(0,0,0,0,0,1);for(var c=n.length,l=0;c>l;l++)h.addColorStop(o[l]/255,i(n[l],a[l]));return h}function n(t,e,i){void 0===i&&(i=0);for(var r=0,n=e.length;n>r;r++)t[r+i]=e[r]}function a(t,e,i,r){for(var n=r[0],a=r[1],o=r[2],s=r[3],h=r[4],c=r[5],l=r[6],u=r[7],p=r[8],d=r[9],f=r[10],g=r[11],$=r[12],y=r[13],v=r[14],b=r[15],m=r[16],x=r[17],T=r[18],_=r[19],D=0,O=e*i*4;O>D;D+=4){var w=t[D+0],E=t[D+1],R=t[D+2],S=t[D+3];t[D+0]=n*w+a*E+o*R+s*S+h,t[D+1]=c*w+l*E+u*R+p*S+d,t[D+2]=f*w+g*E+$*R+y*S+v,t[D+3]=b*w+m*E+x*R+T*S+_}}function o(t,e,i,r,n){s(t,e,i,r),h(t,e,i,n)}function s(t,e,i,r){var a;a=_?new Uint8ClampedArray(4*e):new Array(4*e);for(var o=4*e,s=2*r+1,h=0;i>h;h++){for(var c=h*o,l=0,u=0,p=0,d=0,f=0,g=0,$=4*-r,y=4*r+4;y>$;$+=4){var v=c+$;c>v||v>=c+o||(f=t[v+3],l+=t[v+0]*f,u+=t[v+1]*f,p+=t[v+2]*f,d+=f)}for(var $=c,y=c+o,b=0,m=$-4*r,x=$+4*(r+1);y>$;$+=4,b+=4,x+=4,m+=4)0===d?(a[b+0]=0,a[b+1]=0,a[b+2]=0,a[b+3]=0):(a[b+0]=l/d,a[b+1]=u/d,a[b+2]=p/d,a[b+3]=d/s),f=t[x+3],g=t[m+3],f||0==f?g||0==g?(l+=t[x+0]*f-t[m+0]*g,u+=t[x+1]*f-t[m+1]*g,p+=t[x+2]*f-t[m+2]*g,d+=f-g):(l+=t[x+0]*f,u+=t[x+1]*f,p+=t[x+2]*f,d+=f):(g||0==g)&&(l+=-t[m+0]*g,u+=-t[m+1]*g,p+=-t[m+2]*g,d+=-g);_?t.set(a,c):n(t,a,c)}}function h(t,e,i,r){var n;n=_?new Uint8ClampedArray(4*i):new Array(4*i);for(var a=4*e,o=2*r+1,s=0;e>s;s++){for(var h=4*s,c=0,l=0,u=0,p=0,d=0,f=0,g=-r*a,$=r*a+a;$>g;g+=a){var y=h+g;h>y||y>=h+i*a||(d=t[y+3],c+=t[y+0]*d,l+=t[y+1]*d,u+=t[y+2]*d,p+=d)}for(var g=h,$=h+i*a,v=0,b=h-r*a,m=h+(r+1)*a;$>g;g+=a,v+=4,m+=a,b+=a)0===p?(n[v+0]=0,n[v+1]=0,n[v+2]=0,n[v+3]=0):(n[v+0]=c/p,n[v+1]=l/p,n[v+2]=u/p,n[v+3]=p/o),d=t[m+3],f=t[b+3],d||0==d?f||0==f?(c+=t[m+0]*d-t[b+0]*f,l+=t[m+1]*d-t[b+1]*f,u+=t[m+2]*d-t[b+2]*f,p+=d-f):(c+=t[m+0]*d,l+=t[m+1]*d,u+=t[m+2]*d,p+=d):(f||0==f)&&(c+=-t[b+0]*f,l+=-t[b+1]*f,u+=-t[b+2]*f,p+=-f);for(var x=4*s,$=x+i*a,T=0;$>x;x+=a,T+=4)t[x+0]=n[T+0],t[x+1]=n[T+1],t[x+2]=n[T+2],t[x+3]=n[T+3]}}function c(t,e,i,r,a,s,h,c,f){var g=l(t,r);u(g,e,i,h,c),o(g,e,i,a,s),p(g,f),d(g,t),t.set(g),_?t.set(g):n(t,g)}function l(t,e){e||(e=[0,0,0,0]);var i;_?i=new Uint8ClampedArray(t):(i=new Array(t.length),n(i,t));for(var r=e[0],a=e[1],o=e[2],s=e[3],h=0,c=i.length;c>h;h+=4){var l=i[h+3];i[h+0]=r*l,i[h+1]=a*l,i[h+2]=o*l,i[h+3]=s*l}return i}function u(t,e,i,r,a){var o,s,h=Math.sin(r)*a|0,c=Math.cos(r)*a|0;if(_){o=new Int32Array(t.buffer),s=new Int32Array(o.length);for(var l=0;i>l;l++){var u=l+h;if(!(0>u||u>i))for(var p=0;e>p;p++){var d=p+c;0>d||d>e||(s[u*e+d]=o[l*e+p])}}o.set(s)}else{o=t,s=new Array(o.length);for(var l=0;i>l;l++){var u=l+h;if(!(0>u||u>i))for(var p=0;e>p;p++){var d=p+c;0>d||d>e||(s[4*(u*e+d)+0]=o[4*(l*e+p)+0],s[4*(u*e+d)+1]=o[4*(l*e+p)+1],s[4*(u*e+d)+2]=o[4*(l*e+p)+2],s[4*(u*e+d)+3]=o[4*(l*e+p)+3])}}n(o,s)}}function p(t,e){for(var i=0,r=t.length;r>i;i+=4)t[i+3]*=e}function d(t,e){for(var i=0,r=t.length;r>i;i+=4){var n=t[i+0],a=t[i+1],o=t[i+2],s=t[i+3]/255,h=e[i+0],c=e[i+1],l=e[i+2],u=e[i+3]/255;t[i+0]=h+n*(1-u),t[i+1]=c+a*(1-u),t[i+2]=l+o*(1-u),t[i+3]=255*(u+s*(1-u))}}function f(t,e,i){return t*(1-i)+e*i}function g(t,e,i,r,a,o,s,h,c,l,u,p){var d;d=_?new Uint8ClampedArray(t.length):new Array(t.length);for(var g,$,y=r[3],v=0,b=0,m=h*Math.cos(s),x=h*Math.sin(s),T=7,D=12,O=3.141592653589793,w=a/T,E=o/T,R=0;e>R;R++)for(var S=0;i>S;S++){for(var F=0,P=S*e*4+4*R,C=0,M=0,j=t[P+0]/255,A=t[P+1]/255,B=t[P+2]/255,N=t[P+3]/255,k=0;2*O>=k;k+=2*O/D){g=Math.cos(k+F),$=Math.sin(k+F);for(var L=0;T>L;L++){v=L*w*g,b=L*E*$;var I=Math.round(R+v-m),U=Math.round(S+b-x),X=0;if(I>=e||0>I||0>U||U>=i)X=0;else{var H=U*e*4+4*I;X=t[H+3]/255}C+=(T-L)*X,M+=T-L}}N=Math.max(N,1e-4);var Y=C/M*c*y*(1-l)*Math.max(Math.min(p,u),1-N),W=(M-C)/M*c*y*l*N;N=Math.max(N*u*(1-p),1e-4);var G=W/(W+N),z=f(j,r[0],G),V=f(A,r[1],G),q=f(B,r[2],G),J=Y/(W+N+Y),K=f(z,r[0],J),Q=f(V,r[1],J),Z=f(q,r[2],J),te=Math.min(N+Y+W,1);d[P+0]=255*K,d[P+1]=255*Q,d[P+2]=255*Z,d[P+3]=255*te}_?t.set(d):n(t,d)}var $=["source-over","lighter","destination-out"],y="source-over",v="#000000",b={none:"butt",square:"square",round:"round"},m=[],x=[],T=function(){function n(){this.nestLevel=0,this.renderingMask=!1}return n.prototype.render=function(e,i,r,n){this.nestLevel++;var a=i.context;a.transform(r.a,r.b,r.c,r.d,0,0);var o=this.drawDisplayObject(e,a,r.tx,r.ty,!0),s=t.Matrix.create();if(r.$invertInto(s),a.transform(s.a,s.b,s.c,s.d,0,0),t.Matrix.release(s),this.nestLevel--,0===this.nestLevel){m.length>6&&(m.length=6);for(var h=m.length,c=0;h>c;c++)m[c].resize(0,0)}return o},n.prototype.drawDisplayObject=function(e,i,r,n,a){var o,s=0,h=e.$displayList;if(h&&!a?((e.$cacheDirty||e.$renderDirty||h.$canvasScaleX!=t.sys.DisplayList.$canvasScaleX||h.$canvasScaleY!=t.sys.DisplayList.$canvasScaleY)&&(s+=h.drawToSurface()),o=h.$renderNode):o=e.$renderDirty?e.$getRenderNode():e.$renderNode,e.$cacheDirty=!1,o){switch(s++,i.$offsetX=r,i.$offsetY=n,o.type){case 1:this.renderBitmap(o,i);break;case 2:this.renderText(o,i);break;case 3:this.renderGraphics(o,i);break;case 4:this.renderGroup(o,i);break;case 5:this.renderMesh(o,i);break;case 6:this.renderNormalBitmap(o,i)}i.$offsetX=0,i.$offsetY=0}if(h&&!a)return s;var c=e.$children;if(c)for(var l=c.length,u=0;l>u;u++){var p=c[u],d=void 0,f=void 0;if(p.$useTranslate){var g=p.$getMatrix();d=r+p.$x,f=n+p.$y,i.save(),i.transform(g.a,g.b,g.c,g.d,d,f),d=-p.$anchorOffsetX,f=-p.$anchorOffsetY}else d=r+p.$x-p.$anchorOffsetX,f=n+p.$y-p.$anchorOffsetY;var $=void 0;switch(1!=p.$alpha&&($=i.globalAlpha,i.globalAlpha*=p.$alpha),p.$renderMode){case 1:break;case 2:s+=this.drawWithFilter(p,i,d,f);break;case 3:s+=this.drawWithClip(p,i,d,f);break;case 4:s+=this.drawWithScrollRect(p,i,d,f);break;default:s+=this.drawDisplayObject(p,i,d,f)}p.$useTranslate?i.restore():$&&(i.globalAlpha=$)}return s},n.prototype.drawWithFilter=function(t,e,i,r){if(t.$children&&0==t.$children.length&&(!t.$renderNode||0==t.$renderNode.$getRenderCount()))return 0;var n,s=0,h=t.$filters,l=h.length,u=0!==t.$blendMode;u&&(n=$[t.$blendMode],n||(n=y));var p=t.$getOriginalBounds(),d=p.x,f=p.y,v=p.width,b=p.height;if(0>=v||0>=b)return s;var m=this.createRenderBuffer(v-d,b-f,!0),T=m.context;if(s+=t.$mask?this.drawWithClip(t,T,-d,-f):t.$scrollRect||t.$maskRect?this.drawWithScrollRect(t,T,-d,-f):this.drawDisplayObject(t,T,-d,-f),s>0){u&&(e.globalCompositeOperation=n),s++;for(var _=T.getImageData(0,0,m.surface.width,m.surface.height),D=0;l>D;D++){var O=h[D];if("colorTransform"==O.type)a(_.data,m.surface.width,m.surface.height,O.$matrix);else if("blur"==O.type)o(_.data,m.surface.width,m.surface.height,O.$blurX,O.$blurY);else if("glow"==O.type){var w=O.$red,E=O.$green,R=O.$blue,S=O.$alpha;O.$inner||O.$knockout||O.$hideObject?g(_.data,m.surface.width,m.surface.height,[w/255,E/255,R/255,S],O.$blurX,O.$blurY,O.$angle?O.$angle/180*Math.PI:0,O.$distance||0,O.$strength,O.$inner?1:0,O.$knockout?0:1,O.$hideObject?1:0):c(_.data,m.surface.width,m.surface.height,[w/255,E/255,R/255,S],O.$blurX,O.$blurY,O.$angle?O.$angle/180*Math.PI:0,O.$distance||0,O.$strength)}else"custom"==O.type}T.putImageData(_,0,0),e.drawImage(m.surface,i+d,r+f),u&&(e.globalCompositeOperation=y)}return x.push(m),s},n.prototype.drawWithClip=function(e,i,r,n){var a,o=0,s=0!==e.$blendMode;s&&(a=$[e.$blendMode],a||(a=y));var h=e.$scrollRect?e.$scrollRect:e.$maskRect,c=e.$mask;if(c){var l=c.$getMatrix();if(0==l.a&&0==l.b||0==l.c&&0==l.d)return o}if(!(c||e.$children&&0!=e.$children.length))return h&&(i.save(),i.beginPath(),i.rect(h.x+r,h.y+n,h.width,h.height),i.clip()),s&&(i.globalCompositeOperation=a),o+=this.drawDisplayObject(e,i,r,n),s&&(i.globalCompositeOperation=y),h&&i.restore(),o;var u=c.$getRenderNode();if(c&&(!c.$children||0==c.$children.length)&&u&&3==u.type&&1==u.drawData.length&&1==u.drawData[0].type&&1==u.drawData[0].fillAlpha){this.renderingMask=!0,i.save();var p=t.Matrix.create();p.copyFrom(c.$getConcatenatedMatrix()),c.$getConcatenatedMatrixAt(e,p),i.transform(p.a,p.b,p.c,p.d,p.tx,p.ty);var d=this.drawDisplayObject(c,i,r,n);return this.renderingMask=!1,p.$invertInto(p),i.transform(p.a,p.b,p.c,p.d,p.tx,p.ty),t.Matrix.release(p),h&&(i.beginPath(),i.rect(h.x+r,h.y+n,h.width,h.height),i.clip()),d+=this.drawDisplayObject(e,i,r,n),i.restore(),d}var f=e.$getOriginalBounds(),g=f.x,v=f.y,b=f.width,x=f.height,T=this.createRenderBuffer(b,x),_=T.context;if(!_)return o+=this.drawDisplayObject(e,i,r,n);if(o+=this.drawDisplayObject(e,_,-g,-v),c){var p=t.Matrix.create();if(p.copyFrom(c.$getConcatenatedMatrix()),c.$getConcatenatedMatrixAt(e,p),p.translate(-g,-v),u&&1==u.$getRenderCount()||c.$displayList)_.globalCompositeOperation="destination-in",_.save(),_.setTransform(p.a,p.b,p.c,p.d,p.tx,p.ty),o+=this.drawDisplayObject(c,_,0,0),_.restore();else{var D=this.createRenderBuffer(b,x),O=D.context;O.setTransform(p.a,p.b,p.c,p.d,p.tx,p.ty),o+=this.drawDisplayObject(c,O,0,0),_.globalCompositeOperation="destination-in",_.drawImage(D.surface,0,0),m.push(D)}t.Matrix.release(p)}return o>0&&(o++,s&&(i.globalCompositeOperation=a),h&&(i.save(),i.beginPath(),i.rect(h.x+r,h.y+n,h.width,h.height),i.clip()),i.drawImage(T.surface,r+g,n+v),h&&i.restore(),s&&(i.globalCompositeOperation=y)),m.push(T),o},n.prototype.drawWithScrollRect=function(t,e,i,r){var n=0,a=t.$scrollRect?t.$scrollRect:t.$maskRect;return a.isEmpty()?n:(t.$scrollRect&&(i-=a.x,r-=a.y),e.save(),e.beginPath(),e.rect(a.x+i,a.y+r,a.width,a.height),e.clip(),n+=this.drawDisplayObject(t,e,i,r),e.restore(),n)},n.prototype.drawNodeToBuffer=function(t,e,i,r){var n=e.context;n.setTransform(i.a,i.b,i.c,i.d,i.tx,i.ty),this.renderNode(t,n,r)},n.prototype.drawDisplayToBuffer=function(t,e,i){var r=e.context;i&&r.setTransform(i.a,i.b,i.c,i.d,i.tx,i.ty);var n;n=t.$renderDirty?t.$getRenderNode():t.$renderNode;var a=0;if(n)switch(a++,n.type){case 1:this.renderBitmap(n,r);break;case 2:this.renderText(n,r);break;case 3:this.renderGraphics(n,r);break;case 4:this.renderGroup(n,r);break;case 5:this.renderMesh(n,r);break;case 6:this.renderNormalBitmap(n,r)}var o=t.$children;if(o)for(var s=o.length,h=0;s>h;h++){var c=o[h];switch(c.$renderMode){case 1:break;case 2:a+=this.drawWithFilter(c,r,0,0);break;case 3:a+=this.drawWithClip(c,r,0,0);break;case 4:a+=this.drawWithScrollRect(c,r,0,0);break;default:a+=this.drawDisplayObject(c,r,0,0)}}return a},n.prototype.renderNode=function(t,e,i){var r=0;switch(t.type){case 1:r=this.renderBitmap(t,e);break;case 2:r=1,this.renderText(t,e);break;case 3:r=this.renderGraphics(t,e,i);break;case 4:r=this.renderGroup(t,e);break;case 5:r=this.renderMesh(t,e);break;case 6:r+=this.renderNormalBitmap(t,e)}return r},n.prototype.renderNormalBitmap=function(t,e){var i=t.image;if(!i||!i.source)return 0;if(e.$imageSmoothingEnabled!=t.smoothing&&(e.imageSmoothingEnabled=t.smoothing,e.$imageSmoothingEnabled=t.smoothing),t.rotated){var r=t.sourceX,n=t.sourceY,a=t.sourceW,o=t.sourceH,s=t.drawX,h=t.drawY,c=t.drawW,l=t.drawH;e.save(),e.transform(0,-1,1,0,0,l),e.drawImage(i.source,r,n,o,a,s+e.$offsetX,h+e.$offsetY,l,c),e.restore()}else e.drawImage(i.source,t.sourceX,t.sourceY,t.sourceW,t.sourceH,t.drawX+e.$offsetX,t.drawY+e.$offsetY,t.drawW,t.drawH);return 1},n.prototype.renderBitmap=function(t,e){var i=t.image;if(!i||!i.source)return 0;e.$imageSmoothingEnabled!=t.smoothing&&(e.imageSmoothingEnabled=t.smoothing,e.$imageSmoothingEnabled=t.smoothing);var r,n,o=t.drawData,s=o.length,h=0,c=t.matrix,l=t.blendMode,u=t.alpha,p=!1;c&&(e.save(),p=!0,(0!=e.$offsetX||0!=e.$offsetY)&&(e.translate(e.$offsetX,e.$offsetY),r=e.$offsetX,n=e.$offsetY,e.$offsetX=e.$offsetY=0),e.transform(c.a,c.b,c.c,c.d,c.tx,c.ty)),l&&(e.globalCompositeOperation=$[l]); -var d;u==u&&(d=e.globalAlpha,e.globalAlpha*=u);var f=0,g=t.filter;if(g&&8==s){var v=o[0],b=o[1],x=o[2],T=o[3],_=o[4],D=o[5],O=o[6],w=o[7];t.rotated&&(x=o[3],T=o[2],O=o[7],w=o[6]);var E=this.createRenderBuffer(O,w),R=E.context;f++,t.rotated&&e.transform(0,-1,1,0,0,O),R.drawImage(i.source,v,b,x,T,0,0,O,w),f++;var S=R.getImageData(0,0,O,w);a(S.data,O,w,g.$matrix),R.putImageData(S,0,0),e.drawImage(E.surface,0,0,O,w,_+e.$offsetX,D+e.$offsetY,O,w),m.push(E)}else for(;s>h;)if(f++,t.rotated){var v=o[h++],b=o[h++],T=o[h++],x=o[h++],F=o[h++],P=o[h++],w=o[h++],O=o[h++];e.save(),e.transform(0,-1,1,0,0,O),e.drawImage(i.source,v,b,x,T,F+e.$offsetX,P+e.$offsetY,O,w),e.restore()}else e.drawImage(i.source,o[h++],o[h++],o[h++],o[h++],o[h++]+e.$offsetX,o[h++]+e.$offsetY,o[h++],o[h++]);return p?e.restore():(l&&(e.globalCompositeOperation=y),u==u&&(e.globalAlpha=d)),r&&(e.$offsetX=r),n&&(e.$offsetY=n),f},n.prototype.renderMesh=function(t,e){return 0},n.prototype.renderText=function(i,r){r.textAlign="left",r.textBaseline="middle",r.lineJoin="round";for(var n=i.drawData,a=n.length,o=0;a>o;){var s=n[o++],h=n[o++],c=n[o++],l=n[o++];r.font=e(i,l);var u=null==l.textColor?i.textColor:l.textColor,p=null==l.strokeColor?i.strokeColor:l.strokeColor,d=null==l.stroke?i.stroke:l.stroke;r.fillStyle=t.toColorString(u),r.strokeStyle=t.toColorString(p),d&&(r.lineWidth=2*d,r.strokeText(c,s+r.$offsetX,h+r.$offsetY)),r.fillText(c,s+r.$offsetX,h+r.$offsetY)}},n.prototype.renderGraphics=function(t,e,n){var a=t.drawData,o=a.length;n=!!n;for(var s=0;o>s;s++){var h=a[s];switch(h.type){case 1:var c=h;e.fillStyle=n?v:i(c.fillColor,c.fillAlpha),this.renderPath(h,e),this.renderingMask?e.clip():e.fill();break;case 2:var l=h;e.fillStyle=n?v:r(e,l.gradientType,l.colors,l.alphas,l.ratios,l.matrix),e.save();var u=l.matrix;this.renderPath(h,e),e.transform(u.a,u.b,u.c,u.d,u.tx,u.ty),e.fill(),e.restore();break;case 3:var p=h,d=p.lineWidth;e.lineWidth=d,e.strokeStyle=n?v:i(p.lineColor,p.lineAlpha),e.lineCap=b[p.caps],e.lineJoin=p.joints,e.miterLimit=p.miterLimit,e.setLineDash&&e.setLineDash(p.lineDash);var f=1===d||3===d;f&&e.translate(.5,.5),this.renderPath(h,e),e.stroke(),f&&e.translate(-.5,-.5)}}return 0==o?0:1},n.prototype.renderPath=function(t,e){e.beginPath();for(var i=t.$data,r=t.$commands,n=r.length,a=0,o=0;n>o;o++){var s=r[o];switch(s){case 4:e.bezierCurveTo(i[a++]+e.$offsetX,i[a++]+e.$offsetY,i[a++]+e.$offsetX,i[a++]+e.$offsetY,i[a++]+e.$offsetX,i[a++]+e.$offsetY);break;case 3:e.quadraticCurveTo(i[a++]+e.$offsetX,i[a++]+e.$offsetY,i[a++]+e.$offsetX,i[a++]+e.$offsetY);break;case 2:e.lineTo(i[a++]+e.$offsetX,i[a++]+e.$offsetY);break;case 1:e.moveTo(i[a++]+e.$offsetX,i[a++]+e.$offsetY)}}},n.prototype.renderGroup=function(t,e){var i,r,n=t.matrix,a=!1;n&&(e.save(),a=!0,(0!=e.$offsetX||0!=e.$offsetY)&&(e.translate(e.$offsetX,e.$offsetY),i=e.$offsetX,r=e.$offsetY,e.$offsetX=e.$offsetY=0),e.transform(n.a,n.b,n.c,n.d,n.tx,n.ty));for(var o=0,s=t.drawData,h=s.length,c=0;h>c;c++){var l=s[c];o+=this.renderNode(l,e)}return a&&e.restore(),i&&(e.$offsetX=i),r&&(e.$offsetY=r),o},n.prototype.createRenderBuffer=function(e,i,r){var n=r?x.pop():m.pop();return n?n.resize(e,i,!0):n=new t.sys.CanvasRenderBuffer(e,i),n},n}();t.CanvasRenderer=T,__reflect(T.prototype,"egret.CanvasRenderer"),t.getFontString=e,t.getRGBAString=i;var _=!1;try{_=void 0!==typeof Uint8ClampedArray}catch(D){}}(egret||(egret={}));var egret;!function(t){t.DeviceOrientation=null}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e;!function(t){t.WEB="web",t.NATIVE="native",t.RUNTIME2="runtime2",t.WXGAME="wxgame"}(e=t.RuntimeType||(t.RuntimeType={}));var i=function(){function e(){}return e.language="zh-CN",e.os="Unknown",e.runtimeType=t.RuntimeType.WEB,e.engineVersion="5.2.5",e.renderMode="Unknown",e.boundingClientWidth=0,e.boundingClientHeight=0,e}();t.Capabilities=i,__reflect(i.prototype,"egret.Capabilities")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){var i=e.call(this)||this;return i.$graphics=new t.Graphics,i.$graphics.$setTarget(i),i}return __extends(i,e),i.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(8)},Object.defineProperty(i.prototype,"graphics",{get:function(){return this.$graphics},enumerable:!0,configurable:!0}),i.prototype.$measureContentBounds=function(t){this.$graphics.$measureContentBounds(t)},i.prototype.$hitTest=function(t,i){var r=e.prototype.$hitTest.call(this,t,i);return r==this&&(r=this.$graphics.$hitTest(t,i)),r},i.prototype.$onRemoveFromStage=function(){e.prototype.$onRemoveFromStage.call(this),this.$graphics&&this.$graphics.$onRemoveFromStage()},i}(t.DisplayObject);t.Shape=e,__reflect(e.prototype,"egret.Shape")}(egret||(egret={}));var egret;!function(t){function e(t,e){r[t]=e}function i(t){return r[t]}var r={};t.registerImplementation=e,t.getImplementation=i}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){var i=e.call(this)||this;return i.$graphics=new t.Graphics,i.$graphics.$setTarget(i),i}return __extends(i,e),i.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(9)},Object.defineProperty(i.prototype,"graphics",{get:function(){return this.$graphics},enumerable:!0,configurable:!0}),i.prototype.$hitTest=function(e,i){if(!this.$visible)return null;var r=this.$getInvertedConcatenatedMatrix(),n=r.a*e+r.c*i+r.tx,a=r.b*e+r.d*i+r.ty,o=this.$scrollRect?this.$scrollRect:this.$maskRect;if(o&&!o.contains(n,a))return null;if(this.$mask&&!this.$mask.$hitTest(e,i))return null;for(var s=this.$children,h=!1,c=null,l=s.length-1;l>=0;l--){var u=s[l];if(!u.$maskedObject&&(c=u.$hitTest(e,i))){if(h=!0,c.$touchEnabled)break;c=null}}return c?this.$touchChildren?c:this:h?this:(c=t.DisplayObject.prototype.$hitTest.call(this,e,i),c&&(c=this.$graphics.$hitTest(e,i)),c)},i.prototype.$measureContentBounds=function(t){this.$graphics.$measureContentBounds(t)},i.prototype.$onRemoveFromStage=function(){e.prototype.$onRemoveFromStage.call(this),this.$graphics&&this.$graphics.$onRemoveFromStage()},i}(t.DisplayObjectContainer);t.Sprite=e,__reflect(e.prototype,"egret.Sprite")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e,i){var r=t.call(this,e)||this;return r.firstCharHeight=0,"string"==typeof i?r.charList=r.parseConfig(i):i&&i.hasOwnProperty("frames")?r.charList=i.frames:r.charList={},r}return __extends(e,t),e.prototype.getTexture=function(t){var e=this._textureMap[t];if(!e){var i=this.charList[t];if(!i)return null;e=this.createTexture(t,i.x,i.y,i.w,i.h,i.offX,i.offY,i.sourceW,i.sourceH),this._textureMap[t]=e}return e},e.prototype.getConfig=function(t,e){return this.charList[t]?this.charList[t][e]:0},e.prototype._getFirstCharHeight=function(){if(0==this.firstCharHeight)for(var t in this.charList){var e=this.charList[t];if(e){var i=e.sourceH;if(void 0===i){var r=e.h;void 0===r&&(r=0);var n=e.offY;void 0===n&&(n=0),i=r+n}if(0>=i)continue;this.firstCharHeight=i;break}}return this.firstCharHeight},e.prototype.parseConfig=function(t){t=t.split("\r\n").join("\n");for(var e=t.split("\n"),i=this.getConfigByKey(e[3],"count"),r={},n=4;4+i>n;n++){var a=e[n],o=String.fromCharCode(this.getConfigByKey(a,"id")),s={};r[o]=s,s.x=this.getConfigByKey(a,"x"),s.y=this.getConfigByKey(a,"y"),s.w=this.getConfigByKey(a,"width"),s.h=this.getConfigByKey(a,"height"),s.offX=this.getConfigByKey(a,"xoffset"),s.offY=this.getConfigByKey(a,"yoffset"),s.xadvance=this.getConfigByKey(a,"xadvance")}return r},e.prototype.getConfigByKey=function(t,e){for(var i=t.split(" "),r=0,n=i.length;n>r;r++){var a=i[r];if(e==a.substring(0,e.length)){var o=a.substring(e.length+1);return parseInt(o)}}return 0},e}(t.SpriteSheet);t.BitmapFont=e,__reflect(e.prototype,"egret.BitmapFont")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){var i=e.call(this)||this;return i.$smoothing=t.Bitmap.defaultSmoothing,i.$text="",i.$textFieldWidth=0/0,i.$textLinesChanged=!1,i.$textFieldHeight=0/0,i.$font=null,i.$fontStringChanged=!1,i.$lineSpacing=0,i.$letterSpacing=0,i.$textAlign=t.HorizontalAlign.LEFT,i.$verticalAlign=t.VerticalAlign.TOP,i.$textWidth=0/0,i.$textHeight=0/0,i.$textOffsetX=0,i.$textOffsetY=0,i.$textStartX=0,i.$textStartY=0,i.textLines=[],i.$lineHeights=[],t.nativeRender||(i.$renderNode=new t.sys.BitmapNode),i}return __extends(i,e),i.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(11)},Object.defineProperty(i.prototype,"smoothing",{get:function(){return this.$smoothing},set:function(t){var e=this;t!=e.$smoothing&&(e.$smoothing=t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"text",{get:function(){return this.$text},set:function(t){this.$setText(t)},enumerable:!0,configurable:!0}),i.prototype.$setText=function(t){t=null==t?"":String(t);var e=this;return t==e.$text?!1:(e.$text=t,e.$invalidateContentBounds(),!0)},i.prototype.$getWidth=function(){var t=this,e=t.$textFieldWidth;return isNaN(e)?t.$getContentBounds().width:e},i.prototype.$setWidth=function(t){var e=this;return 0>t||t==e.$textFieldWidth?!1:(e.$textFieldWidth=t,e.$invalidateContentBounds(),!0)},i.prototype.$invalidateContentBounds=function(){this.$renderDirty=!0,this.$textLinesChanged=!0,this.$updateRenderNode()},i.prototype.$getHeight=function(){var t=this,e=t.$textFieldHeight;return isNaN(e)?t.$getContentBounds().height:e},i.prototype.$setHeight=function(t){var e=this;return 0>t||t==e.$textFieldHeight?!1:(e.$textFieldHeight=t,e.$invalidateContentBounds(),!0)},Object.defineProperty(i.prototype,"font",{get:function(){return this.$font},set:function(t){this.$setFont(t)},enumerable:!0,configurable:!0}),i.prototype.$setFont=function(t){var e=this;return e.$font==t?!1:(e.$font=t,e.$fontStringChanged=!0,this.$invalidateContentBounds(),!0)},Object.defineProperty(i.prototype,"lineSpacing",{get:function(){return this.$lineSpacing},set:function(t){this.$setLineSpacing(t)},enumerable:!0,configurable:!0}),i.prototype.$setLineSpacing=function(t){var e=this;return e.$lineSpacing==t?!1:(e.$lineSpacing=t,e.$invalidateContentBounds(),!0)},Object.defineProperty(i.prototype,"letterSpacing",{get:function(){return this.$letterSpacing},set:function(t){this.$setLetterSpacing(t)},enumerable:!0,configurable:!0}),i.prototype.$setLetterSpacing=function(t){var e=this;return e.$letterSpacing==t?!1:(e.$letterSpacing=t,e.$invalidateContentBounds(),!0)},Object.defineProperty(i.prototype,"textAlign",{get:function(){return this.$textAlign},set:function(t){this.$setTextAlign(t)},enumerable:!0,configurable:!0}),i.prototype.$setTextAlign=function(t){var e=this;return e.$textAlign==t?!1:(e.$textAlign=t,e.$invalidateContentBounds(),!0)},Object.defineProperty(i.prototype,"verticalAlign",{get:function(){return this.$verticalAlign},set:function(t){this.$setVerticalAlign(t)},enumerable:!0,configurable:!0}),i.prototype.$setVerticalAlign=function(t){var e=this;return e.$verticalAlign==t?!1:(e.$verticalAlign=t,e.$invalidateContentBounds(),!0)},i.prototype.$updateRenderNode=function(){var e=this,r=this.$getTextLines(),n=r.length;if(0!=n){var a,o=[],s=this.$textLinesWidth,h=e.$font;t.nativeRender||(a=this.$renderNode,h.$texture&&(a.image=h.$texture.$bitmapData),a.smoothing=e.$smoothing);for(var c=h._getFirstCharHeight(),l=Math.ceil(c*i.EMPTY_FACTOR),u=!isNaN(e.$textFieldHeight),p=e.$textWidth,d=e.$textFieldWidth,f=e.$textFieldHeight,g=e.$textAlign,$=this.$textOffsetY+this.$textStartY,y=this.$lineHeights,v=0;n>v;v++){var b=y[v];if(u&&v>0&&$+b>f)break;var m=r[v],x=m.length,T=this.$textOffsetX;if(g!=t.HorizontalAlign.LEFT){var _=d>p?d:p;g==t.HorizontalAlign.RIGHT?T+=_-s[v]:g==t.HorizontalAlign.CENTER&&(T+=Math.floor((_-s[v])/2))}for(var D=0;x>D;D++){var O=m.charAt(D),w=h.getTexture(O);if(w){var E=w.$bitmapWidth,R=w.$bitmapHeight;t.nativeRender?o.push(w.$bitmapX,w.$bitmapY,E,R,T+w.$offsetX,$+w.$offsetY,w.$getScaleBitmapWidth(),w.$getScaleBitmapHeight(),w.$sourceWidth,w.$sourceHeight):(a.imageWidth=w.$sourceWidth,a.imageHeight=w.$sourceHeight,a.drawImage(w.$bitmapX,w.$bitmapY,E,R,T+w.$offsetX,$+w.$offsetY,w.$getScaleBitmapWidth(),w.$getScaleBitmapHeight())),T+=(h.getConfig(O,"xadvance")||w.$getTextureWidth())+e.$letterSpacing}else" "==O?T+=l:t.$warn(1046,O)}$+=b+e.$lineSpacing}if(t.nativeRender){e.$nativeDisplayObject.setDataToBitmapNode(e.$nativeDisplayObject.id,h.$texture,o);var S=e.$getContentBounds();e.$nativeDisplayObject.setWidth(S.width),e.$nativeDisplayObject.setHeight(S.height)}}},i.prototype.$measureContentBounds=function(t){var e=this.$getTextLines();0==e.length?t.setEmpty():t.setTo(this.$textOffsetX+this.$textStartX,this.$textOffsetY+this.$textStartY,this.$textWidth-this.$textOffsetX,this.$textHeight-this.$textOffsetY)},Object.defineProperty(i.prototype,"textWidth",{get:function(){return this.$getTextLines(),this.$textWidth},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"textHeight",{get:function(){return this.$getTextLines(),this.$textHeight},enumerable:!0,configurable:!0}),i.prototype.$getTextLines=function(){function e(t){return b&&n.length>0&&f>b?!1:(f+=c+u,s||h||(l-=p),n.push(t),o.push(c),a.push(l),d=Math.max(l,d),!0)}var r=this;if(!r.$textLinesChanged)return r.textLines;var n=[];r.textLines=n;var a=[];r.$textLinesWidth=a,r.$textLinesChanged=!1;var o=[];if(r.$lineHeights=o,!r.$text||!r.$font)return r.$textWidth=0,r.$textHeight=0,n;for(var s,h,c,l,u=r.$lineSpacing,p=r.$letterSpacing,d=0,f=0,g=0,$=0,y=!isNaN(r.$textFieldWidth),v=r.$textFieldWidth,b=r.$textFieldHeight,m=r.$font,x=m._getFirstCharHeight(),T=Math.ceil(x*i.EMPTY_FACTOR),_=r.$text,D=_.split(/(?:\r\n|\r|\n)/),O=D.length,w=!0,E=0;O>E;E++){var R=D[E],S=R.length;c=0,l=0,s=!0,h=!1;for(var F=0;S>F;F++){s||(l+=p);var P=R.charAt(F),C=void 0,M=void 0,j=0,A=0,B=m.getTexture(P);if(B)C=B.$getTextureWidth(),M=B.$getTextureHeight(),j=B.$offsetX,A=B.$offsetY;else{if(" "!=P){t.$warn(1046,P),s&&(s=!1);continue}C=T,M=x}if(s&&(s=!1,g=Math.min(j,g)),w&&(w=!1,$=Math.min(A,$)),y&&F>0&&l+C>v){if(!e(R.substring(0,F)))break;R=R.substring(F),S=R.length,F=0,l=F==S-1?C:m.getConfig(P,"xadvance")||C,c=M}else l+=F==S-1?C:m.getConfig(P,"xadvance")||C,c=Math.max(M,c)}if(b&&E>0&&f>b)break;if(h=!0,!e(R))break}f-=u,r.$textWidth=d,r.$textHeight=f,this.$textOffsetX=g,this.$textOffsetY=$,this.$textStartX=0,this.$textStartY=0;var N;return v>d&&(N=r.$textAlign,N==t.HorizontalAlign.RIGHT?this.$textStartX=v-d:N==t.HorizontalAlign.CENTER&&(this.$textStartX=Math.floor((v-d)/2))),b>f&&(N=r.$verticalAlign,N==t.VerticalAlign.BOTTOM?this.$textStartY=b-f:N==t.VerticalAlign.MIDDLE&&(this.$textStartY=Math.floor((b-f)/2))),n},i.EMPTY_FACTOR=.33,i}(t.DisplayObject);t.BitmapText=e,__reflect(e.prototype,"egret.BitmapText")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.LEFT="left",t.RIGHT="right",t.CENTER="center",t.JUSTIFY="justify",t.CONTENT_JUSTIFY="contentJustify",t}();t.HorizontalAlign=e,__reflect(e.prototype,"egret.HorizontalAlign")}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){this.replaceArr=[],this.resutlArr=[],this.initReplaceArr()}return e.prototype.initReplaceArr=function(){this.replaceArr=[],this.replaceArr.push([/</g,"<"]),this.replaceArr.push([/>/g,">"]),this.replaceArr.push([/&/g,"&"]),this.replaceArr.push([/"/g,'"']),this.replaceArr.push([/'/g,"'"])},e.prototype.replaceSpecial=function(t){for(var e=0;ei;){var n=e.indexOf("<",i);if(0>n)this.addToResultArr(e.substring(i)),i=r;else{this.addToResultArr(e.substring(i,n));var a=e.indexOf(">",n);-1==a?(t.$error(1038),a=n):"/"==e.charAt(n+1)?this.stackArray.pop():this.addToArray(e.substring(n+1,a)),i=a+1}}return this.resutlArr},e.prototype.parser=function(t){return this.parse(t)},e.prototype.addToResultArr=function(t){""!=t&&(t=this.replaceSpecial(t),this.stackArray.length>0?this.resutlArr.push({text:t,style:this.stackArray[this.stackArray.length-1]}):this.resutlArr.push({text:t}))},e.prototype.changeStringToObject=function(t){t=t.trim();var e={},i=[];if("i"==t.charAt(0)||"b"==t.charAt(0)||"u"==t.charAt(0))this.addProperty(e,t,"true");else if(i=t.match(/^(font|a)\s/)){t=t.substring(i[0].length).trim();for(var r=0,n=void 0;n=t.match(this.getHeadReg());){var a=n[0],o="";t=t.substring(a.length).trim(),'"'==t.charAt(0)?(r=t.indexOf('"',1),o=t.substring(1,r),r+=1):"'"==t.charAt(0)?(r=t.indexOf("'",1),o=t.substring(1,r),r+=1):(o=t.match(/(\S)+/)[0],r=o.length),this.addProperty(e,a.substring(0,a.length-1).trim(),o.trim()),t=t.substring(r).trim()}}return e},e.prototype.getHeadReg=function(){return/^(color|textcolor|strokecolor|stroke|b|bold|i|italic|u|size|fontfamily|href|target)(\s)*=/},e.prototype.addProperty=function(t,e,i){switch(e.toLowerCase()){case"color":case"textcolor":i=i.replace(/#/,"0x"),t.textColor=parseInt(i);break;case"strokecolor":i=i.replace(/#/,"0x"),t.strokeColor=parseInt(i);break;case"stroke":t.stroke=parseInt(i);break;case"b":case"bold":t.bold="true"==i;break;case"u":t.underline="true"==i;break;case"i":case"italic":t.italic="true"==i;break;case"size":t.size=parseInt(i);break;case"fontfamily":t.fontFamily=i;break;case"href":t.href=this.replaceSpecial(i);break;case"target":t.target=this.replaceSpecial(i)}},e.prototype.addToArray=function(t){var e=this.changeStringToObject(t);if(0==this.stackArray.length)this.stackArray.push(e);else{var i=this.stackArray[this.stackArray.length-1];for(var r in i)null==e[r]&&(e[r]=i[r]);this.stackArray.push(e)}},e}();t.HtmlTextParser=e,__reflect(e.prototype,"egret.HtmlTextParser")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){var t=e.call(this)||this;return t.stageTextAdded=!1,t._text=null,t._isFocus=!1,t}return __extends(i,e),i.prototype.init=function(e){this._text=e,this.stageText=new t.StageText,this.stageText.$setTextField(this._text)},i.prototype._addStageText=function(){this.stageTextAdded||(this._text.$inputEnabled||(this._text.$touchEnabled=!0),this.tempStage=this._text.stage,this.stageText.$addToStage(),this.stageText.addEventListener("updateText",this.updateTextHandler,this),this._text.addEventListener(t.TouchEvent.TOUCH_BEGIN,this.onMouseDownHandler,this),this.stageText.addEventListener("blur",this.blurHandler,this),this.stageText.addEventListener("focus",this.focusHandler,this),this.stageTextAdded=!0)},i.prototype._removeStageText=function(){this.stageTextAdded&&(this._text.$inputEnabled||(this._text.$touchEnabled=!1),this.stageText.$removeFromStage(),this.stageText.removeEventListener("updateText",this.updateTextHandler,this),this._text.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this.onMouseDownHandler,this),this.tempStage.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this.onStageDownHandler,this),this.stageText.removeEventListener("blur",this.blurHandler,this),this.stageText.removeEventListener("focus",this.focusHandler,this),this.stageTextAdded=!1)},i.prototype._getText=function(){return this.stageText.$getText()},i.prototype._setText=function(t){this.stageText.$setText(t)},i.prototype._setColor=function(t){this.stageText.$setColor(t)},i.prototype.focusHandler=function(e){this._isFocus||(this._isFocus=!0,e.showing||this._text.$setIsTyping(!0),this._text.dispatchEvent(new t.FocusEvent(t.FocusEvent.FOCUS_IN,!0)))},i.prototype.blurHandler=function(e){this._isFocus&&(this._isFocus=!1,this.tempStage.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this.onStageDownHandler,this),this._text.$setIsTyping(!1),this.stageText.$onBlur(),this._text.dispatchEvent(new t.FocusEvent(t.FocusEvent.FOCUS_OUT,!0)))},i.prototype.onMouseDownHandler=function(t){this.$onFocus()},i.prototype.$onFocus=function(){var e=this;this._text.visible&&(this._isFocus||(this.tempStage.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this.onStageDownHandler,this),t.callLater(function(){e.tempStage.addEventListener(t.TouchEvent.TOUCH_BEGIN,e.onStageDownHandler,e)},this),t.nativeRender&&this.stageText.$setText(this._text.$TextField[13]),this.stageText.$show()))},i.prototype.onStageDownHandler=function(t){t.$target!=this._text&&this.stageText.$hide()},i.prototype.updateTextHandler=function(e){var i,r,n=this._text.$TextField,a=this.stageText.$getText(),o=!1;null!=n[35]&&(i=new RegExp("["+n[35]+"]","g"),r=a.match(i),a=r?r.join(""):"",o=!0),null!=n[36]&&(i=new RegExp("[^"+n[36]+"]","g"),r=a.match(i),a=r?r.join(""):"",o=!0),o&&this.stageText.$getText()!=a&&this.stageText.$setText(a),this.resetText(),this._text.dispatchEvent(new t.Event(t.Event.CHANGE,!0))},i.prototype.resetText=function(){this._text.$setBaseText(this.stageText.$getText())},i.prototype._hideInput=function(){this.stageText.$removeFromStage()},i.prototype.updateInput=function(){!this._text.$visible&&this.stageText&&this._hideInput()},i.prototype._updateProperties=function(){return this._isFocus?(this.stageText.$resetStageText(),void this.updateInput()):(this.stageText.$setText(this._text.$TextField[13]),this.stageText.$resetStageText(),void this.updateInput())},i}(t.HashObject);t.InputController=e,__reflect(e.prototype,"egret.InputController")}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){function e(e,i,n){n=n||{};var a=null==n.italic?i[16]:n.italic,o=null==n.bold?i[15]:n.bold,s=null==n.size?i[0]:n.size,h=n.fontFamily||i[8]||r.default_fontFamily;return t.sys.measureText(e,h,s,o,a)}var i=new RegExp("(?=[\\u00BF-\\u1FFF\\u2C00-\\uD7FF]|\\b|\\s)(?![。,!、》…))}”】\\.\\,\\!\\?\\]\\:])"),r=function(r){function n(){var e=r.call(this)||this;e.$inputEnabled=!1,e.inputUtils=null,e.$graphicsNode=null,e.isFlow=!1,e.textArr=[],e.linesArr=[],e.$isTyping=!1;var i=new t.sys.TextNode;return i.fontFamily=n.default_fontFamily,e.textNode=i,e.$renderNode=i,e.$TextField={0:n.default_size,1:0,2:n.default_textColor,3:0/0,4:0/0,5:0,6:0,7:0,8:n.default_fontFamily,9:"left",10:"top",11:"#ffffff",12:"",13:"",14:[],15:!1,16:!1,17:!0,18:!1,19:!1,20:!1,21:0,22:0,23:0,24:t.TextFieldType.DYNAMIC,25:0,26:"#000000",27:0,28:-1,29:0,30:!1,31:!1,32:0,33:!1,34:16777215,35:null,36:null,37:t.TextFieldInputType.TEXT,38:!1},e}return __extends(n,r),n.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(7)},n.prototype.isInput=function(){return this.$TextField[24]==t.TextFieldType.INPUT},n.prototype.$setTouchEnabled=function(t){r.prototype.$setTouchEnabled.call(this,t),this.isInput()&&(this.$inputEnabled=!0)},Object.defineProperty(n.prototype,"fontFamily",{get:function(){return this.$TextField[8]},set:function(t){this.$setFontFamily(t)},enumerable:!0,configurable:!0}),n.prototype.$setFontFamily=function(e){var i=this.$TextField;return i[8]==e?!1:(i[8]=e,this.invalidateFontString(),t.nativeRender&&this.$nativeDisplayObject.setFontFamily(e),!0)},Object.defineProperty(n.prototype,"size",{get:function(){return this.$TextField[0]},set:function(t){this.$setSize(t)},enumerable:!0,configurable:!0}),n.prototype.$setSize=function(e){var i=this.$TextField;return i[0]==e?!1:(i[0]=e,this.invalidateFontString(),t.nativeRender&&this.$nativeDisplayObject.setFontSize(e),!0)},Object.defineProperty(n.prototype,"bold",{get:function(){return this.$TextField[15]},set:function(t){this.$setBold(t)},enumerable:!0,configurable:!0}),n.prototype.$setBold=function(e){var i=this.$TextField;return e==i[15]?!1:(i[15]=e,this.invalidateFontString(),t.nativeRender&&this.$nativeDisplayObject.setBold(e),!0)},Object.defineProperty(n.prototype,"italic",{get:function(){return this.$TextField[16]},set:function(t){this.$setItalic(t)},enumerable:!0,configurable:!0}),n.prototype.$setItalic=function(e){var i=this.$TextField;return e==i[16]?!1:(i[16]=e,this.invalidateFontString(),t.nativeRender&&this.$nativeDisplayObject.setItalic(e),!0)},n.prototype.invalidateFontString=function(){this.$TextField[17]=!0,this.$invalidateTextField()},Object.defineProperty(n.prototype,"textAlign",{get:function(){return this.$TextField[9]},set:function(t){this.$setTextAlign(t)},enumerable:!0,configurable:!0}),n.prototype.$setTextAlign=function(e){var i=this.$TextField;return i[9]==e?!1:(i[9]=e,this.$invalidateTextField(),t.nativeRender&&this.$nativeDisplayObject.setTextAlign(e),!0)},Object.defineProperty(n.prototype,"verticalAlign",{get:function(){return this.$TextField[10]},set:function(t){this.$setVerticalAlign(t)},enumerable:!0,configurable:!0}),n.prototype.$setVerticalAlign=function(e){var i=this.$TextField;return i[10]==e?!1:(i[10]=e,this.$invalidateTextField(),t.nativeRender&&this.$nativeDisplayObject.setVerticalAlign(e),!0)},Object.defineProperty(n.prototype,"lineSpacing",{get:function(){return this.$TextField[1]},set:function(t){this.$setLineSpacing(t)},enumerable:!0,configurable:!0}),n.prototype.$setLineSpacing=function(e){var i=this.$TextField;return i[1]==e?!1:(i[1]=e,this.$invalidateTextField(),t.nativeRender&&this.$nativeDisplayObject.setLineSpacing(e),!0)},Object.defineProperty(n.prototype,"textColor",{get:function(){return this.$TextField[2]},set:function(t){this.$setTextColor(t)},enumerable:!0,configurable:!0}),n.prototype.$setTextColor=function(e){var i=this.$TextField;return i[2]==e?!1:(i[2]=e,this.inputUtils&&this.inputUtils._setColor(this.$TextField[2]),this.$invalidateTextField(),t.nativeRender&&this.$nativeDisplayObject.setTextColor(e),!0)},Object.defineProperty(n.prototype,"wordWrap",{get:function(){return this.$TextField[19]},set:function(t){this.$setWordWrap(t)},enumerable:!0,configurable:!0}),n.prototype.$setWordWrap=function(e){var i=this.$TextField;e!=i[19]&&(i[20]||(i[19]=e,this.$invalidateTextField(),t.nativeRender&&this.$nativeDisplayObject.setWordWrap(e)))},Object.defineProperty(n.prototype,"type",{get:function(){return this.$TextField[24]},set:function(t){this.$setType(t)},enumerable:!0,configurable:!0}),n.prototype.$setType=function(e){var i=this.$TextField;return i[24]!=e?(i[24]=e,t.nativeRender&&this.$nativeDisplayObject.setType(e),e==t.TextFieldType.INPUT?(isNaN(i[3])&&this.$setWidth(100),isNaN(i[4])&&this.$setHeight(30),this.$setTouchEnabled(!0),null==this.inputUtils&&(this.inputUtils=new t.InputController),this.inputUtils.init(this),this.$invalidateTextField(),this.$stage&&this.inputUtils._addStageText()):(this.inputUtils&&(this.inputUtils._removeStageText(),this.inputUtils=null),this.$setTouchEnabled(!1)),!0):!1},Object.defineProperty(n.prototype,"inputType",{get:function(){return this.$TextField[37]},set:function(e){this.$TextField[37]=e,t.nativeRender&&this.$nativeDisplayObject.setInputType(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"text",{get:function(){return this.$getText()},set:function(t){this.$setText(t)},enumerable:!0,configurable:!0}),n.prototype.$getText=function(){return this.$TextField[24]==t.TextFieldType.INPUT?this.inputUtils._getText():this.$TextField[13]},n.prototype.$setBaseText=function(e){e=null==e?"":e.toString(),this.isFlow=!1;var i=this.$TextField;if(i[13]!=e){this.$invalidateTextField(),i[13]=e;var r="";return r=i[20]?this.changeToPassText(e):e,t.nativeRender&&this.$nativeDisplayObject.setText(r),this.setMiddleStyle([{text:r}]),!0}return!1},n.prototype.$setText=function(t){null==t&&(t="");var e=this.$setBaseText(t);return this.inputUtils&&this.inputUtils._setText(this.$TextField[13]),e},Object.defineProperty(n.prototype,"displayAsPassword",{get:function(){return this.$TextField[20]},set:function(t){this.$setDisplayAsPassword(t)},enumerable:!0,configurable:!0}),n.prototype.$setDisplayAsPassword=function(e){var i=this.$TextField;if(i[20]!=e){i[20]=e,this.$invalidateTextField();var r="";return r=e?this.changeToPassText(i[13]):i[13],t.nativeRender&&this.$nativeDisplayObject.setText(r),this.setMiddleStyle([{text:r}]),!0}return!1},Object.defineProperty(n.prototype,"strokeColor",{get:function(){return this.$TextField[25]},set:function(t){this.$setStrokeColor(t)},enumerable:!0,configurable:!0}),n.prototype.$setStrokeColor=function(e){var i=this.$TextField;return i[25]!=e?(this.$invalidateTextField(),i[25]=e,t.nativeRender&&this.$nativeDisplayObject.setStrokeColor(e),i[26]=t.toColorString(e),!0):!1},Object.defineProperty(n.prototype,"stroke",{get:function(){return this.$TextField[27]},set:function(t){this.$setStroke(t)},enumerable:!0,configurable:!0}),n.prototype.$setStroke=function(e){return this.$TextField[27]!=e?(this.$invalidateTextField(),this.$TextField[27]=e,t.nativeRender&&this.$nativeDisplayObject.setStroke(e),!0):!1},Object.defineProperty(n.prototype,"maxChars",{get:function(){return this.$TextField[21]},set:function(t){this.$setMaxChars(t)},enumerable:!0,configurable:!0}),n.prototype.$setMaxChars=function(e){return this.$TextField[21]!=e?(this.$TextField[21]=e,t.nativeRender&&this.$nativeDisplayObject.setMaxChars(e),!0):!1},Object.defineProperty(n.prototype,"scrollV",{get:function(){return Math.min(Math.max(this.$TextField[28],1),this.maxScrollV)},set:function(e){this.$TextField[28]=Math.max(e,1),t.nativeRender&&this.$nativeDisplayObject.setScrollV(e),this.$invalidateTextField()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"maxScrollV",{get:function(){return this.$getLinesArr(),Math.max(this.$TextField[29]-t.TextFieldUtils.$getScrollNum(this)+1,1)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"selectionBeginIndex",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"selectionEndIndex",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"caretIndex",{get:function(){return 0},enumerable:!0,configurable:!0}),n.prototype.$setSelection=function(t,e){return!1},n.prototype.$getLineHeight=function(){return this.$TextField[1]+this.$TextField[0]},Object.defineProperty(n.prototype,"numLines",{get:function(){return this.$getLinesArr(),this.$TextField[29]},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"multiline",{get:function(){return this.$TextField[30]},set:function(t){this.$setMultiline(t)},enumerable:!0,configurable:!0}),n.prototype.$setMultiline=function(e){return this.$TextField[30]=e,this.$invalidateTextField(),t.nativeRender&&this.$nativeDisplayObject.setMultiline(e),!0},Object.defineProperty(n.prototype,"restrict",{get:function(){var t=this.$TextField,e=null;return null!=t[35]&&(e=t[35]),null!=t[36]&&(null==e&&(e=""),e+="^"+t[36]),e},set:function(t){var e=this.$TextField;if(null==t)e[35]=null,e[36]=null;else{for(var i=-1;i0&&"\\"==t.charAt(i-1);)i++;0==i?(e[35]=null,e[36]=t.substring(i+1)):i>0?(e[35]=t.substring(0,i),e[36]=t.substring(i+1)):(e[35]=t,e[36]=null)}},enumerable:!0,configurable:!0}),n.prototype.$setWidth=function(e){t.nativeRender&&this.$nativeDisplayObject.setTextFieldWidth(e);var i=this.$TextField;if(isNaN(e)){if(isNaN(i[3]))return!1;i[3]=0/0}else{if(i[3]==e)return!1;i[3]=e}return e=+e,0>e?!1:(this.$invalidateTextField(),!0)},n.prototype.$setHeight=function(e){t.nativeRender&&this.$nativeDisplayObject.setTextFieldHeight(e);var i=this.$TextField;if(isNaN(e)){if(isNaN(i[4]))return!1;i[4]=0/0}else{if(i[4]==e)return!1;i[4]=e}return e=+e,0>e?!1:(this.$invalidateTextField(),!0)},n.prototype.$getWidth=function(){var t=this.$TextField;return isNaN(t[3])?this.$getContentBounds().width:t[3]},n.prototype.$getHeight=function(){var t=this.$TextField;return isNaN(t[4])?this.$getContentBounds().height:t[4]},Object.defineProperty(n.prototype,"border",{get:function(){return this.$TextField[31]},set:function(t){this.$setBorder(t)},enumerable:!0,configurable:!0}),n.prototype.$setBorder=function(e){e=!!e,this.$TextField[31]=e,t.nativeRender&&this.$nativeDisplayObject.setBorder(e)},Object.defineProperty(n.prototype,"borderColor",{get:function(){return this.$TextField[32]},set:function(t){this.$setBorderColor(t)},enumerable:!0,configurable:!0}),n.prototype.$setBorderColor=function(e){e=+e||0,this.$TextField[32]=e,t.nativeRender&&this.$nativeDisplayObject.setBorderColor(e) -},Object.defineProperty(n.prototype,"background",{get:function(){return this.$TextField[33]},set:function(t){this.$setBackground(t)},enumerable:!0,configurable:!0}),n.prototype.$setBackground=function(e){this.$TextField[33]=e,t.nativeRender&&this.$nativeDisplayObject.setBackground(e)},Object.defineProperty(n.prototype,"backgroundColor",{get:function(){return this.$TextField[34]},set:function(t){this.$setBackgroundColor(t)},enumerable:!0,configurable:!0}),n.prototype.$setBackgroundColor=function(e){this.$TextField[34]=e,t.nativeRender&&this.$nativeDisplayObject.setBackgroundColor(e)},n.prototype.fillBackground=function(e){var i=this.$graphicsNode;i&&i.clear();var r=this.$TextField;if(r[33]||r[31]||e&&e.length>0){if(!i)if(i=this.$graphicsNode=new t.sys.GraphicsNode,t.nativeRender)this.$renderNode=this.textNode;else{var n=new t.sys.GroupNode;n.addNode(i),n.addNode(this.textNode),this.$renderNode=n}var a=void 0,o=void 0;if(r[33]&&(a=i.beginFill(r[34]),a.drawRect(0,0,this.$getWidth(),this.$getHeight())),r[31]&&(o=i.lineStyle(1,r[32]),o.drawRect(0,0,this.$getWidth()-1,this.$getHeight()-1)),e&&e.length>0)for(var s=r[2],h=-1,c=e.length,l=0;c>l;l+=4){var u=e[l],p=e[l+1],d=e[l+2],f=e[l+3]||s;(0>h||h!=f)&&(h=f,o=i.lineStyle(2,f,1,t.CapsStyle.NONE)),o.moveTo(u,p),o.lineTo(u+d,p)}}if(i){var g=this.$getRenderBounds();i.x=g.x,i.y=g.y,i.width=g.width,i.height=g.height,t.Rectangle.release(g)}},n.prototype.setFocus=function(){this.type==t.TextFieldType.INPUT&&this.$stage&&this.inputUtils.$onFocus()},n.prototype.$onRemoveFromStage=function(){r.prototype.$onRemoveFromStage.call(this),this.removeEvent(),this.$TextField[24]==t.TextFieldType.INPUT&&this.inputUtils._removeStageText(),this.textNode&&(this.textNode.clean(),t.nativeRender&&egret_native.NativeDisplayObject.disposeTextData(this))},n.prototype.$onAddToStage=function(e,i){r.prototype.$onAddToStage.call(this,e,i),this.addEvent(),this.$TextField[24]==t.TextFieldType.INPUT&&this.inputUtils._addStageText()},n.prototype.$invalidateTextField=function(){var e=this;if(e.$renderDirty=!0,e.$TextField[18]=!0,e.$TextField[38]=!0,t.nativeRender);else{var i=e.$parent;i&&!i.$cacheDirty&&(i.$cacheDirty=!0,i.$cacheDirtyUp());var r=e.$maskedObject;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp())}},n.prototype.$getRenderBounds=function(){var e=this.$getContentBounds(),i=t.Rectangle.create();i.copyFrom(e),this.$TextField[31]&&(i.width+=2,i.height+=2);var r=2*this.$TextField[27];return r>0&&(i.width+=2*r,i.height+=2*r),i.x-=r+2,i.y-=r+2,i.width=Math.ceil(i.width)+4,i.height=Math.ceil(i.height)+4,i},n.prototype.$measureContentBounds=function(e){this.$getLinesArr();var i=0,r=0;t.nativeRender?(i=egret_native.nrGetTextFieldWidth(this.$nativeDisplayObject.id),r=egret_native.nrGetTextFieldHeight(this.$nativeDisplayObject.id)):(i=isNaN(this.$TextField[3])?this.$TextField[5]:this.$TextField[3],r=isNaN(this.$TextField[4])?t.TextFieldUtils.$getTextHeight(this):this.$TextField[4]),e.setTo(0,0,i,r)},n.prototype.$updateRenderNode=function(){if(this.$TextField[24]==t.TextFieldType.INPUT){if(this.inputUtils._updateProperties(),this.$isTyping)return void this.fillBackground()}else if(0==this.$TextField[3]){var e=this.$graphicsNode;return void(e&&e.clear())}var i=this.drawText();this.fillBackground(i);var r=this.$getRenderBounds(),n=this.textNode;n.x=r.x,n.y=r.y,n.width=Math.ceil(r.width),n.height=Math.ceil(r.height),t.Rectangle.release(r)},Object.defineProperty(n.prototype,"textFlow",{get:function(){return this.textArr},set:function(e){this.isFlow=!0;var i="";null==e&&(e=[]);for(var r=0;ri;i++)switch(t.charAt(i)){case"\n":e+="\n";break;case"\r":break;default:e+="*"}return e}return t},n.prototype.setMiddleStyle=function(t){this.$TextField[18]=!0,this.$TextField[38]=!0,this.textArr=t,this.$invalidateTextField()},Object.defineProperty(n.prototype,"textWidth",{get:function(){return this.$getLinesArr(),t.nativeRender?egret_native.nrGetTextWidth(this.$nativeDisplayObject.id):this.$TextField[5]},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"textHeight",{get:function(){return this.$getLinesArr(),t.nativeRender?egret_native.nrGetTextHeight(this.$nativeDisplayObject.id):t.TextFieldUtils.$getTextHeight(this)},enumerable:!0,configurable:!0}),n.prototype.appendText=function(t){this.appendElement({text:t})},n.prototype.appendElement=function(e){var i=this.$TextField[13]+e.text;return t.nativeRender?(this.textArr.push(e),this.$TextField[13]=i,this.$TextField[18]=!0,this.$TextField[38]=!0,void this.$nativeDisplayObject.setTextFlow(this.textArr)):void(this.$TextField[20]?this.$setBaseText(i):(this.$TextField[13]=i,this.textArr.push(e),this.setMiddleStyle(this.textArr)))},n.prototype.$getLinesArr=function(){var e=this.$TextField;return t.nativeRender&&e[38]?(egret_native.updateNativeRender(),void(e[38]=!1)):this.$getLinesArr2()},n.prototype.$getLinesArr2=function(){var r=this.$TextField;if(!r[18])return this.linesArr;r[18]=!1;var n=this.textArr;this.linesArr.length=0,r[6]=0,r[5]=0;var a=r[3];if(!isNaN(a)&&0==a)return r[29]=0,[{width:0,height:0,charNum:0,elements:[],hasNextLine:!1}];for(var o,s=this.linesArr,h=0,c=0,l=0,u=0,p=0,d=n.length;d>p;p++){var f=n[p];if(f.text){f.style=f.style||{};for(var g=f.text.toString(),$=g.split(/(?:\r\n|\r|\n)/),y=0,v=$.length;v>y;y++){null==s[u]&&(o={width:0,height:0,elements:[],charNum:0,hasNextLine:!1},s[u]=o,h=0,l=0,c=0),l=r[24]==t.TextFieldType.INPUT?r[0]:Math.max(l,f.style.size||r[0]);var b=!0;if(""==$[y])y==v-1&&(b=!1);else{var m=e($[y],r,f.style);if(isNaN(a))h+=m,c+=$[y].length,o.elements.push({width:m,text:$[y],style:f.style}),y==v-1&&(b=!1);else if(a>=h+m)o.elements.push({width:m,text:$[y],style:f.style}),h+=m,c+=$[y].length,y==v-1&&(b=!1);else{var x=0,T=0,_=$[y],D=void 0;D=r[19]?_.split(i):_.match(/./g);for(var O=D.length,w=0;O>x;x++){var E=D[x].length,R=!1;if(1==E&&O-1>x){var S=D[x].charCodeAt(0),F=D[x+1].charCodeAt(0);if(S>=55296&&56319>=S&&56320==(64512&F)){var P=D[x]+D[x+1];E=2,R=!0,m=e(P,r,f.style)}else m=e(D[x],r,f.style)}else m=e(D[x],r,f.style);if(0!=h&&h+m>a&&h+x!=0)break;if(T+m>a)for(var C=D[x].match(/./g),M=0,j=C.length;j>M;M++){var E=C[M].length,A=!1;if(1==E&&j-1>M){var S=C[M].charCodeAt(0),F=C[M+1].charCodeAt(0);if(S>=55296&&56319>=S&&56320==(64512&F)){var P=C[M]+C[M+1];E=2,A=!0,m=e(P,r,f.style)}else m=e(C[M],r,f.style)}else m=e(C[M],r,f.style);if(M>0&&h+m>a)break;w+=E,T+=m,h+=m,c+=w,A&&M++}else w+=E,T+=m,h+=m,c+=w;R&&x++}if(x>0){o.elements.push({width:T,text:_.substring(0,w),style:f.style});var B=_.substring(w),N=void 0,k=B.length;for(N=0;k>N&&" "==B.charAt(N);N++);$[y]=B.substring(N)}""!=$[y]&&(y--,b=!1)}}b&&(c++,o.hasNextLine=!0),y<$.length-1&&(o.width=h,o.height=l,o.charNum=c,r[5]=Math.max(r[5],h),r[6]+=l,u++)}p==n.length-1&&o&&(o.width=h,o.height=l,o.charNum=c,r[5]=Math.max(r[5],h),r[6]+=l)}else o&&(o.width=h,o.height=l,o.charNum=c,r[5]=Math.max(r[5],h),r[6]+=l)}return r[29]=s.length,s},n.prototype.$setIsTyping=function(e){this.$isTyping=e,this.$invalidateTextField(),t.nativeRender&&this.$nativeDisplayObject.setIsTyping(e)},n.prototype.drawText=function(){var e=this.textNode,i=this.$TextField;e.bold=i[15],e.fontFamily=i[8]||n.default_fontFamily,e.italic=i[16],e.size=i[0],e.stroke=i[27],e.strokeColor=i[25],e.textColor=i[2];var r=this.$getLinesArr();if(0==i[5])return[];var a=isNaN(i[3])?i[5]:i[3],o=t.TextFieldUtils.$getTextHeight(this),s=0,h=t.TextFieldUtils.$getStartLine(this),c=i[4];if(!isNaN(c)&&c>o){var l=t.TextFieldUtils.$getValign(this);s+=l*(c-o)}s=Math.round(s);for(var u=t.TextFieldUtils.$getHalign(this),p=0,d=[],f=h,g=i[29];g>f;f++){var $=r[f],y=$.height;if(s+=y/2,f!=h){if(i[24]==t.TextFieldType.INPUT&&!i[30])break;if(!isNaN(c)&&s>c)break}p=Math.round((a-$.width)*u);for(var v=0,b=$.elements.length;b>v;v++){var m=$.elements[v],x=m.style.size||i[0];e.drawText(p,s+(y-x)/2,m.text,m.style),m.style.underline&&d.push(p,s+y/2,m.width,m.style.textColor),p+=m.width}s+=y/2+i[1]}return d},n.prototype.addEvent=function(){this.addEventListener(t.TouchEvent.TOUCH_TAP,this.onTapHandler,this)},n.prototype.removeEvent=function(){this.removeEventListener(t.TouchEvent.TOUCH_TAP,this.onTapHandler,this)},n.prototype.onTapHandler=function(e){if(this.$TextField[24]!=t.TextFieldType.INPUT){var i=t.TextFieldUtils.$getTextElement(this,e.localX,e.localY);if(null!=i){var r=i.style;if(r&&r.href)if(r.href.match(/^event:/)){var n=r.href.match(/^event:/)[0];t.TextEvent.dispatchTextEvent(this,t.TextEvent.LINK,r.href.substring(n.length))}else open(r.href,r.target||"_blank")}}},n.default_fontFamily="Arial",n.default_size=30,n.default_textColor=16777215,n}(t.DisplayObject);t.TextField=r,__reflect(r.prototype,"egret.TextField")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.TEXT="text",t.TEL="tel",t.PASSWORD="password",t}();t.TextFieldInputType=e,__reflect(e.prototype,"egret.TextFieldInputType")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.DYNAMIC="dynamic",t.INPUT="input",t}();t.TextFieldType=e,__reflect(e.prototype,"egret.TextFieldType")}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){}return e.$getStartLine=function(t){var i=t.$TextField,r=e.$getTextHeight(t),n=0,a=i[4];return isNaN(a)||(a>r||r>a&&(n=Math.max(i[28]-1,0),n=Math.min(i[29]-1,n)),i[30]||(n=Math.max(i[28]-1,0),i[29]>0&&(n=Math.min(i[29]-1,n)))),n},e.$getHalign=function(e){var i=e.$getLinesArr2(),r=0;return e.$TextField[9]==t.HorizontalAlign.CENTER?r=.5:e.$TextField[9]==t.HorizontalAlign.RIGHT&&(r=1),e.$TextField[24]==t.TextFieldType.INPUT&&!e.$TextField[30]&&i.length>1&&(r=0),r},e.$getTextHeight=function(e){var i=t.TextFieldType.INPUT!=e.$TextField[24]||e.$TextField[30]?e.$TextField[6]+(e.$TextField[29]-1)*e.$TextField[1]:e.$TextField[0];return i},e.$getValign=function(i){var r=e.$getTextHeight(i),n=i.$TextField[4];if(!isNaN(n)&&n>r){var a=0;return i.$TextField[10]==t.VerticalAlign.MIDDLE?a=.5:i.$TextField[10]==t.VerticalAlign.BOTTOM&&(a=1),a}return 0},e.$getTextElement=function(t,i,r){var n=e.$getHit(t,i,r),a=t.$getLinesArr2();return n&&a[n.lineIndex]&&a[n.lineIndex].elements[n.textElementIndex]?a[n.lineIndex].elements[n.textElementIndex]:null},e.$getHit=function(t,i,r){var n=t.$getLinesArr2();if(0==t.$TextField[3])return null;var a=0,o=e.$getTextHeight(t),s=0,h=t.$TextField[4];if(!isNaN(h)&&h>o){var c=e.$getValign(t);s=c*(h-o),0!=s&&(r-=s)}for(var l=e.$getStartLine(t),u=0,p=l;p=r){r>u&&(a=p+1);break}if(u+=d.height,u+t.$TextField[1]>r)return null;u+=t.$TextField[1]}if(0==a)return null;var f=n[a-1],g=t.$TextField[3];isNaN(g)&&(g=t.textWidth);var $=e.$getHalign(t);i-=$*(g-f.width);for(var y=0,p=0;py)return{lineIndex:a-1,textElementIndex:p}}return null},e.$getScrollNum=function(t){var e=1;if(t.$TextField[30]){var i=t.height,r=t.size,n=t.lineSpacing;e=Math.floor(i/(r+n));var a=i-(r+n)*e;a>r/2&&e++}return e},e}();t.TextFieldUtils=e,__reflect(e.prototype,"egret.TextFieldUtils")}(egret||(egret={}));var egret;!function(t){var e;!function(t){}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.TOP="top",t.BOTTOM="bottom",t.MIDDLE="middle",t.JUSTIFY="justify",t.CONTENT_JUSTIFY="contentJustify",t}();t.VerticalAlign=e,__reflect(e.prototype,"egret.VerticalAlign")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.encode=function(t){for(var e=new Uint8Array(t),i=e.length,r="",n=0;i>n;n+=3)r+=chars[e[n]>>2],r+=chars[(3&e[n])<<4|e[n+1]>>4],r+=chars[(15&e[n+1])<<2|e[n+2]>>6],r+=chars[63&e[n+2]];return i%3===2?r=r.substring(0,r.length-1)+"=":i%3===1&&(r=r.substring(0,r.length-2)+"=="),r},t.decode=function(t){var e=.75*t.length,i=t.length,r=0,n=0,a=0,o=0,s=0;"="===t[t.length-1]&&(e--,"="===t[t.length-2]&&e--);for(var h=new ArrayBuffer(e),c=new Uint8Array(h),l=0;i>l;l+=4)n=lookup[t.charCodeAt(l)],a=lookup[t.charCodeAt(l+1)],o=lookup[t.charCodeAt(l+2)],s=lookup[t.charCodeAt(l+3)],c[r++]=n<<2|a>>4,c[r++]=(15&a)<<4|o>>2,c[r++]=(3&o)<<6|63&s;return h},t}();t.Base64Util=e,__reflect(e.prototype,"egret.Base64Util")}(egret||(egret={}));for(var chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lookup=new Uint8Array(256),i=0;ii&&(i=0),this.bufferExtSize=i;var r,n=0;if(t){var a=void 0;if(t instanceof Uint8Array?(a=t,n=t.length):(n=t.byteLength,a=new Uint8Array(t)),0==i)r=new Uint8Array(n);else{var o=(n/i|0)+1;r=new Uint8Array(o*i)}r.set(a)}else r=new Uint8Array(i);this.write_position=n,this._position=0,this._bytes=r,this.data=new DataView(r.buffer),this.endian=e.BIG_ENDIAN}return Object.defineProperty(i.prototype,"endian",{get:function(){return 0==this.$endian?e.LITTLE_ENDIAN:e.BIG_ENDIAN},set:function(t){this.$endian=t==e.LITTLE_ENDIAN?0:1},enumerable:!0,configurable:!0}),i.prototype.setArrayBuffer=function(t){},Object.defineProperty(i.prototype,"readAvailable",{get:function(){return this.write_position-this._position},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"buffer",{get:function(){return this.data.buffer.slice(0,this.write_position)},set:function(t){var e,i=t.byteLength,r=new Uint8Array(t),n=this.bufferExtSize;if(0==n)e=new Uint8Array(i);else{var a=(i/n|0)+1;e=new Uint8Array(a*n)}e.set(r),this.write_position=i,this._bytes=e,this.data=new DataView(e.buffer)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rawBuffer",{get:function(){return this.data.buffer},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"bytes",{get:function(){return this._bytes},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"dataView",{get:function(){return this.data},set:function(t){this.buffer=t.buffer},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"bufferOffset",{get:function(){return this.data.byteOffset},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"position",{get:function(){return this._position},set:function(t){this._position=t,t>this.write_position&&(this.write_position=t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"length",{get:function(){return this.write_position},set:function(t){this.write_position=t,this.data.byteLength>t&&(this._position=t),this._validateBuffer(t)},enumerable:!0,configurable:!0}),i.prototype._validateBuffer=function(t){if(this.data.byteLength>0)+1)*e;i=new Uint8Array(r)}i.set(this._bytes),this._bytes=i,this.data=new DataView(i.buffer)}},Object.defineProperty(i.prototype,"bytesAvailable",{get:function(){return this.data.byteLength-this._position},enumerable:!0,configurable:!0}),i.prototype.clear=function(){var t=new ArrayBuffer(this.bufferExtSize);this.data=new DataView(t),this._bytes=new Uint8Array(t),this._position=0,this.write_position=0},i.prototype.readBoolean=function(){return this.validate(1)?!!this._bytes[this.position++]:void 0},i.prototype.readByte=function(){return this.validate(1)?this.data.getInt8(this.position++):void 0},i.prototype.readBytes=function(e,i,r){if(void 0===i&&(i=0),void 0===r&&(r=0),e){var n=this._position,a=this.write_position-n;if(0>a)return void t.$error(1025);if(0==r)r=a;else if(r>a)return void t.$error(1025);var o=e._position;e._position=0,e.validateBuffer(i+r),e._position=o,e._bytes.set(this._bytes.subarray(n,n+r),i),this.position+=r}},i.prototype.readDouble=function(){if(this.validate(8)){var t=this.data.getFloat64(this._position,0==this.$endian);return this.position+=8,t}},i.prototype.readFloat=function(){if(this.validate(4)){var t=this.data.getFloat32(this._position,0==this.$endian);return this.position+=4,t}},i.prototype.readInt=function(){if(this.validate(4)){var t=this.data.getInt32(this._position,0==this.$endian);return this.position+=4,t}},i.prototype.readShort=function(){if(this.validate(2)){var t=this.data.getInt16(this._position,0==this.$endian);return this.position+=2,t}},i.prototype.readUnsignedByte=function(){return this.validate(1)?this._bytes[this.position++]:void 0},i.prototype.readUnsignedInt=function(){if(this.validate(4)){var t=this.data.getUint32(this._position,0==this.$endian);return this.position+=4,t}},i.prototype.readUnsignedShort=function(){if(this.validate(2)){var t=this.data.getUint16(this._position,0==this.$endian);return this.position+=2,t}},i.prototype.readUTF=function(){var t=this.readUnsignedShort();return t>0?this.readUTFBytes(t):""},i.prototype.readUTFBytes=function(t){if(this.validate(t)){var e=this.data,i=new Uint8Array(e.buffer,e.byteOffset+this._position,t);return this.position+=t,this.decodeUTF8(i)}},i.prototype.writeBoolean=function(t){this.validateBuffer(1),this._bytes[this.position++]=+t},i.prototype.writeByte=function(t){this.validateBuffer(1),this._bytes[this.position++]=255&t},i.prototype.writeBytes=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0);var r;0>e||0>i||(r=0==i?t.length-e:Math.min(t.length-e,i),r>0&&(this.validateBuffer(r),this._bytes.set(t._bytes.subarray(e,e+r),this._position),this.position=this._position+r))},i.prototype.writeDouble=function(t){this.validateBuffer(8),this.data.setFloat64(this._position,t,0==this.$endian),this.position+=8},i.prototype.writeFloat=function(t){this.validateBuffer(4),this.data.setFloat32(this._position,t,0==this.$endian),this.position+=4},i.prototype.writeInt=function(t){this.validateBuffer(4),this.data.setInt32(this._position,t,0==this.$endian),this.position+=4},i.prototype.writeShort=function(t){this.validateBuffer(2),this.data.setInt16(this._position,t,0==this.$endian),this.position+=2},i.prototype.writeUnsignedInt=function(t){this.validateBuffer(4),this.data.setUint32(this._position,t,0==this.$endian),this.position+=4},i.prototype.writeUnsignedShort=function(t){this.validateBuffer(2),this.data.setUint16(this._position,t,0==this.$endian),this.position+=2},i.prototype.writeUTF=function(t){var e=this.encodeUTF8(t),i=e.length;this.validateBuffer(2+i),this.data.setUint16(this._position,i,0==this.$endian),this.position+=2,this._writeUint8Array(e,!1)},i.prototype.writeUTFBytes=function(t){this._writeUint8Array(this.encodeUTF8(t))},i.prototype.toString=function(){return"[ByteArray] length:"+this.length+", bytesAvailable:"+this.bytesAvailable},i.prototype._writeUint8Array=function(t,e){void 0===e&&(e=!0);var i=this._position,r=i+t.length;e&&this.validateBuffer(r),this.bytes.set(t,i),this.position=r},i.prototype.validate=function(e){var i=this._bytes.length;return i>0&&this._position+e<=i?!0:void t.$error(1025)},i.prototype.validateBuffer=function(t){this.write_position=t>this.write_position?t:this.write_position,t+=this._position,this._validateBuffer(t)},i.prototype.encodeUTF8=function(t){for(var e=0,i=this.stringToCodePoints(t),r=[];i.length>e;){var n=i[e++];if(this.inRange(n,55296,57343))this.encoderError(n);else if(this.inRange(n,0,127))r.push(n);else{var a=void 0,o=void 0;for(this.inRange(n,128,2047)?(a=1,o=192):this.inRange(n,2048,65535)?(a=2,o=224):this.inRange(n,65536,1114111)&&(a=3,o=240),r.push(this.div(n,Math.pow(64,a))+o);a>0;){var s=this.div(n,Math.pow(64,a-1));r.push(128+s%64),a-=1}}}return new Uint8Array(r)},i.prototype.decodeUTF8=function(t){for(var e,i=!1,r=0,n="",a=0,o=0,s=0,h=0;t.length>r;){var c=t[r++];if(c==this.EOF_byte)e=0!=o?this.decoderError(i):this.EOF_code_point;else if(0==o)this.inRange(c,0,127)?e=c:(this.inRange(c,194,223)?(o=1,h=128,a=c-192):this.inRange(c,224,239)?(o=2,h=2048,a=c-224):this.inRange(c,240,244)?(o=3,h=65536,a=c-240):this.decoderError(i),a*=Math.pow(64,o),e=null);else if(this.inRange(c,128,191))if(s+=1,a+=(c-128)*Math.pow(64,o-s),s!==o)e=null;else{var l=a,u=h;a=0,o=0,s=0,h=0,e=this.inRange(l,u,1114111)&&!this.inRange(l,55296,57343)?l:this.decoderError(i,c)}else a=0,o=0,s=0,h=0,r--,e=this.decoderError(i,c);null!==e&&e!==this.EOF_code_point&&(65535>=e?e>0&&(n+=String.fromCharCode(e)):(e-=65536,n+=String.fromCharCode(55296+(e>>10&1023)),n+=String.fromCharCode(56320+(1023&e))))}return n},i.prototype.encoderError=function(e){t.$error(1026,e)},i.prototype.decoderError=function(e,i){return e&&t.$error(1027),i||65533},i.prototype.inRange=function(t,e,i){return t>=e&&i>=t},i.prototype.div=function(t,e){return Math.floor(t/e)},i.prototype.stringToCodePoints=function(t){for(var e=[],i=0,r=t.length;is;s++){var h=a[s];-1==n.indexOf(h)&&n.push(h)}r.__types__=n}t.registerClass=e}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){var i=e.call(this)||this;return i.$stageWidth=0,i.$stageHeight=0,i.$scaleMode=t.StageScaleMode.SHOW_ALL,i.$orientation=t.OrientationMode.AUTO,i.$maxTouches=99,i.$stage=i,i.$nestLevel=1,i}return __extends(i,e),i.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(13)},Object.defineProperty(i.prototype,"frameRate",{get:function(){return t.ticker.$frameRate},set:function(e){t.ticker.$setFrameRate(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"stageWidth",{get:function(){return this.$stageWidth},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"stageHeight",{get:function(){return this.$stageHeight},enumerable:!0,configurable:!0}),i.prototype.invalidate=function(){t.sys.$invalidateRenderFlag=!0},i.prototype.registerImplementation=function(e,i){t.registerImplementation(e,i)},i.prototype.getImplementation=function(e){return t.getImplementation(e)},Object.defineProperty(i.prototype,"scaleMode",{get:function(){return this.$scaleMode},set:function(t){this.$scaleMode!=t&&(this.$scaleMode=t,this.$screen.updateScreenSize())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"orientation",{get:function(){return this.$orientation},set:function(t){this.$orientation!=t&&(this.$orientation=t,this.$screen.updateScreenSize())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"textureScaleFactor",{get:function(){return t.$TextureScaleFactor},set:function(e){t.$TextureScaleFactor=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"maxTouches",{get:function(){return this.$maxTouches},set:function(t){this.$maxTouches!=t&&(this.$maxTouches=t,this.$screen.updateMaxTouches())},enumerable:!0,configurable:!0}),i.prototype.setContentSize=function(t,e){this.$screen.setContentSize(t,e)},i}(t.DisplayObjectContainer);t.Stage=e,__reflect(e.prototype,"egret.Stage")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return Object.defineProperty(t,"logLevel",{set:function(t){},enumerable:!0,configurable:!0}),t.ALL="all",t.DEBUG="debug",t.INFO="info",t.WARN="warn",t.ERROR="error",t.OFF="off",t}();t.Logger=e,__reflect(e.prototype,"egret.Logger")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.isNumber=function(t){return"number"==typeof t&&!isNaN(t)},t.sin=function(e){var i=Math.floor(e),r=i+1,n=t.sinInt(i);if(i==e)return n;var a=t.sinInt(r);return(e-i)*a+(r-e)*n},t.sinInt=function(t){return t%=360,0>t&&(t+=360),egret_sin_map[t]},t.cos=function(e){var i=Math.floor(e),r=i+1,n=t.cosInt(i);if(i==e)return n;var a=t.cosInt(r);return(e-i)*a+(r-e)*n},t.cosInt=function(t){return t%=360,0>t&&(t+=360),egret_cos_map[t]},t}();t.NumberUtils=e,__reflect(e.prototype,"egret.NumberUtils")}(egret||(egret={}));for(var egret_sin_map={},egret_cos_map={},DEG_TO_RAD=Math.PI/180,NumberUtils_i=0;360>NumberUtils_i;NumberUtils_i++)egret_sin_map[NumberUtils_i]=Math.sin(NumberUtils_i*DEG_TO_RAD),egret_cos_map[NumberUtils_i]=Math.cos(NumberUtils_i*DEG_TO_RAD);egret_sin_map[90]=1,egret_cos_map[90]=0,egret_sin_map[180]=0,egret_cos_map[180]=-1,egret_sin_map[270]=-1,egret_cos_map[270]=0,Function.prototype.bind||(Function.prototype.bind=function(t){"function"!=typeof this&&egret.$error(1029);var e=Array.prototype.slice.call(arguments,1),i=this,r=function(){},n=function(){return i.apply(this instanceof r&&t?this:t,e.concat(Array.prototype.slice.call(arguments)))};return r.prototype=this.prototype,n.prototype=new r,n});var egret;!function(t){var e=function(e){function i(t,i){void 0===i&&(i=0);var r=e.call(this)||this;return r._delay=0,r._currentCount=0,r._running=!1,r.updateInterval=1e3,r.lastCount=1e3,r.lastTimeStamp=0,r.delay=t,r.repeatCount=0|+i,r}return __extends(i,e),Object.defineProperty(i.prototype,"delay",{get:function(){return this._delay},set:function(t){1>t&&(t=1),this._delay!=t&&(this._delay=t,this.lastCount=this.updateInterval=Math.round(60*t))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"currentCount",{get:function(){return this._currentCount},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"running",{get:function(){return this._running},enumerable:!0,configurable:!0}),i.prototype.reset=function(){this.stop(),this._currentCount=0},i.prototype.start=function(){this._running||(this.lastCount=this.updateInterval,this.lastTimeStamp=t.getTimer(),t.ticker.$startTick(this.$update,this),this._running=!0)},i.prototype.stop=function(){this._running&&(t.stopTick(this.$update,this),this._running=!1)},i.prototype.$update=function(e){var i=e-this.lastTimeStamp;if(i>=this._delay)this.lastCount=this.updateInterval;else{if(this.lastCount-=1e3,this.lastCount>0)return!1;this.lastCount+=this.updateInterval}this.lastTimeStamp=e,this._currentCount++;var r=this.repeatCount>0&&this._currentCount>=this.repeatCount;return t.TimerEvent.dispatchTimerEvent(this,t.TimerEvent.TIMER),r&&(this.stop(),t.TimerEvent.dispatchTimerEvent(this,t.TimerEvent.TIMER_COMPLETE)),!1},i}(t.EventDispatcher);t.Timer=e,__reflect(e.prototype,"egret.Timer")}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){function e(e,i){for(var r=[],n=2;na;a++){var o=r[a];if(e=e[o],!e)return null}return i[t]=e,e}var i={};t.getDefinitionByName=e}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){function e(t){var e=typeof t;if(!t||"object"!=e&&!t.prototype)return e;var i=t.prototype?t.prototype:Object.getPrototypeOf(t);if(i.hasOwnProperty("__class__"))return i.__class__;var r=i.constructor.toString().trim(),n=r.indexOf("("),a=r.substring(9,n);return Object.defineProperty(i,"__class__",{value:a,enumerable:!1,writable:!0}),a}t.getQualifiedClassName=e}(egret||(egret={}));var egret;!function(t){function e(e){if(!e||"object"!=typeof e&&!e.prototype)return null;var i=e.prototype?e.prototype:Object.getPrototypeOf(e),r=Object.getPrototypeOf(i);if(!r)return null;var n=t.getQualifiedClassName(r.constructor);return n?n:null}t.getQualifiedSuperclassName=e}(egret||(egret={}));var egret;!function(t){function e(){return Date.now()-t.sys.$START_TIME}t.getTimer=e}(egret||(egret={}));var egret;!function(t){function e(e){var i=t.getDefinitionByName(e);return i?!0:!1}t.hasDefinition=e}(egret||(egret={}));var egret;!function(t){function e(t,e){if(!t||"object"!=typeof t)return!1;var i=Object.getPrototypeOf(t),r=i?i.__types__:null;return r?-1!==r.indexOf(e):!1}t.is=e}(egret||(egret={}));var egret;!function(t){function e(e,i){t.ticker.$startTick(e,i)}t.startTick=e}(egret||(egret={}));var egret;!function(t){function e(e,i){t.ticker.$stopTick(e,i)}t.stopTick=e}(egret||(egret={}));var egret;!function(t){function e(t){0>t&&(t=0),t>16777215&&(t=16777215);for(var e=t.toString(16).toUpperCase();e.length>6;)e=e.slice(1,e.length);for(;e.length<6;)e="0"+e;return"#"+e}t.toColorString=e}(egret||(egret={}));var egret;!function(t){var e;!function(t){}(e=t.sys||(t.sys={}))}(egret||(egret={})); \ No newline at end of file diff --git a/helloworld/libs/modules/egret/egret.web.js b/helloworld/libs/modules/egret/egret.web.js deleted file mode 100644 index 7f8780f..0000000 --- a/helloworld/libs/modules/egret/egret.web.js +++ /dev/null @@ -1,8331 +0,0 @@ -var __reflect = (this && this.__reflect) || function (p, c, t) { - p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; -}; -var __extends = this && this.__extends || function __extends(t, e) { - function r() { - this.constructor = t; -} -for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]); -r.prototype = e.prototype, t.prototype = new r(); -}; -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - function getOption(key) { - if (window.location) { - var search = location.search; - if (search == "") { - return ""; - } - search = search.slice(1); - var searchArr = search.split("&"); - var length_1 = searchArr.length; - for (var i = 0; i < length_1; i++) { - var str = searchArr[i]; - var arr = str.split("="); - if (arr[0] == key) { - return arr[1]; - } - } - } - return ""; - } - web.getOption = getOption; - egret.getOption = getOption; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - var WebExternalInterface = (function () { - function WebExternalInterface() { - } - /** - * @private - * @param functionName - * @param value - */ - WebExternalInterface.call = function (functionName, value) { - }; - /** - * @private - * @param functionName - * @param listener - */ - WebExternalInterface.addCallback = function (functionName, listener) { - }; - return WebExternalInterface; - }()); - web.WebExternalInterface = WebExternalInterface; - __reflect(WebExternalInterface.prototype, "egret.web.WebExternalInterface", ["egret.ExternalInterface"]); - var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf("egretnative") < 0) { - egret.ExternalInterface = WebExternalInterface; - } - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -(function (egret) { - var web; - (function (web) { - var callBackDic = {}; - /** - * @private - */ - var NativeExternalInterface = (function () { - function NativeExternalInterface() { - } - NativeExternalInterface.call = function (functionName, value) { - var data = {}; - data.functionName = functionName; - data.value = value; - egret_native.sendInfoToPlugin(JSON.stringify(data)); - }; - NativeExternalInterface.addCallback = function (functionName, listener) { - callBackDic[functionName] = listener; - }; - return NativeExternalInterface; - }()); - web.NativeExternalInterface = NativeExternalInterface; - __reflect(NativeExternalInterface.prototype, "egret.web.NativeExternalInterface", ["egret.ExternalInterface"]); - /** - * @private - * @param info - */ - function onReceivedPluginInfo(info) { - var data = JSON.parse(info); - var functionName = data.functionName; - var listener = callBackDic[functionName]; - if (listener) { - var value = data.value; - listener.call(null, value); - } - else { - egret.$warn(1050, functionName); - } - } - var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf("egretnative") >= 0) { - egret.ExternalInterface = NativeExternalInterface; - egret_native.receivedPluginInfo = onReceivedPluginInfo; - } - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -(function (egret) { - var web; - (function (web) { - var callBackDic = {}; - /** - * @private - */ - var WebViewExternalInterface = (function () { - function WebViewExternalInterface() { - } - WebViewExternalInterface.call = function (functionName, value) { - __global.ExternalInterface.call(functionName, value); - }; - WebViewExternalInterface.addCallback = function (functionName, listener) { - callBackDic[functionName] = listener; - }; - WebViewExternalInterface.invokeCallback = function (functionName, value) { - var listener = callBackDic[functionName]; - if (listener) { - listener.call(null, value); - } - else { - egret.$warn(1050, functionName); - } - }; - return WebViewExternalInterface; - }()); - web.WebViewExternalInterface = WebViewExternalInterface; - __reflect(WebViewExternalInterface.prototype, "egret.web.WebViewExternalInterface", ["egret.ExternalInterface"]); - var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf("egretwebview") >= 0) { - egret.ExternalInterface = WebViewExternalInterface; - } - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - * @inheritDoc - */ - var HtmlSound = (function (_super) { - __extends(HtmlSound, _super); - /** - * @private - * @inheritDoc - */ - function HtmlSound() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.loaded = false; - return _this; - } - Object.defineProperty(HtmlSound.prototype, "length", { - get: function () { - if (this.originAudio) { - return this.originAudio.duration; - } - throw new Error("sound not loaded!"); - //return 0; - }, - enumerable: true, - configurable: true - }); - /** - * @inheritDoc - */ - HtmlSound.prototype.load = function (url) { - var self = this; - this.url = url; - if (true && !url) { - egret.$error(3002); - } - var audio = new Audio(url); - audio.addEventListener("canplaythrough", onAudioLoaded); - audio.addEventListener("error", onAudioError); - var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf("firefox") >= 0) { - audio.autoplay = !0; - audio.muted = true; - } - audio.load(); - this.originAudio = audio; - if (HtmlSound.clearAudios[this.url]) { - delete HtmlSound.clearAudios[this.url]; - } - HtmlSound.$recycle(this.url, audio); - function onAudioLoaded() { - removeListeners(); - if (ua.indexOf("firefox") >= 0) { - audio.pause(); - audio.muted = false; - } - self.loaded = true; - self.dispatchEventWith(egret.Event.COMPLETE); - } - function onAudioError() { - removeListeners(); - self.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); - } - function removeListeners() { - audio.removeEventListener("canplaythrough", onAudioLoaded); - audio.removeEventListener("error", onAudioError); - } - }; - /** - * @inheritDoc - */ - HtmlSound.prototype.play = function (startTime, loops) { - startTime = +startTime || 0; - loops = +loops || 0; - if (true && this.loaded == false) { - egret.$error(1049); - } - var audio = HtmlSound.$pop(this.url); - if (audio == null) { - audio = this.originAudio.cloneNode(); - } - else { - //audio.load(); - } - audio.autoplay = true; - var channel = new web.HtmlSoundChannel(audio); - channel.$url = this.url; - channel.$loops = loops; - channel.$startTime = startTime; - channel.$play(); - egret.sys.$pushSoundChannel(channel); - return channel; - }; - /** - * @inheritDoc - */ - HtmlSound.prototype.close = function () { - if (this.loaded == false && this.originAudio) - this.originAudio.src = ""; - if (this.originAudio) - this.originAudio = null; - HtmlSound.$clear(this.url); - }; - HtmlSound.$clear = function (url) { - HtmlSound.clearAudios[url] = true; - var array = HtmlSound.audios[url]; - if (array) { - array.length = 0; - } - }; - HtmlSound.$pop = function (url) { - var array = HtmlSound.audios[url]; - if (array && array.length > 0) { - return array.pop(); - } - return null; - }; - HtmlSound.$recycle = function (url, audio) { - if (HtmlSound.clearAudios[url]) { - return; - } - var array = HtmlSound.audios[url]; - if (HtmlSound.audios[url] == null) { - array = HtmlSound.audios[url] = []; - } - array.push(audio); - }; - /** - * Background music - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 背景音乐 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HtmlSound.MUSIC = "music"; - /** - * EFFECT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 音效 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HtmlSound.EFFECT = "effect"; - /** - * @private - */ - HtmlSound.audios = {}; - HtmlSound.clearAudios = {}; - return HtmlSound; - }(egret.EventDispatcher)); - web.HtmlSound = HtmlSound; - __reflect(HtmlSound.prototype, "egret.web.HtmlSound", ["egret.Sound"]); - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - * @inheritDoc - */ - var HtmlSoundChannel = (function (_super) { - __extends(HtmlSoundChannel, _super); - /** - * @private - */ - function HtmlSoundChannel(audio) { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.$startTime = 0; - /** - * @private - */ - _this.audio = null; - //声音是否已经播放完成 - _this.isStopped = false; - _this.canPlay = function () { - _this.audio.removeEventListener("canplay", _this.canPlay); - try { - _this.audio.currentTime = _this.$startTime; - } - catch (e) { - } - finally { - _this.audio.play(); - } - }; - /** - * @private - */ - _this.onPlayEnd = function () { - if (_this.$loops == 1) { - _this.stop(); - _this.dispatchEventWith(egret.Event.SOUND_COMPLETE); - return; - } - if (_this.$loops > 0) { - _this.$loops--; - } - ///////////// - //this.audio.load(); - _this.$play(); - }; - /** - * @private - */ - _this._volume = 1; - audio.addEventListener("ended", _this.onPlayEnd); - _this.audio = audio; - return _this; - } - HtmlSoundChannel.prototype.$play = function () { - if (this.isStopped) { - egret.$error(1036); - return; - } - try { - //this.audio.pause(); - this.audio.volume = this._volume; - this.audio.currentTime = this.$startTime; - } - catch (e) { - this.audio.addEventListener("canplay", this.canPlay); - return; - } - this.audio.play(); - }; - /** - * @private - * @inheritDoc - */ - HtmlSoundChannel.prototype.stop = function () { - if (!this.audio) - return; - if (!this.isStopped) { - egret.sys.$popSoundChannel(this); - } - this.isStopped = true; - var audio = this.audio; - audio.removeEventListener("ended", this.onPlayEnd); - audio.removeEventListener("canplay", this.canPlay); - audio.volume = 0; - this._volume = 0; - this.audio = null; - var url = this.$url; - //延迟一定时间再停止,规避chrome报错 - window.setTimeout(function () { - audio.pause(); - web.HtmlSound.$recycle(url, audio); - }, 200); - }; - Object.defineProperty(HtmlSoundChannel.prototype, "volume", { - /** - * @private - * @inheritDoc - */ - get: function () { - return this._volume; - }, - /** - * @inheritDoc - */ - set: function (value) { - if (this.isStopped) { - egret.$error(1036); - return; - } - this._volume = value; - if (!this.audio) - return; - this.audio.volume = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(HtmlSoundChannel.prototype, "position", { - /** - * @private - * @inheritDoc - */ - get: function () { - if (!this.audio) - return 0; - return this.audio.currentTime; - }, - enumerable: true, - configurable: true - }); - return HtmlSoundChannel; - }(egret.EventDispatcher)); - web.HtmlSoundChannel = HtmlSoundChannel; - __reflect(HtmlSoundChannel.prototype, "egret.web.HtmlSoundChannel", ["egret.SoundChannel", "egret.IEventDispatcher"]); - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - var WebAudioDecode = (function () { - function WebAudioDecode() { - } - /** - * @private - * - */ - WebAudioDecode.decodeAudios = function () { - if (WebAudioDecode.decodeArr.length <= 0) { - return; - } - if (WebAudioDecode.isDecoding) { - return; - } - WebAudioDecode.isDecoding = true; - var decodeInfo = WebAudioDecode.decodeArr.shift(); - WebAudioDecode.ctx.decodeAudioData(decodeInfo["buffer"], function (audioBuffer) { - decodeInfo["self"].audioBuffer = audioBuffer; - if (decodeInfo["success"]) { - decodeInfo["success"](); - } - WebAudioDecode.isDecoding = false; - WebAudioDecode.decodeAudios(); - }, function () { - alert("sound decode error: " + decodeInfo["url"] + "!\nsee http://edn.egret.com/cn/docs/page/156"); - if (decodeInfo["fail"]) { - decodeInfo["fail"](); - } - WebAudioDecode.isDecoding = false; - WebAudioDecode.decodeAudios(); - }); - }; - /** - * @private - */ - WebAudioDecode.decodeArr = []; - /** - * @private - */ - WebAudioDecode.isDecoding = false; - return WebAudioDecode; - }()); - web.WebAudioDecode = WebAudioDecode; - __reflect(WebAudioDecode.prototype, "egret.web.WebAudioDecode"); - /** - * @private - * @inheritDoc - */ - var WebAudioSound = (function (_super) { - __extends(WebAudioSound, _super); - /** - * @private - * @inheritDoc - */ - function WebAudioSound() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.loaded = false; - return _this; - } - Object.defineProperty(WebAudioSound.prototype, "length", { - get: function () { - if (this.audioBuffer) { - return this.audioBuffer.duration; - } - throw new Error("sound not loaded!"); - //return 0; - }, - enumerable: true, - configurable: true - }); - /** - * @inheritDoc - */ - WebAudioSound.prototype.load = function (url) { - var self = this; - this.url = url; - if (true && !url) { - egret.$error(3002); - } - var request = new XMLHttpRequest(); - request.open("GET", url, true); - request.responseType = "arraybuffer"; - request.onreadystatechange = function () { - if (request.readyState == 4) { - var ioError = (request.status >= 400 || request.status == 0); - if (ioError) { - self.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); - } - else { - WebAudioDecode.decodeArr.push({ - "buffer": request.response, - "success": onAudioLoaded, - "fail": onAudioError, - "self": self, - "url": self.url - }); - WebAudioDecode.decodeAudios(); - } - } - }; - request.send(); - function onAudioLoaded() { - self.loaded = true; - self.dispatchEventWith(egret.Event.COMPLETE); - } - function onAudioError() { - self.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); - } - }; - /** - * @inheritDoc - */ - WebAudioSound.prototype.play = function (startTime, loops) { - startTime = +startTime || 0; - loops = +loops || 0; - if (true && this.loaded == false) { - egret.$error(1049); - } - var channel = new web.WebAudioSoundChannel(); - channel.$url = this.url; - channel.$loops = loops; - channel.$audioBuffer = this.audioBuffer; - channel.$startTime = startTime; - channel.$play(); - egret.sys.$pushSoundChannel(channel); - return channel; - }; - /** - * @inheritDoc - */ - WebAudioSound.prototype.close = function () { - }; - /** - * Background music - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 背景音乐 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - WebAudioSound.MUSIC = "music"; - /** - * EFFECT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 音效 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - WebAudioSound.EFFECT = "effect"; - return WebAudioSound; - }(egret.EventDispatcher)); - web.WebAudioSound = WebAudioSound; - __reflect(WebAudioSound.prototype, "egret.web.WebAudioSound", ["egret.Sound"]); - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - * @inheritDoc - */ - var WebAudioSoundChannel = (function (_super) { - __extends(WebAudioSoundChannel, _super); - /** - * @private - */ - function WebAudioSoundChannel() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.$startTime = 0; - /** - * @private - */ - _this.bufferSource = null; - /** - * @private - */ - _this.context = web.WebAudioDecode.ctx; - //声音是否已经播放完成 - _this.isStopped = false; - /** - * @private - */ - _this._currentTime = 0; - /** - * @private - */ - _this._volume = 1; - /** - * @private - */ - _this.onPlayEnd = function () { - if (_this.$loops == 1) { - _this.stop(); - _this.dispatchEventWith(egret.Event.SOUND_COMPLETE); - return; - } - if (_this.$loops > 0) { - _this.$loops--; - } - ///////////// - _this.$play(); - }; - /** - * @private - */ - _this._startTime = 0; - if (_this.context["createGain"]) { - _this.gain = _this.context["createGain"](); - } - else { - _this.gain = _this.context["createGainNode"](); - } - return _this; - } - WebAudioSoundChannel.prototype.$play = function () { - if (this.isStopped) { - egret.$error(1036); - return; - } - if (this.bufferSource) { - this.bufferSource.onended = null; - this.bufferSource = null; - } - var context = this.context; - var gain = this.gain; - var bufferSource = context.createBufferSource(); - this.bufferSource = bufferSource; - bufferSource.buffer = this.$audioBuffer; - bufferSource.connect(gain); - gain.connect(context.destination); - bufferSource.onended = this.onPlayEnd; - this._startTime = Date.now(); - this.gain.gain.value = this._volume; - bufferSource.start(0, this.$startTime); - this._currentTime = 0; - }; - WebAudioSoundChannel.prototype.stop = function () { - if (this.bufferSource) { - var sourceNode = this.bufferSource; - if (sourceNode.stop) { - sourceNode.stop(0); - } - else { - sourceNode.noteOff(0); - } - sourceNode.onended = null; - sourceNode.disconnect(); - this.bufferSource = null; - this.$audioBuffer = null; - } - if (!this.isStopped) { - egret.sys.$popSoundChannel(this); - } - this.isStopped = true; - }; - Object.defineProperty(WebAudioSoundChannel.prototype, "volume", { - /** - * @private - * @inheritDoc - */ - get: function () { - return this._volume; - }, - /** - * @inheritDoc - */ - set: function (value) { - if (this.isStopped) { - egret.$error(1036); - return; - } - this._volume = value; - this.gain.gain.value = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(WebAudioSoundChannel.prototype, "position", { - /** - * @private - * @inheritDoc - */ - get: function () { - if (this.bufferSource) { - return (Date.now() - this._startTime) / 1000 + this.$startTime; - } - return 0; - }, - enumerable: true, - configurable: true - }); - return WebAudioSoundChannel; - }(egret.EventDispatcher)); - web.WebAudioSoundChannel = WebAudioSoundChannel; - __reflect(WebAudioSoundChannel.prototype, "egret.web.WebAudioSoundChannel", ["egret.SoundChannel", "egret.IEventDispatcher"]); - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - * @inheritDoc - */ - var WebVideo = (function (_super) { - __extends(WebVideo, _super); - /** - * @inheritDoc - */ - function WebVideo(url, cache) { - if (cache === void 0) { cache = true; } - var _this = _super.call(this) || this; - /** - * @private - */ - _this.loaded = false; - /** - * @private - */ - _this.closed = false; - /** - * @private - */ - _this.heightSet = NaN; - /** - * @private - */ - _this.widthSet = NaN; - /** - * @private - * pc上视频卡住的时候不能暂停 - */ - _this.waiting = false; - /** - * @private - * 用户是否设置了 pause - */ - _this.userPause = false; - /** - * @private - * 用户是否设置了 play - */ - _this.userPlay = false; - _this.isPlayed = false; - _this.screenChanged = function (e) { - var isfullscreen = document.fullscreenEnabled || document.webkitIsFullScreen; - if (!isfullscreen) { - _this.checkFullScreen(false); - if (!egret.Capabilities.isMobile) { - _this._fullscreen = isfullscreen; - } - } - }; - _this._fullscreen = true; - /** - * @private - * - */ - _this.onVideoLoaded = function () { - _this.video.removeEventListener("canplay", _this.onVideoLoaded); - var video = _this.video; - _this.loaded = true; - //video.pause(); - if (_this.posterData) { - _this.posterData.width = _this.getPlayWidth(); - _this.posterData.height = _this.getPlayHeight(); - } - video.width = video.videoWidth; - video.height = video.videoHeight; - window.setTimeout(function () { - _this.dispatchEventWith(egret.Event.COMPLETE); - }, 200); - }; - _this.$renderNode = new egret.sys.BitmapNode(); - _this.src = url; - _this.once(egret.Event.ADDED_TO_STAGE, _this.loadPoster, _this); - if (url) { - _this.load(); - } - return _this; - } - /** - * @inheritDoc - */ - WebVideo.prototype.load = function (url, cache) { - var _this = this; - if (cache === void 0) { cache = true; } - url = url || this.src; - this.src = url; - if (true && !url) { - egret.$error(3002); - } - if (this.video && this.video.src == url) { - return; - } - var video; - if (!this.video || egret.Capabilities.isMobile) { - video = document.createElement("video"); - this.video = video; - video.controls = null; - } - else { - video = this.video; - } - video.src = url; - video.setAttribute("autoplay", "autoplay"); - video.setAttribute("webkit-playsinline", "true"); - video.addEventListener("canplay", this.onVideoLoaded); - video.addEventListener("error", function () { return _this.onVideoError(); }); - video.addEventListener("ended", function () { return _this.onVideoEnded(); }); - var firstPause = false; - video.addEventListener("canplay", function () { - _this.waiting = false; - if (!firstPause) { - firstPause = true; - video.pause(); - } - else { - if (_this.userPause) { - _this.pause(); - } - else if (_this.userPlay) { - _this.play(); - } - } - }); - video.addEventListener("waiting", function () { - _this.waiting = true; - }); - video.load(); - this.videoPlay(); - video.style.position = "absolute"; - video.style.top = "0px"; - video.style.zIndex = "-88888"; - video.style.left = "0px"; - video.height = 1; - video.width = 1; - }; - /** - * @inheritDoc - */ - WebVideo.prototype.play = function (startTime, loop) { - var _this = this; - if (loop === void 0) { loop = false; } - if (this.loaded == false) { - this.load(this.src); - this.once(egret.Event.COMPLETE, function (e) { return _this.play(startTime, loop); }, this); - return; - } - this.isPlayed = true; - var video = this.video; - if (startTime != undefined) - video.currentTime = +startTime || 0; - video.loop = !!loop; - if (egret.Capabilities.isMobile) { - video.style.zIndex = "-88888"; //移动端,就算设置成最小,只要全屏,都会在最上层,而且在自动退出去后,不担心挡住canvas - } - else { - video.style.zIndex = "9999"; - } - video.style.position = "absolute"; - video.style.top = "0px"; - video.style.left = "0px"; - video.height = video.videoHeight; - video.width = video.videoWidth; - if (egret.Capabilities.os != "Windows PC" && egret.Capabilities.os != "Mac OS") { - window.setTimeout(function () { - video.width = 0; - }, 1000); - } - this.checkFullScreen(this._fullscreen); - }; - WebVideo.prototype.videoPlay = function () { - this.userPause = false; - if (this.waiting) { - this.userPlay = true; - return; - } - this.userPlay = false; - this.video.play(); - }; - WebVideo.prototype.checkFullScreen = function (playFullScreen) { - var video = this.video; - if (playFullScreen) { - if (video.parentElement == null) { - video.removeAttribute("webkit-playsinline"); - document.body.appendChild(video); - } - egret.stopTick(this.markDirty, this); - this.goFullscreen(); - } - else { - if (video.parentElement != null) { - video.parentElement.removeChild(video); - } - video.setAttribute("webkit-playsinline", "true"); - this.setFullScreenMonitor(false); - egret.startTick(this.markDirty, this); - if (egret.Capabilities.isMobile) { - this.video.currentTime = 0; - this.onVideoEnded(); - return; - } - } - this.videoPlay(); - }; - WebVideo.prototype.goFullscreen = function () { - var video = this.video; - var fullscreenType; - fullscreenType = egret.web.getPrefixStyleName('requestFullscreen', video); - if (!video[fullscreenType]) { - fullscreenType = egret.web.getPrefixStyleName('requestFullScreen', video); - if (!video[fullscreenType]) { - return true; - } - } - video.removeAttribute("webkit-playsinline"); - video[fullscreenType](); - this.setFullScreenMonitor(true); - return true; - }; - WebVideo.prototype.setFullScreenMonitor = function (use) { - var video = this.video; - if (use) { - video.addEventListener("mozfullscreenchange", this.screenChanged); - video.addEventListener("webkitfullscreenchange", this.screenChanged); - video.addEventListener("mozfullscreenerror", this.screenError); - video.addEventListener("webkitfullscreenerror", this.screenError); - } - else { - video.removeEventListener("mozfullscreenchange", this.screenChanged); - video.removeEventListener("webkitfullscreenchange", this.screenChanged); - video.removeEventListener("mozfullscreenerror", this.screenError); - video.removeEventListener("webkitfullscreenerror", this.screenError); - } - }; - WebVideo.prototype.screenError = function () { - egret.$error(3014); - }; - WebVideo.prototype.exitFullscreen = function () { - //退出全屏 - if (document['exitFullscreen']) { - document['exitFullscreen'](); - } - else if (document['msExitFullscreen']) { - document['msExitFullscreen'](); - } - else if (document['mozCancelFullScreen']) { - document['mozCancelFullScreen'](); - } - else if (document['oCancelFullScreen']) { - document['oCancelFullScreen'](); - } - else if (document['webkitExitFullscreen']) { - document['webkitExitFullscreen'](); - } - else { - } - }; - /** - * @private - * - */ - WebVideo.prototype.onVideoEnded = function () { - this.pause(); - this.isPlayed = false; - this.dispatchEventWith(egret.Event.ENDED); - }; - /** - * @private - * - */ - WebVideo.prototype.onVideoError = function () { - this.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); - }; - /** - * @inheritDoc - */ - WebVideo.prototype.close = function () { - var _this = this; - this.closed = true; - this.video.removeEventListener("canplay", this.onVideoLoaded); - this.video.removeEventListener("error", function () { return _this.onVideoError(); }); - this.video.removeEventListener("ended", function () { return _this.onVideoEnded(); }); - this.pause(); - if (this.loaded == false && this.video) - this.video.src = ""; - if (this.video && this.video.parentElement) { - this.video.parentElement.removeChild(this.video); - this.video = null; - } - this.loaded = false; - }; - /** - * @inheritDoc - */ - WebVideo.prototype.pause = function () { - this.userPlay = false; - if (this.waiting) { - this.userPause = true; - return; - } - this.userPause = false; - egret.stopTick(this.markDirty, this); - }; - Object.defineProperty(WebVideo.prototype, "volume", { - /** - * @inheritDoc - */ - get: function () { - if (!this.video) - return 1; - return this.video.volume; - }, - /** - * @inheritDoc - */ - set: function (value) { - if (!this.video) - return; - this.video.volume = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(WebVideo.prototype, "position", { - /** - * @inheritDoc - */ - get: function () { - if (!this.video) - return 0; - return this.video.currentTime; - }, - /** - * @inheritDoc - */ - set: function (value) { - if (!this.video) - return; - this.video.currentTime = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(WebVideo.prototype, "fullscreen", { - /** - * @inheritDoc - */ - get: function () { - return this._fullscreen; - }, - /** - * @inheritDoc - */ - set: function (value) { - if (egret.Capabilities.isMobile) { - return; - } - this._fullscreen = !!value; - if (this.video && this.video.paused == false) { - this.checkFullScreen(this._fullscreen); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(WebVideo.prototype, "bitmapData", { - /** - * @inheritDoc - */ - get: function () { - if (!this.video || !this.loaded) - return null; - if (!this._bitmapData) { - this.video.width = this.video.videoWidth; - this.video.height = this.video.videoHeight; - this._bitmapData = new egret.BitmapData(this.video); - this._bitmapData.$deleteSource = false; - } - return this._bitmapData; - }, - enumerable: true, - configurable: true - }); - WebVideo.prototype.loadPoster = function () { - var _this = this; - var poster = this.poster; - if (!poster) - return; - var imageLoader = new egret.ImageLoader(); - imageLoader.once(egret.Event.COMPLETE, function (e) { - var posterData = imageLoader.data; - _this.posterData = imageLoader.data; - _this.$renderDirty = true; - _this.posterData.width = _this.getPlayWidth(); - _this.posterData.height = _this.getPlayHeight(); - }, this); - imageLoader.load(poster); - }; - /** - * @private - */ - WebVideo.prototype.$measureContentBounds = function (bounds) { - var bitmapData = this.bitmapData; - var posterData = this.posterData; - if (bitmapData) { - bounds.setTo(0, 0, this.getPlayWidth(), this.getPlayHeight()); - } - else if (posterData) { - bounds.setTo(0, 0, this.getPlayWidth(), this.getPlayHeight()); - } - else { - bounds.setEmpty(); - } - }; - WebVideo.prototype.getPlayWidth = function () { - if (!isNaN(this.widthSet)) { - return this.widthSet; - } - if (this.bitmapData) { - return this.bitmapData.width; - } - if (this.posterData) { - return this.posterData.width; - } - return NaN; - }; - WebVideo.prototype.getPlayHeight = function () { - if (!isNaN(this.heightSet)) { - return this.heightSet; - } - if (this.bitmapData) { - return this.bitmapData.height; - } - if (this.posterData) { - return this.posterData.height; - } - return NaN; - }; - /** - * @private - */ - WebVideo.prototype.$updateRenderNode = function () { - var node = this.$renderNode; - var bitmapData = this.bitmapData; - var posterData = this.posterData; - var width = this.getPlayWidth(); - var height = this.getPlayHeight(); - if ((!this.isPlayed || egret.Capabilities.isMobile) && posterData) { - node.image = posterData; - node.imageWidth = width; - node.imageHeight = height; - node.drawImage(0, 0, posterData.width, posterData.height, 0, 0, width, height); - } - else if (this.isPlayed && bitmapData) { - node.image = bitmapData; - node.imageWidth = bitmapData.width; - node.imageHeight = bitmapData.height; - egret.WebGLUtils.deleteWebGLTexture(bitmapData.webGLTexture); - bitmapData.webGLTexture = null; - node.drawImage(0, 0, bitmapData.width, bitmapData.height, 0, 0, width, height); - } - }; - WebVideo.prototype.markDirty = function () { - this.$renderDirty = true; - return true; - }; - /** - * @private - * 设置显示高度 - */ - WebVideo.prototype.$setHeight = function (value) { - this.heightSet = value; - _super.prototype.$setHeight.call(this, value); - }; - /** - * @private - * 设置显示宽度 - */ - WebVideo.prototype.$setWidth = function (value) { - this.widthSet = value; - _super.prototype.$setWidth.call(this, value); - }; - Object.defineProperty(WebVideo.prototype, "paused", { - get: function () { - if (this.video) { - return this.video.paused; - } - return true; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(WebVideo.prototype, "length", { - /** - * @inheritDoc - */ - get: function () { - if (this.video) { - return this.video.duration; - } - throw new Error("Video not loaded!"); - }, - enumerable: true, - configurable: true - }); - return WebVideo; - }(egret.DisplayObject)); - web.WebVideo = WebVideo; - __reflect(WebVideo.prototype, "egret.web.WebVideo", ["egret.Video", "egret.DisplayObject"]); - egret.Video = WebVideo; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - var WebHttpRequest = (function (_super) { - __extends(WebHttpRequest, _super); - /** - * @private - */ - function WebHttpRequest() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this._url = ""; - _this._method = ""; - return _this; - } - Object.defineProperty(WebHttpRequest.prototype, "response", { - /** - * @private - * 本次请求返回的数据,数据类型根据responseType设置的值确定。 - */ - get: function () { - if (!this._xhr) { - return null; - } - if (this._xhr.response != undefined) { - return this._xhr.response; - } - if (this._responseType == "text") { - return this._xhr.responseText; - } - if (this._responseType == "arraybuffer" && /msie 9.0/i.test(navigator.userAgent)) { - var w = window; - return w.convertResponseBodyToText(this._xhr["responseBody"]); - } - if (this._responseType == "document") { - return this._xhr.responseXML; - } - /*if (this._xhr.responseXML) { - return this._xhr.responseXML; - } - if (this._xhr.responseText != undefined) { - return this._xhr.responseText; - }*/ - return null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(WebHttpRequest.prototype, "responseType", { - /** - * @private - * 设置返回的数据格式,请使用 HttpResponseType 里定义的枚举值。设置非法的值或不设置,都将使用HttpResponseType.TEXT。 - */ - get: function () { - return this._responseType; - }, - set: function (value) { - this._responseType = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(WebHttpRequest.prototype, "withCredentials", { - /** - * @private - * 表明在进行跨站(cross-site)的访问控制(Access-Control)请求时,是否使用认证信息(例如cookie或授权的header)。 默认为 false。(这个标志不会影响同站的请求) - */ - get: function () { - return this._withCredentials; - }, - set: function (value) { - this._withCredentials = value; - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @returns - */ - WebHttpRequest.prototype.getXHR = function () { - if (window["XMLHttpRequest"]) { - return new window["XMLHttpRequest"](); - } - else { - return new ActiveXObject("MSXML2.XMLHTTP"); - } - }; - /** - * @private - * 初始化一个请求.注意,若在已经发出请求的对象上调用此方法,相当于立即调用abort(). - * @param url 该请求所要访问的URL该请求所要访问的URL - * @param method 请求所使用的HTTP方法, 请使用 HttpMethod 定义的枚举值. - */ - WebHttpRequest.prototype.open = function (url, method) { - if (method === void 0) { method = "GET"; } - this._url = url; - this._method = method; - if (this._xhr) { - this._xhr.abort(); - this._xhr = null; - } - this._xhr = this.getXHR(); //new XMLHttpRequest(); - this._xhr.onreadystatechange = this.onReadyStateChange.bind(this); - this._xhr.onprogress = this.updateProgress.bind(this); - this._xhr.open(this._method, this._url, true); - }; - /** - * @private - * 发送请求. - * @param data 需要发送的数据 - */ - WebHttpRequest.prototype.send = function (data) { - if (this._responseType != null) { - this._xhr.responseType = this._responseType; - } - if (this._withCredentials != null) { - this._xhr.withCredentials = this._withCredentials; - } - if (this.headerObj) { - for (var key in this.headerObj) { - this._xhr.setRequestHeader(key, this.headerObj[key]); - } - } - this._xhr.send(data); - }; - /** - * @private - * 如果请求已经被发送,则立刻中止请求. - */ - WebHttpRequest.prototype.abort = function () { - if (this._xhr) { - this._xhr.abort(); - } - }; - /** - * @private - * 返回所有响应头信息(响应头名和值), 如果响应头还没接受,则返回"". - */ - WebHttpRequest.prototype.getAllResponseHeaders = function () { - if (!this._xhr) { - return null; - } - var result = this._xhr.getAllResponseHeaders(); - return result ? result : ""; - }; - /** - * @private - * 给指定的HTTP请求头赋值.在这之前,您必须确认已经调用 open() 方法打开了一个url. - * @param header 将要被赋值的请求头名称. - * @param value 给指定的请求头赋的值. - */ - WebHttpRequest.prototype.setRequestHeader = function (header, value) { - if (!this.headerObj) { - this.headerObj = {}; - } - this.headerObj[header] = value; - }; - /** - * @private - * 返回指定的响应头的值, 如果响应头还没被接受,或该响应头不存在,则返回"". - * @param header 要返回的响应头名称 - */ - WebHttpRequest.prototype.getResponseHeader = function (header) { - if (!this._xhr) { - return null; - } - var result = this._xhr.getResponseHeader(header); - return result ? result : ""; - }; - /** - * @private - */ - WebHttpRequest.prototype.onReadyStateChange = function () { - var xhr = this._xhr; - if (xhr.readyState == 4) { - var ioError_1 = (xhr.status >= 400 || xhr.status == 0); - var url_1 = this._url; - var self_1 = this; - window.setTimeout(function () { - if (ioError_1) { - if (true && !self_1.hasEventListener(egret.IOErrorEvent.IO_ERROR)) { - egret.$error(1011, url_1); - } - self_1.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); - } - else { - self_1.dispatchEventWith(egret.Event.COMPLETE); - } - }, 0); - } - }; - /** - * @private - */ - WebHttpRequest.prototype.updateProgress = function (event) { - if (event.lengthComputable) { - egret.ProgressEvent.dispatchProgressEvent(this, egret.ProgressEvent.PROGRESS, event.loaded, event.total); - } - }; - return WebHttpRequest; - }(egret.EventDispatcher)); - web.WebHttpRequest = WebHttpRequest; - __reflect(WebHttpRequest.prototype, "egret.web.WebHttpRequest", ["egret.HttpRequest"]); - egret.HttpRequest = WebHttpRequest; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - var winURL = window["URL"] || window["webkitURL"]; - /** - * @private - * ImageLoader 类可用于加载图像(JPG、PNG 或 GIF)文件。使用 load() 方法来启动加载。被加载的图像对象数据将存储在 ImageLoader.data 属性上 。 - */ - var WebImageLoader = (function (_super) { - __extends(WebImageLoader, _super); - function WebImageLoader() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - * 使用 load() 方法加载成功的 BitmapData 图像数据。 - */ - _this.data = null; - /** - * @private - * 当从其他站点加载一个图片时,指定是否启用跨域资源共享(CORS),默认值为null。 - * 可以设置为"anonymous","use-credentials"或null,设置为其他值将等同于"anonymous"。 - */ - _this._crossOrigin = null; - /** - * @private - * 标记crossOrigin有没有被设置过,设置过之后使用设置的属性 - */ - _this._hasCrossOriginSet = false; - /** - * @private - */ - _this.currentImage = null; - /** - * @private - */ - _this.request = null; - return _this; - } - Object.defineProperty(WebImageLoader.prototype, "crossOrigin", { - get: function () { - return this._crossOrigin; - }, - set: function (value) { - this._hasCrossOriginSet = true; - this._crossOrigin = value; - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 启动一次图像加载。注意:若之前已经调用过加载请求,重新调用 load() 将终止先前的请求,并开始新的加载。 - * @param url 要加载的图像文件的地址。 - */ - WebImageLoader.prototype.load = function (url) { - if (web.Html5Capatibility._canUseBlob - && url.indexOf("wxLocalResource:") != 0 //微信专用不能使用 blob - && url.indexOf("data:") != 0 - && url.indexOf("http:") != 0 - && url.indexOf("https:") != 0) { - var request = this.request; - if (!request) { - request = this.request = new egret.web.WebHttpRequest(); - request.addEventListener(egret.Event.COMPLETE, this.onBlobLoaded, this); - request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onBlobError, this); - request.responseType = "blob"; - } - if (true) { - this.currentURL = url; - } - request.open(url); - request.send(); - } - else { - this.loadImage(url); - } - }; - /** - * @private - */ - WebImageLoader.prototype.onBlobLoaded = function (event) { - var blob = this.request.response; - this.request = undefined; - this.loadImage(winURL.createObjectURL(blob)); - }; - /** - * @private - */ - WebImageLoader.prototype.onBlobError = function (event) { - this.dispatchIOError(this.currentURL); - this.request = undefined; - }; - /** - * @private - */ - WebImageLoader.prototype.loadImage = function (src) { - var image = new Image(); - this.data = null; - this.currentImage = image; - if (this._hasCrossOriginSet) { - if (this._crossOrigin) { - image.crossOrigin = this._crossOrigin; - } - } - else { - if (WebImageLoader.crossOrigin) { - image.crossOrigin = WebImageLoader.crossOrigin; - } - } - /*else { - if (image.hasAttribute("crossOrigin")) {//兼容猎豹 - image.removeAttribute("crossOrigin"); - } - }*/ - image.onload = this.onImageComplete.bind(this); - image.onerror = this.onLoadError.bind(this); - image.src = src; - }; - /** - * @private - */ - WebImageLoader.prototype.onImageComplete = function (event) { - var image = this.getImage(event); - if (!image) { - return; - } - this.data = new egret.BitmapData(image); - var self = this; - window.setTimeout(function () { - self.dispatchEventWith(egret.Event.COMPLETE); - }, 0); - }; - /** - * @private - */ - WebImageLoader.prototype.onLoadError = function (event) { - var image = this.getImage(event); - if (!image) { - return; - } - this.dispatchIOError(image.src); - }; - WebImageLoader.prototype.dispatchIOError = function (url) { - var self = this; - window.setTimeout(function () { - if (true && !self.hasEventListener(egret.IOErrorEvent.IO_ERROR)) { - egret.$error(1011, url); - } - self.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); - }, 0); - }; - /** - * @private - */ - WebImageLoader.prototype.getImage = function (event) { - var image = event.target; - var url = image.src; - if (url.indexOf("blob:") == 0) { - try { - winURL.revokeObjectURL(image.src); - } - catch (e) { - egret.$warn(1037); - } - } - image.onerror = null; - image.onload = null; - if (this.currentImage !== image) { - return null; - } - this.currentImage = null; - return image; - }; - /** - * @private - * 指定是否启用跨域资源共享,如果ImageLoader实例有设置过crossOrigin属性将使用设置的属性 - */ - WebImageLoader.crossOrigin = null; - return WebImageLoader; - }(egret.EventDispatcher)); - web.WebImageLoader = WebImageLoader; - __reflect(WebImageLoader.prototype, "egret.web.WebImageLoader", ["egret.ImageLoader"]); - egret.ImageLoader = WebImageLoader; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @classdesc - * @extends egret.StageText - * @private - */ - var HTML5StageText = (function (_super) { - __extends(HTML5StageText, _super); - /** - * @private - */ - function HTML5StageText() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this._isNeedShow = false; - /** - * @private - */ - _this.inputElement = null; - /** - * @private - */ - _this.inputDiv = null; - /** - * @private - */ - _this._gscaleX = 0; - /** - * @private - */ - _this._gscaleY = 0; - /** - * @private - */ - _this.textValue = ""; - /** - * @private - */ - _this.colorValue = 0xffffff; - /** - * @private - */ - _this._styleInfoes = {}; - return _this; - } - /** - * @private - * - * @param textfield - */ - HTML5StageText.prototype.$setTextField = function (textfield) { - this.$textfield = textfield; - return true; - }; - /** - * @private - * - */ - HTML5StageText.prototype.$addToStage = function () { - this.htmlInput = egret.web.$getTextAdapter(this.$textfield); - }; - /** - * @private - * - */ - HTML5StageText.prototype._initElement = function () { - var point = this.$textfield.localToGlobal(0, 0); - var x = point.x; - var y = point.y; - // let m = this.$textfield.$renderNode.renderMatrix; - // let cX = m.a; - // let cY = m.d; - var scaleX = this.htmlInput.$scaleX; - var scaleY = this.htmlInput.$scaleY; - this.inputDiv.style.left = x * scaleX + "px"; - this.inputDiv.style.top = y * scaleY + "px"; - if (this.$textfield.multiline && this.$textfield.height > this.$textfield.size) { - this.inputDiv.style.top = (y) * scaleY + "px"; - this.inputElement.style.top = (-this.$textfield.lineSpacing / 2) * scaleY + "px"; - } - else { - this.inputDiv.style.top = y * scaleY + "px"; - this.inputElement.style.top = 0 + "px"; - } - var node = this.$textfield; - var cX = 1; - var cY = 1; - var rotation = 0; - while (node.parent) { - cX *= node.scaleX; - cY *= node.scaleY; - rotation += node.rotation; - node = node.parent; - } - var transformKey = egret.web.getPrefixStyleName("transform"); - this.inputDiv.style[transformKey] = "rotate(" + rotation + "deg)"; - this._gscaleX = scaleX * cX; - this._gscaleY = scaleY * cY; - }; - /** - * @private - * - */ - HTML5StageText.prototype.$show = function () { - if (!this.htmlInput.isCurrentStageText(this)) { - this.inputElement = this.htmlInput.getInputElement(this); - if (!this.$textfield.multiline) { - this.inputElement.type = this.$textfield.inputType; - } - else { - this.inputElement.type = "text"; - } - this.inputDiv = this.htmlInput._inputDIV; - } - else { - this.inputElement.onblur = null; - } - this.htmlInput._needShow = true; - //标记当前文本被选中 - this._isNeedShow = true; - this._initElement(); - }; - /** - * @private - * - */ - HTML5StageText.prototype.onBlurHandler = function () { - this.htmlInput.clearInputElement(); - window.scrollTo(0, 0); - }; - /** - * @private - * - */ - HTML5StageText.prototype.executeShow = function () { - var self = this; - //打开 - this.inputElement.value = this.$getText(); - if (this.inputElement.onblur == null) { - this.inputElement.onblur = this.onBlurHandler.bind(this); - } - this.$resetStageText(); - if (this.$textfield.maxChars > 0) { - this.inputElement.setAttribute("maxlength", this.$textfield.maxChars); - } - else { - this.inputElement.removeAttribute("maxlength"); - } - this.inputElement.selectionStart = this.inputElement.value.length; - this.inputElement.selectionEnd = this.inputElement.value.length; - this.inputElement.focus(); - }; - /** - * @private - */ - HTML5StageText.prototype.$hide = function () { - if (this.htmlInput) { - this.htmlInput.disconnectStageText(this); - } - }; - /** - * @private - * - * @returns - */ - HTML5StageText.prototype.$getText = function () { - if (!this.textValue) { - this.textValue = ""; - } - return this.textValue; - }; - /** - * @private - * - * @param value - */ - HTML5StageText.prototype.$setText = function (value) { - this.textValue = value; - this.resetText(); - return true; - }; - /** - * @private - * - */ - HTML5StageText.prototype.resetText = function () { - if (this.inputElement) { - this.inputElement.value = this.textValue; - } - }; - HTML5StageText.prototype.$setColor = function (value) { - this.colorValue = value; - this.resetColor(); - return true; - }; - /** - * @private - * - */ - HTML5StageText.prototype.resetColor = function () { - if (this.inputElement) { - this.setElementStyle("color", egret.toColorString(this.colorValue)); - } - }; - HTML5StageText.prototype.$onBlur = function () { - }; - /** - * @private - * - */ - HTML5StageText.prototype._onInput = function () { - var self = this; - window.setTimeout(function () { - if (self.inputElement && self.inputElement.selectionStart == self.inputElement.selectionEnd) { - self.textValue = self.inputElement.value; - egret.Event.dispatchEvent(self, "updateText", false); - } - }, 0); - }; - HTML5StageText.prototype.setAreaHeight = function () { - var textfield = this.$textfield; - if (textfield.multiline) { - var textheight = egret.TextFieldUtils.$getTextHeight(textfield); - if (textfield.height <= textfield.size) { - this.setElementStyle("height", (textfield.size) * this._gscaleY + "px"); - this.setElementStyle("padding", "0px"); - this.setElementStyle("lineHeight", (textfield.size) * this._gscaleY + "px"); - } - else if (textfield.height < textheight) { - this.setElementStyle("height", (textfield.height) * this._gscaleY + "px"); - this.setElementStyle("padding", "0px"); - this.setElementStyle("lineHeight", (textfield.size + textfield.lineSpacing) * this._gscaleY + "px"); - } - else { - this.setElementStyle("height", (textheight + textfield.lineSpacing) * this._gscaleY + "px"); - var rap = (textfield.height - textheight) * this._gscaleY; - var valign = egret.TextFieldUtils.$getValign(textfield); - var top_1 = rap * valign; - var bottom = rap - top_1; - this.setElementStyle("padding", top_1 + "px 0px " + bottom + "px 0px"); - this.setElementStyle("lineHeight", (textfield.size + textfield.lineSpacing) * this._gscaleY + "px"); - } - } - }; - /** - * @private - * - * @param e - */ - HTML5StageText.prototype._onClickHandler = function (e) { - if (this._isNeedShow) { - e.stopImmediatePropagation(); - //e.preventDefault(); - this._isNeedShow = false; - this.executeShow(); - this.dispatchEvent(new egret.Event("focus")); - } - }; - /** - * @private - * - */ - HTML5StageText.prototype._onDisconnect = function () { - this.inputElement = null; - this.dispatchEvent(new egret.Event("blur")); - }; - /** - * @private - * - * @param style - * @param value - */ - HTML5StageText.prototype.setElementStyle = function (style, value) { - if (this.inputElement) { - if (this._styleInfoes[style] != value) { - this.inputElement.style[style] = value; - //this._styleInfoes[style] = value; - } - } - }; - /** - * @private - * - */ - HTML5StageText.prototype.$removeFromStage = function () { - if (this.inputElement) { - this.htmlInput.disconnectStageText(this); - } - }; - /** - * 修改位置 - * @private - */ - HTML5StageText.prototype.$resetStageText = function () { - if (this.inputElement) { - var textfield = this.$textfield; - this.setElementStyle("fontFamily", textfield.fontFamily); - this.setElementStyle("fontStyle", textfield.italic ? "italic" : "normal"); - this.setElementStyle("fontWeight", textfield.bold ? "bold" : "normal"); - this.setElementStyle("textAlign", textfield.textAlign); - this.setElementStyle("fontSize", textfield.size * this._gscaleY + "px"); - this.setElementStyle("color", egret.toColorString(textfield.textColor)); - var tw = void 0; - if (textfield.stage) { - tw = textfield.localToGlobal(0, 0).x; - tw = Math.min(textfield.width, textfield.stage.stageWidth - tw); - } - else { - tw = textfield.width; - } - this.setElementStyle("width", tw * this._gscaleX + "px"); - this.setElementStyle("verticalAlign", textfield.verticalAlign); - if (textfield.multiline) { - this.setAreaHeight(); - } - else { - this.setElementStyle("lineHeight", (textfield.size) * this._gscaleY + "px"); - if (textfield.height < textfield.size) { - this.setElementStyle("height", (textfield.size) * this._gscaleY + "px"); - var bottom = (textfield.size / 2) * this._gscaleY; - this.setElementStyle("padding", "0px 0px " + bottom + "px 0px"); - } - else { - this.setElementStyle("height", (textfield.size) * this._gscaleY + "px"); - var rap = (textfield.height - textfield.size) * this._gscaleY; - var valign = egret.TextFieldUtils.$getValign(textfield); - var top_2 = rap * valign; - var bottom = rap - top_2; - if (bottom < textfield.size / 2 * this._gscaleY) { - bottom = textfield.size / 2 * this._gscaleY; - } - this.setElementStyle("padding", top_2 + "px 0px " + bottom + "px 0px"); - } - } - this.inputDiv.style.clip = "rect(0px " + (textfield.width * this._gscaleX) + "px " + (textfield.height * this._gscaleY) + "px 0px)"; - this.inputDiv.style.height = textfield.height * this._gscaleY + "px"; - this.inputDiv.style.width = tw * this._gscaleX + "px"; - } - }; - return HTML5StageText; - }(egret.EventDispatcher)); - web.HTML5StageText = HTML5StageText; - __reflect(HTML5StageText.prototype, "egret.web.HTML5StageText", ["egret.StageText"]); - egret.StageText = HTML5StageText; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - var HTMLInput = (function () { - function HTMLInput() { - /** - * @private - */ - this._needShow = false; - /** - * @private - */ - this.$scaleX = 1; - /** - * @private - */ - this.$scaleY = 1; - } - /** - * @private - * - * @returns - */ - HTMLInput.prototype.isInputOn = function () { - return this._stageText != null; - }; - /** - * @private - * - * @param stageText - * @returns - */ - HTMLInput.prototype.isCurrentStageText = function (stageText) { - return this._stageText == stageText; - }; - /** - * @private - * - * @param dom - */ - HTMLInput.prototype.initValue = function (dom) { - dom.style.position = "absolute"; - dom.style.left = "0px"; - dom.style.top = "0px"; - dom.style.border = "none"; - dom.style.padding = "0"; - }; - /** - * @private - * - */ - HTMLInput.prototype.$updateSize = function () { - if (!this.canvas) { - return; - } - this.$scaleX = egret.sys.DisplayList.$canvasScaleX; - this.$scaleY = egret.sys.DisplayList.$canvasScaleY; - this.StageDelegateDiv.style.left = this.canvas.style.left; - this.StageDelegateDiv.style.top = this.canvas.style.top; - var transformKey = egret.web.getPrefixStyleName("transform"); - this.StageDelegateDiv.style[transformKey] = this.canvas.style[transformKey]; - this.StageDelegateDiv.style[egret.web.getPrefixStyleName("transformOrigin")] = "0% 0% 0px"; - }; - /** - * @private - * - * @param container - * @param canvas - * @returns - */ - HTMLInput.prototype._initStageDelegateDiv = function (container, canvas) { - this.canvas = canvas; - var self = this; - var stageDelegateDiv; - if (!stageDelegateDiv) { - stageDelegateDiv = document.createElement("div"); - this.StageDelegateDiv = stageDelegateDiv; - stageDelegateDiv.id = "StageDelegateDiv"; - container.appendChild(stageDelegateDiv); - self.initValue(stageDelegateDiv); - self._inputDIV = document.createElement("div"); - self.initValue(self._inputDIV); - self._inputDIV.style.width = "0px"; - self._inputDIV.style.height = "0px"; - self._inputDIV.style.left = 0 + "px"; - self._inputDIV.style.top = "-100px"; - self._inputDIV.style[egret.web.getPrefixStyleName("transformOrigin")] = "0% 0% 0px"; - stageDelegateDiv.appendChild(self._inputDIV); - this.canvas.addEventListener("click", function (e) { - if (self._needShow) { - self._needShow = false; - self._stageText._onClickHandler(e); - self.show(); - } - else { - if (self._inputElement) { - self.clearInputElement(); - self._inputElement.blur(); - self._inputElement = null; - } - } - }); - self.initInputElement(true); - self.initInputElement(false); - } - }; - //初始化输入框 - HTMLInput.prototype.initInputElement = function (multiline) { - var self = this; - //增加1个空的textarea - var inputElement; - if (multiline) { - inputElement = document.createElement("textarea"); - inputElement.style["resize"] = "none"; - self._multiElement = inputElement; - inputElement.id = "egretTextarea"; - } - else { - inputElement = document.createElement("input"); - self._simpleElement = inputElement; - inputElement.id = "egretInput"; - } - inputElement.type = "text"; - self._inputDIV.appendChild(inputElement); - inputElement.setAttribute("tabindex", "-1"); - inputElement.style.width = "1px"; - inputElement.style.height = "12px"; - self.initValue(inputElement); - inputElement.style.outline = "thin"; - inputElement.style.background = "none"; - inputElement.style.overflow = "hidden"; - inputElement.style.wordBreak = "break-all"; - //隐藏输入框 - inputElement.style.opacity = 0; - inputElement.oninput = function () { - if (self._stageText) { - self._stageText._onInput(); - } - }; - }; - /** - * @private - * - */ - HTMLInput.prototype.show = function () { - var self = this; - var inputElement = self._inputElement; - //隐藏输入框 - egret.$callAsync(function () { - inputElement.style.opacity = 1; - }, self); - }; - /** - * @private - * - * @param stageText - */ - HTMLInput.prototype.disconnectStageText = function (stageText) { - if (this._stageText == null || this._stageText == stageText) { - this.clearInputElement(); - if (this._inputElement) { - this._inputElement.blur(); - } - } - this._needShow = false; - }; - /** - * @private - * - */ - HTMLInput.prototype.clearInputElement = function () { - var self = this; - if (self._inputElement) { - self._inputElement.value = ""; - self._inputElement.onblur = null; - self._inputElement.style.width = "1px"; - self._inputElement.style.height = "12px"; - self._inputElement.style.left = "0px"; - self._inputElement.style.top = "0px"; - self._inputElement.style.opacity = 0; - var otherElement = void 0; - if (self._simpleElement == self._inputElement) { - otherElement = self._multiElement; - } - else { - otherElement = self._simpleElement; - } - otherElement.style.display = "block"; - self._inputDIV.style.left = 0 + "px"; - self._inputDIV.style.top = "-100px"; - self._inputDIV.style.height = 0 + "px"; - self._inputDIV.style.width = 0 + "px"; - } - if (self._stageText) { - self._stageText._onDisconnect(); - self._stageText = null; - this.canvas['userTyping'] = false; - } - }; - /** - * @private - * - * @param stageText - * @returns - */ - HTMLInput.prototype.getInputElement = function (stageText) { - var self = this; - self.clearInputElement(); - self._stageText = stageText; - this.canvas['userTyping'] = true; - if (self._stageText.$textfield.multiline) { - self._inputElement = self._multiElement; - } - else { - self._inputElement = self._simpleElement; - } - var otherElement; - if (self._simpleElement == self._inputElement) { - otherElement = self._multiElement; - } - else { - otherElement = self._simpleElement; - } - otherElement.style.display = "none"; - return self._inputElement; - }; - return HTMLInput; - }()); - web.HTMLInput = HTMLInput; - __reflect(HTMLInput.prototype, "egret.web.HTMLInput"); - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -(function (egret) { - var web; - (function (web) { - var stageToTextLayerMap = {}; - var stageToCanvasMap = {}; - var stageToContainerMap = {}; - /** - * @private - * 获取 - */ - function $getTextAdapter(textfield) { - var stageHash = textfield.stage ? textfield.stage.$hashCode : 0; - var adapter = stageToTextLayerMap[stageHash]; - var canvas = stageToCanvasMap[stageHash]; - var container = stageToContainerMap[stageHash]; - if (canvas && container) { - //adapter._initStageDelegateDiv(container, canvas); - //adapter.$updateSize(); - delete stageToCanvasMap[stageHash]; - delete stageToContainerMap[stageHash]; - } - return adapter; - } - web.$getTextAdapter = $getTextAdapter; - /** - * @private - */ - function $cacheTextAdapter(adapter, stage, container, canvas) { - adapter._initStageDelegateDiv(container, canvas); - stageToTextLayerMap[stage.$hashCode] = adapter; - stageToCanvasMap[stage.$hashCode] = canvas; - stageToContainerMap[stage.$hashCode] = container; - } - web.$cacheTextAdapter = $cacheTextAdapter; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - var context = null; - /** - * @private - */ - var fontCache = {}; - /** - * 测量文本在指定样式下的宽度。 - * @param text 要测量的文本内容。 - * @param fontFamily 字体名称 - * @param fontSize 字体大小 - * @param bold 是否粗体 - * @param italic 是否斜体 - */ - function measureText(text, fontFamily, fontSize, bold, italic) { - if (!context) { - createContext(); - } - var font = ""; - if (italic) - font += "italic "; - if (bold) - font += "bold "; - font += (fontSize || 12) + "px "; - font += (fontFamily || "Arial"); - context.font = font; - return context.measureText(text).width; - } - /** - * @private - */ - function createContext() { - context = egret.sys.canvasHitTestBuffer.context; - context.textAlign = "left"; - context.textBaseline = "middle"; - } - egret.sys.measureText = measureText; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * 创建一个canvas。 - */ - function createCanvas(width, height) { - var canvas = document.createElement("canvas"); - if (!isNaN(width) && !isNaN(height)) { - canvas.width = width; - canvas.height = height; - } - var context = canvas.getContext("2d"); - if (context["imageSmoothingEnabled"] === undefined) { - var keys = ["webkitImageSmoothingEnabled", "mozImageSmoothingEnabled", "msImageSmoothingEnabled"]; - var key_1; - for (var i = keys.length - 1; i >= 0; i--) { - key_1 = keys[i]; - if (context[key_1] !== void 0) { - break; - } - } - try { - Object.defineProperty(context, "imageSmoothingEnabled", { - get: function () { - return this[key_1]; - }, - set: function (value) { - this[key_1] = value; - } - }); - } - catch (e) { - context["imageSmoothingEnabled"] = context[key_1]; - } - } - return canvas; - } - var sharedCanvas; - /** - * @private - * Canvas2D渲染缓冲 - */ - var CanvasRenderBuffer = (function () { - function CanvasRenderBuffer(width, height, root) { - this.surface = createCanvas(width, height); - this.context = this.surface.getContext("2d"); - if (this.context) { - this.context.$offsetX = 0; - this.context.$offsetY = 0; - } - } - Object.defineProperty(CanvasRenderBuffer.prototype, "width", { - /** - * 渲染缓冲的宽度,以像素为单位。 - * @readOnly - */ - get: function () { - return this.surface.width; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CanvasRenderBuffer.prototype, "height", { - /** - * 渲染缓冲的高度,以像素为单位。 - * @readOnly - */ - get: function () { - return this.surface.height; - }, - enumerable: true, - configurable: true - }); - /** - * 改变渲染缓冲的大小并清空缓冲区 - * @param width 改变后的宽 - * @param height 改变后的高 - * @param useMaxSize 若传入true,则将改变后的尺寸与已有尺寸对比,保留较大的尺寸。 - */ - CanvasRenderBuffer.prototype.resize = function (width, height, useMaxSize) { - var surface = this.surface; - if (useMaxSize) { - var change = false; - if (surface.width < width) { - surface.width = width; - change = true; - } - if (surface.height < height) { - surface.height = height; - change = true; - } - //尺寸没有变化时,将绘制属性重置 - if (!change) { - this.context.globalCompositeOperation = "source-over"; - this.context.setTransform(1, 0, 0, 1, 0, 0); - this.context.globalAlpha = 1; - } - } - else { - if (surface.width != width) { - surface.width = width; - } - if (surface.height != height) { - surface.height = height; - } - } - this.clear(); - }; - /** - * 获取指定区域的像素 - */ - CanvasRenderBuffer.prototype.getPixels = function (x, y, width, height) { - if (width === void 0) { width = 1; } - if (height === void 0) { height = 1; } - return this.context.getImageData(x, y, width, height).data; - }; - /** - * 转换成base64字符串,如果图片(或者包含的图片)跨域,则返回null - * @param type 转换的类型,如: "image/png","image/jpeg" - */ - CanvasRenderBuffer.prototype.toDataURL = function (type, encoderOptions) { - return this.surface.toDataURL(type, encoderOptions); - }; - /** - * 清空缓冲区数据 - */ - CanvasRenderBuffer.prototype.clear = function () { - this.context.setTransform(1, 0, 0, 1, 0, 0); - this.context.clearRect(0, 0, this.surface.width, this.surface.height); - }; - /** - * 销毁绘制对象 - */ - CanvasRenderBuffer.prototype.destroy = function () { - this.surface.width = this.surface.height = 0; - }; - return CanvasRenderBuffer; - }()); - web.CanvasRenderBuffer = CanvasRenderBuffer; - __reflect(CanvasRenderBuffer.prototype, "egret.web.CanvasRenderBuffer", ["egret.sys.RenderBuffer"]); - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided this the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - var WebTouchHandler = (function (_super) { - __extends(WebTouchHandler, _super); - /** - * @private - */ - function WebTouchHandler(stage, canvas) { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.onTouchBegin = function (event) { - var location = _this.getLocation(event); - _this.touch.onTouchBegin(location.x, location.y, event.identifier); - }; - _this.onMouseMove = function (event) { - if (event.buttons == 0) { - _this.onTouchEnd(event); - } - else { - _this.onTouchMove(event); - } - }; - /** - * @private - */ - _this.onTouchMove = function (event) { - var location = _this.getLocation(event); - _this.touch.onTouchMove(location.x, location.y, event.identifier); - }; - /** - * @private - */ - _this.onTouchEnd = function (event) { - var location = _this.getLocation(event); - _this.touch.onTouchEnd(location.x, location.y, event.identifier); - }; - /** - * @private - */ - _this.scaleX = 1; - /** - * @private - */ - _this.scaleY = 1; - /** - * @private - */ - _this.rotation = 0; - _this.canvas = canvas; - _this.touch = new egret.sys.TouchHandler(stage); - _this.addListeners(); - return _this; - } - /** - * @private - * 添加事件监听 - */ - WebTouchHandler.prototype.addListeners = function () { - var _this = this; - if (window.navigator.msPointerEnabled) { - this.canvas.addEventListener("MSPointerDown", function (event) { - event.identifier = event.pointerId; - _this.onTouchBegin(event); - _this.prevent(event); - }, false); - this.canvas.addEventListener("MSPointerMove", function (event) { - event.identifier = event.pointerId; - _this.onTouchMove(event); - _this.prevent(event); - }, false); - this.canvas.addEventListener("MSPointerUp", function (event) { - event.identifier = event.pointerId; - _this.onTouchEnd(event); - _this.prevent(event); - }, false); - } - else { - if (!egret.Capabilities.isMobile) { - this.addMouseListener(); - } - this.addTouchListener(); - } - }; - /** - * @private - * - */ - WebTouchHandler.prototype.addMouseListener = function () { - this.canvas.addEventListener("mousedown", this.onTouchBegin); - this.canvas.addEventListener("mousemove", this.onMouseMove); - this.canvas.addEventListener("mouseup", this.onTouchEnd); - }; - /** - * @private - * - */ - WebTouchHandler.prototype.addTouchListener = function () { - var _this = this; - this.canvas.addEventListener("touchstart", function (event) { - var l = event.changedTouches.length; - for (var i = 0; i < l; i++) { - _this.onTouchBegin(event.changedTouches[i]); - } - _this.prevent(event); - }, false); - this.canvas.addEventListener("touchmove", function (event) { - var l = event.changedTouches.length; - for (var i = 0; i < l; i++) { - _this.onTouchMove(event.changedTouches[i]); - } - _this.prevent(event); - }, false); - this.canvas.addEventListener("touchend", function (event) { - var l = event.changedTouches.length; - for (var i = 0; i < l; i++) { - _this.onTouchEnd(event.changedTouches[i]); - } - _this.prevent(event); - }, false); - this.canvas.addEventListener("touchcancel", function (event) { - var l = event.changedTouches.length; - for (var i = 0; i < l; i++) { - _this.onTouchEnd(event.changedTouches[i]); - } - _this.prevent(event); - }, false); - }; - /** - * @private - */ - WebTouchHandler.prototype.prevent = function (event) { - event.stopPropagation(); - if (event["isScroll"] != true && !this.canvas['userTyping']) { - event.preventDefault(); - } - }; - /** - * @private - */ - WebTouchHandler.prototype.getLocation = function (event) { - event.identifier = +event.identifier || 0; - var doc = document.documentElement; - var box = this.canvas.getBoundingClientRect(); - var left = box.left + window.pageXOffset - doc.clientLeft; - var top = box.top + window.pageYOffset - doc.clientTop; - var x = event.pageX - left, newx = x; - var y = event.pageY - top, newy = y; - if (this.rotation == 90) { - newx = y; - newy = box.width - x; - } - else if (this.rotation == -90) { - newx = box.height - y; - newy = x; - } - newx = newx / this.scaleX; - newy = newy / this.scaleY; - return egret.$TempPoint.setTo(Math.round(newx), Math.round(newy)); - }; - /** - * @private - * 更新屏幕当前的缩放比例,用于计算准确的点击位置。 - * @param scaleX 水平方向的缩放比例。 - * @param scaleY 垂直方向的缩放比例。 - */ - WebTouchHandler.prototype.updateScaleMode = function (scaleX, scaleY, rotation) { - this.scaleX = scaleX; - this.scaleY = scaleY; - this.rotation = rotation; - }; - /** - * @private - * 更新同时触摸点的数量 - */ - WebTouchHandler.prototype.$updateMaxTouches = function () { - this.touch.$initMaxTouches(); - }; - return WebTouchHandler; - }(egret.HashObject)); - web.WebTouchHandler = WebTouchHandler; - __reflect(WebTouchHandler.prototype, "egret.web.WebTouchHandler"); - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - web.WebLifeCycleHandler = function (context) { - var handleVisibilityChange = function () { - if (!document[hidden]) { - context.resume(); - } - else { - context.pause(); - } - }; - window.addEventListener("focus", context.resume, false); - window.addEventListener("blur", context.pause, false); - var hidden, visibilityChange; - if (typeof document.hidden !== "undefined") { - hidden = "hidden"; - visibilityChange = "visibilitychange"; - } - else if (typeof document["mozHidden"] !== "undefined") { - hidden = "mozHidden"; - visibilityChange = "mozvisibilitychange"; - } - else if (typeof document["msHidden"] !== "undefined") { - hidden = "msHidden"; - visibilityChange = "msvisibilitychange"; - } - else if (typeof document["webkitHidden"] !== "undefined") { - hidden = "webkitHidden"; - visibilityChange = "webkitvisibilitychange"; - } - else if (typeof document["oHidden"] !== "undefined") { - hidden = "oHidden"; - visibilityChange = "ovisibilitychange"; - } - if ("onpageshow" in window && "onpagehide" in window) { - window.addEventListener("pageshow", context.resume, false); - window.addEventListener("pagehide", context.pause, false); - } - if (hidden && visibilityChange) { - document.addEventListener(visibilityChange, handleVisibilityChange, false); - } - var ua = navigator.userAgent; - var isWX = /micromessenger/gi.test(ua); - var isQQBrowser = /mqq/ig.test(ua); - var isQQ = /mobile.*qq/gi.test(ua); - if (isQQ || isWX) { - isQQBrowser = false; - } - if (isQQBrowser) { - var browser = window["browser"] || {}; - browser.execWebFn = browser.execWebFn || {}; - browser.execWebFn.postX5GamePlayerMessage = function (event) { - var eventType = event.type; - if (eventType == "app_enter_background") { - context.pause(); - } - else if (eventType == "app_enter_foreground") { - context.resume(); - } - }; - window["browser"] = browser; - } - }; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - var AudioType = (function () { - function AudioType() { - } - /** - * @private - */ - AudioType.WEB_AUDIO = 2; - /** - * @private - */ - AudioType.HTML5_AUDIO = 3; - return AudioType; - }()); - web.AudioType = AudioType; - __reflect(AudioType.prototype, "egret.web.AudioType"); - /** - * html5兼容性配置 - * @private - */ - var Html5Capatibility = (function (_super) { - __extends(Html5Capatibility, _super); - /** - * @private - */ - function Html5Capatibility() { - return _super.call(this) || this; - } - /** - * @private - * - */ - Html5Capatibility.$init = function () { - var ua = navigator.userAgent.toLowerCase(); - Html5Capatibility.ua = ua; - Html5Capatibility._canUseBlob = false; - var canUseWebAudio = window["AudioContext"] || window["webkitAudioContext"] || window["mozAudioContext"]; - if (canUseWebAudio) { - try { - //防止某些chrome版本创建异常问题 - web.WebAudioDecode.ctx = new (window["AudioContext"] || window["webkitAudioContext"] || window["mozAudioContext"])(); - } - catch (e) { - canUseWebAudio = false; - } - } - var audioType = Html5Capatibility._audioType; - var checkAudioType; - if ((audioType == AudioType.WEB_AUDIO && canUseWebAudio) || audioType == AudioType.HTML5_AUDIO) { - checkAudioType = false; - Html5Capatibility.setAudioType(audioType); - } - else { - checkAudioType = true; - Html5Capatibility.setAudioType(AudioType.HTML5_AUDIO); - } - if (ua.indexOf("android") >= 0) { - if (checkAudioType && canUseWebAudio) { - Html5Capatibility.setAudioType(AudioType.WEB_AUDIO); - } - } - else if (ua.indexOf("iphone") >= 0 || ua.indexOf("ipad") >= 0 || ua.indexOf("ipod") >= 0) { - if (Html5Capatibility.getIOSVersion() >= 7) { - Html5Capatibility._canUseBlob = true; - if (checkAudioType && canUseWebAudio) { - Html5Capatibility.setAudioType(AudioType.WEB_AUDIO); - } - } - } - var winURL = window["URL"] || window["webkitURL"]; - if (!winURL) { - Html5Capatibility._canUseBlob = false; - } - if (ua.indexOf("egretnative") >= 0) { - Html5Capatibility.setAudioType(AudioType.HTML5_AUDIO); - Html5Capatibility._canUseBlob = true; - } - egret.Sound = Html5Capatibility._AudioClass; - }; - Html5Capatibility.setAudioType = function (type) { - Html5Capatibility._audioType = type; - switch (type) { - case AudioType.WEB_AUDIO: - Html5Capatibility._AudioClass = egret.web.WebAudioSound; - break; - case AudioType.HTML5_AUDIO: - Html5Capatibility._AudioClass = egret.web.HtmlSound; - break; - } - }; - /** - * @private - * 获取ios版本 - * @returns {string} - */ - Html5Capatibility.getIOSVersion = function () { - var matches = Html5Capatibility.ua.toLowerCase().match(/cpu [^\d]*\d.*like mac os x/); - if (!matches || matches.length == 0) { - return 0; - } - var value = matches[0]; - return parseInt(value.match(/\d+(_\d)*/)[0]) || 0; - }; - //当前浏览器版本是否支持blob - Html5Capatibility._canUseBlob = false; - //当前浏览器版本是否支持webaudio - Html5Capatibility._audioType = 0; - /** - * @private - */ - Html5Capatibility.ua = ""; - return Html5Capatibility; - }(egret.HashObject)); - web.Html5Capatibility = Html5Capatibility; - __reflect(Html5Capatibility.prototype, "egret.web.Html5Capatibility"); - /** - * @private - */ - var currentPrefix = null; - /** - * @private - */ - function getPrefixStyleName(name, element) { - var header = ""; - if (element != null) { - header = getPrefix(name, element); - } - else { - if (currentPrefix == null) { - var tempStyle = document.createElement('div').style; - currentPrefix = getPrefix("transform", tempStyle); - } - header = currentPrefix; - } - if (header == "") { - return name; - } - return header + name.charAt(0).toUpperCase() + name.substring(1, name.length); - } - web.getPrefixStyleName = getPrefixStyleName; - /** - * @private - */ - function getPrefix(name, element) { - if (name in element) { - return ""; - } - name = name.charAt(0).toUpperCase() + name.substring(1, name.length); - var transArr = ["webkit", "ms", "Moz", "O"]; - for (var i = 0; i < transArr.length; i++) { - var tempStyle = transArr[i] + name; - if (tempStyle in element) { - return transArr[i]; - } - } - return ""; - } - web.getPrefix = getPrefix; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - * 刷新所有Egret播放器的显示区域尺寸。仅当使用外部JavaScript代码动态修改了Egret容器大小时,需要手动调用此方法刷新显示区域。 - * 当网页尺寸发生改变时此方法会自动被调用。 - */ - function updateAllScreens() { - if (!isRunning) { - return; - } - var containerList = document.querySelectorAll(".egret-player"); - var length = containerList.length; - for (var i = 0; i < length; i++) { - var container = containerList[i]; - var player = container["egret-player"]; - player.updateScreenSize(); - } - } - var isRunning = false; - /** - * @private - * 网页加载完成,实例化页面中定义的Egret标签 - */ - function runEgret(options) { - if (isRunning) { - return; - } - isRunning = true; - if (!options) { - options = {}; - } - var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf("egretnative") >= 0 && ua.indexOf("egretwebview") == -1) { - egret.Capabilities["runtimeType" + ""] = egret.RuntimeType.RUNTIME2; - } - if (ua.indexOf("egretnative") >= 0 && egret.nativeRender) { - egret_native.addModuleCallback(function () { - web.Html5Capatibility.$init(); - // WebGL上下文参数自定义 - if (options.renderMode == "webgl") { - // WebGL抗锯齿默认关闭,提升PC及某些平台性能 - var antialias = options.antialias; - web.WebGLRenderContext.antialias = !!antialias; - } - egret.sys.CanvasRenderBuffer = web.CanvasRenderBuffer; - setRenderMode(options.renderMode); - egret_native.nrSetRenderMode(2); - var canvasScaleFactor; - if (options.canvasScaleFactor) { - canvasScaleFactor = options.canvasScaleFactor; - } - else if (options.calculateCanvasScaleFactor) { - canvasScaleFactor = options.calculateCanvasScaleFactor(egret.sys.canvasHitTestBuffer.context); - } - else { - canvasScaleFactor = window.devicePixelRatio; - } - egret.sys.DisplayList.$canvasScaleFactor = canvasScaleFactor; - var ticker = egret.ticker; - startTicker(ticker); - if (options.screenAdapter) { - egret.sys.screenAdapter = options.screenAdapter; - } - else if (!egret.sys.screenAdapter) { - egret.sys.screenAdapter = new egret.sys.DefaultScreenAdapter(); - } - var list = document.querySelectorAll(".egret-player"); - var length = list.length; - for (var i = 0; i < length; i++) { - var container = list[i]; - var player = new web.WebPlayer(container, options); - container["egret-player"] = player; - } - window.addEventListener("resize", function () { - if (isNaN(resizeTimer)) { - resizeTimer = window.setTimeout(doResize, 300); - } - }); - }, null); - egret_native.initNativeRender(); - } - else { - web.Html5Capatibility._audioType = options.audioType; - web.Html5Capatibility.$init(); - // WebGL上下文参数自定义 - if (options.renderMode == "webgl") { - // WebGL抗锯齿默认关闭,提升PC及某些平台性能 - var antialias = options.antialias; - web.WebGLRenderContext.antialias = !!antialias; - // WebGLRenderContext.antialias = (typeof antialias == undefined) ? true : antialias; - } - egret.sys.CanvasRenderBuffer = web.CanvasRenderBuffer; - setRenderMode(options.renderMode); - var canvasScaleFactor = void 0; - if (options.canvasScaleFactor) { - canvasScaleFactor = options.canvasScaleFactor; - } - else if (options.calculateCanvasScaleFactor) { - canvasScaleFactor = options.calculateCanvasScaleFactor(egret.sys.canvasHitTestBuffer.context); - } - else { - //based on : https://github.com/jondavidjohn/hidpi-canvas-polyfill - var context = egret.sys.canvasHitTestBuffer.context; - var backingStore = context.backingStorePixelRatio || - context.webkitBackingStorePixelRatio || - context.mozBackingStorePixelRatio || - context.msBackingStorePixelRatio || - context.oBackingStorePixelRatio || - context.backingStorePixelRatio || 1; - canvasScaleFactor = (window.devicePixelRatio || 1) / backingStore; - } - egret.sys.DisplayList.$canvasScaleFactor = canvasScaleFactor; - var ticker_1 = egret.ticker; - startTicker(ticker_1); - if (options.screenAdapter) { - egret.sys.screenAdapter = options.screenAdapter; - } - else if (!egret.sys.screenAdapter) { - egret.sys.screenAdapter = new egret.sys.DefaultScreenAdapter(); - } - var list = document.querySelectorAll(".egret-player"); - var length_2 = list.length; - for (var i = 0; i < length_2; i++) { - var container = list[i]; - var player = new web.WebPlayer(container, options); - container["egret-player"] = player; - } - window.addEventListener("resize", function () { - if (isNaN(resizeTimer)) { - resizeTimer = window.setTimeout(doResize, 300); - } - }); - } - } - /** - * 设置渲染模式。"auto","webgl","canvas" - * @param renderMode - */ - function setRenderMode(renderMode) { - if (renderMode == "webgl" && egret.WebGLUtils.checkCanUseWebGL()) { - egret.sys.RenderBuffer = web.WebGLRenderBuffer; - egret.sys.systemRenderer = new web.WebGLRenderer(); - egret.sys.canvasRenderer = new egret.CanvasRenderer(); - egret.sys.customHitTestBuffer = new web.WebGLRenderBuffer(3, 3); - egret.sys.canvasHitTestBuffer = new web.CanvasRenderBuffer(3, 3); - egret.Capabilities["renderMode" + ""] = "webgl"; - } - else { - egret.sys.RenderBuffer = web.CanvasRenderBuffer; - egret.sys.systemRenderer = new egret.CanvasRenderer(); - egret.sys.canvasRenderer = egret.sys.systemRenderer; - egret.sys.customHitTestBuffer = new web.CanvasRenderBuffer(3, 3); - egret.sys.canvasHitTestBuffer = egret.sys.customHitTestBuffer; - egret.Capabilities["renderMode" + ""] = "canvas"; - } - } - /** - * @private - * 启动心跳计时器。 - */ - function startTicker(ticker) { - var requestAnimationFrame = window["requestAnimationFrame"] || - window["webkitRequestAnimationFrame"] || - window["mozRequestAnimationFrame"] || - window["oRequestAnimationFrame"] || - window["msRequestAnimationFrame"]; - if (!requestAnimationFrame) { - requestAnimationFrame = function (callback) { - return window.setTimeout(callback, 1000 / 60); - }; - } - requestAnimationFrame(onTick); - function onTick() { - ticker.update(); - requestAnimationFrame(onTick); - } - } - //覆盖原生的isNaN()方法实现,在不同浏览器上有2~10倍性能提升。 - window["isNaN"] = function (value) { - value = +value; - return value !== value; - }; - egret.runEgret = runEgret; - egret.updateAllScreens = updateAllScreens; - var resizeTimer = NaN; - function doResize() { - resizeTimer = NaN; - egret.updateAllScreens(); - } - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -if (true) { - var language = navigator.language || navigator["browserLanguage"] || "en_US"; - language = language.replace("-", "_"); - if (language in egret.$locale_strings) - egret.$language = language; -} -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - var WebCapability = (function () { - function WebCapability() { - } - /** - * @private - * 检测系统属性 - */ - WebCapability.detect = function () { - var capabilities = egret.Capabilities; - var ua = navigator.userAgent.toLowerCase(); - capabilities["isMobile" + ""] = (ua.indexOf('mobile') != -1 || ua.indexOf('android') != -1); - if (capabilities.isMobile) { - if (ua.indexOf("windows") < 0 && (ua.indexOf("iphone") != -1 || ua.indexOf("ipad") != -1 || ua.indexOf("ipod") != -1)) { - capabilities["os" + ""] = "iOS"; - } - else if (ua.indexOf("android") != -1 && ua.indexOf("linux") != -1) { - capabilities["os" + ""] = "Android"; - } - else if (ua.indexOf("windows") != -1) { - capabilities["os" + ""] = "Windows Phone"; - } - } - else { - if (ua.indexOf("windows nt") != -1) { - capabilities["os" + ""] = "Windows PC"; - } - else if (ua.indexOf("mac os") != -1) { - capabilities["os" + ""] = "Mac OS"; - } - } - var language = (navigator.language || navigator["browserLanguage"]).toLowerCase(); - var strings = language.split("-"); - if (strings.length > 1) { - strings[1] = strings[1].toUpperCase(); - } - capabilities["language" + ""] = strings.join("-"); - WebCapability.injectUIntFixOnIE9(); - }; - WebCapability.injectUIntFixOnIE9 = function () { - if (/msie 9.0/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) { - var IEBinaryToArray_ByteStr_Script = "\r\n" + - "\r\n\r\n\r\n";document.write(e)}},t}();t.WebCapability=r,__reflect(r.prototype,"egret.web.WebCapability"),r.detect()}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(){function t(t,r,i,n,a){if(this.showPanle=!0,this.fpsHeight=0,this.WIDTH=101,this.HEIGHT=20,this.bgCanvasColor="#18304b",this.fpsFrontColor="#18fefe",this.WIDTH_COST=50,this.cost1Color="#18fefe",this.cost3Color="#ff0000",this.arrFps=[],this.arrCost=[],this.arrLog=[],r||i){"canvas"==e.Capabilities.renderMode?this.renderMode="Canvas":this.renderMode="WebGL",this.panelX=void 0===a.x?0:parseInt(a.x),this.panelY=void 0===a.y?0:parseInt(a.y),this.fontColor=void 0===a.textColor?"#ffffff":a.textColor.replace("0x","#"),this.fontSize=void 0===a.size?12:parseInt(a.size),e.Capabilities.isMobile&&(this.fontSize-=2);var o=document.createElement("div");o.style.position="absolute",o.style.background="rgba(0,0,0,"+a.bgAlpha+")",o.style.left=this.panelX+"px",o.style.top=this.panelY+"px",o.style.pointerEvents="none",document.body.appendChild(o);var s=document.createElement("div");s.style.color=this.fontColor,s.style.fontSize=this.fontSize+"px",s.style.lineHeight=this.fontSize+"px",s.style.margin="4px 4px 4px 4px",this.container=s,o.appendChild(s),r&&this.addFps(),i&&this.addLog()}}return t.prototype.addFps=function(){var e=document.createElement("div");e.style.display="inline-block",this.containerFps=e,this.container.appendChild(e);var t=document.createElement("div");t.style.paddingBottom="2px",this.fps=t,this.containerFps.appendChild(t),t.innerHTML="0 FPS "+this.renderMode+"
      min0 max0 avg0";var r=document.createElement("canvas");this.containerFps.appendChild(r),r.width=this.WIDTH,r.height=this.HEIGHT,this.canvasFps=r;var i=r.getContext("2d");this.contextFps=i,i.fillStyle=this.bgCanvasColor,i.fillRect(0,0,this.WIDTH,this.HEIGHT);var n=document.createElement("div");this.divDatas=n,this.containerFps.appendChild(n);var a=document.createElement("div");a.style["float"]="left",a.innerHTML="Draw
      Cost",n.appendChild(a);var o=document.createElement("div");o.style.paddingLeft=a.offsetWidth+20+"px",n.appendChild(o);var s=document.createElement("div");this.divDraw=s,s.innerHTML="0
      ",o.appendChild(s);var c=document.createElement("div");this.divCost=c,c.innerHTML='0 0',o.appendChild(c),r=document.createElement("canvas"),this.canvasCost=r,this.containerFps.appendChild(r),r.width=this.WIDTH,r.height=this.HEIGHT,i=r.getContext("2d"),this.contextCost=i,i.fillStyle=this.bgCanvasColor,i.fillRect(0,0,this.WIDTH,this.HEIGHT),i.fillStyle="#000000",i.fillRect(this.WIDTH_COST,0,1,this.HEIGHT),this.fpsHeight=this.container.offsetHeight},t.prototype.addLog=function(){var e=document.createElement("div");e.style.maxWidth=document.body.clientWidth-8-this.panelX+"px",e.style.wordWrap="break-word",this.log=e,this.container.appendChild(e)},t.prototype.update=function(e,t){void 0===t&&(t=!1);var r,i,n;t?(r=this.arrFps[this.arrFps.length-1],i=this.arrCost[this.arrCost.length-1][0],n=this.arrCost[this.arrCost.length-1][1]):(r=e.fps,i=e.costTicker,n=e.costRender,this.lastNumDraw=e.draw,this.arrFps.push(r),this.arrCost.push([i,n]));var a=0,o=this.arrFps.length;o>101&&(o=101,this.arrFps.shift(),this.arrCost.shift());for(var s=this.arrFps[0],c=this.arrFps[0],l=0;o>l;l++){var h=this.arrFps[l];a+=h,s>h?s=h:h>c&&(c=h)}var u=this.WIDTH,d=this.HEIGHT,f=this.contextFps;f.drawImage(this.canvasFps,1,0,u-1,d,0,0,u-1,d),f.fillStyle=this.bgCanvasColor,f.fillRect(u-1,0,1,d);var p=Math.floor(r/60*20);1>p&&(p=1),f.fillStyle=this.fpsFrontColor,f.fillRect(u-1,20-p,1,p);var v=this.WIDTH_COST;f=this.contextCost,f.drawImage(this.canvasCost,1,0,v-1,d,0,0,v-1,d),f.drawImage(this.canvasCost,v+2,0,v-1,d,v+1,0,v-1,d);var g=Math.floor(i/2);1>g?g=1:g>20&&(g=20);var y=Math.floor(n/2);1>y?y=1:y>20&&(y=20),f.fillStyle=this.bgCanvasColor,f.fillRect(v-1,0,1,d),f.fillRect(2*v,0,1,d),f.fillRect(3*v+1,0,1,d),f.fillStyle=this.cost1Color,f.fillRect(v-1,20-g,1,g),f.fillStyle=this.cost3Color,f.fillRect(2*v,20-y,1,y);var x=Math.floor(a/o),m=r+" FPS "+this.renderMode;this.showPanle&&(m+="
      min"+s+" max"+c+" avg"+x,this.divDraw.innerHTML=this.lastNumDraw+"
      ",this.divCost.innerHTML=''+i+' '+n+""),this.fps.innerHTML=m},t.prototype.updateInfo=function(e){this.arrLog.push(e),this.updateLogLayout()},t.prototype.updateWarn=function(e){this.arrLog.push("[Warning]"+e),this.updateLogLayout()},t.prototype.updateError=function(e){this.arrLog.push("[Error]"+e),this.updateLogLayout()},t.prototype.updateLogLayout=function(){for(this.log.innerHTML=this.arrLog.join("
      ");document.body.clientHeight")},t}();t.WebFps=r,__reflect(r.prototype,"egret.web.WebFps",["egret.FPSDisplay"]),e.FPSDisplay=r}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r;!function(r){function i(e){return window.localStorage.getItem(e)}function n(t,r){try{return window.localStorage.setItem(t,r),!0}catch(i){return e.$warn(1047,t,r),!1}}function a(e){window.localStorage.removeItem(e)}function o(){window.localStorage.clear()}t.getItem=i,t.setItem=n,t.removeItem=a,t.clear=o}(r=t.web||(t.web={}))}(t=e.localStorage||(e.localStorage={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(r){function i(e,t){var i=r.call(this)||this;return i.init(e,t),i.initOrientation(),i}return __extends(i,r),i.prototype.init=function(r,i){var n=this.readOption(r,i),a=new e.Stage;a.$screen=this,a.$scaleMode=n.scaleMode,a.$orientation=n.orientation,a.$maxTouches=n.maxTouches,a.frameRate=n.frameRate,a.textureScaleFactor=n.textureScaleFactor;var o=new e.sys.RenderBuffer(void 0,void 0,!0),s=o.surface;this.attachCanvas(r,s);var c=new t.WebTouchHandler(a,s),l=new e.sys.Player(o,a,n.entryClassName);e.lifecycle.stage=a,e.lifecycle.addLifecycleListener(t.WebLifeCycleHandler);var h=new t.HTMLInput;(n.showFPS||n.showLog)&&(e.nativeRender||l.displayFPS(n.showFPS,n.showLog,n.logFilter,n.fpsStyles)),this.playerOption=n,this.container=r,this.canvas=s,this.stage=a,this.player=l,this.webTouchHandler=c,this.webInput=h,e.web.$cacheTextAdapter(h,a,r,s),this.updateScreenSize(),this.updateMaxTouches(),l.start()},i.prototype.initOrientation=function(){var t=this;window.addEventListener("orientationchange",function(){window.setTimeout(function(){e.StageOrientationEvent.dispatchStageOrientationEvent(t.stage,e.StageOrientationEvent.ORIENTATION_CHANGE)},350)})},i.prototype.readOption=function(t,r){var i={};i.entryClassName=t.getAttribute("data-entry-class"),i.scaleMode=t.getAttribute("data-scale-mode")||e.StageScaleMode.NO_SCALE,i.frameRate=+t.getAttribute("data-frame-rate")||30,i.contentWidth=+t.getAttribute("data-content-width")||480,i.contentHeight=+t.getAttribute("data-content-height")||800,i.orientation=t.getAttribute("data-orientation")||e.OrientationMode.AUTO,i.maxTouches=+t.getAttribute("data-multi-fingered")||2,i.textureScaleFactor=+t.getAttribute("texture-scale-factor")||1,i.showFPS="true"==t.getAttribute("data-show-fps");for(var n=t.getAttribute("data-show-fps-style")||"",a=n.split(","),o={},s=0;sa||c==e.OrientationMode.PORTRAIT&&a>o);var l=s?o:a,h=s?a:o;e.Capabilities.boundingClientWidth=l,e.Capabilities.boundingClientHeight=h;var u=e.sys.screenAdapter.calculateStageSize(this.stage.$scaleMode,l,h,r.contentWidth,r.contentHeight),d=u.stageWidth,f=u.stageHeight,p=u.displayWidth,v=u.displayHeight;t.style[e.web.getPrefixStyleName("transformOrigin")]="0% 0% 0px",t.width!=d&&(t.width=d),t.height!=f&&(t.height=f);var g=0;s?c==e.OrientationMode.LANDSCAPE?(g=90,t.style.top=n+(o-p)/2+"px",t.style.left=(a+v)/2+"px"):(g=-90,t.style.top=n+(o+p)/2+"px",t.style.left=(a-v)/2+"px"):(t.style.top=n+(o-v)/2+"px",t.style.left=(a-p)/2+"px");var y=p/d,x=v/f,m=y*e.sys.DisplayList.$canvasScaleFactor,b=x*e.sys.DisplayList.$canvasScaleFactor;"canvas"==e.Capabilities.renderMode&&(m=Math.ceil(m),b=Math.ceil(b));var w=e.Matrix.create();w.identity(),w.scale(y/m,x/b),w.rotate(g*Math.PI/180);var E="matrix("+w.a+","+w.b+","+w.c+","+w.d+","+w.tx+","+w.ty+")";e.Matrix.release(w),t.style[e.web.getPrefixStyleName("transform")]=E,e.sys.DisplayList.$setCanvasScale(m,b),this.webTouchHandler.updateScaleMode(y,x,g),this.webInput.$updateSize(),this.player.updateStageSize(d,f),e.nativeRender&&(t.width=d*m,t.height=f*b)}}},i.prototype.setContentSize=function(e,t){var r=this.playerOption;r.contentWidth=e,r.contentHeight=t,this.updateScreenSize()},i.prototype.updateMaxTouches=function(){this.webTouchHandler.$updateMaxTouches()},i}(e.HashObject);t.WebPlayer=r,__reflect(r.prototype,"egret.web.WebPlayer",["egret.sys.Screen"])}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){function r(t,r){s||(s=document.createElement("canvas"),c=s.getContext("2d"));var i=t.$getTextureWidth(),n=t.$getTextureHeight();null==r&&(r=e.$TempRectangle,r.x=0,r.y=0,r.width=i,r.height=n),r.x=Math.min(r.x,i-1),r.y=Math.min(r.y,n-1),r.width=Math.min(r.width,i-r.x),r.height=Math.min(r.height,n-r.y);var a=r.width,o=r.height,l=s;if(l.style.width=a+"px",l.style.height=o+"px",s.width=a,s.height=o,"webgl"==e.Capabilities.renderMode){var h=void 0;t.$renderBuffer?h=t:(h=new e.RenderTexture,h.drawToTexture(new e.Bitmap(t)));for(var u=h.$renderBuffer.getPixels(r.x,r.y,a,o),d=new ImageData(a,o),f=0;fn;n++){var a=t.childNodes[n];if(1==a.nodeType)return i(a,null)}return null}function i(e,t){if("parsererror"==e.localName)throw new Error(e.textContent);for(var r=new a(e.localName,t,e.prefix,e.namespaceURI,e.nodeName),n=e.attributes,s=r.attributes,c=n.length,l=0;c>l;l++){var h=n[l],u=h.name;0!=u.indexOf("xmlns:")&&(s[u]=h.value,r["$"+u]=h.value)}var d=e.childNodes;c=d.length;for(var f=r.children,l=0;c>l;l++){var p=d[l],v=p.nodeType,g=null;if(1==v)g=i(p,r);else if(3==v){var y=p.textContent.trim();y&&(g=new o(y,r))}g&&f.push(g)}return r}var n=function(){function e(e,t){this.nodeType=e,this.parent=t}return e}();t.XMLNode=n,__reflect(n.prototype,"egret.web.XMLNode");var a=function(e){function t(t,r,i,n,a){var o=e.call(this,1,r)||this;return o.attributes={},o.children=[],o.localName=t,o.prefix=i,o.namespace=n,o.name=a,o}return __extends(t,e),t}(n);t.XML=a,__reflect(a.prototype,"egret.web.XML");var o=function(e){function t(t,r){var i=e.call(this,3,r)||this;return i.text=t,i}return __extends(t,e),t}(n);t.XMLText=o,__reflect(o.prototype,"egret.web.XMLText");var s=new DOMParser;e.XML={parse:r}}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(t){function r(){var r=null!==t&&t.apply(this,arguments)||this;return r.onChange=function(t){var i=new e.OrientationEvent(e.Event.CHANGE);i.beta=t.beta,i.gamma=t.gamma,i.alpha=t.alpha,r.dispatchEvent(i)},r}return __extends(r,t),r.prototype.start=function(){window.addEventListener("deviceorientation",this.onChange)},r.prototype.stop=function(){window.removeEventListener("deviceorientation",this.onChange)},r}(e.EventDispatcher);t.WebDeviceOrientation=r,__reflect(r.prototype,"egret.web.WebDeviceOrientation",["egret.DeviceOrientation"])}(t=e.web||(e.web={}))}(egret||(egret={})),egret.DeviceOrientation=egret.web.WebDeviceOrientation;var egret;!function(e){var t;!function(t){var r=function(t){function r(r){var i=t.call(this)||this;return i.onUpdate=function(t){var r=new e.GeolocationEvent(e.Event.CHANGE),n=t.coords;r.altitude=n.altitude,r.heading=n.heading,r.accuracy=n.accuracy,r.latitude=n.latitude,r.longitude=n.longitude,r.speed=n.speed,r.altitudeAccuracy=n.altitudeAccuracy,i.dispatchEvent(r)},i.onError=function(t){var r=e.GeolocationEvent.UNAVAILABLE;t.code==t.PERMISSION_DENIED&&(r=e.GeolocationEvent.PERMISSION_DENIED);var n=new e.GeolocationEvent(e.IOErrorEvent.IO_ERROR);n.errorType=r,n.errorMessage=t.message,i.dispatchEvent(n)},i.geolocation=navigator.geolocation,i}return __extends(r,t),r.prototype.start=function(){var t=this.geolocation;t?this.watchId=t.watchPosition(this.onUpdate,this.onError):this.onError({code:2,message:e.sys.tr(3004),PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2})},r.prototype.stop=function(){var e=this.geolocation;e.clearWatch(this.watchId)},r}(e.EventDispatcher);t.WebGeolocation=r,__reflect(r.prototype,"egret.web.WebGeolocation",["egret.Geolocation"]),e.Geolocation=e.web.WebGeolocation}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(t){function r(){var r=null!==t&&t.apply(this,arguments)||this;return r.onChange=function(t){var i=new e.MotionEvent(e.Event.CHANGE),n={x:t.acceleration.x,y:t.acceleration.y,z:t.acceleration.z},a={x:t.accelerationIncludingGravity.x,y:t.accelerationIncludingGravity.y,z:t.accelerationIncludingGravity.z},o={alpha:t.rotationRate.alpha,beta:t.rotationRate.beta,gamma:t.rotationRate.gamma};i.acceleration=n,i.accelerationIncludingGravity=a,i.rotationRate=o,r.dispatchEvent(i)},r}return __extends(r,t),r.prototype.start=function(){window.addEventListener("devicemotion",this.onChange)},r.prototype.stop=function(){window.removeEventListener("devicemotion",this.onChange)},r}(e.EventDispatcher);t.WebMotion=r,__reflect(r.prototype,"egret.web.WebMotion",["egret.Motion"]),e.Motion=e.web.WebMotion}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(e){}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(e){var t=function(){function e(){this.drawData=[],this.drawDataLen=0}return e.prototype.pushDrawRect=function(){if(0==this.drawDataLen||1!=this.drawData[this.drawDataLen-1].type){var e=this.drawData[this.drawDataLen]||{};e.type=1,e.count=0,this.drawData[this.drawDataLen]=e,this.drawDataLen++}this.drawData[this.drawDataLen-1].count+=2},e.prototype.pushDrawTexture=function(e,t,r,i,n){if(void 0===t&&(t=2),r){var a=this.drawData[this.drawDataLen]||{};a.type=0,a.texture=e,a.filter=r,a.count=t,a.textureWidth=i,a.textureHeight=n,this.drawData[this.drawDataLen]=a,this.drawDataLen++}else{if(0==this.drawDataLen||0!=this.drawData[this.drawDataLen-1].type||e!=this.drawData[this.drawDataLen-1].texture||this.drawData[this.drawDataLen-1].filter){var a=this.drawData[this.drawDataLen]||{};a.type=0,a.texture=e,a.count=0,this.drawData[this.drawDataLen]=a,this.drawDataLen++}this.drawData[this.drawDataLen-1].count+=t}},e.prototype.pushChangeSmoothing=function(e,t){e.smoothing=t;var r=this.drawData[this.drawDataLen]||{};r.type=10,r.texture=e,r.smoothing=t,this.drawData[this.drawDataLen]=r,this.drawDataLen++},e.prototype.pushPushMask=function(e){void 0===e&&(e=1);var t=this.drawData[this.drawDataLen]||{};t.type=2,t.count=2*e,this.drawData[this.drawDataLen]=t,this.drawDataLen++},e.prototype.pushPopMask=function(e){void 0===e&&(e=1);var t=this.drawData[this.drawDataLen]||{};t.type=3,t.count=2*e,this.drawData[this.drawDataLen]=t,this.drawDataLen++},e.prototype.pushSetBlend=function(e){for(var t=this.drawDataLen,r=!1,i=t-1;i>=0;i--){var n=this.drawData[i];if(n){if((0==n.type||1==n.type)&&(r=!0),!r&&4==n.type){this.drawData.splice(i,1),this.drawDataLen--;continue}if(4==n.type){if(n.value==e)return;break}}}var a=this.drawData[this.drawDataLen]||{};a.type=4,a.value=e,this.drawData[this.drawDataLen]=a,this.drawDataLen++},e.prototype.pushResize=function(e,t,r){var i=this.drawData[this.drawDataLen]||{};i.type=5,i.buffer=e,i.width=t,i.height=r,this.drawData[this.drawDataLen]=i,this.drawDataLen++},e.prototype.pushClearColor=function(){var e=this.drawData[this.drawDataLen]||{};e.type=6,this.drawData[this.drawDataLen]=e,this.drawDataLen++},e.prototype.pushActivateBuffer=function(e){for(var t=this.drawDataLen,r=!1,i=t-1;i>=0;i--){var n=this.drawData[i];!n||(4!=n.type&&7!=n.type&&(r=!0),r||7!=n.type)||(this.drawData.splice(i,1),this.drawDataLen--)}var a=this.drawData[this.drawDataLen]||{};a.type=7,a.buffer=e,a.width=e.rootRenderTarget.width,a.height=e.rootRenderTarget.height,this.drawData[this.drawDataLen]=a,this.drawDataLen++},e.prototype.pushEnableScissor=function(e,t,r,i){var n=this.drawData[this.drawDataLen]||{};n.type=8,n.x=e,n.y=t,n.width=r,n.height=i,this.drawData[this.drawDataLen]=n,this.drawDataLen++},e.prototype.pushDisableScissor=function(){var e=this.drawData[this.drawDataLen]||{};e.type=9,this.drawData[this.drawDataLen]=e,this.drawDataLen++},e.prototype.clear=function(){for(var e=0;er;r+=6,i+=4)this.indices[r+0]=i+0,this.indices[r+1]=i+1,this.indices[r+2]=i+2,this.indices[r+3]=i+0,this.indices[r+4]=i+2,this.indices[r+5]=i+3}return e.prototype.reachMaxSize=function(e,t){return void 0===e&&(e=4),void 0===t&&(t=6),this.vertexIndex>this.vertexMaxSize-e||this.indexIndex>this.indicesMaxSize-t},e.prototype.getVertices=function(){var e=this.vertices.subarray(0,this.vertexIndex*this.vertSize); -return e},e.prototype.getIndices=function(){return this.indices},e.prototype.getMeshIndices=function(){return this.indicesForMesh},e.prototype.changeToMeshIndices=function(){if(!this.hasMesh){for(var e=0,t=this.indexIndex;t>e;++e)this.indicesForMesh[e]=this.indices[e];this.hasMesh=!0}},e.prototype.isMesh=function(){return this.hasMesh},e.prototype.cacheArrays=function(e,t,r,i,n,a,o,s,c,l,h,u,d,f,p){var v=e.globalAlpha,g=e.globalMatrix,y=g.a,x=g.b,m=g.c,b=g.d,w=g.tx,E=g.ty,T=e.$offsetX,_=e.$offsetY;if((0!=T||0!=_)&&(w=T*y+_*m+w,E=T*x+_*b+E),!d){(0!=a||0!=o)&&(w=a*y+o*m+w,E=a*x+o*b+E);var S=s/i;1!=S&&(y=S*y,x=S*x);var L=c/n;1!=L&&(m=L*m,b=L*b)}if(d){var C=this.vertices,R=this.vertexIndex*this.vertSize,A=0,D=0,O=0,I=0,M=0,$=0,B=0;for(A=0,O=u.length;O>A;A+=2)D=R+5*A/2,$=d[A],B=d[A+1],I=u[A],M=u[A+1],C[D+0]=y*$+m*B+w,C[D+1]=x*$+b*B+E,p?(C[D+2]=(t+(1-M)*n)/l,C[D+3]=(r+I*i)/h):(C[D+2]=(t+I*i)/l,C[D+3]=(r+M*n)/h),C[D+4]=v;if(this.hasMesh)for(var F=0,P=f.length;P>F;++F)this.indicesForMesh[this.indexIndex+F]=f[F]+this.vertexIndex;this.vertexIndex+=u.length/2,this.indexIndex+=f.length}else{var G=l,W=h,N=i,H=n;t/=G,r/=W;var C=this.vertices,R=this.vertexIndex*this.vertSize;if(p){var U=i;i=n/G,n=U/W,C[R++]=w,C[R++]=E,C[R++]=i+t,C[R++]=r,C[R++]=v,C[R++]=y*N+w,C[R++]=x*N+E,C[R++]=i+t,C[R++]=n+r,C[R++]=v,C[R++]=y*N+m*H+w,C[R++]=b*H+x*N+E,C[R++]=t,C[R++]=n+r,C[R++]=v,C[R++]=m*H+w,C[R++]=b*H+E,C[R++]=t,C[R++]=r,C[R++]=v}else i/=G,n/=W,C[R++]=w,C[R++]=E,C[R++]=t,C[R++]=r,C[R++]=v,C[R++]=y*N+w,C[R++]=x*N+E,C[R++]=i+t,C[R++]=r,C[R++]=v,C[R++]=y*N+m*H+w,C[R++]=b*H+x*N+E,C[R++]=i+t,C[R++]=n+r,C[R++]=v,C[R++]=m*H+w,C[R++]=b*H+E,C[R++]=t,C[R++]=n+r,C[R++]=v;if(this.hasMesh){var k=this.indicesForMesh;k[this.indexIndex+0]=0+this.vertexIndex,k[this.indexIndex+1]=1+this.vertexIndex,k[this.indexIndex+2]=2+this.vertexIndex,k[this.indexIndex+3]=0+this.vertexIndex,k[this.indexIndex+4]=2+this.vertexIndex,k[this.indexIndex+5]=3+this.vertexIndex}this.vertexIndex+=4,this.indexIndex+=6}},e.prototype.clear=function(){this.hasMesh=!1,this.vertexIndex=0,this.indexIndex=0},e}();e.WebGLVertexArrayObject=t,__reflect(t.prototype,"egret.web.WebGLVertexArrayObject")}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(t){function r(e,r,i){var n=t.call(this)||this;return n.clearColor=[0,0,0,0],n.useFrameBuffer=!0,n.gl=e,n.width=r||1,n.height=i||1,n}return __extends(r,t),r.prototype.resize=function(e,t){var r=this.gl;this.width=e,this.height=t,this.frameBuffer&&(r.bindTexture(r.TEXTURE_2D,this.texture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,e,t,0,r.RGBA,r.UNSIGNED_BYTE,null)),this.stencilBuffer&&(r.deleteRenderbuffer(this.stencilBuffer),this.stencilBuffer=null)},r.prototype.activate=function(){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,this.getFrameBuffer())},r.prototype.getFrameBuffer=function(){return this.useFrameBuffer?this.frameBuffer:null},r.prototype.initFrameBuffer=function(){if(!this.frameBuffer){var e=this.gl;this.texture=this.createTexture(),this.frameBuffer=e.createFramebuffer(),e.bindFramebuffer(e.FRAMEBUFFER,this.frameBuffer),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.texture,0)}},r.prototype.createTexture=function(){var e=this.gl,t=e.createTexture();return t.glContext=e,e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,this.width,this.height,0,e.RGBA,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),t},r.prototype.clear=function(e){var t=this.gl;e&&this.activate(),t.colorMask(!0,!0,!0,!0),t.clearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),t.clear(t.COLOR_BUFFER_BIT)},r.prototype.enabledStencil=function(){if(this.frameBuffer&&!this.stencilBuffer){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,this.frameBuffer),this.stencilBuffer=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,this.stencilBuffer),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,this.width,this.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,this.stencilBuffer)}},r.prototype.dispose=function(){e.WebGLUtils.deleteWebGLTexture(this.texture)},r}(e.HashObject);t.WebGLRenderTarget=r,__reflect(r.prototype,"egret.web.WebGLRenderTarget")}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){function r(e,t){var r=document.createElement("canvas");return isNaN(e)||isNaN(t)||(r.width=e,r.height=t),r}var i=function(){function i(i,n){if(this.glID=null,this.projectionX=0/0,this.projectionY=0/0,this.contextLost=!1,this.$scissorState=!1,this.vertSize=5,this.surface=r(i,n),!e.nativeRender){this.initWebGL(),this.$bufferStack=[];var a=this.context;this.vertexBuffer=a.createBuffer(),this.indexBuffer=a.createBuffer(),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),this.drawCmdManager=new t.WebGLDrawCmdManager,this.vao=new t.WebGLVertexArrayObject,this.setGlobalCompositeOperation("source-over")}}return i.getInstance=function(e,t){return this.instance?this.instance:(this.instance=new i(e,t),this.instance)},i.prototype.pushBuffer=function(e){this.$bufferStack.push(e),e!=this.currentBuffer&&(this.currentBuffer,this.drawCmdManager.pushActivateBuffer(e)),this.currentBuffer=e},i.prototype.popBuffer=function(){if(!(this.$bufferStack.length<=1)){var e=this.$bufferStack.pop(),t=this.$bufferStack[this.$bufferStack.length-1];e!=t&&this.drawCmdManager.pushActivateBuffer(t),this.currentBuffer=t}},i.prototype.activateBuffer=function(e,t,r){e.rootRenderTarget.activate(),this.bindIndices||this.uploadIndicesArray(this.vao.getIndices()),e.restoreStencil(),e.restoreScissor(),this.onResize(t,r)},i.prototype.uploadVerticesArray=function(e){var t=this.context;t.bufferData(t.ARRAY_BUFFER,e,t.STREAM_DRAW)},i.prototype.uploadIndicesArray=function(e){var t=this.context;t.bufferData(t.ELEMENT_ARRAY_BUFFER,e,t.STATIC_DRAW),this.bindIndices=!0},i.prototype.destroy=function(){this.surface.width=this.surface.height=0},i.prototype.onResize=function(e,t){e=e||this.surface.width,t=t||this.surface.height,this.projectionX=e/2,this.projectionY=-t/2,this.context&&this.context.viewport(0,0,e,t)},i.prototype.resize=function(e,t,r){var i=this.surface;r?(i.widthr;r++){var i=this.drawCmdManager.drawData[r];t=this.drawData(i,t),7==i.type&&(this.activatedBuffer=i.buffer),(0==i.type||1==i.type||2==i.type||3==i.type)&&this.activatedBuffer&&this.activatedBuffer.$computeDrawCall&&this.activatedBuffer.$drawCalls++}this.vao.isMesh()&&this.uploadIndicesArray(this.vao.getIndices()),this.drawCmdManager.clear(),this.vao.clear()}},i.prototype.drawData=function(e,r){if(e){var i,n=this.context,a=e.filter;switch(e.type){case 0:a?"custom"===a.type?i=t.EgretWebGLProgram.getProgram(n,a.$vertexSrc,a.$fragmentSrc,a.$shaderKey):"colorTransform"===a.type?i=t.EgretWebGLProgram.getProgram(n,t.EgretShaderLib.default_vert,t.EgretShaderLib.colorTransform_frag,"colorTransform"):"blurX"===a.type?i=t.EgretWebGLProgram.getProgram(n,t.EgretShaderLib.default_vert,t.EgretShaderLib.blur_frag,"blur"):"blurY"===a.type?i=t.EgretWebGLProgram.getProgram(n,t.EgretShaderLib.default_vert,t.EgretShaderLib.blur_frag,"blur"):"glow"===a.type&&(i=t.EgretWebGLProgram.getProgram(n,t.EgretShaderLib.default_vert,t.EgretShaderLib.glow_frag,"glow")):i=t.EgretWebGLProgram.getProgram(n,t.EgretShaderLib.default_vert,t.EgretShaderLib.texture_frag,"texture"),this.activeProgram(n,i),this.syncUniforms(i,a,e.textureWidth,e.textureHeight),r+=this.drawTextureElements(e,r);break;case 1:i=t.EgretWebGLProgram.getProgram(n,t.EgretShaderLib.default_vert,t.EgretShaderLib.primitive_frag,"primitive"),this.activeProgram(n,i),this.syncUniforms(i,a,e.textureWidth,e.textureHeight),r+=this.drawRectElements(e,r);break;case 2:i=t.EgretWebGLProgram.getProgram(n,t.EgretShaderLib.default_vert,t.EgretShaderLib.primitive_frag,"primitive"),this.activeProgram(n,i),this.syncUniforms(i,a,e.textureWidth,e.textureHeight),r+=this.drawPushMaskElements(e,r);break;case 3:i=t.EgretWebGLProgram.getProgram(n,t.EgretShaderLib.default_vert,t.EgretShaderLib.primitive_frag,"primitive"),this.activeProgram(n,i),this.syncUniforms(i,a,e.textureWidth,e.textureHeight),r+=this.drawPopMaskElements(e,r);break;case 4:this.setBlendMode(e.value);break;case 5:e.buffer.rootRenderTarget.resize(e.width,e.height),this.onResize(e.width,e.height);break;case 6:if(this.activatedBuffer){var o=this.activatedBuffer.rootRenderTarget;(0!=o.width||0!=o.height)&&o.clear(!0)}break;case 7:this.activateBuffer(e.buffer,e.width,e.height);break;case 8:var s=this.activatedBuffer;s&&(s.rootRenderTarget&&s.rootRenderTarget.enabledStencil(),s.enableScissor(e.x,e.y,e.width,e.height));break;case 9:s=this.activatedBuffer,s&&s.disableScissor();break;case 10:n.bindTexture(n.TEXTURE_2D,e.texture),e.smoothing?(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR)):(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST))}return r}},i.prototype.activeProgram=function(e,t){if(t!=this.currentProgram){e.useProgram(t.id);var r=t.attributes;for(var i in r)"aVertexPosition"===i?(e.vertexAttribPointer(r.aVertexPosition.location,2,e.FLOAT,!1,20,0),e.enableVertexAttribArray(r.aVertexPosition.location)):"aTextureCoord"===i?(e.vertexAttribPointer(r.aTextureCoord.location,2,e.FLOAT,!1,20,8),e.enableVertexAttribArray(r.aTextureCoord.location)):"aColor"===i&&(e.vertexAttribPointer(r.aColor.location,1,e.FLOAT,!1,20,16),e.enableVertexAttribArray(r.aColor.location));this.currentProgram=t}},i.prototype.syncUniforms=function(e,t,r,i){var n=e.uniforms;t&&"custom"===t.type;for(var a in n)if("projectionVector"===a)n[a].setValue({x:this.projectionX,y:this.projectionY});else if("uTextureSize"===a)n[a].setValue({x:r,y:i});else if("uSampler"===a);else{var o=t.$uniforms[a];void 0!==o&&n[a].setValue(o)}},i.prototype.drawTextureElements=function(e,t){var r=this.context;r.bindTexture(r.TEXTURE_2D,e.texture);var i=3*e.count;return r.drawElements(r.TRIANGLES,i,r.UNSIGNED_SHORT,2*t),i},i.prototype.drawRectElements=function(e,t){var r=this.context,i=3*e.count;return r.drawElements(r.TRIANGLES,i,r.UNSIGNED_SHORT,2*t),i},i.prototype.drawPushMaskElements=function(e,t){var r=this.context,i=3*e.count,n=this.activatedBuffer;if(n){n.rootRenderTarget&&n.rootRenderTarget.enabledStencil(),0==n.stencilHandleCount&&(n.enableStencil(),r.clear(r.STENCIL_BUFFER_BIT));var a=n.stencilHandleCount;n.stencilHandleCount++,r.colorMask(!1,!1,!1,!1),r.stencilFunc(r.EQUAL,a,255),r.stencilOp(r.KEEP,r.KEEP,r.INCR),r.drawElements(r.TRIANGLES,i,r.UNSIGNED_SHORT,2*t),r.stencilFunc(r.EQUAL,a+1,255),r.colorMask(!0,!0,!0,!0),r.stencilOp(r.KEEP,r.KEEP,r.KEEP)}return i},i.prototype.drawPopMaskElements=function(e,t){var r=this.context,i=3*e.count,n=this.activatedBuffer;if(n)if(n.stencilHandleCount--,0==n.stencilHandleCount)n.disableStencil();else{var a=n.stencilHandleCount;r.colorMask(!1,!1,!1,!1),r.stencilFunc(r.EQUAL,a+1,255),r.stencilOp(r.KEEP,r.KEEP,r.DECR),r.drawElements(r.TRIANGLES,i,r.UNSIGNED_SHORT,2*t),r.stencilFunc(r.EQUAL,a,255),r.colorMask(!0,!0,!0,!0),r.stencilOp(r.KEEP,r.KEEP,r.KEEP)}return i},i.prototype.setBlendMode=function(e){var t=this.context,r=i.blendModesForGL[e];r&&t.blendFunc(r[0],r[1])},i.prototype.drawTargetWidthFilters=function(e,r){var i,n=r,a=e.length;if(a>1)for(var o=0;a-1>o;o++){var s=e[o],c=r.rootRenderTarget.width,l=r.rootRenderTarget.height;i=t.WebGLRenderBuffer.create(c,l),i.setTransform(1,0,0,1,0,0),i.globalAlpha=1,this.drawToRenderTarget(s,r,i),r!=n&&t.WebGLRenderBuffer.release(r),r=i}var h=e[a-1];this.drawToRenderTarget(h,r,this.currentBuffer),r!=n&&t.WebGLRenderBuffer.release(r)},i.prototype.drawToRenderTarget=function(e,r,i){if(!this.contextLost){this.vao.reachMaxSize()&&this.$drawWebGL(),this.pushBuffer(i);var n,a=r,o=r.rootRenderTarget.width,s=r.rootRenderTarget.height;if("blur"==e.type){var c=e.blurXFilter,l=e.blurYFilter;0!=c.blurX&&0!=l.blurY?(n=t.WebGLRenderBuffer.create(o,s),n.setTransform(1,0,0,1,0,0),n.globalAlpha=1,this.drawToRenderTarget(e.blurXFilter,r,n),r!=a&&t.WebGLRenderBuffer.release(r),r=n,e=l):e=0===c.blurX?l:c}i.saveTransform(),i.transform(1,0,0,-1,0,s),this.vao.cacheArrays(i,0,0,o,s,0,0,o,s,o,s),i.restoreTransform(),this.drawCmdManager.pushDrawTexture(r.rootRenderTarget.texture,2,e,o,s),r!=a&&t.WebGLRenderBuffer.release(r),this.popBuffer()}},i.initBlendMode=function(){i.blendModesForGL={},i.blendModesForGL["source-over"]=[1,771],i.blendModesForGL.lighter=[1,1],i.blendModesForGL["lighter-in"]=[770,771],i.blendModesForGL["destination-out"]=[0,771],i.blendModesForGL["destination-in"]=[0,770]},i.glContextId=0,i.blendModesForGL=null,i}();t.WebGLRenderContext=i,__reflect(i.prototype,"egret.web.WebGLRenderContext"),i.initBlendMode()}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(r){function n(i,n,a){var o=r.call(this)||this;if(o.globalAlpha=1,o.stencilState=!1,o.$stencilList=[],o.stencilHandleCount=0,o.$scissorState=!1,o.scissorRect=new e.Rectangle,o.$hasScissor=!1,o.$drawCalls=0,o.$computeDrawCall=!1,o.globalMatrix=new e.Matrix,o.savedGlobalMatrix=new e.Matrix,o.$offsetX=0,o.$offsetY=0,o.context=t.WebGLRenderContext.getInstance(i,n),e.nativeRender)return a?o.surface=o.context.surface:o.surface=new egret_native.NativeRenderSurface(o,i,n,a),o.rootRenderTarget=null,o;if(o.rootRenderTarget=new t.WebGLRenderTarget(o.context.context,3,3),i&&n&&o.resize(i,n),o.root=a,o.root)o.context.pushBuffer(o),o.surface=o.context.surface,o.$computeDrawCall=!0;else{var s=o.context.activatedBuffer;s&&s.rootRenderTarget.activate(),o.rootRenderTarget.initFrameBuffer(),o.surface=o.rootRenderTarget}return o}return __extends(n,r),n.prototype.enableStencil=function(){this.stencilState||(this.context.enableStencilTest(),this.stencilState=!0)},n.prototype.disableStencil=function(){this.stencilState&&(this.context.disableStencilTest(),this.stencilState=!1)},n.prototype.restoreStencil=function(){this.stencilState?this.context.enableStencilTest():this.context.disableStencilTest()},n.prototype.enableScissor=function(e,t,r,i){this.$scissorState||(this.$scissorState=!0,this.scissorRect.setTo(e,t,r,i),this.context.enableScissorTest(this.scissorRect))},n.prototype.disableScissor=function(){this.$scissorState&&(this.$scissorState=!1,this.scissorRect.setEmpty(),this.context.disableScissorTest())},n.prototype.restoreScissor=function(){this.$scissorState?this.context.enableScissorTest(this.scissorRect):this.context.disableScissorTest()},Object.defineProperty(n.prototype,"width",{get:function(){return e.nativeRender?this.surface.width:this.rootRenderTarget.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return e.nativeRender?this.surface.height:this.rootRenderTarget.height},enumerable:!0,configurable:!0}),n.prototype.resize=function(t,r,i){return t=t||1,r=r||1,e.nativeRender?void this.surface.resize(t,r):((t!=this.rootRenderTarget.width||r!=this.rootRenderTarget.height)&&(this.context.drawCmdManager.pushResize(this,t,r),this.rootRenderTarget.width=t,this.rootRenderTarget.height=r),this.root&&this.context.resize(t,r,i),this.context.pushBuffer(this),this.context.clear(),void this.context.popBuffer())},n.prototype.getPixels=function(t,r,i,n){void 0===i&&(i=1),void 0===n&&(n=1);var a=new Uint8Array(4*i*n);if(e.nativeRender)egret_native.activateBuffer(this),egret_native.nrGetPixels(t,r,i,n,a),egret_native.activateBuffer(null);else{var o=this.rootRenderTarget.useFrameBuffer;this.rootRenderTarget.useFrameBuffer=!0,this.rootRenderTarget.activate(),this.context.getPixels(t,r,i,n,a),this.rootRenderTarget.useFrameBuffer=o,this.rootRenderTarget.activate()}for(var s=new Uint8Array(4*i*n),c=0;n>c;c++)for(var l=0;i>l;l++){var h=4*(i*(n-c-1)+l),u=4*(i*c+l),d=a[u+3];s[h]=Math.round(a[u]/d*255),s[h+1]=Math.round(a[u+1]/d*255),s[h+2]=Math.round(a[u+2]/d*255),s[h+3]=a[u+3]}return s},n.prototype.toDataURL=function(e,t){return this.context.surface.toDataURL(e,t)},n.prototype.destroy=function(){this.context.destroy()},n.prototype.onRenderFinish=function(){this.$drawCalls=0},n.prototype.drawFrameBufferToSurface=function(e,t,r,i,n,a,o,s,c){void 0===c&&(c=!1),this.rootRenderTarget.useFrameBuffer=!1,this.rootRenderTarget.activate(),this.context.disableStencilTest(),this.context.disableScissorTest(),this.setTransform(1,0,0,1,0,0),this.globalAlpha=1,this.context.setGlobalCompositeOperation("source-over"),c&&this.context.clear(),this.context.drawImage(this.rootRenderTarget,e,t,r,i,n,a,o,s,r,i,!1),this.context.$drawWebGL(),this.rootRenderTarget.useFrameBuffer=!0,this.rootRenderTarget.activate(),this.restoreStencil(),this.restoreScissor()},n.prototype.drawSurfaceToFrameBuffer=function(e,t,r,i,n,a,o,s,c){void 0===c&&(c=!1),this.rootRenderTarget.useFrameBuffer=!0,this.rootRenderTarget.activate(),this.context.disableStencilTest(),this.context.disableScissorTest(),this.setTransform(1,0,0,1,0,0),this.globalAlpha=1,this.context.setGlobalCompositeOperation("source-over"),c&&this.context.clear(),this.context.drawImage(this.context.surface,e,t,r,i,n,a,o,s,r,i,!1),this.context.$drawWebGL(),this.rootRenderTarget.useFrameBuffer=!1,this.rootRenderTarget.activate(),this.restoreStencil(),this.restoreScissor()},n.prototype.clear=function(){this.context.pushBuffer(this),this.context.clear(),this.context.popBuffer()},n.prototype.setTransform=function(e,t,r,i,n,a){var o=this.globalMatrix;o.a=e,o.b=t,o.c=r,o.d=i,o.tx=n,o.ty=a},n.prototype.transform=function(e,t,r,i,n,a){var o=this.globalMatrix,s=o.a,c=o.b,l=o.c,h=o.d;(1!=e||0!=t||0!=r||1!=i)&&(o.a=e*s+t*l,o.b=e*c+t*h,o.c=r*s+i*l,o.d=r*c+i*h),o.tx=n*s+a*l+o.tx,o.ty=n*c+a*h+o.ty},n.prototype.useOffset=function(){var e=this;(0!=e.$offsetX||0!=e.$offsetY)&&(e.globalMatrix.append(1,0,0,1,e.$offsetX,e.$offsetY),e.$offsetX=e.$offsetY=0)},n.prototype.saveTransform=function(){var e=this.globalMatrix,t=this.savedGlobalMatrix;t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t.tx=e.tx,t.ty=e.ty},n.prototype.restoreTransform=function(){var e=this.globalMatrix,t=this.savedGlobalMatrix;e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e.tx=t.tx,e.ty=t.ty},n.create=function(e,t){var r=i.pop();if(r){r.resize(e,t);var a=r.globalMatrix;a.a=1,a.b=0,a.c=0,a.d=1,a.tx=0,a.ty=0,r.globalAlpha=1,r.$offsetX=0,r.$offsetY=0}else r=new n(e,t),r.$computeDrawCall=!1;return r},n.release=function(e){i.push(e)},n.autoClear=!0,n}(e.HashObject);t.WebGLRenderBuffer=r,__reflect(r.prototype,"egret.web.WebGLRenderBuffer",["egret.sys.RenderBuffer"]);var i=[]}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=["source-over","lighter","destination-out"],i="source-over",n=[],a=function(){function a(){this.nestLevel=0}return a.prototype.render=function(t,r,i,a){this.nestLevel++;var o=r,s=o.context;s.pushBuffer(o),o.transform(i.a,i.b,i.c,i.d,0,0),this.drawDisplayObject(t,o,i.tx,i.ty,!0),s.$drawWebGL();var c=o.$drawCalls;o.onRenderFinish(),s.popBuffer();var l=e.Matrix.create();if(i.$invertInto(l),o.transform(l.a,l.b,l.c,l.d,0,0),e.Matrix.release(l),this.nestLevel--,0===this.nestLevel){n.length>6&&(n.length=6);for(var h=n.length,u=0;h>u;u++)n[u].resize(0,0)}return c},a.prototype.drawDisplayObject=function(t,r,i,n,a){var o,s=0,c=t.$displayList;if(c&&!a?((t.$cacheDirty||t.$renderDirty||c.$canvasScaleX!=e.sys.DisplayList.$canvasScaleX||c.$canvasScaleY!=e.sys.DisplayList.$canvasScaleY)&&(s+=c.drawToSurface()),o=c.$renderNode):o=t.$renderDirty?t.$getRenderNode():t.$renderNode,t.$cacheDirty=!1,o){switch(s++,r.$offsetX=i,r.$offsetY=n,o.type){case 1:this.renderBitmap(o,r);break;case 2:this.renderText(o,r);break;case 3:this.renderGraphics(o,r);break;case 4:this.renderGroup(o,r);break;case 5:this.renderMesh(o,r);break;case 6:this.renderNormalBitmap(o,r)}r.$offsetX=0,r.$offsetY=0}if(c&&!a)return s;var l=t.$children;if(l)for(var h=l.length,u=0;h>u;u++){var d=l[u],f=void 0,p=void 0,v=void 0;1!=d.$alpha&&(v=r.globalAlpha,r.globalAlpha*=d.$alpha);var g=void 0;if(d.$useTranslate){var y=d.$getMatrix();f=i+d.$x,p=n+d.$y;var x=r.globalMatrix;g=e.Matrix.create(),g.a=x.a,g.b=x.b,g.c=x.c,g.d=x.d,g.tx=x.tx,g.ty=x.ty,r.transform(y.a,y.b,y.c,y.d,f,p),f=-d.$anchorOffsetX,p=-d.$anchorOffsetY}else f=i+d.$x-d.$anchorOffsetX,p=n+d.$y-d.$anchorOffsetY;switch(d.$renderMode){case 1:break;case 2:s+=this.drawWithFilter(d,r,f,p);break;case 3:s+=this.drawWithClip(d,r,f,p);break;case 4:s+=this.drawWithScrollRect(d,r,f,p);break;default:s+=this.drawDisplayObject(d,r,f,p)}if(v&&(r.globalAlpha=v),g){var y=r.globalMatrix;y.a=g.a,y.b=g.b,y.c=g.c,y.d=g.d,y.tx=g.tx,y.ty=g.ty,e.Matrix.release(g)}}return s},a.prototype.drawWithFilter=function(t,a,o,s){var c=0;if(t.$children&&0==t.$children.length&&(!t.$renderNode||0==t.$renderNode.$getRenderCount()))return c;var l,h=t.$filters,u=0!==t.$blendMode;u&&(l=r[t.$blendMode],l||(l=i));var d=t.$getOriginalBounds(),f=d.x,p=d.y,v=d.width,g=d.height;if(0>=v||0>=g)return c;if(!t.mask&&1==h.length&&("colorTransform"==h[0].type||"custom"===h[0].type&&0===h[0].padding)){var y=this.getRenderCount(t);if(!t.$children||1==y)return u&&a.context.setGlobalCompositeOperation(l),a.context.$filter=h[0],c+=t.$mask?this.drawWithClip(t,a,o,s):t.$scrollRect||t.$maskRect?this.drawWithScrollRect(t,a,o,s):this.drawDisplayObject(t,a,o,s),a.context.$filter=null,u&&a.context.setGlobalCompositeOperation(i),c}var x=this.createRenderBuffer(v,g);if(x.context.pushBuffer(x),c+=t.$mask?this.drawWithClip(t,x,-f,-p):t.$scrollRect||t.$maskRect?this.drawWithScrollRect(t,x,-f,-p):this.drawDisplayObject(t,x,-f,-p),x.context.popBuffer(),c>0){u&&a.context.setGlobalCompositeOperation(l),c++,a.$offsetX=o+f,a.$offsetY=s+p;var m=e.Matrix.create(),b=a.globalMatrix;m.a=b.a,m.b=b.b,m.c=b.c,m.d=b.d,m.tx=b.tx,m.ty=b.ty,a.useOffset(),a.context.drawTargetWidthFilters(h,x),b.a=m.a,b.b=m.b,b.c=m.c,b.d=m.d,b.tx=m.tx,b.ty=m.ty,e.Matrix.release(m),u&&a.context.setGlobalCompositeOperation(i)}return n.push(x),c},a.prototype.getRenderCount=function(e){var t=0,r=e.$getRenderNode();if(r&&(t+=r.$getRenderCount()),e.$children)for(var i=0,n=e.$children;i0)return 2;if(a.$children)t+=this.getRenderCount(a);else{var s=a.$getRenderNode();s&&(t+=s.$getRenderCount())}}return t},a.prototype.drawWithClip=function(t,a,o,s){var c,l=0,h=0!==t.$blendMode;h&&(c=r[t.$blendMode],c||(c=i));var u=t.$scrollRect?t.$scrollRect:t.$maskRect,d=t.$mask;if(d){var f=d.$getMatrix();if(0==f.a&&0==f.b||0==f.c&&0==f.d)return l}if(d||t.$children&&0!=t.$children.length){var p=t.$getOriginalBounds(),v=p.x,g=p.y,y=p.width,x=p.height,m=this.createRenderBuffer(y,x);if(m.context.pushBuffer(m),l+=this.drawDisplayObject(t,m,-v,-g),d){var b=this.createRenderBuffer(y,x);b.context.pushBuffer(b);var w=e.Matrix.create();w.copyFrom(d.$getConcatenatedMatrix()),d.$getConcatenatedMatrixAt(t,w),w.translate(-v,-g),b.setTransform(w.a,w.b,w.c,w.d,w.tx,w.ty),e.Matrix.release(w),l+=this.drawDisplayObject(d,b,0,0),b.context.popBuffer(),m.context.setGlobalCompositeOperation("destination-in"),m.setTransform(1,0,0,-1,0,b.height);var E=b.rootRenderTarget.width,T=b.rootRenderTarget.height;m.context.drawTexture(b.rootRenderTarget.texture,0,0,E,T,0,0,E,T,E,T),m.setTransform(1,0,0,1,0,0),m.context.setGlobalCompositeOperation("source-over"),b.setTransform(1,0,0,1,0,0),n.push(b)}if(m.context.setGlobalCompositeOperation(i),m.context.popBuffer(),l>0){l++,h&&a.context.setGlobalCompositeOperation(c),u&&a.context.pushMask(u.x+o,u.y+s,u.width,u.height);var _=e.Matrix.create(),S=a.globalMatrix;_.a=S.a,_.b=S.b,_.c=S.c,_.d=S.d,_.tx=S.tx,_.ty=S.ty,S.append(1,0,0,-1,o+v,s+g+m.height);var L=m.rootRenderTarget.width,C=m.rootRenderTarget.height;a.context.drawTexture(m.rootRenderTarget.texture,0,0,L,C,0,0,L,C,L,C),u&&m.context.popMask(),h&&a.context.setGlobalCompositeOperation(i);var R=a.globalMatrix;R.a=_.a,R.b=_.b,R.c=_.c,R.d=_.d,R.tx=_.tx,R.ty=_.ty,e.Matrix.release(_)}return n.push(m),l}return u&&a.context.pushMask(u.x+o,u.y+s,u.width,u.height),h&&a.context.setGlobalCompositeOperation(c),l+=this.drawDisplayObject(t,a,o,s),h&&a.context.setGlobalCompositeOperation(i),u&&a.context.popMask(),l},a.prototype.drawWithScrollRect=function(e,t,r,i){var n=0,a=e.$scrollRect?e.$scrollRect:e.$maskRect;if(a.isEmpty())return n;e.$scrollRect&&(r-=a.x,i-=a.y);var o=t.globalMatrix,s=t.context,c=!1;if(t.$hasScissor||0!=o.b||0!=o.c)t.context.pushMask(a.x+r,a.y+i,a.width,a.height);else{var l=o.a,h=o.d,u=o.tx,d=o.ty,f=a.x+r,p=a.y+i,v=f+a.width,g=p+a.height,y=void 0,x=void 0,m=void 0,b=void 0;if(1==l&&1==h)y=f+u,x=p+d,m=v+u,b=g+d;else{var w=l*f+u,E=h*p+d,T=l*v+u,_=h*p+d,S=l*v+u,L=h*g+d,C=l*f+u,R=h*g+d,A=0;w>T&&(A=w,w=T,T=A),S>C&&(A=S,S=C,C=A),y=S>w?w:S,m=T>C?T:C,E>_&&(A=E,E=_,_=A),L>R&&(A=L,L=R,R=A),x=L>E?E:L,b=_>R?_:R}s.enableScissor(y,-b+t.height,m-y,b-x),c=!0}return n+=this.drawDisplayObject(e,t,r,i),c?s.disableScissor():s.popMask(),n},a.prototype.drawNodeToBuffer=function(e,t,r,i){var n=t;n.context.pushBuffer(n),n.setTransform(r.a,r.b,r.c,r.d,r.tx,r.ty),this.renderNode(e,t,0,0,i),n.context.$drawWebGL(),n.onRenderFinish(),n.context.popBuffer()},a.prototype.drawDisplayToBuffer=function(e,t,r){t.context.pushBuffer(t),r&&t.setTransform(r.a,r.b,r.c,r.d,r.tx,r.ty);var i;i=e.$renderDirty?e.$getRenderNode():e.$renderNode;var n=0;if(i)switch(n++,i.type){case 1:this.renderBitmap(i,t);break;case 2:this.renderText(i,t);break;case 3:this.renderGraphics(i,t);break;case 4:this.renderGroup(i,t);break;case 5:this.renderMesh(i,t);break;case 6:this.renderNormalBitmap(i,t)}var a=e.$children;if(a)for(var o=a.length,s=0;o>s;s++){var c=a[s];switch(c.$renderMode){case 1:break;case 2:n+=this.drawWithFilter(c,t,0,0);break;case 3:n+=this.drawWithClip(c,t,0,0);break;case 4:n+=this.drawWithScrollRect(c,t,0,0); -break;default:n+=this.drawDisplayObject(c,t,0,0)}}return t.context.$drawWebGL(),t.onRenderFinish(),t.context.popBuffer(),n},a.prototype.renderNode=function(e,t,r,i,n){switch(t.$offsetX=r,t.$offsetY=i,e.type){case 1:this.renderBitmap(e,t);break;case 2:this.renderText(e,t);break;case 3:this.renderGraphics(e,t,n);break;case 4:this.renderGroup(e,t);break;case 5:this.renderMesh(e,t);break;case 6:this.renderNormalBitmap(e,t)}},a.prototype.renderNormalBitmap=function(e,t){var r=e.image;r&&t.context.drawImage(r,e.sourceX,e.sourceY,e.sourceW,e.sourceH,e.drawX,e.drawY,e.drawW,e.drawH,e.imageWidth,e.imageHeight,e.rotated,e.smoothing)},a.prototype.renderBitmap=function(t,n){var a=t.image;if(a){var o,s,c,l=t.drawData,h=l.length,u=0,d=t.matrix,f=t.blendMode,p=t.alpha;if(d){o=e.Matrix.create();var v=n.globalMatrix;o.a=v.a,o.b=v.b,o.c=v.c,o.d=v.d,o.tx=v.tx,o.ty=v.ty,s=n.$offsetX,c=n.$offsetY,n.useOffset(),n.transform(d.a,d.b,d.c,d.d,d.tx,d.ty)}f&&n.context.setGlobalCompositeOperation(r[f]);var g;if(p==p&&(g=n.globalAlpha,n.globalAlpha*=p),t.filter){for(n.context.$filter=t.filter;h>u;)n.context.drawImage(a,l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],t.imageWidth,t.imageHeight,t.rotated,t.smoothing);n.context.$filter=null}else for(;h>u;)n.context.drawImage(a,l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],t.imageWidth,t.imageHeight,t.rotated,t.smoothing);if(f&&n.context.setGlobalCompositeOperation(i),p==p&&(n.globalAlpha=g),d){var y=n.globalMatrix;y.a=o.a,y.b=o.b,y.c=o.c,y.d=o.d,y.tx=o.tx,y.ty=o.ty,n.$offsetX=s,n.$offsetY=c,e.Matrix.release(o)}}},a.prototype.renderMesh=function(t,n){var a,o,s,c=t.image,l=t.drawData,h=l.length,u=0,d=t.matrix,f=t.blendMode,p=t.alpha;if(d){a=e.Matrix.create();var v=n.globalMatrix;a.a=v.a,a.b=v.b,a.c=v.c,a.d=v.d,a.tx=v.tx,a.ty=v.ty,o=n.$offsetX,s=n.$offsetY,n.useOffset(),n.transform(d.a,d.b,d.c,d.d,d.tx,d.ty)}f&&n.context.setGlobalCompositeOperation(r[f]);var g;if(p==p&&(g=n.globalAlpha,n.globalAlpha*=p),t.filter){for(n.context.$filter=t.filter;h>u;)n.context.drawMesh(c,l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],t.imageWidth,t.imageHeight,t.uvs,t.vertices,t.indices,t.bounds,t.rotated,t.smoothing);n.context.$filter=null}else for(;h>u;)n.context.drawMesh(c,l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],t.imageWidth,t.imageHeight,t.uvs,t.vertices,t.indices,t.bounds,t.rotated,t.smoothing);if(f&&n.context.setGlobalCompositeOperation(i),p==p&&(n.globalAlpha=g),d){var y=n.globalMatrix;y.a=a.a,y.b=a.b,y.c=a.c,y.d=a.d,y.tx=a.tx,y.ty=a.ty,n.$offsetX=o,n.$offsetY=s,e.Matrix.release(a)}},a.prototype.renderText=function(r,i){var n=r.width-r.x,a=r.height-r.y;if(!(0>=n||0>=a)&&n&&a&&0!=r.drawData.length){var o=e.sys.DisplayList.$canvasScaleX,s=e.sys.DisplayList.$canvasScaleY,c=i.context.$maxTextureSize;n*o>c&&(o*=c/(n*o)),a*s>c&&(s*=c/(a*s)),n*=o,a*=s;var l=r.x*o,h=r.y*s;if((r.$canvasScaleX!=o||r.$canvasScaleY!=s)&&(r.$canvasScaleX=o,r.$canvasScaleY=s,r.dirtyRender=!0),this.canvasRenderBuffer&&this.canvasRenderBuffer.context?r.dirtyRender&&this.canvasRenderBuffer.resize(n,a):(this.canvasRenderer=new e.CanvasRenderer,this.canvasRenderBuffer=new t.CanvasRenderBuffer(n,a)),this.canvasRenderBuffer.context){if((1!=o||1!=s)&&this.canvasRenderBuffer.context.setTransform(o,0,0,s,0,0),l||h?(r.dirtyRender&&this.canvasRenderBuffer.context.setTransform(o,0,0,s,-l,-h),i.transform(1,0,0,1,l/o,h/s)):(1!=o||1!=s)&&this.canvasRenderBuffer.context.setTransform(o,0,0,s,0,0),r.dirtyRender){var u=this.canvasRenderBuffer.surface;this.canvasRenderer.renderText(r,this.canvasRenderBuffer.context);var d=r.$texture;d?i.context.updateTexture(d,u):(d=i.context.createTexture(u),r.$texture=d),r.$textureWidth=u.width,r.$textureHeight=u.height}var f=r.$textureWidth,p=r.$textureHeight;i.context.drawTexture(r.$texture,0,0,f,p,0,0,f/o,p/s,f,p),(l||h)&&(r.dirtyRender&&this.canvasRenderBuffer.context.setTransform(o,0,0,s,0,0),i.transform(1,0,0,1,-l/o,-h/s)),r.dirtyRender=!1}}},a.prototype.renderGraphics=function(r,i,n){var a=r.width,o=r.height;if(!(0>=a||0>=o)&&a&&o&&0!=r.drawData.length){var s=e.sys.DisplayList.$canvasScaleX,c=e.sys.DisplayList.$canvasScaleY;(1>a*s||1>o*c)&&(s=c=1),(r.$canvasScaleX!=s||r.$canvasScaleY!=c)&&(r.$canvasScaleX=s,r.$canvasScaleY=c,r.dirtyRender=!0),a*=s,o*=c;var l=Math.ceil(a),h=Math.ceil(o);if(s*=l/a,c*=h/o,a=l,o=h,this.canvasRenderBuffer&&this.canvasRenderBuffer.context?(r.dirtyRender||n)&&this.canvasRenderBuffer.resize(a,o):(this.canvasRenderer=new e.CanvasRenderer,this.canvasRenderBuffer=new t.CanvasRenderBuffer(a,o)),this.canvasRenderBuffer.context){(1!=s||1!=c)&&this.canvasRenderBuffer.context.setTransform(s,0,0,c,0,0),(r.x||r.y)&&((r.dirtyRender||n)&&this.canvasRenderBuffer.context.translate(-r.x,-r.y),i.transform(1,0,0,1,r.x,r.y));var u=this.canvasRenderBuffer.surface;if(n){this.canvasRenderer.renderGraphics(r,this.canvasRenderBuffer.context,!0),e.WebGLUtils.deleteWebGLTexture(u);var d=i.context.getWebGLTexture(u);i.context.drawTexture(d,0,0,a,o,0,0,a,o,u.width,u.height)}else{if(r.dirtyRender){this.canvasRenderer.renderGraphics(r,this.canvasRenderBuffer.context);var d=r.$texture;d?i.context.updateTexture(d,u):(d=i.context.createTexture(u),r.$texture=d),r.$textureWidth=u.width,r.$textureHeight=u.height}var f=r.$textureWidth,p=r.$textureHeight;i.context.drawTexture(r.$texture,0,0,f,p,0,0,f/s,p/c,f,p)}(r.x||r.y)&&((r.dirtyRender||n)&&this.canvasRenderBuffer.context.translate(r.x,r.y),i.transform(1,0,0,1,-r.x,-r.y)),n||(r.dirtyRender=!1)}}},a.prototype.renderGroup=function(t,r){var i,n,a,o=t.matrix;if(o){i=e.Matrix.create();var s=r.globalMatrix;i.a=s.a,i.b=s.b,i.c=s.c,i.d=s.d,i.tx=s.tx,i.ty=s.ty,n=r.$offsetX,a=r.$offsetY,r.useOffset(),r.transform(o.a,o.b,o.c,o.d,o.tx,o.ty)}for(var c=t.drawData,l=c.length,h=0;l>h;h++){var u=c[h];this.renderNode(u,r,r.$offsetX,r.$offsetY)}if(o){var d=r.globalMatrix;d.a=i.a,d.b=i.b,d.c=i.c,d.d=i.d,d.tx=i.tx,d.ty=i.ty,r.$offsetX=n,r.$offsetY=a,e.Matrix.release(i)}},a.prototype.createRenderBuffer=function(e,r){var i=n.pop();return i?i.resize(e,r):(i=new t.WebGLRenderBuffer(e,r),i.$computeDrawCall=!1),i},a}();t.WebGLRenderer=a,__reflect(a.prototype,"egret.web.WebGLRenderer",["egret.sys.SystemRenderer"])}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(e){var t;!function(e){e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.FLOAT=5126]="FLOAT",e[e.BYTE=65535]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT"}(t=e.WEBGL_ATTRIBUTE_TYPE||(e.WEBGL_ATTRIBUTE_TYPE={}));var r=function(){function e(e,t,r){this.gl=e,this.name=r.name,this.type=r.type,this.size=r.size,this.location=e.getAttribLocation(t,this.name),this.count=0,this.initCount(e),this.format=e.FLOAT,this.initFormat(e)}return e.prototype.initCount=function(e){var r=this.type;switch(r){case t.FLOAT:case t.BYTE:case t.UNSIGNED_BYTE:case t.UNSIGNED_SHORT:this.count=1;break;case t.FLOAT_VEC2:this.count=2;break;case t.FLOAT_VEC3:this.count=3;break;case t.FLOAT_VEC4:this.count=4}},e.prototype.initFormat=function(e){var r=this.type;switch(r){case t.FLOAT:case t.FLOAT_VEC2:case t.FLOAT_VEC3:case t.FLOAT_VEC4:this.format=e.FLOAT;break;case t.UNSIGNED_BYTE:this.format=e.UNSIGNED_BYTE;break;case t.UNSIGNED_SHORT:this.format=e.UNSIGNED_SHORT;break;case t.BYTE:this.format=e.BYTE}},e}();e.EgretWebGLAttribute=r,__reflect(r.prototype,"egret.web.EgretWebGLAttribute")}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(e){function t(e,t,r){var i=e.createShader(t);e.shaderSource(i,r),e.compileShader(i);var n=e.getShaderParameter(i,e.COMPILE_STATUS);return n||(console.log("shader not compiled!"),console.log(e.getShaderInfoLog(i))),i}function r(e,t,r){var i=e.createProgram();return e.attachShader(i,t),e.attachShader(i,r),e.linkProgram(i),i}function i(t,r){for(var i={},n=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES),a=0;n>a;a++){var o=t.getActiveAttrib(r,a),s=o.name,c=new e.EgretWebGLAttribute(t,r,o);i[s]=c}return i}function n(t,r){for(var i={},n=t.getProgramParameter(r,t.ACTIVE_UNIFORMS),a=0;n>a;a++){var o=t.getActiveUniform(r,a),s=o.name,c=new e.EgretWebGLUniform(t,r,o);i[s]=c}return i}var a=function(){function e(e,a,o){this.vshaderSource=a,this.fshaderSource=o,this.vertexShader=t(e,e.VERTEX_SHADER,this.vshaderSource),this.fragmentShader=t(e,e.FRAGMENT_SHADER,this.fshaderSource),this.id=r(e,this.vertexShader,this.fragmentShader),this.uniforms=n(e,this.id),this.attributes=i(e,this.id)}return e.getProgram=function(t,r,i,n){return this.programCache[n]||(this.programCache[n]=new e(t,r,i)),this.programCache[n]},e.deleteProgram=function(e,t,r,i){},e.programCache={},e}();e.EgretWebGLProgram=a,__reflect(a.prototype,"egret.web.EgretWebGLProgram")}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(e){var t;!function(e){e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D",e[e.SAMPLER_CUBE=35680]="SAMPLER_CUBE",e[e.BYTE=65535]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT"}(t=e.WEBGL_UNIFORM_TYPE||(e.WEBGL_UNIFORM_TYPE={}));var r=function(){function e(e,t,r){this.gl=e,this.name=r.name,this.type=r.type,this.size=r.size,this.location=e.getUniformLocation(t,this.name),this.setDefaultValue(),this.generateSetValue(),this.generateUpload()}return e.prototype.setDefaultValue=function(){var e=this.type;switch(e){case t.FLOAT:case t.SAMPLER_2D:case t.SAMPLER_CUBE:case t.BOOL:case t.INT:this.value=0;break;case t.FLOAT_VEC2:case t.BOOL_VEC2:case t.INT_VEC2:this.value=[0,0];break;case t.FLOAT_VEC3:case t.BOOL_VEC3:case t.INT_VEC3:this.value=[0,0,0];break;case t.FLOAT_VEC4:case t.BOOL_VEC4:case t.INT_VEC4:this.value=[0,0,0,0];break;case t.FLOAT_MAT2:this.value=new Float32Array([1,0,0,1]);break;case t.FLOAT_MAT3:this.value=new Float32Array([1,0,0,0,1,0,0,0,1]);break;case t.FLOAT_MAT4:this.value=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}},e.prototype.generateSetValue=function(){var e=this.type;switch(e){case t.FLOAT:case t.SAMPLER_2D:case t.SAMPLER_CUBE:case t.BOOL:case t.INT:this.setValue=function(e){var t=this.value!==e;this.value=e,t&&this.upload()};break;case t.FLOAT_VEC2:case t.BOOL_VEC2:case t.INT_VEC2:this.setValue=function(e){var t=this.value[0]!==e.x||this.value[1]!==e.y;this.value[0]=e.x,this.value[1]=e.y,t&&this.upload()};break;case t.FLOAT_VEC3:case t.BOOL_VEC3:case t.INT_VEC3:this.setValue=function(e){this.value[0]=e.x,this.value[1]=e.y,this.value[2]=e.z,this.upload()};break;case t.FLOAT_VEC4:case t.BOOL_VEC4:case t.INT_VEC4:this.setValue=function(e){this.value[0]=e.x,this.value[1]=e.y,this.value[2]=e.z,this.value[3]=e.w,this.upload()};break;case t.FLOAT_MAT2:case t.FLOAT_MAT3:case t.FLOAT_MAT4:this.setValue=function(e){this.value.set(e),this.upload()}}},e.prototype.generateUpload=function(){var e=this.gl,r=this.type,i=this.location;switch(r){case t.FLOAT:this.upload=function(){var t=this.value;e.uniform1f(i,t)};break;case t.FLOAT_VEC2:this.upload=function(){var t=this.value;e.uniform2f(i,t[0],t[1])};break;case t.FLOAT_VEC3:this.upload=function(){var t=this.value;e.uniform3f(i,t[0],t[1],t[2])};break;case t.FLOAT_VEC4:this.upload=function(){var t=this.value;e.uniform4f(i,t[0],t[1],t[2],t[3])};break;case t.SAMPLER_2D:case t.SAMPLER_CUBE:case t.BOOL:case t.INT:this.upload=function(){var t=this.value;e.uniform1i(i,t)};break;case t.BOOL_VEC2:case t.INT_VEC2:this.upload=function(){var t=this.value;e.uniform2i(i,t[0],t[1])};break;case t.BOOL_VEC3:case t.INT_VEC3:this.upload=function(){var t=this.value;e.uniform3i(i,t[0],t[1],t[2])};break;case t.BOOL_VEC4:case t.INT_VEC4:this.upload=function(){var t=this.value;e.uniform4i(i,t[0],t[1],t[2],t[3])};break;case t.FLOAT_MAT2:this.upload=function(){var t=this.value;e.uniformMatrix2fv(i,!1,t)};break;case t.FLOAT_MAT3:this.upload=function(){var t=this.value;e.uniformMatrix3fv(i,!1,t)};break;case t.FLOAT_MAT4:this.upload=function(){var t=this.value;e.uniformMatrix4fv(i,!1,t)}}},e}();e.EgretWebGLUniform=r,__reflect(r.prototype,"egret.web.EgretWebGLUniform")}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(e){var t=function(){function e(){}return e.blur_frag="precision mediump float;\nuniform vec2 blur;\nuniform sampler2D uSampler;\nvarying vec2 vTextureCoord;\nuniform vec2 uTextureSize;\nvoid main()\n{\n const int sampleRadius = 5;\n const int samples = sampleRadius * 2 + 1;\n vec2 blurUv = blur / uTextureSize;\n vec4 color = vec4(0, 0, 0, 0);\n vec2 uv = vec2(0.0, 0.0);\n blurUv /= float(sampleRadius);\n for (int i = -sampleRadius; i <= sampleRadius; i++) {\n uv.x = vTextureCoord.x + float(i) * blurUv.x;\n uv.y = vTextureCoord.y + float(i) * blurUv.y;\n color += texture2D(uSampler, uv);\n }\n color /= float(samples);\n gl_FragColor = color;\n}",e.colorTransform_frag="precision mediump float;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nuniform mat4 matrix;\nuniform vec4 colorAdd;\nuniform sampler2D uSampler;\nvoid main(void) {\n vec4 texColor = texture2D(uSampler, vTextureCoord);\n if(texColor.a > 0.) {\n texColor = vec4(texColor.rgb / texColor.a, texColor.a);\n }\n vec4 locColor = clamp(texColor * matrix + colorAdd, 0., 1.);\n gl_FragColor = vColor * vec4(locColor.rgb * locColor.a, locColor.a);\n}",e.default_vert="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec2 aColor;\nuniform vec2 projectionVector;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nconst vec2 center = vec2(-1.0, 1.0);\nvoid main(void) {\n gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n vColor = vec4(aColor.x, aColor.x, aColor.x, aColor.x);\n}",e.glow_frag="precision highp float;\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float dist;\nuniform float angle;\nuniform vec4 color;\nuniform float alpha;\nuniform float blurX;\nuniform float blurY;\nuniform float strength;\nuniform float inner;\nuniform float knockout;\nuniform float hideObject;\nuniform vec2 uTextureSize;\nfloat random(vec2 scale)\n{\n return fract(sin(dot(gl_FragCoord.xy, scale)) * 43758.5453);\n}\nvoid main(void) {\n vec2 px = vec2(1.0 / uTextureSize.x, 1.0 / uTextureSize.y);\n const float linearSamplingTimes = 7.0;\n const float circleSamplingTimes = 12.0;\n vec4 ownColor = texture2D(uSampler, vTextureCoord);\n vec4 curColor;\n float totalAlpha = 0.0;\n float maxTotalAlpha = 0.0;\n float curDistanceX = 0.0;\n float curDistanceY = 0.0;\n float offsetX = dist * cos(angle) * px.x;\n float offsetY = dist * sin(angle) * px.y;\n const float PI = 3.14159265358979323846264;\n float cosAngle;\n float sinAngle;\n float offset = PI * 2.0 / circleSamplingTimes * random(vec2(12.9898, 78.233));\n float stepX = blurX * px.x / linearSamplingTimes;\n float stepY = blurY * px.y / linearSamplingTimes;\n for (float a = 0.0; a <= PI * 2.0; a += PI * 2.0 / circleSamplingTimes) {\n cosAngle = cos(a + offset);\n sinAngle = sin(a + offset);\n for (float i = 1.0; i <= linearSamplingTimes; i++) {\n curDistanceX = i * stepX * cosAngle;\n curDistanceY = i * stepY * sinAngle;\n \n curColor = texture2D(uSampler, vec2(vTextureCoord.x + curDistanceX - offsetX, vTextureCoord.y + curDistanceY + offsetY));\n totalAlpha += (linearSamplingTimes - i) * curColor.a;\n maxTotalAlpha += (linearSamplingTimes - i);\n }\n }\n ownColor.a = max(ownColor.a, 0.0001);\n ownColor.rgb = ownColor.rgb / ownColor.a;\n float outerGlowAlpha = (totalAlpha / maxTotalAlpha) * strength * alpha * (1. - inner) * max(min(hideObject, knockout), 1. - ownColor.a);\n float innerGlowAlpha = ((maxTotalAlpha - totalAlpha) / maxTotalAlpha) * strength * alpha * inner * ownColor.a;\n ownColor.a = max(ownColor.a * knockout * (1. - hideObject), 0.0001);\n vec3 mix1 = mix(ownColor.rgb, color.rgb, innerGlowAlpha / (innerGlowAlpha + ownColor.a));\n vec3 mix2 = mix(mix1, color.rgb, outerGlowAlpha / (innerGlowAlpha + ownColor.a + outerGlowAlpha));\n float resultAlpha = min(ownColor.a + outerGlowAlpha + innerGlowAlpha, 1.);\n gl_FragColor = vec4(mix2 * resultAlpha, resultAlpha);\n}",e.primitive_frag="precision lowp float;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvoid main(void) {\n gl_FragColor = vColor;\n}",e.texture_frag="precision lowp float;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nuniform sampler2D uSampler;\nvoid main(void) {\n gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;\n}",e}();e.EgretShaderLib=t,__reflect(t.prototype,"egret.web.EgretShaderLib")}(t=e.web||(e.web={}))}(egret||(egret={})); \ No newline at end of file diff --git a/helloworld/libs/modules/game/game.d.ts b/helloworld/libs/modules/game/game.d.ts deleted file mode 100644 index fd2bcc8..0000000 --- a/helloworld/libs/modules/game/game.d.ts +++ /dev/null @@ -1,2482 +0,0 @@ -declare namespace egret { - /** - * The URLLoaderDataFormat class provides values that specify how downloaded data is received. - * @see http://edn.egret.com/cn/docs/page/600 Read different data format - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLLoaderDataFormat.ts - * @language en_US - */ - /** - * URLLoaderDataFormat 类提供了一些用于指定如何接收已下载数据的值。 - * @see http://edn.egret.com/cn/docs/page/600 读取不同数据格式 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLLoaderDataFormat.ts - * @language zh_CN - */ - class URLLoaderDataFormat { - /** - * Specify that downloaded data is received as raw binary data. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 指定以原始二进制数据形式接收下载的数据。 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - static BINARY: string; - /** - * Specify that downloaded data is received as text. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定以文本形式接收已下载的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TEXT: string; - /** - * Specify that downloaded data is received as URL-encoded variables. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定以 URL 编码变量形式接收下载的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static VARIABLES: string; - /** - * Specify that downloaded data is received as bitmap texture. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定以位图纹理形式接收已下载的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TEXTURE: string; - /** - * Specify that downloaded data is received as sound. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定以声音形式接收已下载的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static SOUND: string; - } -} -declare namespace egret { - /** - * @version Egret 2.4 - * @platform Web,Native - * @private - */ - class FrameLabel extends EventDispatcher { - /** - * @private - */ - private _name; - /** - * @private - */ - private _frame; - /** - * @private - */ - private _end; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(name: string, frame: number, end?: number); - /** - * Frame number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 标签名 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly name: string; - /** - * Frame serial number of the label - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 标签所在帧序号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly frame: number; - /** - * Frame serial number, the end of the label - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 标签对应的结束帧序号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly end: number; - /** - * Duplicate the current frame label object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 复制当前帧标签对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clone(): FrameLabel; - } -} -declare namespace egret { - /** - * @classdesc 使用 MovieClipData 类,您可以创建 MovieClip 对象和处理 MovieClip 对象的数据。MovieClipData 一般由MovieClipDataFactory生成 - * @see http://edn.egret.com/cn/docs/page/596 MovieClip序列帧动画 - * @version Egret 2.4 - * @platform Web,Native - */ - class MovieClipData extends HashObject { - /** - * @private - * MovieClip数据 - */ - $mcData: any; - /** - * 总帧数 - * @version Egret 2.4 - * @platform Web,Native - */ - numFrames: number; - /** - * 帧数据列表 - * @version Egret 2.4 - * @platform Web,Native - */ - frames: any[]; - /** - * 帧标签列表 - * @version Egret 2.4 - * @platform Web,Native - */ - labels: any[]; - /** - * 帧事件列表 - * @version Egret 2.4 - * @platform Web,Native - */ - events: any[]; - /** - * 帧率 - * @version Egret 2.4 - * @platform Web,Native - */ - frameRate: number; - /** - * 纹理数据 - * @version Egret 2.4 - * @platform Web,Native - */ - textureData: any; - /** - * 纹理集 - * @version Egret 2.4 - * @platform Web,Native - */ - spriteSheet: SpriteSheet; - /** - * 创建一个 egret.MovieClipData 对象 - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - /** - * @private - * - * @param mcData - * @param textureData - * @param spriteSheet - */ - $init(mcData: any, textureData: any, spriteSheet: SpriteSheet): void; - /** - * 根据指定帧序号获取该帧对应的关键帧数据 - * @param frame {number} 帧序号 - * @returns {any} 帧数据对象 - * @version Egret 2.4 - * @platform Web,Native - */ - getKeyFrameData(frame: number): any; - /** - * 根据指定帧序号获取该帧对应的Texture对象 - * @param frame {number} 帧序号 - * @returns {egret.Texture} Texture对象 - * @version Egret 2.4 - * @platform Web,Native - */ - getTextureByFrame(frame: number): Texture; - $getOffsetByFrame(frame: number, point: Point): void; - /** - * @private - * - * @param resName - * @returns - */ - private getTextureByResName(resName); - /** - * @private - * - * @returns - */ - $isDataValid(): boolean; - /** - * @private - * - * @returns - */ - $isTextureValid(): boolean; - /** - * @private - * - * @param mcData - */ - $fillMCData(mcData: any): void; - /** - * @private - * - * @param framesData - */ - private fillFramesData(framesData); - /** - * @private - * - * @param frameLabelsData - */ - private fillFrameLabelsData(frameLabelsData); - /** - * @private - * - * @param frameEventsData - */ - private fillFrameEventsData(frameEventsData); - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * MovieClip数据源 - */ - mcData: MovieClipData; - /** - * @private - * - * @param value - */ - private setMCData(value); - } -} -declare namespace egret { - /** - * @classdesc 使用 MovieClipDataFactory 类,可以生成 MovieClipData 对象用于创建MovieClip - * @see http://edn.egret.com/cn/docs/page/596 MovieClip序列帧动画 - * @version Egret 2.4 - * @platform Web,Native - */ - class MovieClipDataFactory extends EventDispatcher { - /** - * 是否开启缓存 - * @version Egret 2.4 - * @platform Web,Native - */ - enableCache: boolean; - /** - * @private - */ - $mcDataSet: any; - /** - * @private - */ - $spriteSheet: SpriteSheet; - /** - * @private - */ - $mcDataCache: any; - /** - * 创建一个 egret.MovieClipDataFactory 对象 - * @param movieClipDataSet {any} MovieClip数据集,该数据集必须由Egret官方工具生成 - * @param texture {Texture} 纹理 - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(movieClipDataSet?: any, texture?: Texture); - /** - * 清空缓存 - * @version Egret 2.4 - * @platform Web,Native - */ - clearCache(): void; - /** - * 根据名字生成一个MovieClipData实例。可以用于创建MovieClip。 - * @param movieClipName {string} MovieClip名字. 可选参数,默认为"", 相当于取第一个MovieClip数据 - * @returns {MovieClipData} 生成的MovieClipData对象 - * @version Egret 2.4 - * @platform Web,Native - */ - generateMovieClipData(movieClipName?: string): MovieClipData; - /** - * @private - * - * @param movieClipName - * @param cache - * @returns - */ - private findFromCache(movieClipName, cache); - /** - * @private - * - * @param movieClipName - * @param movieClip - * @param cache - */ - private fillData(movieClipName, movieClip, cache); - /** - * MovieClip数据集 - * @version Egret 2.4 - * @platform Web,Native - */ - mcDataSet: any; - /** - * MovieClip需要使用的纹理图 - */ - texture: Texture; - /** - * 由纹理图生成的精灵表 - * @version Egret 2.4 - * @platform Web,Native - */ - readonly spriteSheet: SpriteSheet; - /** - * @private - * - * @param value - */ - private setTexture(value); - } -} -declare namespace egret { - /** - * When the movieClip's current frame have a frameLabel, dispatches MovieClipEvent object. FrameLabel Event type: MovieClipEvent.FRAME_LABEL - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当动画的当前帧有事件,将调度 MovieClipEvent 对象。帧事件类型 MovieClipEvent.FRAME_LABEL. - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class MovieClipEvent extends Event { - /** - * TextEvent create an object that contains information about movieClip events. - * @param type Type of event, you can access the MovieClipEvent.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determine whether the Event object can be canceled. The default value is false. - * @param frameLabel When the current frame have a frameLabel, the event listeners can access this information through the frameLabel property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 MovieClipEvent 对象,其中包含有关帧事件的信息。 - * @param type 事件的类型,可以作为 MovieClipEvent.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param frameLabel 动画上的帧事件。事件侦听器可以通过 frameLabel 属性访问此信息。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, frameLabel?: string); - /** - * Dispatched whenever the current frame have a frameLabel. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 动画的当前帧上有事件时调度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static FRAME_LABEL: string; - /** - * In MovieClipEvent.FRAME_LABEL event, event corresponding string. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在 MovieClipEvent.FRAME_LABEL 事件中,event对应的字符串。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - frameLabel: string; - /** - * EventDispatcher object using the specified event object thrown MovieClipEvent. The objects will be thrown in the object cache pool for the next round robin. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param frameLabel MovieClipEvent object frameLabel - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出 MovieClipEvent 事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 派发事件目标 - * @param type 事件类型 - * @param frameLabel MovieClipEvent 对象的 frameLabel 赋值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchMovieClipEvent(target: IEventDispatcher, type: string, frameLabel?: string): boolean; - } -} -declare namespace egret { - /** - * @private - */ - class ScrollEase { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - /** - * - * @param amount - * @returns - * @version Egret 2.4 - * @platform Web,Native - */ - static get(amount: any): Function; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - static quintOut: Function; - /** - * - * @param pow - * @returns - * @version Egret 2.4 - * @platform Web,Native - */ - static getPowOut(pow: any): Function; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - static quartOut: Function; - } - /** - * @private - */ - class ScrollTween extends EventDispatcher { - /** - * @private - */ - private static _tweens; - /** - * @private - */ - private static IGNORE; - /** - * @private - */ - private static _plugins; - /** - * @private - */ - private static _inited; - /** - * @private - */ - private _target; - /** - * @private - */ - private _useTicks; - /** - * @private - */ - private ignoreGlobalPause; - /** - * @private - */ - private loop; - /** - * @private - */ - private pluginData; - /** - * @private - */ - private _curQueueProps; - /** - * @private - */ - private _initQueueProps; - /** - * @private - */ - private _steps; - /** - * @private - */ - private _actions; - /** - * @private - */ - private paused; - /** - * @private - */ - private duration; - /** - * @private - */ - private _prevPos; - /** - * @private - */ - private position; - /** - * @private - */ - private _prevPosition; - /** - * @private - */ - private _stepPosition; - /** - * @private - */ - private passive; - /** - * Activate an object and add a ScrollTween animation to the object - * @param target {any} The object to be activated - * @param props {any} Parameters, support loop onChange onChangeObj - * @param pluginData {any} Write realized - * @param override {boolean} Whether to remove the object before adding a tween, the default value false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 激活一个对象,对其添加 ScrollTween 动画 - * @param target {any} 要激活 ScrollTween 的对象 - * @param props {any} 参数,支持loop(循环播放) onChange(变化函数) onChangeObj(变化函数作用域) - * @param pluginData {any} 暂未实现 - * @param override {boolean} 是否移除对象之前添加的tween,默认值false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static get(target: any, props?: any, pluginData?: any, override?: boolean): ScrollTween; - /** - * Delete all ScrollTween animations from an object - * @param target The object whose ScrollTween to be deleted - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 删除一个对象上的全部 ScrollTween 动画 - * @param target 需要移除 ScrollTween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static removeTweens(target: any): void; - /** - * @private - * - * @param delta - * @param paused - */ - private static tick(timeStamp, paused?); - private static _lastTime; - /** - * @private - * - * @param tween - * @param value - */ - private static _register(tween, value); - /** - * 创建一个 egret.ScrollTween 对象 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(target: any, props: any, pluginData: any); - /** - * @private - * - * @param target - * @param props - * @param pluginData - */ - private initialize(target, props, pluginData); - /** - * @private - * - * @param value - * @param actionsMode - * @returns - */ - private setPosition(value, actionsMode?); - /** - * @private - * - * @param startPos - * @param endPos - * @param includeStart - */ - private _runActions(startPos, endPos, includeStart?); - /** - * @private - * - * @param step - * @param ratio - */ - private _updateTargetProps(step, ratio); - /** - * Whether setting is paused - * @param value {boolean} Whether to pause - * @returns ScrollTween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置是否暂停 - * @param value {boolean} 是否暂停 - * @returns Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setPaused(value: boolean): ScrollTween; - /** - * @private - * - * @param props - * @returns - */ - private _cloneProps(props); - /** - * @private - * - * @param o - * @returns - */ - private _addStep(o); - /** - * @private - * - * @param o - * @returns - */ - private _appendQueueProps(o); - /** - * @private - * - * @param o - * @returns - */ - private _addAction(o); - /** - * Modify the property of the specified display object to a specified value - * @param props {Object} Property set of an object - * @param duration {number} Duration - * @param ease {egret.ScrollEase} Easing algorithm - * @returns {egret.ScrollTween} ScrollTween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定显示对象的属性修改为指定值 - * @param props {Object} 对象的属性集合 - * @param duration {number} 持续时间 - * @param ease {egret.ScrollEase} 缓动算法 - * @returns {egret.ScrollTween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - to(props: any, duration?: number, ease?: Function): ScrollTween; - /** - * Execute callback function - * @param callback {Function} Callback method - * @param thisObj {any} this action scope of the callback method - * @param params {any[]} Parameter of the callback method - * @returns {egret.ScrollTween} ScrollTween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 执行回调函数 - * @param callback {Function} 回调方法 - * @param thisObj {any} 回调方法this作用域 - * @param params {any[]} 回调方法参数 - * @returns {egret.ScrollTween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - call(callback: Function, thisObj?: any, params?: any[]): ScrollTween; - /** - * @method egret.ScrollTween#tick - * @param delta {number} - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - tick(delta: number): void; - } -} -declare namespace egret { - /** - * ScrollView auxiliary classes for slides, you will pass a display object constructor. It can display more than the range display object within the specified size range. And can easily drag in this range. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/display/ScrollView.ts - * @language en_US - */ - /** - * ScrollView 是用于滑动的辅助类,将一个显示对象传入构造函数即可。可以在指定的尺寸范围内显示超过该范围的显示对象。并可以在此范围内随意拖动。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/display/ScrollView.ts - * @language zh_CN - */ - class ScrollView extends DisplayObjectContainer { - /** - * @private - */ - _ScrV_Props_: ScrollViewProperties; - /** - * Start rolling threshold when the touch point from the initial touch point at a distance exceeding this value will trigger roll - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 开始滚动的阈值,当触摸点偏离初始触摸点的距离超过这个值时才会触发滚动 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scrollBeginThreshold: number; - /** - * Scrolling speed, the speed is required and the default speed ratio. - * The range of scrollSpeed> 0 assigned to 2:00, the speed is 2 times the default speed - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 滚动速度,这个值为需要的速度与默认速度的比值。 - * 取值范围为 scrollSpeed > 0 赋值为 2 时,速度是默认速度的 2 倍 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scrollSpeed: number; - /** - * Whether to enable rebound, rebound When enabled, ScrollView contents allowed to continue to drag the border after arriving at the end user drag operation, and then bounce back boundary position - * @default true - * @version Egret 2.4 - * @language en_US - */ - /** - * 是否启用回弹,当启用回弹后,ScrollView中内容在到达边界后允许继续拖动,在用户拖动操作结束后,再反弹回边界位置 - * @default true - * @version Egret 2.4 - * @language zh_CN - */ - bounces: boolean; - /** - * Create a egret.ScrollView objects - * @param content {egret.DisplayObject} You need to scroll object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.ScrollView 对象 - * @param content {egret.DisplayObject} 需要滚动的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(content?: DisplayObject); - /** - * @private - */ - _content: DisplayObject; - /** - * Set to scroll object - * @param content {egret.DisplayObject} You need to scroll object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置需要滚动的对象 - * @param content {egret.DisplayObject} 需要滚动的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setContent(content: DisplayObject): void; - /** - * Remove rolling objects - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 移除滚动的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - removeContent(): void; - /** - * Vertical scroll bar display policy, on / off / auto. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 垂直滚动条显示策略,on/off/auto。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - verticalScrollPolicy: string; - /** - * The horizontal scroll bar display policy, on / off / auto. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 水平滚动条显示策略,on/off/auto。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - horizontalScrollPolicy: string; - /** - * Gets or sets the horizontal scroll position - * @returns {number} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取或设置水平滚动位置, - * @returns {number} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scrollLeft: number; - /** - * Gets or sets the vertical scroll position - * @returns {number} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取或设置垂直滚动位置, - * @returns {number} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scrollTop: number; - /** - * Set scroll position - * @param top {number} The vertical scroll position - * @param left {number} The horizontal scroll position - * @param isOffset {boolean} Optional parameter, the default is false, whether it is the amount of scrolling increase as top = 1 on behalf of one pixel scroll up - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置滚动位置 - * @param top {number} 垂直滚动位置 - * @param left {number} 水平滚动位置 - * @param isOffset {boolean} 可选参数,默认是false,是否是滚动增加量,如 top=1 代表往上滚动1像素 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setScrollPosition(top: number, left: number, isOffset?: boolean): void; - /** - * @private - * - * @param top - * @param left - */ - private _validatePosition(top?, left?); - /** - * @private - * @inheritDoc - */ - $setWidth(value: number): void; - /** - * @private - * @inheritDoc - */ - $setHeight(value: number): void; - /** - * @private - * - */ - _updateContentPosition(): void; - /** - * @private - * - * @returns - */ - _checkScrollPolicy(): boolean; - /** - * @private - * - * @param policy - * @param contentLength - * @param viewLength - * @returns - */ - private __checkScrollPolicy(policy, contentLength, viewLength); - /** - * @private - * - * @returns - */ - _addEvents(): void; - /** - * @private - * - * @returns - */ - _removeEvents(): void; - private _tempStage; - /** - * @private - * - * @param e - */ - _onTouchBegin(e: TouchEvent): void; - /** - * @private - */ - private delayTouchBeginEvent; - /** - * @private - */ - private touchBeginTimer; - /** - * @private - * - * @param event - */ - _onTouchBeginCapture(event: TouchEvent): void; - /** - * @private - * - * @param event - * @returns - */ - private _onTouchEndCapture(event); - /** - * @private - * - */ - private _onTouchBeginTimer(); - /** - * @private - * - * @param event - * @returns - */ - private dispatchPropagationEvent(event); - /** - * @private - * - * @param event - * @returns - */ - _onTouchMove(event: TouchEvent): void; - /** - * @private - * - * @param event - * @returns - */ - _onTouchEnd(event: TouchEvent): void; - /** - * @private - * - * @param event - * @returns - */ - _onEnterFrame(event: Event): void; - /** - * @private - * - * @param e - * @returns - */ - private _logTouchEvent(e); - /** - * @private - * - * @param e - * @returns - */ - private _getPointChange(e); - /** - * @private - * - * @param e - * @returns - */ - private _calcVelocitys(e); - /** - * @private - * - * @returns - */ - _getContentWidth(): number; - /** - * @private - * - * @returns - */ - _getContentHeight(): number; - /** - * The left side of the maximum distance - * @returns The left side of the maximum distance - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 距离左侧的最大值 - * @returns 距离左侧最大值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getMaxScrollLeft(): number; - /** - * Above the maximum distance - * @returns Above the maximum distance - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 距离上方最大值 - * @returns 距离上方最大值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getMaxScrollTop(): number; - /** - * @private - */ - private static weight; - /** - * @private - * - */ - private _moveAfterTouchEnd(); - /** - * @private - * - * @param tw - */ - private onTweenFinished(tw); - /** - * @private - * - * @returns - */ - _onScrollStarted(): void; - /** - * @private - * - * @returns - */ - _onScrollFinished(): void; - /** - * Set the scroll position above the distance - * @param scrollTop Position above distance - * @param duration Easing of time, in milliseconds - * @returns Get tween vertical scrolling - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置滚动距离上方的位置 - * @param scrollTop 距离上方的位置 - * @param duration 缓动时间,毫秒单位 - * @returns 获取垂直滚动的tween - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setScrollTop(scrollTop: number, duration?: number): void; - /** - * Set the scroll position from the left side - * @param scrollLeft From the position on the left side - * @param duration Get tween vertical scrolling - * @returns Gets the horizontal scroll tween - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置滚动距离左侧的位置 - * @param scrollLeft 距离左侧的位置 - * @param duration 缓动时间,毫秒单位 - * @returns 获取水平滚动的tween - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setScrollLeft(scrollLeft: number, duration?: number): void; - /** - * @private - * - * @param pixelsPerMS - * @param curPos - * @param maxPos - * @returns - */ - private getAnimationDatas(pixelsPerMS, curPos, maxPos); - /** - * @private - * - * @param event - * @returns - */ - private cloneTouchEvent(event); - /** - * @private - * - * @returns - */ - private throwNotSupportedError(); - /** - * @deprecated - * @inheritDoc - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - addChild(child: DisplayObject): DisplayObject; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - addChildAt(child: DisplayObject, index: number): DisplayObject; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - removeChild(child: DisplayObject): DisplayObject; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - removeChildAt(index: number): DisplayObject; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - setChildIndex(child: DisplayObject, index: number): void; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - swapChildren(child1: DisplayObject, child2: DisplayObject): void; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - swapChildrenAt(index1: number, index2: number): void; - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - class ScrollViewProperties { - /** - * @private - */ - _verticalScrollPolicy: string; - /** - * @private - */ - _horizontalScrollPolicy: string; - /** - * @private - */ - _scrollLeft: number; - /** - * @private - */ - _scrollTop: number; - /** - * @private - */ - _hCanScroll: boolean; - /** - * @private - */ - _vCanScroll: boolean; - /** - * @private - */ - _lastTouchPosition: egret.Point; - /** - * @private - */ - _touchStartPosition: egret.Point; - /** - * @private - */ - _scrollStarted: boolean; - /** - * @private - */ - _lastTouchTime: number; - /** - * @private - */ - _lastTouchEvent: TouchEvent; - /** - * @private - */ - _velocitys: Array<{ - x: number; - y: number; - }>; - /** - * @private - */ - _isHTweenPlaying: boolean; - /** - * @private - */ - _isVTweenPlaying: boolean; - /** - * @private - */ - _hScrollTween: ScrollTween; - /** - * @private - */ - _vScrollTween: ScrollTween; - /** - * @private - */ - _bounces: boolean; - } -} -declare namespace egret { - /** - * UThe URLLoader class downloads data from a URL as text, binary data, or URL-encoded variables. It is useful for downloading text files, XML, or other information to be used in a dynamic, data-driven application. - * A URLLoader object downloads all of the data from a URL before making it available to code in the applications. It sends out notifications about the progress of the download, - * which you can monitor through bytesLoaded and bytesTotal properties, as well as through dispatched events. - * @see http://edn.egret.com/cn/docs/page/601 Build communication request - * @event egret.Event.COMPLETE Dispatched when the net request is complete. - * @event egret.IOErrorEvent.IO_ERROR io error. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLLoader.ts - * @language en_US - */ - /** - * URLLoader 类以文本、二进制数据或 URL 编码变量的形式从 URL 下载数据。在下载文本文件、XML 或其他用于动态数据驱动应用程序的信息时,它很有用。 - * URLLoader 对象会先从 URL 中下载所有数据,然后才将数据用于应用程序中的代码。它会发出有关下载进度的通知, - * 通过 bytesLoaded 和 bytesTotal 属性以及已调度的事件,可以监视下载进度。 - * @see http://edn.egret.com/cn/docs/page/601 构建通信请求 - * @event egret.Event.COMPLETE 加载完成后调度。 - * @event egret.IOErrorEvent.IO_ERROR 加载错误后调度。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLLoader.ts - * @language zh_CN - */ - class URLLoader extends EventDispatcher { - /** - * Create an egret.URLLoader object - * @param request {URLRequest} A URLRequest object specifies the URL to be downloaded. - * If this parameter is omitted, no load operation begins. If a parameter is specified, the load operation begins immediately - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建 egret.URLLoader 对象 - * @param request {URLRequest} 一个 URLRequest 对象,指定要下载的 URL。 - * 如果省略该参数,则不开始加载操作。如果已指定参数,则立即开始加载操作 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(request?: URLRequest); - /** - * Control whether the downloaded data is received as text (URLLoaderDataFormat.TEXT), raw binary data (URLLoaderDataFormat.BINARY), or URL-encoded variables (URLLoaderDataFormat.VARIABLES). - * If the value of the dataFormat property is URLLoaderDataFormat.TEXT, the received data is a string containing the text of the loaded file. - * If the value of the dataFormat property is URLLoaderDataFormat.BINARY, the received data is a ByteArray object containing the raw binary data. - * If the value of the dataFormat property is URLLoaderDataFormat.TEXTURE, the received data is a Texture object containing the bitmap data. - * If the value of the dataFormat property is URLLoaderDataFormat.VARIABLES, the received data is a URLVariables object containing the URL-encoded variables. - * The default value is URLLoaderDataFormat.TEXT. - * @default egret.URLLoaderDataFormat.TEXT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 控制是以文本 (URLLoaderDataFormat.TEXT)、原始二进制数据 (URLLoaderDataFormat.BINARY) 还是 URL 编码变量 (URLLoaderDataFormat.VARIABLES) 接收下载的数据。 - * 如果 dataFormat 属性的值是 URLLoaderDataFormat.TEXT,则所接收的数据是一个包含已加载文件文本的字符串。 - * 如果 dataFormat 属性的值是 URLLoaderDataFormat.BINARY,则所接收的数据是一个包含原始二进制数据的 ByteArray 对象。 - * 如果 dataFormat 属性的值是 URLLoaderDataFormat.TEXTURE,则所接收的数据是一个包含位图数据的Texture对象。 - * 如果 dataFormat 属性的值是 URLLoaderDataFormat.VARIABLES,则所接收的数据是一个包含 URL 编码变量的 URLVariables 对象。 - * @default egret.URLLoaderDataFormat.TEXT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dataFormat: string; - /** - * The data received from the load operation. This property is populated only when the load operation is complete. The format of the data depends on the setting of the dataFormat property: - * If the dataFormat property is URLLoaderDataFormat.TEXT, the received data is a string containing the text of the loaded file. - * If the dataFormat property is URLLoaderDataFormat.BINARY, the received data is a ByteArray object containing the raw binary data. - * If the dataFormat property is URLLoaderDataFormat.TEXTURE, the received data is a Texture object containing the bitmap data. - * If the dataFormat property is URLLoaderDataFormat.VARIABLES, the received data is a URLVariables object containing the URL-encoded variables. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从加载操作接收的数据。只有完成加载操作时,才会填充该属性。该数据的格式取决于 dataFormat 属性的设置: - * 如果 dataFormat 属性是 URLLoaderDataFormat.TEXT,则所接收的数据是一个包含已加载文件文本的字符串。 - * 如果 dataFormat 属性是 URLLoaderDataFormat.BINARY,则所接收的数据是一个包含原始二进制数据的 ByteArray 对象。 - * 如果 dataFormat 属性是 URLLoaderDataFormat.TEXTURE,则所接收的数据是一个包含位图数据的Texture对象。 - * 如果 dataFormat 属性是 URLLoaderDataFormat.VARIABLES,则所接收的数据是一个包含 URL 编码变量的 URLVariables 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - data: any; - /** - * @private - */ - _request: URLRequest; - /** - * Send and load data from the specified URL. The data can be received as text, raw binary data, or URL-encoded variables, depending on the value you set for the dataFormat property. - * Note that the default value of the dataFormat property is text. If you want to send data to the specified URL, you can set the data property in the URLRequest object. - * @param request {URLRequest} A URLRequest object specifies the URL to be downloaded. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从指定的 URL 发送和加载数据。可以以文本、原始二进制数据或 URL 编码变量格式接收数据,这取决于为 dataFormat 属性所设置的值。 - * 请注意 dataFormat 属性的默认值为文本。如果想将数据发送至指定的 URL,则可以在 URLRequest 对象中设置 data 属性。 - * @param request {URLRequest} 一个 URLRequest 对象,指定要下载的 URL。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - load(request: URLRequest): void; - private getResponseType(dataFormat); - /** - * @private - * - * @param loader - */ - private loadSound(loader); - /** - * @private - * - * @param loader - */ - private loadTexture(loader); - /** - * @private - */ - _status: number; - /** - * @private - * - */ - __recycle(): void; - } -} -declare namespace egret { - /** - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/display/MovieClip.ts - * @language en_US - */ - /** - * 影片剪辑,可以通过影片剪辑播放序列帧动画。MovieClip 类从以下类继承而来:DisplayObject 和 EventDispatcher。不同于 DisplayObject 对象,MovieClip 对象拥有一个时间轴。 - * @extends egret.DisplayObject - * @event egret.Event.COMPLETE 动画播放完成。 - * @event egret.Event.LOOP_COMPLETE 动画循环播放完成。循环最后一次只派发 COMPLETE 事件,不派发 LOOP_COMPLETE 事件。 - * @see http://edn.egret.com/cn/docs/page/596 MovieClip序列帧动画 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/display/MovieClip.ts - * @language zh_CN - */ - class MovieClip extends DisplayObject { - $texture: Texture; - private offsetPoint; - $movieClipData: MovieClipData; - /** - * @private - */ - private frames; - /** - * @private - */ - $totalFrames: number; - /** - * @version Egret 2.4 - * @platform Web,Native - * @private - */ - frameLabels: any[]; - /** - * @private - */ - $frameLabelStart: number; - /** - * @private - */ - $frameLabelEnd: number; - /** - * @version Egret 2.4 - * @platform Web,Native - * @private - */ - frameEvents: any[]; - /** - * @private - */ - private frameIntervalTime; - /** - * @private - */ - $eventPool: string[]; - $isPlaying: boolean; - /** - * @private - */ - private isStopped; - /** - * @private - */ - private playTimes; - /** - * @private - */ - $currentFrameNum: number; - /** - * @private - */ - $nextFrameNum: number; - /** - * @private - */ - private displayedKeyFrameNum; - /** - * @private - */ - private passedTime; - /** - * @private - */ - private $frameRate; - /** - * 创建新的 MovieClip 实例。创建 MovieClip 之后,调用舞台上的显示对象容器的addElement方法。 - * @param movieClipData {movieClipData} 被引用的 movieClipData 对象 - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(movieClipData?: MovieClipData); - protected createNativeDisplayObject(): void; - /** - * @private - */ - $smoothing: boolean; - /** - * Whether or not is smoothed when scaled. - * @version Egret 3.0 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否进行平滑处理。 - * @version Egret 3.0 - * @platform Web - * @language zh_CN - */ - smoothing: boolean; - /** - * @private - * - */ - $init(): void; - /** - * @private - * - */ - $reset(): void; - /** - * @private - * - */ - private _initFrame(); - /** - * @private - */ - $updateRenderNode(): void; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - /** - * @private - * - * @param stage - * @param nestLevel - */ - $onAddToStage(stage: Stage, nestLevel: number): void; - /** - * @private - * - */ - $onRemoveFromStage(): void; - /** - * @private - * 返回帧标签为指定字符串的FrameLabel对象 - * @param labelName {string} 帧标签名 - * @param ignoreCase {boolean} 是否忽略大小写,可选参数,默认false - * @returns {egret.FrameLabel} FrameLabel对象 - */ - private getFrameLabelByName(labelName, ignoreCase?); - /** - * @private - * 根据帧标签,设置开始和结束的帧数 - * @param labelName {string} 帧标签名 - */ - private getFrameStartEnd(labelName); - /** - * @private - * 返回指定序号的帧的FrameLabel对象 - * @param frame {number} 帧序号 - * @returns {egret.FrameLabel} FrameLabel对象 - */ - private getFrameLabelByFrame(frame); - /** - * @private - * 返回指定序号的帧对应的FrameLabel对象,如果当前帧没有标签,则返回前面最近的有标签的帧的FrameLabel对象 - * @method egret.MovieClip#getFrameLabelForFrame - * @param frame {number} 帧序号 - * @returns {egret.FrameLabel} FrameLabel对象 - */ - private getFrameLabelForFrame(frame); - /** - * 继续播放当前动画 - * @param playTimes {number} 播放次数。 参数为整数,可选参数,>=1:设定播放次数,<0:循环播放,默认值 0:不改变播放次数(MovieClip初始播放次数设置为1), - * @version Egret 2.4 - * @platform Web,Native - */ - play(playTimes?: number): void; - /** - * 暂停播放动画 - * @version Egret 2.4 - * @platform Web,Native - */ - stop(): void; - /** - * 将播放头移到前一帧并停止 - * @version Egret 2.4 - * @platform Web,Native - */ - prevFrame(): void; - /** - * 跳到后一帧并停止 - * @version Egret 2.4 - * @platform Web,Native - */ - nextFrame(): void; - /** - * 将播放头移到指定帧并播放 - * @param frame {any} 指定帧的帧号或帧标签 - * @param playTimes {number} 播放次数。 参数为整数,可选参数,>=1:设定播放次数,<0:循环播放,默认值 0:不改变播放次数, - * @version Egret 2.4 - * @platform Web,Native - */ - gotoAndPlay(frame: string | number, playTimes?: number): void; - /** - * 将播放头移到指定帧并停止 - * @param frame {any} 指定帧的帧号或帧标签 - * @version Egret 2.4 - * @platform Web,Native - */ - gotoAndStop(frame: string | number): void; - /** - * @private - * - * @param frame - */ - private gotoFrame(frame); - /** - * @private - */ - private lastTime; - /** - * @private - * - * @param advancedTime - * @returns - */ - private advanceTime(timeStamp); - /** - * @private - * - */ - private advanceFrame(); - /** - * @private - * - */ - private constructFrame(); - /** - * @private - * - */ - $renderFrame(): void; - /** - * @private - * - */ - private handlePendingEvent(); - /** - * MovieClip 实例中帧的总数 - * @version Egret 2.4 - * @platform Web,Native - */ - readonly totalFrames: number; - /** - * MovieClip 实例当前播放的帧的序号 - * @version Egret 2.4 - * @platform Web,Native - */ - readonly currentFrame: number; - /** - * MovieClip 实例当前播放的帧的标签。如果当前帧没有标签,则 currentFrameLabel返回null。 - * @version Egret 2.4 - * @platform Web,Native - */ - readonly currentFrameLabel: string; - /** - * 当前播放的帧对应的标签,如果当前帧没有标签,则currentLabel返回包含标签的先前帧的标签。如果当前帧和先前帧都不包含标签,currentLabel返回null。 - * @version Egret 2.4 - * @platform Web,Native - */ - readonly currentLabel: string; - /** - * MovieClip 实例的帧频 - * @version Egret 2.4 - * @platform Web,Native - */ - frameRate: number; - /** - * MovieClip 实例当前是否正在播放 - * @version Egret 2.4 - * @platform Web,Native - */ - readonly isPlaying: boolean; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * MovieClip数据源 - */ - movieClipData: MovieClipData; - /** - * @private - * - * @param value - */ - private setMovieClipData(value); - /** - * @private - * - * @param value - */ - private setPlayTimes(value); - /** - * @private - * - * @param value - */ - private setIsStopped(value); - } -} -declare namespace egret { - /** - * The URLRequest class captures all of the information in a single HTTP request. - * @see http://edn.egret.com/cn/index.php/article/index/id/601 Build communication request - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequest.ts - * @language en_US - */ - /** - * URLRequest 类可捕获单个 HTTP 请求中的所有信息。 - * @see http://edn.egret.com/cn/index.php/article/index/id/601 构建通信请求 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequest.ts - * @language zh_CN - */ - class URLRequest extends HashObject { - /** - * Create an egret.URLRequest object - * @param url {string} Addresses for URL requests - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.URLRequest 对象 - * @param url {string} 进行网络请求的地址 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(url?: string); - /** - * An object contains data to be transmitted with the URL request. - * This property is used in conjunction with the method property. When the value of method is GET, the value of data is appended to the value of URLRequest.url, using HTTP query-string syntax. - * When the method value is POST (or any value other than GET), the value of data is transmitted in the body of the HTTP request. - * The URLRequest API offers binary POST support and support for URL-encoded variables, as well as support for strings. The data object can be a ArrayBuffer, URLVariables, or String object. - * The way in which the data is used depends on the type of object used: - * If the object is a ArrayBuffer object, the binary data of the ArrayBuffer object is used as POST data. For GET, data of ArrayBuffer type is not supported. - * If the object is a URLVariables object and the method is POST, then the variables are encoded using x-www-form-urlencoded format and the resulting string is used as POST data. - * If the object is a URLVariables object and the method is GET, the URLVariables object will define variables to be sent with the URLRequest object. - * Otherwise, the object is converted into a string, and the string is used as the POST or GET data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个对象,它包含将随 URL 请求一起传输的数据。 - * 该属性与 method 属性配合使用。当 method 值为 GET 时,将使用 HTTP 查询字符串语法将 data 值追加到 URLRequest.url 值。 - * 当 method 值为 POST(或 GET 之外的任何值)时,将在 HTTP 请求体中传输 data 值。 - * URLRequest API 支持二进制 POST,并支持 URL 编码变量和字符串。该数据对象可以是 ArrayBuffer、URLVariables 或 String 对象。 - * 该数据的使用方式取决于所用对象的类型: - * 如果该对象为 ArrayBuffer 对象,则 ArrayBuffer 对象的二进制数据用作 POST 数据。对于 GET,不支持 ArrayBuffer 类型的数据。 - * 如果该对象是 URLVariables 对象,并且该方法是 POST,则使用 x-www-form-urlencoded 格式对变量进行编码,并且生成的字符串会用作 POST 数据。 - * 如果该对象是 URLVariables 对象,并且该方法是 GET,则 URLVariables 对象将定义要随 URLRequest 对象一起发送的变量。 - * 否则,该对象会转换为字符串,并且该字符串会用作 POST 或 GET 数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - data: any; - /** - * Request method, valid values are URLRequestMethod.GET or URLRequestMethod.POST. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 请求方式,有效值为URLRequestMethod.GET 或 URLRequestMethod.POST。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - method: string; - /** - * The requested URL. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 所请求的 URL。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - url: string; - /** - * The array of HTTP request headers to be appended to the HTTP request. The array is composed of URLRequestHeader objects. - * Each object in the array must be a URLRequestHeader object that contains a name string and a value string. - * Because of browser compatibility, this property has not been achieved in html5 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要追加到 HTTP 请求的 HTTP 请求标头的数组。该数组由 URLRequestHeader 对象组成。 - * 数组中的每一对象必须是包含一个名称字符串和一个值字符串的 URLRequestHeader 对象。 - * 由于浏览器兼容性原因,该属性在 html5 中并未实现 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - requestHeaders: Array; - } -} -declare namespace egret { - /** - * A URLRequestHeader object encapsulates a single HTTP request header and consists of a name/value pair. URLRequestHeader objects are used in the requestHeaders property of the URLRequest class. - * Note: Because of browser compatibility, this property has not been achieved in html5 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequestHeader.ts - * @language en_US - */ - /** - * URLRequestHeader 对象封装了一个 HTTP 请求标头并由一个名称/值对组成。URLRequestHeader 对象在 URLRequest 类的 requestHeaders 属性中使用。 - * 注意:由于浏览器兼容性原因,在 html5 中并未实现 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequestHeader.ts - * @language zh_CN - */ - class URLRequestHeader { - /** - * HTTP request header name, such as Content-Type - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HTTP 请求标头名称,如 Content-Type - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - name: string; - /** - * The values associated with the name property (such as text/plain). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 与 name 属性相关联的值,如 text/plain - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - value: string; - /** - * Create an egret.URLRequestHeader object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.URLRequestHeader 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(name: string, value: string); - } -} -declare namespace egret { - /** - * The URLRequestMethod class provides values that specify whether the - * URLRequest object should use the POST method or the GET method when sending data to a server. - * @see http://edn.egret.com/cn/docs/page/599 POST与GET - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequestMethod.ts - * @language en_US - */ - /** - * URLRequestMethod 类提供了一些值,这些值可指定在将数据发送到服务器时, - * URLRequest 对象应使用 POST 方法还是 GET 方法。 - * @see http://edn.egret.com/cn/docs/page/599 POST与GET - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequestMethod.ts - * @language zh_CN - */ - class URLRequestMethod { - /** - * Specify that the URLRequest object is a GET. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 URLRequest 对象是一个 GET。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static GET: string; - /** - * Specify that the URLRequest object is a POST. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 URLRequest 对象是一个 POST。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static POST: string; - } -} -declare namespace egret { - /** - * The URLVariables class allows you to transfer variables between an application and a server. - * Use URLVariables objects with methods of the URLLoader class and the data property of the URLRequest class. - * @see http://edn.egret.com/cn/docs/page/598 Send the request with parameters - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLVariables.ts - * @language en_US - */ - /** - * 使用 URLVariables 类可以在应用程序和服务器之间传输变量。 - * 将 URLVariables 对象与 URLLoader 类的方法、URLRequest 类的 data 属性一起使用。 - * @see http://edn.egret.com/cn/docs/page/598 发送带参数的请求 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLVariables.ts - * @language zh_CN - */ - class URLVariables extends HashObject { - /** - * Create an egret.URLVariable object - * @param source {String} A URL-encoded string containing name/value pairs. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.URLVariables 对象 - * @param source {String} 包含名称/值对的 URL 编码的字符串。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(source?: string); - /** - * Key-value pair data object saved in this URLVariables object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 此 URLVariables 储存的键值对数据对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - variables: Object; - /** - * Convert the variable string into the property of this URLVariables.variables object. - * @param source {string} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将变量字符串转换为此 URLVariables.variables 对象的属性。 - * @param source {string} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - decode(source: string): void; - /** - * Return a string containing all enumerable variables using the MIME content encoding format : application/x-www-form-urlencoded. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 以 MIME 内容编码格式 application/x-www-form-urlencoded 返回包含所有可枚举变量的字符串。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - toString(): string; - /** - * @private - * - * @param key - * @param value - */ - private encodeValue(key, value); - /** - * @private - * - * @param key - * @param value - */ - private encodeArray(key, value); - } -} -declare namespace egret { - /** - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/player/Ticker.ts - * @language en_US - */ - /** - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/player/Ticker.ts - * @language zh_CN - */ - class Ticker extends EventDispatcher { - /** - * @deprecated - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - private _timeScale; - private _paused; - private _callIndex; - private _callList; - private _lastTime; - private update(timeStamp); - private callBackList; - /** - * 注册帧回调事件,同一函数的重复监听会被忽略。推荐使用 egret.startTick 替代此方法。 - * @method egret.Ticker#register - * @param listener {Function} 帧回调函数,参数返回上一帧和这帧的间隔时间。示例:onEnterFrame(frameTime:number):void - * @param thisObject {any} 帧回调函数的this对象 - * @param priority {number} 事件优先级,开发者请勿传递 Number.NEGATIVE_INFINITY 和 Number.POSITIVE_INFINITY - * @version Egret 2.4 - * @platform Web,Native - * @deprecated - */ - register(listener: Function, thisObject: any, priority?: number): void; - /** - * 取消侦听enterFrame事件。推荐使用 egret.stopTick 替代此方法。 - * @method egret.Ticker#unregister - * @param listener {Function} 事件侦听函数 - * @param thisObject {any} 侦听函数的this对象 - * @version Egret 2.4 - * @platform Web,Native - * @deprecated - */ - unregister(listener: Function, thisObject: any): void; - /** - * @deprecated - * @param timeScale {number} - * @private - */ - setTimeScale(timeScale: number): void; - /** - * @deprecated - * @method egret.Ticker#getTimeScale - * @private - */ - getTimeScale(): number; - /** - * 暂停 - * @deprecated - * @method egret.Ticker#pause - */ - pause(): void; - /** - * 继续 - * @deprecated - * @method egret.Ticker#resume - */ - resume(): void; - /** - * @private - */ - private static instance; - /** - * @method egret.Ticker.getInstance - * @returns {Ticker} - * @version Egret 2.4 - * @platform Web,Native - * @deprecated - */ - static getInstance(): egret.Ticker; - } -} -declare namespace egret { - /** - * @class egret.MainContext - * @classdesc - * MainContext是游戏的核心跨平台接口,组合了多个功能Context,并是游戏启动的主入口 - * @extends egret.EventDispatcher - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - class MainContext extends EventDispatcher { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - /** - * 渲染Context - * @member egret.MainContext#rendererContext - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * 触摸Context - * @member egret.MainContext#touchContext - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * 设备divice - * @member egret.MainContext#deviceContext - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * 舞台 - * @member egret.MainContext#stage - * @version Egret 2.4 - * @platform Web,Native - */ - readonly stage: Stage; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - static deviceType: string; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - static DEVICE_PC: string; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - static DEVICE_MOBILE: string; - /** - * 游戏启动,开启主循环,参考Flash的滑动跑道模型 - * @method egret.MainContext#run - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @private - */ - private static _instance; - /** - * @method egret.Ticker.getInstance - * @returns {Ticker} - * @version Egret 2.4 - * @platform Web,Native - */ - static readonly instance: egret.MainContext; - } -} -declare namespace egret { - /** - * Tool class for object cache repeat use, which can be used to construct an object pool. Objects are automatically recycled after a certain duration. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/Recycler.ts - * @private - * @language en_US - */ - /** - * 对象缓存复用工具类,可用于构建对象池,一段时间后会自动回收对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/Recycler.ts - * @private - * @language zh_CN - */ - class Recycler extends HashObject { - /** - * Create an egret.Recycler object - * @param autoDisposeTime {number} Number of frames when objects are destroyed automatically. Default value: 300 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.Recycler 对象 - * @param autoDisposeTime {number} 多少帧后自动销毁对象,默认值300 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(autoDisposeTime?: number); - /** - * @private - */ - static _callBackList: any[]; - static $init(): void; - static onUpdate(timeStamp: number): boolean; - /** - * @private - * 多少帧后自动销毁对象。 - */ - private autoDisposeTime; - /** - * @private - */ - private frameCount; - /** - * @private - * - */ - $checkFrame(): void; - /** - * @private - */ - private objectPool; - /** - * @private - */ - private _length; - /** - * Number of cached objects" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缓存的对象数量 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly length: number; - /** - * Cache an object for repeat use - * @param object {any} The object to be cached - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缓存一个对象以复用 - * @param object {any} 需要缓存的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - push(object: any): void; - /** - * Obtain a cached object - * @returns {any} The obtained cached object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取一个缓存的对象 - * @returns {any} 获得的缓存对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - pop(): any; - /** - * Immediately clear all cached objects. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 立即清空所有缓存的对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dispose(): void; - } -} -declare namespace egret { - /** - * To specify a delay (in milliseconds) calls the function specified interval loop. - * @param listener {Function} Listener function - * @param thisObject {any} this object - * @param delay {number} Delay time, in milliseconds - * @param ...args {any} Parameter list - * @returns {number} Return index which can be used for clearInterval - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/setInterval.ts - * @language en_US - */ - /** - * 以指定的延迟(以毫秒为单位)间隔循环调用指定的函数。 - * @param listener {Function} 侦听函数 - * @param thisObject {any} this对象 - * @param delay {number} 延迟时间,以毫秒为单位 - * @param ...args {any} 参数列表 - * @returns {number} 返回索引,可以用于 clearInterval - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/setInterval.ts - * @language zh_CN - */ - function setInterval(listener: (this: Z, ...arg) => void, thisObject: Z, delay: number, ...args: any[]): number; - /** - * Clear function to run after a specified delay. - * @param key {number} Index that egret.setInterval returns - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/setInterval.ts - * @language en_US - */ - /** - * 清除指定延迟后运行的函数。 - * @param key {number} egret.setInterval所返回的索引 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/setInterval.ts - * @language zh_CN - */ - function clearInterval(key: number): void; -} -declare namespace egret { - /** - * Run the designated function in specified delay (in milliseconds). - * @param listener {Function} Listener function - * @param thisObject {any} this object - * @param delay {number} Delay time, in milliseconds - * @param ...args {any} Parameter list - * @returns {number} Return index which can be used for clearTimeout - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/setTimeout.ts - * @language en_US - */ - /** - * 在指定的延迟(以毫秒为单位)后运行指定的函数。 - * @param listener {Function} 侦听函数 - * @param thisObject {any} this对象 - * @param delay {number} 延迟时间,以毫秒为单位 - * @param ...args {any} 参数列表 - * @returns {number} 返回索引,可以用于 clearTimeout - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/setTimeout.ts - * @language zh_CN - */ - function setTimeout(listener: (this: Z, ...arg) => void, thisObject: Z, delay: number, ...args: any[]): number; - /** - * Function run after the specified delay is cleared. - * @param key {number} Index that egret.setTimeout returns - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 清除指定延迟后运行的函数。 - * @param key {number} egret.setTimeout所返回的索引 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function clearTimeout(key: number): void; -} diff --git a/helloworld/libs/modules/game/game.js b/helloworld/libs/modules/game/game.js deleted file mode 100644 index 72581f2..0000000 --- a/helloworld/libs/modules/game/game.js +++ /dev/null @@ -1,4815 +0,0 @@ -var __reflect = (this && this.__reflect) || function (p, c, t) { - p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; -}; -var __extends = this && this.__extends || function __extends(t, e) { - function r() { - this.constructor = t; -} -for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]); -r.prototype = e.prototype, t.prototype = new r(); -}; -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The URLLoaderDataFormat class provides values that specify how downloaded data is received. - * @see http://edn.egret.com/cn/docs/page/600 Read different data format - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLLoaderDataFormat.ts - * @language en_US - */ - /** - * URLLoaderDataFormat 类提供了一些用于指定如何接收已下载数据的值。 - * @see http://edn.egret.com/cn/docs/page/600 读取不同数据格式 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLLoaderDataFormat.ts - * @language zh_CN - */ - var URLLoaderDataFormat = (function () { - function URLLoaderDataFormat() { - } - /** - * Specify that downloaded data is received as raw binary data. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 指定以原始二进制数据形式接收下载的数据。 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - URLLoaderDataFormat.BINARY = "binary"; - /** - * Specify that downloaded data is received as text. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定以文本形式接收已下载的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - URLLoaderDataFormat.TEXT = "text"; - /** - * Specify that downloaded data is received as URL-encoded variables. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定以 URL 编码变量形式接收下载的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - URLLoaderDataFormat.VARIABLES = "variables"; - /** - * Specify that downloaded data is received as bitmap texture. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定以位图纹理形式接收已下载的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - URLLoaderDataFormat.TEXTURE = "texture"; - /** - * Specify that downloaded data is received as sound. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定以声音形式接收已下载的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - URLLoaderDataFormat.SOUND = "sound"; - return URLLoaderDataFormat; - }()); - egret.URLLoaderDataFormat = URLLoaderDataFormat; - __reflect(URLLoaderDataFormat.prototype, "egret.URLLoaderDataFormat"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @version Egret 2.4 - * @platform Web,Native - * @private - */ - var FrameLabel = (function (_super) { - __extends(FrameLabel, _super); - /** - * @version Egret 2.4 - * @platform Web,Native - */ - function FrameLabel(name, frame /*int*/, end /*int*/) { - var _this = _super.call(this) || this; - _this._name = name; - _this._frame = frame | 0; - if (end) - _this._end = end | 0; - return _this; - } - Object.defineProperty(FrameLabel.prototype, "name", { - /** - * Frame number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 标签名 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(FrameLabel.prototype, "frame", { - /** - * Frame serial number of the label - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 标签所在帧序号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._frame; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(FrameLabel.prototype, "end", { - /** - * Frame serial number, the end of the label - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 标签对应的结束帧序号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._end; - }, - enumerable: true, - configurable: true - }); - /** - * Duplicate the current frame label object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 复制当前帧标签对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - FrameLabel.prototype.clone = function () { - return new FrameLabel(this._name, this._frame, this._end); - }; - return FrameLabel; - }(egret.EventDispatcher)); - egret.FrameLabel = FrameLabel; - __reflect(FrameLabel.prototype, "egret.FrameLabel"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @classdesc 使用 MovieClipData 类,您可以创建 MovieClip 对象和处理 MovieClip 对象的数据。MovieClipData 一般由MovieClipDataFactory生成 - * @see http://edn.egret.com/cn/docs/page/596 MovieClip序列帧动画 - * @version Egret 2.4 - * @platform Web,Native - */ - var MovieClipData = (function (_super) { - __extends(MovieClipData, _super); - /** - * 创建一个 egret.MovieClipData 对象 - * @version Egret 2.4 - * @platform Web,Native - */ - function MovieClipData() { - var _this = _super.call(this) || this; - /** - * @private - * MovieClip数据 - */ - _this.$mcData = null; - /** - * 总帧数 - * @version Egret 2.4 - * @platform Web,Native - */ - _this.numFrames = 1; - /** - * 帧数据列表 - * @version Egret 2.4 - * @platform Web,Native - */ - _this.frames = []; - /** - * 帧标签列表 - * @version Egret 2.4 - * @platform Web,Native - */ - _this.labels = null; - /** - * 帧事件列表 - * @version Egret 2.4 - * @platform Web,Native - */ - _this.events = []; - /** - * 帧率 - * @version Egret 2.4 - * @platform Web,Native - */ - _this.frameRate = 0; - /** - * 纹理数据 - * @version Egret 2.4 - * @platform Web,Native - */ - _this.textureData = null; - /** - * 纹理集 - * @version Egret 2.4 - * @platform Web,Native - */ - _this.spriteSheet = null; - return _this; - } - /** - * @private - * - * @param mcData - * @param textureData - * @param spriteSheet - */ - MovieClipData.prototype.$init = function (mcData, textureData, spriteSheet) { - this.textureData = textureData; - this.spriteSheet = spriteSheet; - this.setMCData(mcData); - }; - /** - * 根据指定帧序号获取该帧对应的关键帧数据 - * @param frame {number} 帧序号 - * @returns {any} 帧数据对象 - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClipData.prototype.getKeyFrameData = function (frame) { - var outputFrameData = this.frames[frame - 1]; - if (outputFrameData.frame) { - outputFrameData = this.frames[outputFrameData.frame - 1]; - } - return outputFrameData; - }; - /** - * 根据指定帧序号获取该帧对应的Texture对象 - * @param frame {number} 帧序号 - * @returns {egret.Texture} Texture对象 - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClipData.prototype.getTextureByFrame = function (frame) { - var frameData = this.getKeyFrameData(frame); - if (frameData.res) { - var outputTexture = this.getTextureByResName(frameData.res); - return outputTexture; - } - return null; - }; - MovieClipData.prototype.$getOffsetByFrame = function (frame, point) { - var frameData = this.getKeyFrameData(frame); - if (frameData.res) { - point.setTo(frameData.x | 0, frameData.y | 0); - } - }; - /** - * @private - * - * @param resName - * @returns - */ - MovieClipData.prototype.getTextureByResName = function (resName) { - if (this.spriteSheet == null) { - return null; - } - var texture = this.spriteSheet.getTexture(resName); - if (!texture) { - var textureData = this.textureData[resName]; - texture = this.spriteSheet.createTexture(resName, textureData.x, textureData.y, textureData.w, textureData.h); - } - return texture; - }; - /** - * @private - * - * @returns - */ - MovieClipData.prototype.$isDataValid = function () { - return this.frames.length > 0; - }; - /** - * @private - * - * @returns - */ - MovieClipData.prototype.$isTextureValid = function () { - return this.textureData != null && this.spriteSheet != null; - }; - /** - * @private - * - * @param mcData - */ - MovieClipData.prototype.$fillMCData = function (mcData) { - this.frameRate = mcData["frameRate"] || 24; - this.fillFramesData(mcData.frames); - this.fillFrameLabelsData(mcData.labels); - this.fillFrameEventsData(mcData.events); - }; - /** - * @private - * - * @param framesData - */ - MovieClipData.prototype.fillFramesData = function (framesData) { - var frames = this.frames; - var length = framesData ? framesData.length : 0; - var keyFramePosition; - for (var i = 0; i < length; i++) { - var frameData = framesData[i]; - frames.push(frameData); - if (frameData.duration) { - var duration = parseInt(frameData.duration); - if (duration > 1) { - keyFramePosition = frames.length; - for (var j = 1; j < duration; j++) { - frames.push({ "frame": keyFramePosition }); - } - } - } - } - this.numFrames = frames.length; - }; - /** - * @private - * - * @param frameLabelsData - */ - MovieClipData.prototype.fillFrameLabelsData = function (frameLabelsData) { - if (frameLabelsData) { - var length_1 = frameLabelsData.length; - if (length_1 > 0) { - this.labels = []; - for (var i = 0; i < length_1; i++) { - var label = frameLabelsData[i]; - this.labels.push(new egret.FrameLabel(label.name, label.frame, label.end)); - } - } - } - }; - /** - * @private - * - * @param frameEventsData - */ - MovieClipData.prototype.fillFrameEventsData = function (frameEventsData) { - if (frameEventsData) { - var length_2 = frameEventsData.length; - if (length_2 > 0) { - this.events = []; - for (var i = 0; i < length_2; i++) { - var events = frameEventsData[i]; - this.events[events.frame] = events.name; - } - } - } - }; - Object.defineProperty(MovieClipData.prototype, "mcData", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$mcData; - }, - /** - * MovieClip数据源 - */ - set: function (value) { - this.setMCData(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - MovieClipData.prototype.setMCData = function (value) { - if (this.$mcData == value) { - return; - } - this.$mcData = value; - if (value) { - this.$fillMCData(value); - } - }; - return MovieClipData; - }(egret.HashObject)); - egret.MovieClipData = MovieClipData; - __reflect(MovieClipData.prototype, "egret.MovieClipData"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @classdesc 使用 MovieClipDataFactory 类,可以生成 MovieClipData 对象用于创建MovieClip - * @see http://edn.egret.com/cn/docs/page/596 MovieClip序列帧动画 - * @version Egret 2.4 - * @platform Web,Native - */ - var MovieClipDataFactory = (function (_super) { - __extends(MovieClipDataFactory, _super); - /** - * 创建一个 egret.MovieClipDataFactory 对象 - * @param movieClipDataSet {any} MovieClip数据集,该数据集必须由Egret官方工具生成 - * @param texture {Texture} 纹理 - * @version Egret 2.4 - * @platform Web,Native - */ - function MovieClipDataFactory(movieClipDataSet, texture) { - var _this = _super.call(this) || this; - /** - * 是否开启缓存 - * @version Egret 2.4 - * @platform Web,Native - */ - _this.enableCache = true; - /** - * @private - */ - _this.$mcDataCache = {}; - _this.$mcDataSet = movieClipDataSet; - _this.setTexture(texture); - return _this; - } - /** - * 清空缓存 - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClipDataFactory.prototype.clearCache = function () { - this.$mcDataCache = {}; - }; - /** - * 根据名字生成一个MovieClipData实例。可以用于创建MovieClip。 - * @param movieClipName {string} MovieClip名字. 可选参数,默认为"", 相当于取第一个MovieClip数据 - * @returns {MovieClipData} 生成的MovieClipData对象 - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClipDataFactory.prototype.generateMovieClipData = function (movieClipName) { - if (movieClipName === void 0) { movieClipName = ""; } - if (movieClipName == "") { - if (this.$mcDataSet) { - for (movieClipName in this.$mcDataSet.mc) { - break; - } - } - } - if (movieClipName == "") { - return null; - } - var output = this.findFromCache(movieClipName, this.$mcDataCache); - if (!output) { - output = new egret.MovieClipData(); - this.fillData(movieClipName, output, this.$mcDataCache); - } - return output; - }; - /** - * @private - * - * @param movieClipName - * @param cache - * @returns - */ - MovieClipDataFactory.prototype.findFromCache = function (movieClipName, cache) { - if (this.enableCache && cache[movieClipName]) { - return cache[movieClipName]; - } - return null; - }; - /** - * @private - * - * @param movieClipName - * @param movieClip - * @param cache - */ - MovieClipDataFactory.prototype.fillData = function (movieClipName, movieClip, cache) { - if (this.$mcDataSet) { - var mcData = this.$mcDataSet.mc[movieClipName]; - if (mcData) { - movieClip.$init(mcData, this.$mcDataSet.res, this.$spriteSheet); - if (this.enableCache) { - cache[movieClipName] = movieClip; - } - } - } - }; - Object.defineProperty(MovieClipDataFactory.prototype, "mcDataSet", { - /** - * MovieClip数据集 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$mcDataSet; - }, - set: function (value) { - this.$mcDataSet = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClipDataFactory.prototype, "texture", { - /** - * MovieClip需要使用的纹理图 - */ - set: function (value) { - this.setTexture(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClipDataFactory.prototype, "spriteSheet", { - /** - * 由纹理图生成的精灵表 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$spriteSheet; - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - MovieClipDataFactory.prototype.setTexture = function (value) { - this.$spriteSheet = value ? new egret.SpriteSheet(value) : null; - }; - return MovieClipDataFactory; - }(egret.EventDispatcher)); - egret.MovieClipDataFactory = MovieClipDataFactory; - __reflect(MovieClipDataFactory.prototype, "egret.MovieClipDataFactory"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * When the movieClip's current frame have a frameLabel, dispatches MovieClipEvent object. FrameLabel Event type: MovieClipEvent.FRAME_LABEL - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当动画的当前帧有事件,将调度 MovieClipEvent 对象。帧事件类型 MovieClipEvent.FRAME_LABEL. - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var MovieClipEvent = (function (_super) { - __extends(MovieClipEvent, _super); - /** - * TextEvent create an object that contains information about movieClip events. - * @param type Type of event, you can access the MovieClipEvent.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determine whether the Event object can be canceled. The default value is false. - * @param frameLabel When the current frame have a frameLabel, the event listeners can access this information through the frameLabel property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 MovieClipEvent 对象,其中包含有关帧事件的信息。 - * @param type 事件的类型,可以作为 MovieClipEvent.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param frameLabel 动画上的帧事件。事件侦听器可以通过 frameLabel 属性访问此信息。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function MovieClipEvent(type, bubbles, cancelable, frameLabel) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - if (frameLabel === void 0) { frameLabel = null; } - var _this = _super.call(this, type, bubbles, cancelable) || this; - /** - * In MovieClipEvent.FRAME_LABEL event, event corresponding string. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在 MovieClipEvent.FRAME_LABEL 事件中,event对应的字符串。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.frameLabel = null; - _this.frameLabel = frameLabel; - return _this; - } - /** - * EventDispatcher object using the specified event object thrown MovieClipEvent. The objects will be thrown in the object cache pool for the next round robin. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param frameLabel MovieClipEvent object frameLabel - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出 MovieClipEvent 事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 派发事件目标 - * @param type 事件类型 - * @param frameLabel MovieClipEvent 对象的 frameLabel 赋值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - MovieClipEvent.dispatchMovieClipEvent = function (target, type, frameLabel) { - if (frameLabel === void 0) { frameLabel = null; } - var event = egret.Event.create(MovieClipEvent, type); - event.frameLabel = frameLabel; - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * Dispatched whenever the current frame have a frameLabel. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 动画的当前帧上有事件时调度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - MovieClipEvent.FRAME_LABEL = "frame_label"; - return MovieClipEvent; - }(egret.Event)); - egret.MovieClipEvent = MovieClipEvent; - __reflect(MovieClipEvent.prototype, "egret.MovieClipEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - */ - var ScrollEase = (function () { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - function ScrollEase() { - egret.$error(1014); - } - /** - * - * @param amount - * @returns - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollEase.get = function (amount) { - if (amount < -1) { - amount = -1; - } - if (amount > 1) { - amount = 1; - } - return function (t) { - if (amount == 0) { - return t; - } - if (amount < 0) { - return t * (t * -amount + 1 + amount); - } - return t * ((2 - t) * amount + (1 - amount)); - }; - }; - /** - * - * @param pow - * @returns - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollEase.getPowOut = function (pow) { - return function (t) { - return 1 - Math.pow(1 - t, pow); - }; - }; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollEase.quintOut = ScrollEase.getPowOut(5); - /** - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollEase.quartOut = ScrollEase.getPowOut(4); - return ScrollEase; - }()); - egret.ScrollEase = ScrollEase; - __reflect(ScrollEase.prototype, "egret.ScrollEase"); - /** - * @private - */ - var ScrollTween = (function (_super) { - __extends(ScrollTween, _super); - /** - * 创建一个 egret.ScrollTween 对象 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - function ScrollTween(target, props, pluginData) { - var _this = _super.call(this) || this; - /** - * @private - */ - _this._target = null; - /** - * @private - */ - _this._useTicks = false; - /** - * @private - */ - _this.ignoreGlobalPause = false; - /** - * @private - */ - _this.loop = false; - /** - * @private - */ - _this.pluginData = null; - /** - * @private - */ - _this._steps = null; - /** - * @private - */ - _this._actions = null; - /** - * @private - */ - _this.paused = false; - /** - * @private - */ - _this.duration = 0; - /** - * @private - */ - _this._prevPos = -1; - /** - * @private - */ - _this.position = null; - /** - * @private - */ - _this._prevPosition = 0; - /** - * @private - */ - _this._stepPosition = 0; - /** - * @private - */ - _this.passive = false; - _this.initialize(target, props, pluginData); - return _this; - } - /** - * Activate an object and add a ScrollTween animation to the object - * @param target {any} The object to be activated - * @param props {any} Parameters, support loop onChange onChangeObj - * @param pluginData {any} Write realized - * @param override {boolean} Whether to remove the object before adding a tween, the default value false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 激活一个对象,对其添加 ScrollTween 动画 - * @param target {any} 要激活 ScrollTween 的对象 - * @param props {any} 参数,支持loop(循环播放) onChange(变化函数) onChangeObj(变化函数作用域) - * @param pluginData {any} 暂未实现 - * @param override {boolean} 是否移除对象之前添加的tween,默认值false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollTween.get = function (target, props, pluginData, override) { - if (props === void 0) { props = null; } - if (pluginData === void 0) { pluginData = null; } - if (override === void 0) { override = false; } - if (override) { - ScrollTween.removeTweens(target); - } - return new ScrollTween(target, props, pluginData); - }; - /** - * Delete all ScrollTween animations from an object - * @param target The object whose ScrollTween to be deleted - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 删除一个对象上的全部 ScrollTween 动画 - * @param target 需要移除 ScrollTween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollTween.removeTweens = function (target) { - if (!target.tween_count) { - return; - } - var tweens = ScrollTween._tweens; - for (var i = tweens.length - 1; i >= 0; i--) { - if (tweens[i]._target == target) { - tweens[i].paused = true; - tweens.splice(i, 1); - } - } - target.tween_count = 0; - }; - /** - * @private - * - * @param delta - * @param paused - */ - ScrollTween.tick = function (timeStamp, paused) { - if (paused === void 0) { paused = false; } - var delta = timeStamp - ScrollTween._lastTime; - ScrollTween._lastTime = timeStamp; - var tweens = ScrollTween._tweens.concat(); - for (var i = tweens.length - 1; i >= 0; i--) { - var tween = tweens[i]; - if ((paused && !tween.ignoreGlobalPause) || tween.paused) { - continue; - } - tween.tick(tween._useTicks ? 1 : delta); - } - return false; - }; - /** - * @private - * - * @param tween - * @param value - */ - ScrollTween._register = function (tween, value) { - var target = tween._target; - var tweens = ScrollTween._tweens; - if (value) { - if (target) { - target.tween_count = target.tween_count > 0 ? target.tween_count + 1 : 1; - } - tweens.push(tween); - if (!ScrollTween._inited) { - ScrollTween._lastTime = egret.getTimer(); - egret.ticker.$startTick(ScrollTween.tick, null); - ScrollTween._inited = true; - } - } - else { - if (target) { - target.tween_count--; - } - var i = tweens.length; - while (i--) { - if (tweens[i] == tween) { - tweens.splice(i, 1); - return; - } - } - } - }; - /** - * @private - * - * @param target - * @param props - * @param pluginData - */ - ScrollTween.prototype.initialize = function (target, props, pluginData) { - this._target = target; - if (props) { - this._useTicks = props.useTicks; - this.ignoreGlobalPause = props.ignoreGlobalPause; - this.loop = props.loop; - props.onChange && this.addEventListener("change", props.onChange, props.onChangeObj); - if (props.override) { - ScrollTween.removeTweens(target); - } - } - this.pluginData = pluginData || {}; - this._curQueueProps = {}; - this._initQueueProps = {}; - this._steps = []; - this._actions = []; - if (props && props.paused) { - this.paused = true; - } - else { - ScrollTween._register(this, true); - } - if (props && props.position != null) { - this.setPosition(props.position); - } - }; - /** - * @private - * - * @param value - * @param actionsMode - * @returns - */ - ScrollTween.prototype.setPosition = function (value, actionsMode) { - if (actionsMode === void 0) { actionsMode = 1; } - if (value < 0) { - value = 0; - } - //正常化位置 - var t = value; - var end = false; - if (t >= this.duration) { - if (this.loop) { - t = t % this.duration; - } - else { - t = this.duration; - end = true; - } - } - if (t == this._prevPos) { - return end; - } - var prevPos = this._prevPos; - this.position = this._prevPos = t; - this._prevPosition = value; - if (this._target) { - if (end) { - //结束 - this._updateTargetProps(null, 1); - } - else if (this._steps.length > 0) { - // 找到新的tween - var i = void 0; - var l = this._steps.length; - for (i = 0; i < l; i++) { - if (this._steps[i].t > t) { - break; - } - } - var step = this._steps[i - 1]; - this._updateTargetProps(step, (this._stepPosition = t - step.t) / step.d); - } - } - if (end) { - this.setPaused(true); - } - //执行actions - if (actionsMode != 0 && this._actions.length > 0) { - if (this._useTicks) { - this._runActions(t, t); - } - else if (actionsMode == 1 && t < prevPos) { - if (prevPos != this.duration) { - this._runActions(prevPos, this.duration); - } - this._runActions(0, t, true); - } - else { - this._runActions(prevPos, t); - } - } - this.dispatchEventWith("change"); - return end; - }; - /** - * @private - * - * @param startPos - * @param endPos - * @param includeStart - */ - ScrollTween.prototype._runActions = function (startPos, endPos, includeStart) { - if (includeStart === void 0) { includeStart = false; } - var sPos = startPos; - var ePos = endPos; - var i = -1; - var j = this._actions.length; - var k = 1; - if (startPos > endPos) { - //把所有的倒置 - sPos = endPos; - ePos = startPos; - i = j; - j = k = -1; - } - while ((i += k) != j) { - var action = this._actions[i]; - var pos = action.t; - if (pos == ePos || (pos > sPos && pos < ePos) || (includeStart && pos == startPos)) { - action.f.apply(action.o, action.p); - } - } - }; - /** - * @private - * - * @param step - * @param ratio - */ - ScrollTween.prototype._updateTargetProps = function (step, ratio) { - var p0, p1, v, v0, v1, arr; - if (!step && ratio == 1) { - this.passive = false; - p0 = p1 = this._curQueueProps; - } - else { - this.passive = !!step.v; - //不更新props. - if (this.passive) { - return; - } - //使用ease - if (step.e) { - ratio = step.e(ratio, 0, 1, 1); - } - p0 = step.p0; - p1 = step.p1; - } - for (var n in this._initQueueProps) { - if ((v0 = p0[n]) == null) { - p0[n] = v0 = this._initQueueProps[n]; - } - if ((v1 = p1[n]) == null) { - p1[n] = v1 = v0; - } - if (v0 == v1 || ratio == 0 || ratio == 1 || (typeof (v0) != "number")) { - v = ratio == 1 ? v1 : v0; - } - else { - v = v0 + (v1 - v0) * ratio; - } - var ignore = false; - if (arr = ScrollTween._plugins[n]) { - for (var i = 0, l = arr.length; i < l; i++) { - var v2 = arr[i].tween(this, n, v, p0, p1, ratio, !!step && p0 == p1, !step); - if (v2 == ScrollTween.IGNORE) { - ignore = true; - } - else { - v = v2; - } - } - } - if (!ignore) { - this._target[n] = v; - } - } - }; - /** - * Whether setting is paused - * @param value {boolean} Whether to pause - * @returns ScrollTween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置是否暂停 - * @param value {boolean} 是否暂停 - * @returns Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollTween.prototype.setPaused = function (value) { - this.paused = value; - ScrollTween._register(this, !value); - return this; - }; - /** - * @private - * - * @param props - * @returns - */ - ScrollTween.prototype._cloneProps = function (props) { - var o = {}; - for (var n in props) { - o[n] = props[n]; - } - return o; - }; - /** - * @private - * - * @param o - * @returns - */ - ScrollTween.prototype._addStep = function (o) { - if (o.d > 0) { - this._steps.push(o); - o.t = this.duration; - this.duration += o.d; - } - return this; - }; - /** - * @private - * - * @param o - * @returns - */ - ScrollTween.prototype._appendQueueProps = function (o) { - var arr, oldValue, i, l, injectProps; - for (var n in o) { - if (this._initQueueProps[n] === undefined) { - oldValue = this._target[n]; - //设置plugins - if (arr = ScrollTween._plugins[n]) { - for (i = 0, l = arr.length; i < l; i++) { - oldValue = arr[i].init(this, n, oldValue); - } - } - this._initQueueProps[n] = this._curQueueProps[n] = (oldValue === undefined) ? null : oldValue; - } - else { - oldValue = this._curQueueProps[n]; - } - } - for (var n in o) { - oldValue = this._curQueueProps[n]; - if (arr = ScrollTween._plugins[n]) { - injectProps = injectProps || {}; - for (i = 0, l = arr.length; i < l; i++) { - if (arr[i].step) { - arr[i].step(this, n, oldValue, o[n], injectProps); - } - } - } - this._curQueueProps[n] = o[n]; - } - if (injectProps) { - this._appendQueueProps(injectProps); - } - return this._curQueueProps; - }; - /** - * @private - * - * @param o - * @returns - */ - ScrollTween.prototype._addAction = function (o) { - o.t = this.duration; - this._actions.push(o); - return this; - }; - /** - * Modify the property of the specified display object to a specified value - * @param props {Object} Property set of an object - * @param duration {number} Duration - * @param ease {egret.ScrollEase} Easing algorithm - * @returns {egret.ScrollTween} ScrollTween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定显示对象的属性修改为指定值 - * @param props {Object} 对象的属性集合 - * @param duration {number} 持续时间 - * @param ease {egret.ScrollEase} 缓动算法 - * @returns {egret.ScrollTween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollTween.prototype.to = function (props, duration, ease) { - if (ease === void 0) { ease = undefined; } - if (isNaN(duration) || duration < 0) { - duration = 0; - } - return this._addStep({ d: duration || 0, p0: this._cloneProps(this._curQueueProps), e: ease, p1: this._cloneProps(this._appendQueueProps(props)) }); - }; - /** - * Execute callback function - * @param callback {Function} Callback method - * @param thisObj {any} this action scope of the callback method - * @param params {any[]} Parameter of the callback method - * @returns {egret.ScrollTween} ScrollTween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 执行回调函数 - * @param callback {Function} 回调方法 - * @param thisObj {any} 回调方法this作用域 - * @param params {any[]} 回调方法参数 - * @returns {egret.ScrollTween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollTween.prototype.call = function (callback, thisObj, params) { - if (thisObj === void 0) { thisObj = undefined; } - if (params === void 0) { params = undefined; } - return this._addAction({ f: callback, p: params ? params : [], o: thisObj ? thisObj : this._target }); - }; - /** - * @method egret.ScrollTween#tick - * @param delta {number} - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollTween.prototype.tick = function (delta) { - if (this.paused) { - return; - } - this.setPosition(this._prevPosition + delta); - }; - /** - * @private - */ - ScrollTween._tweens = []; - /** - * @private - */ - ScrollTween.IGNORE = {}; - /** - * @private - */ - ScrollTween._plugins = {}; - /** - * @private - */ - ScrollTween._inited = false; - ScrollTween._lastTime = 0; - return ScrollTween; - }(egret.EventDispatcher)); - egret.ScrollTween = ScrollTween; - __reflect(ScrollTween.prototype, "egret.ScrollTween"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * ScrollView auxiliary classes for slides, you will pass a display object constructor. It can display more than the range display object within the specified size range. And can easily drag in this range. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/display/ScrollView.ts - * @language en_US - */ - /** - * ScrollView 是用于滑动的辅助类,将一个显示对象传入构造函数即可。可以在指定的尺寸范围内显示超过该范围的显示对象。并可以在此范围内随意拖动。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/display/ScrollView.ts - * @language zh_CN - */ - var ScrollView = (function (_super) { - __extends(ScrollView, _super); - /** - * Create a egret.ScrollView objects - * @param content {egret.DisplayObject} You need to scroll object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.ScrollView 对象 - * @param content {egret.DisplayObject} 需要滚动的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function ScrollView(content) { - if (content === void 0) { content = null; } - var _this = _super.call(this) || this; - /** - * Start rolling threshold when the touch point from the initial touch point at a distance exceeding this value will trigger roll - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 开始滚动的阈值,当触摸点偏离初始触摸点的距离超过这个值时才会触发滚动 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.scrollBeginThreshold = 10; - /** - * Scrolling speed, the speed is required and the default speed ratio. - * The range of scrollSpeed> 0 assigned to 2:00, the speed is 2 times the default speed - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 滚动速度,这个值为需要的速度与默认速度的比值。 - * 取值范围为 scrollSpeed > 0 赋值为 2 时,速度是默认速度的 2 倍 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.scrollSpeed = 1; - /** - * @private - */ - _this._content = null; - /** - * @private - */ - _this.delayTouchBeginEvent = null; - /** - * @private - */ - _this.touchBeginTimer = null; - _this.touchEnabled = true; - _this._ScrV_Props_ = new egret.ScrollViewProperties(); - if (content) { - _this.setContent(content); - } - return _this; - } - Object.defineProperty(ScrollView.prototype, "bounces", { - /** - * Whether to enable rebound, rebound When enabled, ScrollView contents allowed to continue to drag the border after arriving at the end user drag operation, and then bounce back boundary position - * @default true - * @version Egret 2.4 - * @language en_US - */ - /** - * 是否启用回弹,当启用回弹后,ScrollView中内容在到达边界后允许继续拖动,在用户拖动操作结束后,再反弹回边界位置 - * @default true - * @version Egret 2.4 - * @language zh_CN - */ - get: function () { - return this._ScrV_Props_._bounces; - }, - set: function (value) { - this._ScrV_Props_._bounces = !!value; - }, - enumerable: true, - configurable: true - }); - /** - * Set to scroll object - * @param content {egret.DisplayObject} You need to scroll object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置需要滚动的对象 - * @param content {egret.DisplayObject} 需要滚动的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollView.prototype.setContent = function (content) { - if (this._content === content) - return; - this.removeContent(); - if (content) { - this._content = content; - _super.prototype.addChild.call(this, content); - this._addEvents(); - } - }; - /** - * Remove rolling objects - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 移除滚动的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollView.prototype.removeContent = function () { - if (this._content) { - this._removeEvents(); - _super.prototype.removeChildAt.call(this, 0); - } - this._content = null; - }; - Object.defineProperty(ScrollView.prototype, "verticalScrollPolicy", { - /** - * Vertical scroll bar display policy, on / off / auto. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 垂直滚动条显示策略,on/off/auto。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._ScrV_Props_._verticalScrollPolicy; - }, - set: function (value) { - if (value == this._ScrV_Props_._verticalScrollPolicy) - return; - this._ScrV_Props_._verticalScrollPolicy = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollView.prototype, "horizontalScrollPolicy", { - /** - * The horizontal scroll bar display policy, on / off / auto. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 水平滚动条显示策略,on/off/auto。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._ScrV_Props_._horizontalScrollPolicy; - }, - set: function (value) { - if (value == this._ScrV_Props_._horizontalScrollPolicy) - return; - this._ScrV_Props_._horizontalScrollPolicy = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollView.prototype, "scrollLeft", { - /** - * Gets or sets the horizontal scroll position - * @returns {number} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取或设置水平滚动位置, - * @returns {number} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._ScrV_Props_._scrollLeft; - }, - set: function (value) { - if (value == this._ScrV_Props_._scrollLeft) - return; - this._ScrV_Props_._scrollLeft = value; - this._validatePosition(false, true); - this._updateContentPosition(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollView.prototype, "scrollTop", { - /** - * Gets or sets the vertical scroll position - * @returns {number} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取或设置垂直滚动位置, - * @returns {number} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._ScrV_Props_._scrollTop; - }, - set: function (value) { - if (value == this._ScrV_Props_._scrollTop) - return; - this._ScrV_Props_._scrollTop = value; - this._validatePosition(true, false); - this._updateContentPosition(); - }, - enumerable: true, - configurable: true - }); - /** - * Set scroll position - * @param top {number} The vertical scroll position - * @param left {number} The horizontal scroll position - * @param isOffset {boolean} Optional parameter, the default is false, whether it is the amount of scrolling increase as top = 1 on behalf of one pixel scroll up - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置滚动位置 - * @param top {number} 垂直滚动位置 - * @param left {number} 水平滚动位置 - * @param isOffset {boolean} 可选参数,默认是false,是否是滚动增加量,如 top=1 代表往上滚动1像素 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollView.prototype.setScrollPosition = function (top, left, isOffset) { - if (isOffset === void 0) { isOffset = false; } - if (isOffset && top == 0 && left == 0) - return; - if (!isOffset && this._ScrV_Props_._scrollTop == top - && this._ScrV_Props_._scrollLeft == left) - return; - var oldTop = this._ScrV_Props_._scrollTop, oldLeft = this._ScrV_Props_._scrollLeft; - if (isOffset) { - var maxLeft = this.getMaxScrollLeft(); - var maxTop = this.getMaxScrollTop(); - if (oldTop <= 0 || oldTop >= maxTop) { - top = top / 2; - } - if (oldLeft <= 0 || oldLeft >= maxLeft) { - left = left / 2; - } - var newTop = oldTop + top; - var newLeft = oldLeft + left; - //判断是否回弹 - var bounces = this._ScrV_Props_._bounces; - if (!bounces) { - if (newTop <= 0 || newTop >= maxTop) - newTop = Math.max(0, Math.min(newTop, maxTop)); - if (newLeft <= 0 || newLeft >= maxLeft) - newLeft = Math.max(0, Math.min(newLeft, maxLeft)); - } - this._ScrV_Props_._scrollTop = newTop; - this._ScrV_Props_._scrollLeft = newLeft; - } - else { - this._ScrV_Props_._scrollTop = top; - this._ScrV_Props_._scrollLeft = left; - } - this._validatePosition(true, true); - this._updateContentPosition(); - }; - /** - * @private - * - * @param top - * @param left - */ - ScrollView.prototype._validatePosition = function (top, left) { - if (top === void 0) { top = false; } - if (left === void 0) { left = false; } - if (top) { - var height = this.height; - var contentHeight = this._getContentHeight(); - this._ScrV_Props_._scrollTop = Math.max(this._ScrV_Props_._scrollTop, (0 - height) / 2); - this._ScrV_Props_._scrollTop = Math.min(this._ScrV_Props_._scrollTop, contentHeight > height ? (contentHeight - height / 2) : height / 2); - } - if (left) { - var width = this.width; - var contentWidth = this._getContentWidth(); - this._ScrV_Props_._scrollLeft = Math.max(this._ScrV_Props_._scrollLeft, (0 - width) / 2); - this._ScrV_Props_._scrollLeft = Math.min(this._ScrV_Props_._scrollLeft, contentWidth > width ? (contentWidth - width / 2) : width / 2); - } - }; - /** - * @private - * @inheritDoc - */ - ScrollView.prototype.$setWidth = function (value) { - if (this.$explicitWidth == value) { - return; - } - _super.prototype.$setWidth.call(this, value); - this._updateContentPosition(); - }; - /** - * @private - * @inheritDoc - */ - ScrollView.prototype.$setHeight = function (value) { - if (this.$explicitHeight == value) { - return; - } - _super.prototype.$setHeight.call(this, value); - this._updateContentPosition(); - }; - /** - * @private - * - */ - ScrollView.prototype._updateContentPosition = function () { - var height = this.height; - var width = this.width; - //这里将坐标取整,避免有些浏览器精度低产生“黑线”问题 - this.scrollRect = new egret.Rectangle(Math.round(this._ScrV_Props_._scrollLeft), Math.round(this._ScrV_Props_._scrollTop), width, height); - this.dispatchEvent(new egret.Event(egret.Event.CHANGE)); - }; - /** - * @private - * - * @returns - */ - ScrollView.prototype._checkScrollPolicy = function () { - var hpolicy = this._ScrV_Props_._horizontalScrollPolicy; - var hCanScroll = this.__checkScrollPolicy(hpolicy, this._getContentWidth(), this.width); - this._ScrV_Props_._hCanScroll = hCanScroll; - var vpolicy = this._ScrV_Props_._verticalScrollPolicy; - var vCanScroll = this.__checkScrollPolicy(vpolicy, this._getContentHeight(), this.height); - this._ScrV_Props_._vCanScroll = vCanScroll; - return hCanScroll || vCanScroll; - }; - /** - * @private - * - * @param policy - * @param contentLength - * @param viewLength - * @returns - */ - ScrollView.prototype.__checkScrollPolicy = function (policy, contentLength, viewLength) { - if (policy == "on") - return true; - if (policy == "off") - return false; - return contentLength > viewLength; - }; - /** - * @private - * - * @returns - */ - ScrollView.prototype._addEvents = function () { - this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this._onTouchBegin, this); - this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this._onTouchBeginCapture, this, true); - this.addEventListener(egret.TouchEvent.TOUCH_END, this._onTouchEndCapture, this, true); - }; - /** - * @private - * - * @returns - */ - ScrollView.prototype._removeEvents = function () { - this.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this._onTouchBegin, this); - this.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this._onTouchBeginCapture, this, true); - this.removeEventListener(egret.TouchEvent.TOUCH_END, this._onTouchEndCapture, this, true); - }; - /** - * @private - * - * @param e - */ - ScrollView.prototype._onTouchBegin = function (e) { - if (e.$isDefaultPrevented) { - return; - } - var canScroll = this._checkScrollPolicy(); - if (!canScroll) { - return; - } - this._ScrV_Props_._touchStartPosition.x = e.stageX; - this._ScrV_Props_._touchStartPosition.y = e.stageY; - if (this._ScrV_Props_._isHTweenPlaying || this._ScrV_Props_._isVTweenPlaying) { - this._onScrollFinished(); - } - this._tempStage = this.stage; - this._tempStage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this._onTouchMove, this); - this._tempStage.addEventListener(egret.TouchEvent.TOUCH_END, this._onTouchEnd, this); - this._tempStage.addEventListener(egret.TouchEvent.LEAVE_STAGE, this._onTouchEnd, this); - this.addEventListener(egret.Event.ENTER_FRAME, this._onEnterFrame, this); - this._logTouchEvent(e); - e.preventDefault(); - }; - /** - * @private - * - * @param event - */ - ScrollView.prototype._onTouchBeginCapture = function (event) { - var canScroll = this._checkScrollPolicy(); - if (!canScroll) { - return; - } - var target = event.target; - while (target != this) { - if ("_checkScrollPolicy" in target) { - canScroll = target._checkScrollPolicy(); - if (canScroll) { - return; - } - } - target = target.parent; - } - event.stopPropagation(); - var evt = this.cloneTouchEvent(event); - this.delayTouchBeginEvent = evt; - if (!this.touchBeginTimer) { - this.touchBeginTimer = new egret.Timer(100, 1); - this.touchBeginTimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this._onTouchBeginTimer, this); - } - this.touchBeginTimer.start(); - this._onTouchBegin(event); - }; - /** - * @private - * - * @param event - * @returns - */ - ScrollView.prototype._onTouchEndCapture = function (event) { - var _this = this; - if (!this.delayTouchBeginEvent) { - return; - } - this._onTouchBeginTimer(); - event.stopPropagation(); - var evt = this.cloneTouchEvent(event); - egret.callLater(function () { - if (_this.stage) { - _this.dispatchPropagationEvent(evt); - } - }, this); - }; - /** - * @private - * - */ - ScrollView.prototype._onTouchBeginTimer = function () { - this.touchBeginTimer.stop(); - var event = this.delayTouchBeginEvent; - this.delayTouchBeginEvent = null; - //Dispatch event only if the scroll view is still on the stage - if (this.stage) - this.dispatchPropagationEvent(event); - }; - /** - * @private - * - * @param event - * @returns - */ - ScrollView.prototype.dispatchPropagationEvent = function (event) { - var target = event.$target; - var list = this.$getPropagationList(target); - var length = list.length; - var targetIndex = list.length * 0.5; - var startIndex = -1; - for (var i = 0; i < length; i++) { - if (list[i] === this._content) { - startIndex = i; - break; - } - } - list.splice(0, startIndex + 1); - targetIndex -= startIndex + 1; - this.$dispatchPropagationEvent(event, list, targetIndex); - egret.Event.release(event); - }; - /** - * @private - * - * @param event - * @returns - */ - ScrollView.prototype._onTouchMove = function (event) { - if (this._ScrV_Props_._lastTouchPosition.x == event.stageX && this._ScrV_Props_._lastTouchPosition.y == event.stageY) - return; - if (!this._ScrV_Props_._scrollStarted) { - var x = event.stageX - this._ScrV_Props_._touchStartPosition.x, y = event.stageY - this._ScrV_Props_._touchStartPosition.y; - var distance = Math.sqrt(x * x + y * y); - if (distance < this.scrollBeginThreshold) { - this._logTouchEvent(event); - return; - } - } - this._ScrV_Props_._scrollStarted = true; - if (this.delayTouchBeginEvent) { - this.delayTouchBeginEvent = null; - this.touchBeginTimer.stop(); - } - this.touchChildren = false; - var offset = this._getPointChange(event); - this.setScrollPosition(offset.y, offset.x, true); - this._calcVelocitys(event); - this._logTouchEvent(event); - }; - /** - * @private - * - * @param event - * @returns - */ - ScrollView.prototype._onTouchEnd = function (event) { - this.touchChildren = true; - this._ScrV_Props_._scrollStarted = false; - this._tempStage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this._onTouchMove, this); - this._tempStage.removeEventListener(egret.TouchEvent.TOUCH_END, this._onTouchEnd, this); - this._tempStage.removeEventListener(egret.TouchEvent.LEAVE_STAGE, this._onTouchEnd, this); - this.removeEventListener(egret.Event.ENTER_FRAME, this._onEnterFrame, this); - this._moveAfterTouchEnd(); - }; - /** - * @private - * - * @param event - * @returns - */ - ScrollView.prototype._onEnterFrame = function (event) { - var time = egret.getTimer(); - if (time - this._ScrV_Props_._lastTouchTime > 100 && time - this._ScrV_Props_._lastTouchTime < 300) { - this._calcVelocitys(this._ScrV_Props_._lastTouchEvent); - } - }; - /** - * @private - * - * @param e - * @returns - */ - ScrollView.prototype._logTouchEvent = function (e) { - this._ScrV_Props_._lastTouchPosition.x = e.stageX; - this._ScrV_Props_._lastTouchPosition.y = e.stageY; - this._ScrV_Props_._lastTouchEvent = this.cloneTouchEvent(e); - this._ScrV_Props_._lastTouchTime = egret.getTimer(); - }; - /** - * @private - * - * @param e - * @returns - */ - ScrollView.prototype._getPointChange = function (e) { - return { - x: this._ScrV_Props_._hCanScroll === false ? 0 : (this._ScrV_Props_._lastTouchPosition.x - e.stageX), - y: this._ScrV_Props_._vCanScroll === false ? 0 : (this._ScrV_Props_._lastTouchPosition.y - e.stageY) - }; - }; - /** - * @private - * - * @param e - * @returns - */ - ScrollView.prototype._calcVelocitys = function (e) { - var time = egret.getTimer(); - if (this._ScrV_Props_._lastTouchTime == 0) { - this._ScrV_Props_._lastTouchTime = time; - return; - } - var change = this._getPointChange(e); - var timeoffset = time - this._ScrV_Props_._lastTouchTime; - change.x /= timeoffset; - change.y /= timeoffset; - this._ScrV_Props_._velocitys.push(change); - if (this._ScrV_Props_._velocitys.length > 5) - this._ScrV_Props_._velocitys.shift(); - this._ScrV_Props_._lastTouchPosition.x = e.stageX; - this._ScrV_Props_._lastTouchPosition.y = e.stageY; - }; - /** - * @private - * - * @returns - */ - ScrollView.prototype._getContentWidth = function () { - return this._content.$explicitWidth || this._content.width; - }; - /** - * @private - * - * @returns - */ - ScrollView.prototype._getContentHeight = function () { - return this._content.$explicitHeight || this._content.height; - }; - /** - * The left side of the maximum distance - * @returns The left side of the maximum distance - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 距离左侧的最大值 - * @returns 距离左侧最大值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollView.prototype.getMaxScrollLeft = function () { - var max = this._getContentWidth() - this.width; - return Math.max(0, max); - }; - /** - * Above the maximum distance - * @returns Above the maximum distance - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 距离上方最大值 - * @returns 距离上方最大值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollView.prototype.getMaxScrollTop = function () { - var max = this._getContentHeight() - this.height; - return Math.max(0, max); - }; - /** - * @private - * - */ - ScrollView.prototype._moveAfterTouchEnd = function () { - if (this._ScrV_Props_._velocitys.length == 0) - return; - var sum = { x: 0, y: 0 }, totalW = 0; - for (var i = 0; i < this._ScrV_Props_._velocitys.length; i++) { - var v = this._ScrV_Props_._velocitys[i]; - var w = ScrollView.weight[i]; - sum.x += v.x * w; - sum.y += v.y * w; - totalW += w; - } - this._ScrV_Props_._velocitys.length = 0; - if (this.scrollSpeed <= 0) - this.scrollSpeed = 1; - var x = sum.x / totalW * this.scrollSpeed, y = sum.y / totalW * this.scrollSpeed; - var pixelsPerMSX = Math.abs(x), pixelsPerMSY = Math.abs(y); - var maxLeft = this.getMaxScrollLeft(); - var maxTop = this.getMaxScrollTop(); - var datax = pixelsPerMSX > 0.02 ? this.getAnimationDatas(x, this._ScrV_Props_._scrollLeft, maxLeft) : { - position: this._ScrV_Props_._scrollLeft, - duration: 1 - }; - var datay = pixelsPerMSY > 0.02 ? this.getAnimationDatas(y, this._ScrV_Props_._scrollTop, maxTop) : { - position: this._ScrV_Props_._scrollTop, - duration: 1 - }; - this.setScrollLeft(datax.position, datax.duration); - this.setScrollTop(datay.position, datay.duration); - }; - /** - * @private - * - * @param tw - */ - ScrollView.prototype.onTweenFinished = function (tw) { - if (tw == this._ScrV_Props_._vScrollTween) - this._ScrV_Props_._isVTweenPlaying = false; - if (tw == this._ScrV_Props_._hScrollTween) - this._ScrV_Props_._isHTweenPlaying = false; - if (this._ScrV_Props_._isHTweenPlaying == false && this._ScrV_Props_._isVTweenPlaying == false) { - this._onScrollFinished(); - } - }; - /** - * @private - * - * @returns - */ - ScrollView.prototype._onScrollStarted = function () { - }; - /** - * @private - * - * @returns - */ - ScrollView.prototype._onScrollFinished = function () { - egret.ScrollTween.removeTweens(this); - this._ScrV_Props_._hScrollTween = null; - this._ScrV_Props_._vScrollTween = null; - this._ScrV_Props_._isHTweenPlaying = false; - this._ScrV_Props_._isVTweenPlaying = false; - this.dispatchEvent(new egret.Event(egret.Event.COMPLETE)); - }; - /** - * Set the scroll position above the distance - * @param scrollTop Position above distance - * @param duration Easing of time, in milliseconds - * @returns Get tween vertical scrolling - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置滚动距离上方的位置 - * @param scrollTop 距离上方的位置 - * @param duration 缓动时间,毫秒单位 - * @returns 获取垂直滚动的tween - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollView.prototype.setScrollTop = function (scrollTop, duration) { - if (duration === void 0) { duration = 0; } - var finalPosition = Math.min(this.getMaxScrollTop(), Math.max(scrollTop, 0)); - if (duration == 0) { - this.scrollTop = finalPosition; - return; - } - if (this._ScrV_Props_._bounces == false) - scrollTop = finalPosition; - var vtween = egret.ScrollTween.get(this).to({ scrollTop: scrollTop }, duration, egret.ScrollEase.quartOut); - if (finalPosition != scrollTop) { - vtween.to({ scrollTop: finalPosition }, 300, egret.ScrollEase.quintOut); - } - this._ScrV_Props_._isVTweenPlaying = true; - this._ScrV_Props_._vScrollTween = vtween; - vtween.call(this.onTweenFinished, this, [vtween]); - if (!this._ScrV_Props_._isHTweenPlaying) - this._onScrollStarted(); - }; - /** - * Set the scroll position from the left side - * @param scrollLeft From the position on the left side - * @param duration Get tween vertical scrolling - * @returns Gets the horizontal scroll tween - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置滚动距离左侧的位置 - * @param scrollLeft 距离左侧的位置 - * @param duration 缓动时间,毫秒单位 - * @returns 获取水平滚动的tween - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollView.prototype.setScrollLeft = function (scrollLeft, duration) { - if (duration === void 0) { duration = 0; } - var finalPosition = Math.min(this.getMaxScrollLeft(), Math.max(scrollLeft, 0)); - if (duration == 0) { - this.scrollLeft = finalPosition; - return; - } - if (this._ScrV_Props_._bounces == false) - scrollLeft = finalPosition; - var htween = egret.ScrollTween.get(this).to({ scrollLeft: scrollLeft }, duration, egret.ScrollEase.quartOut); - if (finalPosition != scrollLeft) { - htween.to({ scrollLeft: finalPosition }, 300, egret.ScrollEase.quintOut); - } - this._ScrV_Props_._isHTweenPlaying = true; - this._ScrV_Props_._hScrollTween = htween; - htween.call(this.onTweenFinished, this, [htween]); - if (!this._ScrV_Props_._isVTweenPlaying) - this._onScrollStarted(); - }; - /** - * @private - * - * @param pixelsPerMS - * @param curPos - * @param maxPos - * @returns - */ - ScrollView.prototype.getAnimationDatas = function (pixelsPerMS, curPos, maxPos) { - var absPixelsPerMS = Math.abs(pixelsPerMS); - var extraFricition = 0.95; - var duration = 0; - var friction = 0.998; - var minVelocity = 0.02; - var posTo = curPos + pixelsPerMS * 500; - if (posTo < 0 || posTo > maxPos) { - posTo = curPos; - while (Math.abs(pixelsPerMS) != Infinity && Math.abs(pixelsPerMS) > minVelocity) { - posTo += pixelsPerMS; - if (posTo < 0 || posTo > maxPos) { - pixelsPerMS *= friction * extraFricition; - } - else { - pixelsPerMS *= friction; - } - duration++; - } - } - else { - duration = -Math.log(minVelocity / absPixelsPerMS) * 500; - } - var result = { - position: Math.min(maxPos + 50, Math.max(posTo, -50)), - duration: duration - }; - return result; - }; - /** - * @private - * - * @param event - * @returns - */ - ScrollView.prototype.cloneTouchEvent = function (event) { - var evt = new egret.TouchEvent(event.type, event.bubbles, event.cancelable); - evt.touchPointID = event.touchPointID; - evt.$stageX = event.stageX; - evt.$stageY = event.stageY; - //evt.ctrlKey = event.ctrlKey; - //evt.altKey = event.altKey; - //evt.shiftKey = event.shiftKey; - evt.touchDown = event.touchDown; - evt.$isDefaultPrevented = false; - evt.$target = event.target; - return evt; - }; - /** - * @private - * - * @returns - */ - ScrollView.prototype.throwNotSupportedError = function () { - egret.$error(1023); - }; - /** - * @deprecated - * @inheritDoc - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollView.prototype.addChild = function (child) { - this.throwNotSupportedError(); - return null; - }; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollView.prototype.addChildAt = function (child, index) { - this.throwNotSupportedError(); - return null; - }; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollView.prototype.removeChild = function (child) { - this.throwNotSupportedError(); - return null; - }; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollView.prototype.removeChildAt = function (index) { - this.throwNotSupportedError(); - return null; - }; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollView.prototype.setChildIndex = function (child, index) { - this.throwNotSupportedError(); - }; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollView.prototype.swapChildren = function (child1, child2) { - this.throwNotSupportedError(); - }; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollView.prototype.swapChildrenAt = function (index1, index2) { - this.throwNotSupportedError(); - }; - /** - * @private - */ - ScrollView.weight = [1, 1.33, 1.66, 2, 2.33]; - return ScrollView; - }(egret.DisplayObjectContainer)); - egret.ScrollView = ScrollView; - __reflect(ScrollView.prototype, "egret.ScrollView"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - var ScrollViewProperties = (function () { - function ScrollViewProperties() { - /** - * @private - */ - this._verticalScrollPolicy = "auto"; - /** - * @private - */ - this._horizontalScrollPolicy = "auto"; - /** - * @private - */ - this._scrollLeft = 0; - /** - * @private - */ - this._scrollTop = 0; - /** - * @private - */ - this._hCanScroll = false; - /** - * @private - */ - this._vCanScroll = false; - /** - * @private - */ - this._lastTouchPosition = new egret.Point(0, 0); - /** - * @private - */ - this._touchStartPosition = new egret.Point(0, 0); - /** - * @private - */ - this._scrollStarted = false; - /** - * @private - */ - this._lastTouchTime = 0; - /** - * @private - */ - this._lastTouchEvent = null; - /** - * @private - */ - this._velocitys = []; - /** - * @private - */ - this._isHTweenPlaying = false; - /** - * @private - */ - this._isVTweenPlaying = false; - /** - * @private - */ - this._hScrollTween = null; - /** - * @private - */ - this._vScrollTween = null; - /** - * @private - */ - this._bounces = true; - } - return ScrollViewProperties; - }()); - egret.ScrollViewProperties = ScrollViewProperties; - __reflect(ScrollViewProperties.prototype, "egret.ScrollViewProperties"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - function $getUrl(request) { - var url = request.url; - //get请求没有设置参数,而是设置URLVariables的情况 - if (url.indexOf("?") == -1 && request.method == egret.URLRequestMethod.GET && request.data && request.data instanceof egret.URLVariables) { - url = url + "?" + request.data.toString(); - } - return url; - } - /** - * UThe URLLoader class downloads data from a URL as text, binary data, or URL-encoded variables. It is useful for downloading text files, XML, or other information to be used in a dynamic, data-driven application. - * A URLLoader object downloads all of the data from a URL before making it available to code in the applications. It sends out notifications about the progress of the download, - * which you can monitor through bytesLoaded and bytesTotal properties, as well as through dispatched events. - * @see http://edn.egret.com/cn/docs/page/601 Build communication request - * @event egret.Event.COMPLETE Dispatched when the net request is complete. - * @event egret.IOErrorEvent.IO_ERROR io error. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLLoader.ts - * @language en_US - */ - /** - * URLLoader 类以文本、二进制数据或 URL 编码变量的形式从 URL 下载数据。在下载文本文件、XML 或其他用于动态数据驱动应用程序的信息时,它很有用。 - * URLLoader 对象会先从 URL 中下载所有数据,然后才将数据用于应用程序中的代码。它会发出有关下载进度的通知, - * 通过 bytesLoaded 和 bytesTotal 属性以及已调度的事件,可以监视下载进度。 - * @see http://edn.egret.com/cn/docs/page/601 构建通信请求 - * @event egret.Event.COMPLETE 加载完成后调度。 - * @event egret.IOErrorEvent.IO_ERROR 加载错误后调度。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLLoader.ts - * @language zh_CN - */ - var URLLoader = (function (_super) { - __extends(URLLoader, _super); - /** - * Create an egret.URLLoader object - * @param request {URLRequest} A URLRequest object specifies the URL to be downloaded. - * If this parameter is omitted, no load operation begins. If a parameter is specified, the load operation begins immediately - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建 egret.URLLoader 对象 - * @param request {URLRequest} 一个 URLRequest 对象,指定要下载的 URL。 - * 如果省略该参数,则不开始加载操作。如果已指定参数,则立即开始加载操作 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function URLLoader(request) { - if (request === void 0) { request = null; } - var _this = _super.call(this) || this; - /** - * Control whether the downloaded data is received as text (URLLoaderDataFormat.TEXT), raw binary data (URLLoaderDataFormat.BINARY), or URL-encoded variables (URLLoaderDataFormat.VARIABLES). - * If the value of the dataFormat property is URLLoaderDataFormat.TEXT, the received data is a string containing the text of the loaded file. - * If the value of the dataFormat property is URLLoaderDataFormat.BINARY, the received data is a ByteArray object containing the raw binary data. - * If the value of the dataFormat property is URLLoaderDataFormat.TEXTURE, the received data is a Texture object containing the bitmap data. - * If the value of the dataFormat property is URLLoaderDataFormat.VARIABLES, the received data is a URLVariables object containing the URL-encoded variables. - * The default value is URLLoaderDataFormat.TEXT. - * @default egret.URLLoaderDataFormat.TEXT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 控制是以文本 (URLLoaderDataFormat.TEXT)、原始二进制数据 (URLLoaderDataFormat.BINARY) 还是 URL 编码变量 (URLLoaderDataFormat.VARIABLES) 接收下载的数据。 - * 如果 dataFormat 属性的值是 URLLoaderDataFormat.TEXT,则所接收的数据是一个包含已加载文件文本的字符串。 - * 如果 dataFormat 属性的值是 URLLoaderDataFormat.BINARY,则所接收的数据是一个包含原始二进制数据的 ByteArray 对象。 - * 如果 dataFormat 属性的值是 URLLoaderDataFormat.TEXTURE,则所接收的数据是一个包含位图数据的Texture对象。 - * 如果 dataFormat 属性的值是 URLLoaderDataFormat.VARIABLES,则所接收的数据是一个包含 URL 编码变量的 URLVariables 对象。 - * @default egret.URLLoaderDataFormat.TEXT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.dataFormat = egret.URLLoaderDataFormat.TEXT; - /** - * The data received from the load operation. This property is populated only when the load operation is complete. The format of the data depends on the setting of the dataFormat property: - * If the dataFormat property is URLLoaderDataFormat.TEXT, the received data is a string containing the text of the loaded file. - * If the dataFormat property is URLLoaderDataFormat.BINARY, the received data is a ByteArray object containing the raw binary data. - * If the dataFormat property is URLLoaderDataFormat.TEXTURE, the received data is a Texture object containing the bitmap data. - * If the dataFormat property is URLLoaderDataFormat.VARIABLES, the received data is a URLVariables object containing the URL-encoded variables. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从加载操作接收的数据。只有完成加载操作时,才会填充该属性。该数据的格式取决于 dataFormat 属性的设置: - * 如果 dataFormat 属性是 URLLoaderDataFormat.TEXT,则所接收的数据是一个包含已加载文件文本的字符串。 - * 如果 dataFormat 属性是 URLLoaderDataFormat.BINARY,则所接收的数据是一个包含原始二进制数据的 ByteArray 对象。 - * 如果 dataFormat 属性是 URLLoaderDataFormat.TEXTURE,则所接收的数据是一个包含位图数据的Texture对象。 - * 如果 dataFormat 属性是 URLLoaderDataFormat.VARIABLES,则所接收的数据是一个包含 URL 编码变量的 URLVariables 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.data = null; - /** - * @private - */ - _this._request = null; - /** - * @private - */ - _this._status = -1; - if (request) { - _this.load(request); - } - return _this; - } - /** - * Send and load data from the specified URL. The data can be received as text, raw binary data, or URL-encoded variables, depending on the value you set for the dataFormat property. - * Note that the default value of the dataFormat property is text. If you want to send data to the specified URL, you can set the data property in the URLRequest object. - * @param request {URLRequest} A URLRequest object specifies the URL to be downloaded. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从指定的 URL 发送和加载数据。可以以文本、原始二进制数据或 URL 编码变量格式接收数据,这取决于为 dataFormat 属性所设置的值。 - * 请注意 dataFormat 属性的默认值为文本。如果想将数据发送至指定的 URL,则可以在 URLRequest 对象中设置 data 属性。 - * @param request {URLRequest} 一个 URLRequest 对象,指定要下载的 URL。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - URLLoader.prototype.load = function (request) { - this._request = request; - this.data = null; - var loader = this; - if (loader.dataFormat == egret.URLLoaderDataFormat.TEXTURE) { - this.loadTexture(loader); - return; - } - if (loader.dataFormat == egret.URLLoaderDataFormat.SOUND) { - this.loadSound(loader); - return; - } - var virtualUrl = $getUrl(request); - var httpRequest = new egret.HttpRequest(); - httpRequest.open(virtualUrl, request.method == egret.URLRequestMethod.POST ? egret.HttpMethod.POST : egret.HttpMethod.GET); - var sendData; - if (request.method == egret.URLRequestMethod.GET || !request.data) { - } - else if (request.data instanceof egret.URLVariables) { - httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - var urlVars = request.data; - sendData = urlVars.toString(); - } - else { - httpRequest.setRequestHeader("Content-Type", "multipart/form-data"); - sendData = request.data; - } - var length = request.requestHeaders.length; - for (var i = 0; i < length; i++) { - var urlRequestHeader = request.requestHeaders[i]; - httpRequest.setRequestHeader(urlRequestHeader.name, urlRequestHeader.value); - } - httpRequest.addEventListener(egret.Event.COMPLETE, function () { - loader.data = httpRequest.response; - egret.Event.dispatchEvent(loader, egret.Event.COMPLETE); - }, this); - httpRequest.addEventListener(egret.IOErrorEvent.IO_ERROR, function () { - egret.IOErrorEvent.dispatchIOErrorEvent(loader); - }, this); - httpRequest.responseType = loader.dataFormat == egret.URLLoaderDataFormat.BINARY ? egret.HttpResponseType.ARRAY_BUFFER : egret.HttpResponseType.TEXT; - httpRequest.send(sendData); - }; - URLLoader.prototype.getResponseType = function (dataFormat) { - switch (dataFormat) { - case egret.URLLoaderDataFormat.TEXT: - case egret.URLLoaderDataFormat.VARIABLES: - return egret.URLLoaderDataFormat.TEXT; - case egret.URLLoaderDataFormat.BINARY: - return "arraybuffer"; - default: - return dataFormat; - } - }; - /** - * @private - * - * @param loader - */ - URLLoader.prototype.loadSound = function (loader) { - var self = this; - var virtualUrl = loader._request.url; - var sound = new egret.Sound(); - sound.addEventListener(egret.Event.COMPLETE, onLoadComplete, self); - sound.addEventListener(egret.IOErrorEvent.IO_ERROR, onError, self); - sound.addEventListener(egret.ProgressEvent.PROGRESS, onPostProgress, self); - sound.load(virtualUrl); - function onPostProgress(event) { - loader.dispatchEvent(event); - } - function onError(event) { - removeListeners(); - loader.dispatchEvent(event); - } - function onLoadComplete(e) { - removeListeners(); - loader.data = sound; - window.setTimeout(function () { - loader.dispatchEventWith(egret.Event.COMPLETE); - }, 0); - } - function removeListeners() { - sound.removeEventListener(egret.Event.COMPLETE, onLoadComplete, self); - sound.removeEventListener(egret.IOErrorEvent.IO_ERROR, onError, self); - sound.removeEventListener(egret.ProgressEvent.PROGRESS, onPostProgress, self); - } - }; - /** - * @private - * - * @param loader - */ - URLLoader.prototype.loadTexture = function (loader) { - var self = this; - var virtualUrl = loader._request.url; - var imageLoader = new egret.ImageLoader(); - imageLoader.addEventListener(egret.Event.COMPLETE, onLoadComplete, self); - imageLoader.addEventListener(egret.IOErrorEvent.IO_ERROR, onError, self); - imageLoader.addEventListener(egret.ProgressEvent.PROGRESS, onPostProgress, self); - imageLoader.load(virtualUrl); - function onPostProgress(event) { - loader.dispatchEvent(event); - } - function onError(event) { - removeListeners(); - loader.dispatchEvent(event); - } - function onLoadComplete(e) { - removeListeners(); - var bitmapData = imageLoader.data; - bitmapData.source.setAttribute("bitmapSrc", virtualUrl); - var texture = new egret.Texture(); - texture._setBitmapData(bitmapData); - loader.data = texture; - window.setTimeout(function () { - loader.dispatchEventWith(egret.Event.COMPLETE); - }, self); - } - function removeListeners() { - imageLoader.removeEventListener(egret.Event.COMPLETE, onLoadComplete, self); - imageLoader.removeEventListener(egret.IOErrorEvent.IO_ERROR, onError, self); - imageLoader.removeEventListener(egret.ProgressEvent.PROGRESS, onPostProgress, self); - } - }; - /** - * @private - * - */ - URLLoader.prototype.__recycle = function () { - this._request = null; - this.data = null; - }; - return URLLoader; - }(egret.EventDispatcher)); - egret.URLLoader = URLLoader; - __reflect(URLLoader.prototype, "egret.URLLoader"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/display/MovieClip.ts - * @language en_US - */ - /** - * 影片剪辑,可以通过影片剪辑播放序列帧动画。MovieClip 类从以下类继承而来:DisplayObject 和 EventDispatcher。不同于 DisplayObject 对象,MovieClip 对象拥有一个时间轴。 - * @extends egret.DisplayObject - * @event egret.Event.COMPLETE 动画播放完成。 - * @event egret.Event.LOOP_COMPLETE 动画循环播放完成。循环最后一次只派发 COMPLETE 事件,不派发 LOOP_COMPLETE 事件。 - * @see http://edn.egret.com/cn/docs/page/596 MovieClip序列帧动画 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/display/MovieClip.ts - * @language zh_CN - */ - var MovieClip = (function (_super) { - __extends(MovieClip, _super); - //Construct Function - /** - * 创建新的 MovieClip 实例。创建 MovieClip 之后,调用舞台上的显示对象容器的addElement方法。 - * @param movieClipData {movieClipData} 被引用的 movieClipData 对象 - * @version Egret 2.4 - * @platform Web,Native - */ - function MovieClip(movieClipData) { - var _this = _super.call(this) || this; - //Render Property - _this.$texture = null; - //Render Property - _this.offsetPoint = egret.Point.create(0, 0); - //Data Property - _this.$movieClipData = null; - /** - * @private - */ - _this.frames = null; - /** - * @private - */ - _this.$totalFrames = 0; - /** - * @version Egret 2.4 - * @platform Web,Native - * @private - */ - _this.frameLabels = null; - /** - * @private - */ - _this.$frameLabelStart = 0; - /** - * @private - */ - _this.$frameLabelEnd = 0; - /** - * @version Egret 2.4 - * @platform Web,Native - * @private - */ - _this.frameEvents = null; - /** - * @private - */ - _this.frameIntervalTime = 0; - /** - * @private - */ - _this.$eventPool = null; - //Animation Property - _this.$isPlaying = false; - /** - * @private - */ - _this.isStopped = true; - /** - * @private - */ - _this.playTimes = 0; - /** - * @private - */ - _this.$currentFrameNum = 0; - /** - * @private - */ - _this.$nextFrameNum = 1; - /** - * @private - */ - _this.displayedKeyFrameNum = 0; - /** - * @private - */ - _this.passedTime = 0; - /** - * @private - */ - _this.$frameRate = NaN; - /** - * @private - */ - _this.lastTime = 0; - _this.$smoothing = egret.Bitmap.defaultSmoothing; - _this.setMovieClipData(movieClipData); - if (!egret.nativeRender) { - _this.$renderNode = new egret.sys.NormalBitmapNode(); - } - return _this; - } - MovieClip.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(11 /* BITMAP_TEXT */); - }; - Object.defineProperty(MovieClip.prototype, "smoothing", { - /** - * Whether or not is smoothed when scaled. - * @version Egret 3.0 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否进行平滑处理。 - * @version Egret 3.0 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$smoothing; - }, - set: function (value) { - if (value == this.$smoothing) { - return; - } - this.$smoothing = value; - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - */ - MovieClip.prototype.$init = function () { - this.$reset(); - var movieClipData = this.$movieClipData; - if (movieClipData && movieClipData.$isDataValid()) { - this.frames = movieClipData.frames; - this.$totalFrames = movieClipData.numFrames; - this.frameLabels = movieClipData.labels; - this.frameEvents = movieClipData.events; - this.$frameRate = movieClipData.frameRate; - this.frameIntervalTime = 1000 / this.$frameRate; - this._initFrame(); - } - }; - /** - * @private - * - */ - MovieClip.prototype.$reset = function () { - this.frames = null; - this.playTimes = 0; - this.$isPlaying = false; - this.setIsStopped(true); - this.$currentFrameNum = 0; - this.$nextFrameNum = 1; - this.displayedKeyFrameNum = 0; - this.passedTime = 0; - this.$eventPool = []; - }; - /** - * @private - * - */ - MovieClip.prototype._initFrame = function () { - if (this.$movieClipData.$isTextureValid()) { - this.advanceFrame(); - this.constructFrame(); - } - }; - /** - * @private - */ - MovieClip.prototype.$updateRenderNode = function () { - var texture = this.$texture; - if (texture) { - var offsetX = Math.round(this.offsetPoint.x); - var offsetY = Math.round(this.offsetPoint.y); - var bitmapWidth = texture.$bitmapWidth; - var bitmapHeight = texture.$bitmapHeight; - var textureWidth = texture.$getTextureWidth(); - var textureHeight = texture.$getTextureHeight(); - var destW = Math.round(texture.$getScaleBitmapWidth()); - var destH = Math.round(texture.$getScaleBitmapHeight()); - var sourceWidth = texture.$sourceWidth; - var sourceHeight = texture.$sourceHeight; - egret.sys.BitmapNode.$updateTextureData(this.$renderNode, texture.$bitmapData, texture.$bitmapX, texture.$bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH, sourceWidth, sourceHeight, egret.BitmapFillMode.SCALE, this.$smoothing); - } - }; - /** - * @private - */ - MovieClip.prototype.$measureContentBounds = function (bounds) { - var texture = this.$texture; - if (texture) { - var x = this.offsetPoint.x; - var y = this.offsetPoint.y; - var w = texture.$getTextureWidth(); - var h = texture.$getTextureHeight(); - bounds.setTo(x, y, w, h); - } - else { - bounds.setEmpty(); - } - }; - /** - * @private - * - * @param stage - * @param nestLevel - */ - MovieClip.prototype.$onAddToStage = function (stage, nestLevel) { - _super.prototype.$onAddToStage.call(this, stage, nestLevel); - if (this.$isPlaying && this.$totalFrames > 1) { - this.setIsStopped(false); - } - }; - /** - * @private - * - */ - MovieClip.prototype.$onRemoveFromStage = function () { - _super.prototype.$onRemoveFromStage.call(this); - this.setIsStopped(true); - }; - //Data Function - /** - * @private - * 返回帧标签为指定字符串的FrameLabel对象 - * @param labelName {string} 帧标签名 - * @param ignoreCase {boolean} 是否忽略大小写,可选参数,默认false - * @returns {egret.FrameLabel} FrameLabel对象 - */ - MovieClip.prototype.getFrameLabelByName = function (labelName, ignoreCase) { - if (ignoreCase === void 0) { ignoreCase = false; } - if (ignoreCase) { - labelName = labelName.toLowerCase(); - } - var frameLabels = this.frameLabels; - if (frameLabels) { - var outputFramelabel = null; - for (var i = 0; i < frameLabels.length; i++) { - outputFramelabel = frameLabels[i]; - if (ignoreCase ? outputFramelabel.name.toLowerCase() == labelName : outputFramelabel.name == labelName) { - return outputFramelabel; - } - } - } - return null; - }; - /** - * @private - * 根据帧标签,设置开始和结束的帧数 - * @param labelName {string} 帧标签名 - */ - MovieClip.prototype.getFrameStartEnd = function (labelName) { - var frameLabels = this.frameLabels; - if (frameLabels) { - var outputFramelabel = null; - for (var i = 0; i < frameLabels.length; i++) { - outputFramelabel = frameLabels[i]; - if (labelName == outputFramelabel.name) { - this.$frameLabelStart = outputFramelabel.frame; - this.$frameLabelEnd = outputFramelabel.end; - break; - } - } - } - }; - /** - * @private - * 返回指定序号的帧的FrameLabel对象 - * @param frame {number} 帧序号 - * @returns {egret.FrameLabel} FrameLabel对象 - */ - MovieClip.prototype.getFrameLabelByFrame = function (frame) { - var frameLabels = this.frameLabels; - if (frameLabels) { - var outputFramelabel = null; - for (var i = 0; i < frameLabels.length; i++) { - outputFramelabel = frameLabels[i]; - if (outputFramelabel.frame == frame) { - return outputFramelabel; - } - } - } - return null; - }; - /** - * @private - * 返回指定序号的帧对应的FrameLabel对象,如果当前帧没有标签,则返回前面最近的有标签的帧的FrameLabel对象 - * @method egret.MovieClip#getFrameLabelForFrame - * @param frame {number} 帧序号 - * @returns {egret.FrameLabel} FrameLabel对象 - */ - MovieClip.prototype.getFrameLabelForFrame = function (frame) { - var outputFrameLabel = null; - var tempFrameLabel = null; - var frameLabels = this.frameLabels; - if (frameLabels) { - for (var i = 0; i < frameLabels.length; i++) { - tempFrameLabel = frameLabels[i]; - if (tempFrameLabel.frame > frame) { - return outputFrameLabel; - } - outputFrameLabel = tempFrameLabel; - } - } - return outputFrameLabel; - }; - //Animation Function - /** - * 继续播放当前动画 - * @param playTimes {number} 播放次数。 参数为整数,可选参数,>=1:设定播放次数,<0:循环播放,默认值 0:不改变播放次数(MovieClip初始播放次数设置为1), - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClip.prototype.play = function (playTimes) { - if (playTimes === void 0) { playTimes = 0; } - this.lastTime = egret.getTimer(); - this.passedTime = 0; - this.$isPlaying = true; - this.setPlayTimes(playTimes); - if (this.$totalFrames > 1 && this.$stage) { - this.setIsStopped(false); - } - }; - /** - * 暂停播放动画 - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClip.prototype.stop = function () { - this.$isPlaying = false; - this.setIsStopped(true); - }; - /** - * 将播放头移到前一帧并停止 - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClip.prototype.prevFrame = function () { - this.gotoAndStop(this.$currentFrameNum - 1); - }; - /** - * 跳到后一帧并停止 - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClip.prototype.nextFrame = function () { - this.gotoAndStop(this.$currentFrameNum + 1); - }; - /** - * 将播放头移到指定帧并播放 - * @param frame {any} 指定帧的帧号或帧标签 - * @param playTimes {number} 播放次数。 参数为整数,可选参数,>=1:设定播放次数,<0:循环播放,默认值 0:不改变播放次数, - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClip.prototype.gotoAndPlay = function (frame, playTimes) { - if (playTimes === void 0) { playTimes = 0; } - if (arguments.length == 0 || arguments.length > 2) { - egret.$error(1022, "MovieClip.gotoAndPlay()"); - } - if (typeof frame === "string") { - this.getFrameStartEnd(frame); - } - else { - this.$frameLabelStart = 0; - this.$frameLabelEnd = 0; - } - this.play(playTimes); - this.gotoFrame(frame); - }; - /** - * 将播放头移到指定帧并停止 - * @param frame {any} 指定帧的帧号或帧标签 - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClip.prototype.gotoAndStop = function (frame) { - if (arguments.length != 1) { - egret.$error(1022, "MovieClip.gotoAndStop()"); - } - this.stop(); - this.gotoFrame(frame); - }; - /** - * @private - * - * @param frame - */ - MovieClip.prototype.gotoFrame = function (frame) { - var frameNum; - if (typeof frame === "string") { - frameNum = this.getFrameLabelByName(frame).frame; - } - else { - frameNum = parseInt(frame + '', 10); - if (frameNum != frame) { - egret.$error(1022, "Frame Label Not Found"); - } - } - if (frameNum < 1) { - frameNum = 1; - } - else if (frameNum > this.$totalFrames) { - frameNum = this.$totalFrames; - } - if (frameNum == this.$nextFrameNum) { - return; - } - this.$nextFrameNum = frameNum; - this.advanceFrame(); - this.constructFrame(); - this.handlePendingEvent(); - }; - /** - * @private - * - * @param advancedTime - * @returns - */ - MovieClip.prototype.advanceTime = function (timeStamp) { - var self = this; - var advancedTime = timeStamp - self.lastTime; - self.lastTime = timeStamp; - var frameIntervalTime = self.frameIntervalTime; - var currentTime = self.passedTime + advancedTime; - self.passedTime = currentTime % frameIntervalTime; - var num = currentTime / frameIntervalTime; - if (num < 1) { - return false; - } - while (num >= 1) { - num--; - self.$nextFrameNum++; - if (self.$nextFrameNum > self.$totalFrames || (self.$frameLabelStart > 0 && self.$nextFrameNum > self.$frameLabelEnd)) { - if (self.playTimes == -1) { - self.$eventPool.push(egret.Event.LOOP_COMPLETE); - self.$nextFrameNum = 1; - } - else { - self.playTimes--; - if (self.playTimes > 0) { - self.$eventPool.push(egret.Event.LOOP_COMPLETE); - self.$nextFrameNum = 1; - } - else { - self.$nextFrameNum = self.$totalFrames; - self.$eventPool.push(egret.Event.COMPLETE); - self.stop(); - break; - } - } - } - if (self.$currentFrameNum == self.$frameLabelEnd) { - self.$nextFrameNum = self.$frameLabelStart; - } - self.advanceFrame(); - } - self.constructFrame(); - self.handlePendingEvent(); - return false; - }; - /** - * @private - * - */ - MovieClip.prototype.advanceFrame = function () { - this.$currentFrameNum = this.$nextFrameNum; - var event = this.frameEvents[this.$nextFrameNum]; - if (event && event != "") { - egret.MovieClipEvent.dispatchMovieClipEvent(this, egret.MovieClipEvent.FRAME_LABEL, event); - } - }; - /** - * @private - * - */ - MovieClip.prototype.constructFrame = function () { - var self = this; - var currentFrameNum = self.$currentFrameNum; - if (self.displayedKeyFrameNum == currentFrameNum) { - return; - } - var texture = self.$movieClipData.getTextureByFrame(currentFrameNum); - self.$texture = texture; - self.$movieClipData.$getOffsetByFrame(currentFrameNum, self.offsetPoint); - self.displayedKeyFrameNum = currentFrameNum; - self.$renderDirty = true; - if (egret.nativeRender) { - self.$nativeDisplayObject.setDataToBitmapNode(self.$nativeDisplayObject.id, texture, [texture.$bitmapX, texture.$bitmapY, texture.$bitmapWidth, texture.$bitmapHeight, - self.offsetPoint.x, self.offsetPoint.y, texture.$getScaleBitmapWidth(), texture.$getScaleBitmapHeight(), - texture.$sourceWidth, texture.$sourceHeight]); - //todo 负数offsetPoint - self.$nativeDisplayObject.setWidth(texture.$getTextureWidth() + self.offsetPoint.x); - self.$nativeDisplayObject.setHeight(texture.$getTextureHeight() + self.offsetPoint.y); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - /** - * @private - * - */ - MovieClip.prototype.$renderFrame = function () { - var self = this; - self.$texture = self.$movieClipData.getTextureByFrame(self.$currentFrameNum); - self.$renderDirty = true; - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - }; - /** - * @private - * - */ - MovieClip.prototype.handlePendingEvent = function () { - if (this.$eventPool.length != 0) { - this.$eventPool.reverse(); - var eventPool = this.$eventPool; - var length_3 = eventPool.length; - var isComplete = false; - var isLoopComplete = false; - for (var i = 0; i < length_3; i++) { - var event_1 = eventPool.pop(); - if (event_1 == egret.Event.LOOP_COMPLETE) { - isLoopComplete = true; - } - else if (event_1 == egret.Event.COMPLETE) { - isComplete = true; - } - else { - this.dispatchEventWith(event_1); - } - } - if (isLoopComplete) { - this.dispatchEventWith(egret.Event.LOOP_COMPLETE); - } - if (isComplete) { - this.dispatchEventWith(egret.Event.COMPLETE); - } - } - }; - Object.defineProperty(MovieClip.prototype, "totalFrames", { - //Properties - /** - * MovieClip 实例中帧的总数 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$totalFrames; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "currentFrame", { - /** - * MovieClip 实例当前播放的帧的序号 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$currentFrameNum; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "currentFrameLabel", { - /** - * MovieClip 实例当前播放的帧的标签。如果当前帧没有标签,则 currentFrameLabel返回null。 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - var label = this.getFrameLabelByFrame(this.$currentFrameNum); - return label && label.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "currentLabel", { - /** - * 当前播放的帧对应的标签,如果当前帧没有标签,则currentLabel返回包含标签的先前帧的标签。如果当前帧和先前帧都不包含标签,currentLabel返回null。 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - var label = this.getFrameLabelForFrame(this.$currentFrameNum); - return label ? label.name : null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "frameRate", { - /** - * MovieClip 实例的帧频 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$frameRate; - }, - set: function (value) { - if (value == this.$frameRate) { - return; - } - this.$frameRate = value; - this.frameIntervalTime = 1000 / this.$frameRate; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "isPlaying", { - /** - * MovieClip 实例当前是否正在播放 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$isPlaying; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "movieClipData", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$movieClipData; - }, - /** - * MovieClip数据源 - */ - set: function (value) { - this.setMovieClipData(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - MovieClip.prototype.setMovieClipData = function (value) { - if (this.$movieClipData == value) { - return; - } - this.$movieClipData = value; - this.$init(); - }; - /** - * @private - * - * @param value - */ - MovieClip.prototype.setPlayTimes = function (value) { - if (value < 0 || value >= 1) { - this.playTimes = value < 0 ? -1 : Math.floor(value); - } - }; - /** - * @private - * - * @param value - */ - MovieClip.prototype.setIsStopped = function (value) { - if (this.isStopped == value) { - return; - } - this.isStopped = value; - if (value) { - egret.ticker.$stopTick(this.advanceTime, this); - } - else { - this.playTimes = this.playTimes == 0 ? 1 : this.playTimes; - this.lastTime = egret.getTimer(); - egret.ticker.$startTick(this.advanceTime, this); - } - }; - return MovieClip; - }(egret.DisplayObject)); - egret.MovieClip = MovieClip; - __reflect(MovieClip.prototype, "egret.MovieClip"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The URLRequest class captures all of the information in a single HTTP request. - * @see http://edn.egret.com/cn/index.php/article/index/id/601 Build communication request - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequest.ts - * @language en_US - */ - /** - * URLRequest 类可捕获单个 HTTP 请求中的所有信息。 - * @see http://edn.egret.com/cn/index.php/article/index/id/601 构建通信请求 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequest.ts - * @language zh_CN - */ - var URLRequest = (function (_super) { - __extends(URLRequest, _super); - /** - * Create an egret.URLRequest object - * @param url {string} Addresses for URL requests - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.URLRequest 对象 - * @param url {string} 进行网络请求的地址 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function URLRequest(url) { - if (url === void 0) { url = null; } - var _this = _super.call(this) || this; - /** - * An object contains data to be transmitted with the URL request. - * This property is used in conjunction with the method property. When the value of method is GET, the value of data is appended to the value of URLRequest.url, using HTTP query-string syntax. - * When the method value is POST (or any value other than GET), the value of data is transmitted in the body of the HTTP request. - * The URLRequest API offers binary POST support and support for URL-encoded variables, as well as support for strings. The data object can be a ArrayBuffer, URLVariables, or String object. - * The way in which the data is used depends on the type of object used: - * If the object is a ArrayBuffer object, the binary data of the ArrayBuffer object is used as POST data. For GET, data of ArrayBuffer type is not supported. - * If the object is a URLVariables object and the method is POST, then the variables are encoded using x-www-form-urlencoded format and the resulting string is used as POST data. - * If the object is a URLVariables object and the method is GET, the URLVariables object will define variables to be sent with the URLRequest object. - * Otherwise, the object is converted into a string, and the string is used as the POST or GET data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个对象,它包含将随 URL 请求一起传输的数据。 - * 该属性与 method 属性配合使用。当 method 值为 GET 时,将使用 HTTP 查询字符串语法将 data 值追加到 URLRequest.url 值。 - * 当 method 值为 POST(或 GET 之外的任何值)时,将在 HTTP 请求体中传输 data 值。 - * URLRequest API 支持二进制 POST,并支持 URL 编码变量和字符串。该数据对象可以是 ArrayBuffer、URLVariables 或 String 对象。 - * 该数据的使用方式取决于所用对象的类型: - * 如果该对象为 ArrayBuffer 对象,则 ArrayBuffer 对象的二进制数据用作 POST 数据。对于 GET,不支持 ArrayBuffer 类型的数据。 - * 如果该对象是 URLVariables 对象,并且该方法是 POST,则使用 x-www-form-urlencoded 格式对变量进行编码,并且生成的字符串会用作 POST 数据。 - * 如果该对象是 URLVariables 对象,并且该方法是 GET,则 URLVariables 对象将定义要随 URLRequest 对象一起发送的变量。 - * 否则,该对象会转换为字符串,并且该字符串会用作 POST 或 GET 数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.data = null; - /** - * Request method, valid values are URLRequestMethod.GET or URLRequestMethod.POST. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 请求方式,有效值为URLRequestMethod.GET 或 URLRequestMethod.POST。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.method = egret.URLRequestMethod.GET; - /** - * The requested URL. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 所请求的 URL。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.url = ""; - /** - * The array of HTTP request headers to be appended to the HTTP request. The array is composed of URLRequestHeader objects. - * Each object in the array must be a URLRequestHeader object that contains a name string and a value string. - * Because of browser compatibility, this property has not been achieved in html5 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要追加到 HTTP 请求的 HTTP 请求标头的数组。该数组由 URLRequestHeader 对象组成。 - * 数组中的每一对象必须是包含一个名称字符串和一个值字符串的 URLRequestHeader 对象。 - * 由于浏览器兼容性原因,该属性在 html5 中并未实现 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.requestHeaders = []; - _this.url = url; - return _this; - } - return URLRequest; - }(egret.HashObject)); - egret.URLRequest = URLRequest; - __reflect(URLRequest.prototype, "egret.URLRequest"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * A URLRequestHeader object encapsulates a single HTTP request header and consists of a name/value pair. URLRequestHeader objects are used in the requestHeaders property of the URLRequest class. - * Note: Because of browser compatibility, this property has not been achieved in html5 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequestHeader.ts - * @language en_US - */ - /** - * URLRequestHeader 对象封装了一个 HTTP 请求标头并由一个名称/值对组成。URLRequestHeader 对象在 URLRequest 类的 requestHeaders 属性中使用。 - * 注意:由于浏览器兼容性原因,在 html5 中并未实现 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequestHeader.ts - * @language zh_CN - */ - var URLRequestHeader = (function () { - /** - * Create an egret.URLRequestHeader object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.URLRequestHeader 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function URLRequestHeader(name, value) { - /** - * HTTP request header name, such as Content-Type - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HTTP 请求标头名称,如 Content-Type - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - this.name = ""; - /** - * The values associated with the name property (such as text/plain). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 与 name 属性相关联的值,如 text/plain - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - this.value = ""; - this.name = name; - this.value = value; - } - return URLRequestHeader; - }()); - egret.URLRequestHeader = URLRequestHeader; - __reflect(URLRequestHeader.prototype, "egret.URLRequestHeader"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The URLRequestMethod class provides values that specify whether the - * URLRequest object should use the POST method or the GET method when sending data to a server. - * @see http://edn.egret.com/cn/docs/page/599 POST与GET - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequestMethod.ts - * @language en_US - */ - /** - * URLRequestMethod 类提供了一些值,这些值可指定在将数据发送到服务器时, - * URLRequest 对象应使用 POST 方法还是 GET 方法。 - * @see http://edn.egret.com/cn/docs/page/599 POST与GET - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequestMethod.ts - * @language zh_CN - */ - var URLRequestMethod = (function () { - function URLRequestMethod() { - } - /** - * Specify that the URLRequest object is a GET. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 URLRequest 对象是一个 GET。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - URLRequestMethod.GET = "get"; - /** - * Specify that the URLRequest object is a POST. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 URLRequest 对象是一个 POST。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - URLRequestMethod.POST = "post"; - return URLRequestMethod; - }()); - egret.URLRequestMethod = URLRequestMethod; - __reflect(URLRequestMethod.prototype, "egret.URLRequestMethod"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The URLVariables class allows you to transfer variables between an application and a server. - * Use URLVariables objects with methods of the URLLoader class and the data property of the URLRequest class. - * @see http://edn.egret.com/cn/docs/page/598 Send the request with parameters - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLVariables.ts - * @language en_US - */ - /** - * 使用 URLVariables 类可以在应用程序和服务器之间传输变量。 - * 将 URLVariables 对象与 URLLoader 类的方法、URLRequest 类的 data 属性一起使用。 - * @see http://edn.egret.com/cn/docs/page/598 发送带参数的请求 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLVariables.ts - * @language zh_CN - */ - var URLVariables = (function (_super) { - __extends(URLVariables, _super); - /** - * Create an egret.URLVariable object - * @param source {String} A URL-encoded string containing name/value pairs. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.URLVariables 对象 - * @param source {String} 包含名称/值对的 URL 编码的字符串。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function URLVariables(source) { - if (source === void 0) { source = null; } - var _this = _super.call(this) || this; - /** - * Key-value pair data object saved in this URLVariables object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 此 URLVariables 储存的键值对数据对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.variables = null; - if (source !== null) { - _this.decode(source); - } - return _this; - } - /** - * Convert the variable string into the property of this URLVariables.variables object. - * @param source {string} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将变量字符串转换为此 URLVariables.variables 对象的属性。 - * @param source {string} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - URLVariables.prototype.decode = function (source) { - if (!this.variables) { - this.variables = {}; - } - source = source.split("+").join(" "); - var tokens, re = /[?&]?([^=]+)=([^&]*)/g; - while (tokens = re.exec(source)) { - var key = decodeURIComponent(tokens[1]), val = decodeURIComponent(tokens[2]); - //没有重复键值,直接赋值 - if ((key in this.variables) == false) { - this.variables[key] = val; - continue; - } - //有重复键值,如果已经存在数组,直接push到数组,否则创建一个新数组 - var value = this.variables[key]; - if (value instanceof Array) { - value.push(val); - } - else { - this.variables[key] = [value, val]; - } - } - }; - /** - * Return a string containing all enumerable variables using the MIME content encoding format : application/x-www-form-urlencoded. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 以 MIME 内容编码格式 application/x-www-form-urlencoded 返回包含所有可枚举变量的字符串。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - URLVariables.prototype.toString = function () { - if (!this.variables) { - return ""; - } - var variables = this.variables; - var stringArray = []; - for (var key in variables) { - stringArray.push(this.encodeValue(key, variables[key])); - } - return stringArray.join("&"); - }; - /** - * @private - * - * @param key - * @param value - */ - URLVariables.prototype.encodeValue = function (key, value) { - if (value instanceof Array) { - return this.encodeArray(key, value); - } - else { - return encodeURIComponent(key) + "=" + encodeURIComponent(value); - } - }; - /** - * @private - * - * @param key - * @param value - */ - URLVariables.prototype.encodeArray = function (key, value) { - if (!key) - return ""; - if (value.length == 0) { - return encodeURIComponent(key) + "="; - } - return value.map(function (v) { return encodeURIComponent(key) + "=" + encodeURIComponent(v); }).join("&"); - }; - return URLVariables; - }(egret.HashObject)); - egret.URLVariables = URLVariables; - __reflect(URLVariables.prototype, "egret.URLVariables"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/player/Ticker.ts - * @language en_US - */ - /** - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/player/Ticker.ts - * @language zh_CN - */ - var Ticker = (function (_super) { - __extends(Ticker, _super); - /** - * @deprecated - * @version Egret 2.4 - * @platform Web,Native - */ - function Ticker() { - var _this = _super.call(this) || this; - _this._timeScale = 1; - _this._paused = false; - _this._callIndex = -1; - _this._lastTime = 0; - _this.callBackList = []; - if (Ticker.instance != null) { - if (true) { - egret.$error(1033); - } - } - egret.ticker.$startTick(_this.update, _this); - _this._lastTime = egret.getTimer(); - return _this; - } - Ticker.prototype.update = function (timeStamp) { - var advancedTime = timeStamp - this._lastTime; - this._lastTime = timeStamp; - if (this._paused) { - return false; - } - var frameTime = advancedTime * this._timeScale; - this._callList = this.callBackList.concat(); - this._callIndex = 0; - for (; this._callIndex < this._callList.length; this._callIndex++) { - var eventBin = this._callList[this._callIndex]; - eventBin.listener.call(eventBin.thisObject, frameTime); - } - this._callIndex = -1; - this._callList = null; - return false; - }; - /** - * 注册帧回调事件,同一函数的重复监听会被忽略。推荐使用 egret.startTick 替代此方法。 - * @method egret.Ticker#register - * @param listener {Function} 帧回调函数,参数返回上一帧和这帧的间隔时间。示例:onEnterFrame(frameTime:number):void - * @param thisObject {any} 帧回调函数的this对象 - * @param priority {number} 事件优先级,开发者请勿传递 Number.NEGATIVE_INFINITY 和 Number.POSITIVE_INFINITY - * @version Egret 2.4 - * @platform Web,Native - * @deprecated - */ - Ticker.prototype.register = function (listener, thisObject, priority) { - if (priority === void 0) { priority = 0; } - this.$insertEventBin(this.callBackList, "", listener, thisObject, false, priority, false); - }; - /** - * 取消侦听enterFrame事件。推荐使用 egret.stopTick 替代此方法。 - * @method egret.Ticker#unregister - * @param listener {Function} 事件侦听函数 - * @param thisObject {any} 侦听函数的this对象 - * @version Egret 2.4 - * @platform Web,Native - * @deprecated - */ - Ticker.prototype.unregister = function (listener, thisObject) { - this.$removeEventBin(this.callBackList, listener, thisObject); - }; - /** - * @deprecated - * @param timeScale {number} - * @private - */ - Ticker.prototype.setTimeScale = function (timeScale) { - this._timeScale = timeScale; - }; - /** - * @deprecated - * @method egret.Ticker#getTimeScale - * @private - */ - Ticker.prototype.getTimeScale = function () { - return this._timeScale; - }; - /** - * 暂停 - * @deprecated - * @method egret.Ticker#pause - */ - Ticker.prototype.pause = function () { - this._paused = true; - }; - /** - * 继续 - * @deprecated - * @method egret.Ticker#resume - */ - Ticker.prototype.resume = function () { - this._paused = false; - }; - /** - * @method egret.Ticker.getInstance - * @returns {Ticker} - * @version Egret 2.4 - * @platform Web,Native - * @deprecated - */ - Ticker.getInstance = function () { - if (Ticker.instance == null) { - Ticker.instance = new Ticker(); - } - return Ticker.instance; - }; - return Ticker; - }(egret.EventDispatcher)); - egret.Ticker = Ticker; - __reflect(Ticker.prototype, "egret.Ticker"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @class egret.MainContext - * @classdesc - * MainContext是游戏的核心跨平台接口,组合了多个功能Context,并是游戏启动的主入口 - * @extends egret.EventDispatcher - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - var MainContext = (function (_super) { - __extends(MainContext, _super); - /** - * @version Egret 2.4 - * @platform Web,Native - */ - function MainContext() { - return _super.call(this) || this; - } - Object.defineProperty(MainContext.prototype, "stage", { - /** - * 渲染Context - * @member egret.MainContext#rendererContext - * @version Egret 2.4 - * @platform Web,Native - */ - //public rendererContext:RendererContext = null; - /** - * 触摸Context - * @member egret.MainContext#touchContext - * @version Egret 2.4 - * @platform Web,Native - */ - //public touchContext:TouchContext = null; - /** - * 设备divice - * @member egret.MainContext#deviceContext - * @version Egret 2.4 - * @platform Web,Native - */ - //public deviceContext:DeviceContext = null; - /** - * 舞台 - * @member egret.MainContext#stage - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return egret.sys.$TempStage; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MainContext, "instance", { - /** - * @method egret.Ticker.getInstance - * @returns {Ticker} - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - if (MainContext._instance == null) { - MainContext._instance = new MainContext(); - } - return MainContext._instance; - }, - enumerable: true, - configurable: true - }); - /** - * @version Egret 2.4 - * @platform Web,Native - */ - MainContext.deviceType = null; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - MainContext.DEVICE_PC = "web"; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - MainContext.DEVICE_MOBILE = "native"; - return MainContext; - }(egret.EventDispatcher)); - egret.MainContext = MainContext; - __reflect(MainContext.prototype, "egret.MainContext"); -})(egret || (egret = {})); -/** - * @private - */ -egret["testDeviceType1"] = function () { - if (!window["navigator"]) { - return true; - } - var ua = navigator.userAgent.toLowerCase(); - return (ua.indexOf('mobile') != -1 || ua.indexOf('android') != -1); -}; -egret.MainContext.deviceType = egret["testDeviceType1"]() ? egret.MainContext.DEVICE_MOBILE : egret.MainContext.DEVICE_PC; -delete egret["testDeviceType1"]; -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Tool class for object cache repeat use, which can be used to construct an object pool. Objects are automatically recycled after a certain duration. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/Recycler.ts - * @private - * @language en_US - */ - /** - * 对象缓存复用工具类,可用于构建对象池,一段时间后会自动回收对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/Recycler.ts - * @private - * @language zh_CN - */ - var Recycler = (function (_super) { - __extends(Recycler, _super); - /** - * Create an egret.Recycler object - * @param autoDisposeTime {number} Number of frames when objects are destroyed automatically. Default value: 300 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.Recycler 对象 - * @param autoDisposeTime {number} 多少帧后自动销毁对象,默认值300 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Recycler(autoDisposeTime) { - if (autoDisposeTime === void 0) { autoDisposeTime = 300; } - var _this = _super.call(this) || this; - /** - * @private - */ - _this.objectPool = []; - /** - * @private - */ - _this._length = 0; - if (autoDisposeTime < 1) - autoDisposeTime = 1; - _this.autoDisposeTime = autoDisposeTime; - _this.frameCount = 0; - return _this; - } - Recycler.$init = function () { - egret.ticker.$startTick(Recycler.onUpdate, Recycler); - }; - Recycler.onUpdate = function (timeStamp) { - var list = Recycler._callBackList; - for (var i = list.length - 1; i >= 0; i--) { - list[i].$checkFrame(); - } - return false; - }; - /** - * @private - * - */ - Recycler.prototype.$checkFrame = function () { - this.frameCount--; - if (this.frameCount <= 0) { - this.dispose(); - } - }; - Object.defineProperty(Recycler.prototype, "length", { - /** - * Number of cached objects" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缓存的对象数量 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._length; - }, - enumerable: true, - configurable: true - }); - /** - * Cache an object for repeat use - * @param object {any} The object to be cached - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缓存一个对象以复用 - * @param object {any} 需要缓存的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Recycler.prototype.push = function (object) { - var pool = this.objectPool; - if (pool.indexOf(object) == -1) { - pool.push(object); - if (object.__recycle) { - object.__recycle(); - } - this._length++; - if (this.frameCount == 0) { - this.frameCount = this.autoDisposeTime; - Recycler._callBackList.push(this); - } - } - }; - /** - * Obtain a cached object - * @returns {any} The obtained cached object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取一个缓存的对象 - * @returns {any} 获得的缓存对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Recycler.prototype.pop = function () { - if (this._length == 0) - return null; - this._length--; - return this.objectPool.pop(); - }; - /** - * Immediately clear all cached objects. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 立即清空所有缓存的对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Recycler.prototype.dispose = function () { - if (this._length > 0) { - this.objectPool = []; - this._length = 0; - } - this.frameCount = 0; - var list = Recycler._callBackList; - var index = list.indexOf(this); - if (index != -1) { - list.splice(index, 1); - } - }; - /** - * @private - */ - Recycler._callBackList = []; - return Recycler; - }(egret.HashObject)); - egret.Recycler = Recycler; - __reflect(Recycler.prototype, "egret.Recycler"); - Recycler.$init(); -})(egret || (egret = {})); -var egret; -(function (egret) { - var setIntervalCache = {}; - var setIntervalIndex = 0; - var setIntervalCount = 0; - var lastTime = 0; - /** - * To specify a delay (in milliseconds) calls the function specified interval loop. - * @param listener {Function} Listener function - * @param thisObject {any} this object - * @param delay {number} Delay time, in milliseconds - * @param ...args {any} Parameter list - * @returns {number} Return index which can be used for clearInterval - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/setInterval.ts - * @language en_US - */ - /** - * 以指定的延迟(以毫秒为单位)间隔循环调用指定的函数。 - * @param listener {Function} 侦听函数 - * @param thisObject {any} this对象 - * @param delay {number} 延迟时间,以毫秒为单位 - * @param ...args {any} 参数列表 - * @returns {number} 返回索引,可以用于 clearInterval - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/setInterval.ts - * @language zh_CN - */ - function setInterval(listener, thisObject, delay) { - var args = []; - for (var _i = 3; _i < arguments.length; _i++) { - args[_i - 3] = arguments[_i]; - } - var data = { listener: listener, thisObject: thisObject, delay: delay, originDelay: delay, params: args }; - setIntervalCount++; - if (setIntervalCount == 1) { - lastTime = egret.getTimer(); - egret.ticker.$startTick(intervalUpdate, null); - } - setIntervalIndex++; - setIntervalCache[setIntervalIndex] = data; - return setIntervalIndex; - } - egret.setInterval = setInterval; - /** - * Clear function to run after a specified delay. - * @param key {number} Index that egret.setInterval returns - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/setInterval.ts - * @language en_US - */ - /** - * 清除指定延迟后运行的函数。 - * @param key {number} egret.setInterval所返回的索引 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/setInterval.ts - * @language zh_CN - */ - function clearInterval(key) { - if (setIntervalCache[key]) { - setIntervalCount--; - delete setIntervalCache[key]; - if (setIntervalCount == 0) { - egret.ticker.$stopTick(intervalUpdate, null); - } - } - } - egret.clearInterval = clearInterval; - /** - * @private - * - * @param dt - */ - function intervalUpdate(timeStamp) { - var dt = timeStamp - lastTime; - lastTime = timeStamp; - for (var key in setIntervalCache) { - var data = setIntervalCache[key]; - data.delay -= dt; - if (data.delay <= 0) { - data.delay = data.originDelay; - data.listener.apply(data.thisObject, data.params); - } - } - return false; - } -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var setTimeoutCache = {}; - var setTimeoutIndex = 0; - var setTimeoutCount = 0; - var lastTime = 0; - /** - * Run the designated function in specified delay (in milliseconds). - * @param listener {Function} Listener function - * @param thisObject {any} this object - * @param delay {number} Delay time, in milliseconds - * @param ...args {any} Parameter list - * @returns {number} Return index which can be used for clearTimeout - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/setTimeout.ts - * @language en_US - */ - /** - * 在指定的延迟(以毫秒为单位)后运行指定的函数。 - * @param listener {Function} 侦听函数 - * @param thisObject {any} this对象 - * @param delay {number} 延迟时间,以毫秒为单位 - * @param ...args {any} 参数列表 - * @returns {number} 返回索引,可以用于 clearTimeout - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/setTimeout.ts - * @language zh_CN - */ - function setTimeout(listener, thisObject, delay) { - var args = []; - for (var _i = 3; _i < arguments.length; _i++) { - args[_i - 3] = arguments[_i]; - } - var data = { listener: listener, thisObject: thisObject, delay: delay, params: args }; - setTimeoutCount++; - if (setTimeoutCount == 1 && egret.ticker) { - lastTime = egret.getTimer(); - egret.ticker.$startTick(timeoutUpdate, null); - } - setTimeoutIndex++; - setTimeoutCache[setTimeoutIndex] = data; - return setTimeoutIndex; - } - egret.setTimeout = setTimeout; - /** - * Function run after the specified delay is cleared. - * @param key {number} Index that egret.setTimeout returns - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 清除指定延迟后运行的函数。 - * @param key {number} egret.setTimeout所返回的索引 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function clearTimeout(key) { - if (setTimeoutCache[key]) { - setTimeoutCount--; - delete setTimeoutCache[key]; - if (setTimeoutCount == 0 && egret.ticker) { - egret.ticker.$stopTick(timeoutUpdate, null); - } - } - } - egret.clearTimeout = clearTimeout; - /** - * @private - * - * @param dt - */ - function timeoutUpdate(timeStamp) { - var dt = timeStamp - lastTime; - lastTime = timeStamp; - for (var key in setTimeoutCache) { - var key2 = key; - var data = setTimeoutCache[key2]; - data.delay -= dt; - if (data.delay <= 0) { - data.listener.apply(data.thisObject, data.params); - clearTimeout(key2); - } - } - return false; - } -})(egret || (egret = {})); diff --git a/helloworld/libs/modules/game/game.min.js b/helloworld/libs/modules/game/game.min.js deleted file mode 100644 index 5b06524..0000000 --- a/helloworld/libs/modules/game/game.min.js +++ /dev/null @@ -1,2 +0,0 @@ -var __reflect=this&&this.__reflect||function(t,e,r){t.__class__=e,r?r.push(e):r=[e],t.__types__=t.__types__?r.concat(t.__types__):r},__extends=this&&this.__extends||function(t,e){function r(){this.constructor=t}for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);r.prototype=e.prototype,t.prototype=new r},egret;!function(t){var e=function(){function t(){}return t.BINARY="binary",t.TEXT="text",t.VARIABLES="variables",t.TEXTURE="texture",t.SOUND="sound",t}();t.URLLoaderDataFormat=e,__reflect(e.prototype,"egret.URLLoaderDataFormat")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e,r,i){var o=t.call(this)||this;return o._name=e,o._frame=0|r,i&&(o._end=0|i),o}return __extends(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"frame",{get:function(){return this._frame},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"end",{get:function(){return this._end},enumerable:!0,configurable:!0}),e.prototype.clone=function(){return new e(this._name,this._frame,this._end)},e}(t.EventDispatcher);t.FrameLabel=e,__reflect(e.prototype,"egret.FrameLabel")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(){var t=e.call(this)||this;return t.$mcData=null,t.numFrames=1,t.frames=[],t.labels=null,t.events=[],t.frameRate=0,t.textureData=null,t.spriteSheet=null,t}return __extends(r,e),r.prototype.$init=function(t,e,r){this.textureData=e,this.spriteSheet=r,this.setMCData(t)},r.prototype.getKeyFrameData=function(t){var e=this.frames[t-1];return e.frame&&(e=this.frames[e.frame-1]),e},r.prototype.getTextureByFrame=function(t){var e=this.getKeyFrameData(t);if(e.res){var r=this.getTextureByResName(e.res);return r}return null},r.prototype.$getOffsetByFrame=function(t,e){var r=this.getKeyFrameData(t);r.res&&e.setTo(0|r.x,0|r.y)},r.prototype.getTextureByResName=function(t){if(null==this.spriteSheet)return null;var e=this.spriteSheet.getTexture(t);if(!e){var r=this.textureData[t];e=this.spriteSheet.createTexture(t,r.x,r.y,r.w,r.h)}return e},r.prototype.$isDataValid=function(){return this.frames.length>0},r.prototype.$isTextureValid=function(){return null!=this.textureData&&null!=this.spriteSheet},r.prototype.$fillMCData=function(t){this.frameRate=t.frameRate||24,this.fillFramesData(t.frames),this.fillFrameLabelsData(t.labels),this.fillFrameEventsData(t.events)},r.prototype.fillFramesData=function(t){for(var e,r=this.frames,i=t?t.length:0,o=0;i>o;o++){var n=t[o];if(r.push(n),n.duration){var s=parseInt(n.duration);if(s>1){e=r.length;for(var a=1;s>a;a++)r.push({frame:e})}}}this.numFrames=r.length},r.prototype.fillFrameLabelsData=function(e){if(e){var r=e.length;if(r>0){this.labels=[];for(var i=0;r>i;i++){var o=e[i];this.labels.push(new t.FrameLabel(o.name,o.frame,o.end))}}}},r.prototype.fillFrameEventsData=function(t){if(t){var e=t.length;if(e>0){this.events=[];for(var r=0;e>r;r++){var i=t[r];this.events[i.frame]=i.name}}}},Object.defineProperty(r.prototype,"mcData",{get:function(){return this.$mcData},set:function(t){this.setMCData(t)},enumerable:!0,configurable:!0}),r.prototype.setMCData=function(t){this.$mcData!=t&&(this.$mcData=t,t&&this.$fillMCData(t))},r}(t.HashObject);t.MovieClipData=e,__reflect(e.prototype,"egret.MovieClipData")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(t,r){var i=e.call(this)||this;return i.enableCache=!0,i.$mcDataCache={},i.$mcDataSet=t,i.setTexture(r),i}return __extends(r,e),r.prototype.clearCache=function(){this.$mcDataCache={}},r.prototype.generateMovieClipData=function(e){if(void 0===e&&(e=""),""==e&&this.$mcDataSet)for(e in this.$mcDataSet.mc)break;if(""==e)return null;var r=this.findFromCache(e,this.$mcDataCache);return r||(r=new t.MovieClipData,this.fillData(e,r,this.$mcDataCache)),r},r.prototype.findFromCache=function(t,e){return this.enableCache&&e[t]?e[t]:null},r.prototype.fillData=function(t,e,r){if(this.$mcDataSet){var i=this.$mcDataSet.mc[t];i&&(e.$init(i,this.$mcDataSet.res,this.$spriteSheet),this.enableCache&&(r[t]=e))}},Object.defineProperty(r.prototype,"mcDataSet",{get:function(){return this.$mcDataSet},set:function(t){this.$mcDataSet=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"texture",{set:function(t){this.setTexture(t)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"spriteSheet",{get:function(){return this.$spriteSheet},enumerable:!0,configurable:!0}),r.prototype.setTexture=function(e){this.$spriteSheet=e?new t.SpriteSheet(e):null},r}(t.EventDispatcher);t.MovieClipDataFactory=e,__reflect(e.prototype,"egret.MovieClipDataFactory")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(t,r,i,o){void 0===r&&(r=!1),void 0===i&&(i=!1),void 0===o&&(o=null);var n=e.call(this,t,r,i)||this;return n.frameLabel=null,n.frameLabel=o,n}return __extends(r,e),r.dispatchMovieClipEvent=function(e,i,o){void 0===o&&(o=null);var n=t.Event.create(r,i);n.frameLabel=o;var s=e.dispatchEvent(n);return t.Event.release(n),s},r.FRAME_LABEL="frame_label",r}(t.Event);t.MovieClipEvent=e,__reflect(e.prototype,"egret.MovieClipEvent")}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){t.$error(1014)}return e.get=function(t){return-1>t&&(t=-1),t>1&&(t=1),function(e){return 0==t?e:0>t?e*(e*-t+1+t):e*((2-e)*t+(1-t))}},e.getPowOut=function(t){return function(e){return 1-Math.pow(1-e,t)}},e.quintOut=e.getPowOut(5),e.quartOut=e.getPowOut(4),e}();t.ScrollEase=e,__reflect(e.prototype,"egret.ScrollEase");var r=function(e){function r(t,r,i){var o=e.call(this)||this;return o._target=null,o._useTicks=!1,o.ignoreGlobalPause=!1,o.loop=!1,o.pluginData=null,o._steps=null,o._actions=null,o.paused=!1,o.duration=0,o._prevPos=-1,o.position=null,o._prevPosition=0,o._stepPosition=0,o.passive=!1,o.initialize(t,r,i),o}return __extends(r,e),r.get=function(t,e,i,o){return void 0===e&&(e=null),void 0===i&&(i=null),void 0===o&&(o=!1),o&&r.removeTweens(t),new r(t,e,i)},r.removeTweens=function(t){if(t.tween_count){for(var e=r._tweens,i=e.length-1;i>=0;i--)e[i]._target==t&&(e[i].paused=!0,e.splice(i,1));t.tween_count=0}},r.tick=function(t,e){void 0===e&&(e=!1);var i=t-r._lastTime;r._lastTime=t;for(var o=r._tweens.concat(),n=o.length-1;n>=0;n--){var s=o[n];e&&!s.ignoreGlobalPause||s.paused||s.tick(s._useTicks?1:i)}return!1},r._register=function(e,i){var o=e._target,n=r._tweens;if(i)o&&(o.tween_count=o.tween_count>0?o.tween_count+1:1),n.push(e),r._inited||(r._lastTime=t.getTimer(),t.ticker.$startTick(r.tick,null),r._inited=!0);else{o&&o.tween_count--;for(var s=n.length;s--;)if(n[s]==e)return void n.splice(s,1)}},r.prototype.initialize=function(t,e,i){this._target=t,e&&(this._useTicks=e.useTicks,this.ignoreGlobalPause=e.ignoreGlobalPause,this.loop=e.loop,e.onChange&&this.addEventListener("change",e.onChange,e.onChangeObj),e.override&&r.removeTweens(t)),this.pluginData=i||{},this._curQueueProps={},this._initQueueProps={},this._steps=[],this._actions=[],e&&e.paused?this.paused=!0:r._register(this,!0),e&&null!=e.position&&this.setPosition(e.position)},r.prototype.setPosition=function(t,e){void 0===e&&(e=1),0>t&&(t=0);var r=t,i=!1;if(r>=this.duration&&(this.loop?r%=this.duration:(r=this.duration,i=!0)),r==this._prevPos)return i;var o=this._prevPos;if(this.position=this._prevPos=r,this._prevPosition=t,this._target)if(i)this._updateTargetProps(null,1);else if(this._steps.length>0){var n=void 0,s=this._steps.length;for(n=0;s>n&&!(this._steps[n].t>r);n++);var a=this._steps[n-1];this._updateTargetProps(a,(this._stepPosition=r-a.t)/a.d)}return i&&this.setPaused(!0),0!=e&&this._actions.length>0&&(this._useTicks?this._runActions(r,r):1==e&&o>r?(o!=this.duration&&this._runActions(o,this.duration),this._runActions(0,r,!0)):this._runActions(o,r)),this.dispatchEventWith("change"),i},r.prototype._runActions=function(t,e,r){void 0===r&&(r=!1);var i=t,o=e,n=-1,s=this._actions.length,a=1;for(t>e&&(i=e,o=t,n=s,s=a=-1);(n+=a)!=s;){var c=this._actions[n],l=c.t;(l==o||l>i&&o>l||r&&l==t)&&c.f.apply(c.o,c.p)}},r.prototype._updateTargetProps=function(t,e){var i,o,n,s,a,c;if(t||1!=e){if(this.passive=!!t.v,this.passive)return;t.e&&(e=t.e(e,0,1,1)),i=t.p0,o=t.p1}else this.passive=!1,i=o=this._curQueueProps;for(var l in this._initQueueProps){null==(s=i[l])&&(i[l]=s=this._initQueueProps[l]),null==(a=o[l])&&(o[l]=a=s),n=s==a||0==e||1==e||"number"!=typeof s?1==e?a:s:s+(a-s)*e;var h=!1;if(c=r._plugins[l])for(var u=0,p=c.length;p>u;u++){var _=c[u].tween(this,l,n,i,o,e,!!t&&i==o,!t);_==r.IGNORE?h=!0:n=_}h||(this._target[l]=n)}},r.prototype.setPaused=function(t){return this.paused=t,r._register(this,!t),this},r.prototype._cloneProps=function(t){var e={};for(var r in t)e[r]=t[r];return e},r.prototype._addStep=function(t){return t.d>0&&(this._steps.push(t),t.t=this.duration,this.duration+=t.d),this},r.prototype._appendQueueProps=function(t){var e,i,o,n,s;for(var a in t)if(void 0===this._initQueueProps[a]){if(i=this._target[a],e=r._plugins[a])for(o=0,n=e.length;n>o;o++)i=e[o].init(this,a,i);this._initQueueProps[a]=this._curQueueProps[a]=void 0===i?null:i}else i=this._curQueueProps[a];for(var a in t){if(i=this._curQueueProps[a],e=r._plugins[a])for(s=s||{},o=0,n=e.length;n>o;o++)e[o].step&&e[o].step(this,a,i,t[a],s);this._curQueueProps[a]=t[a]}return s&&this._appendQueueProps(s),this._curQueueProps},r.prototype._addAction=function(t){return t.t=this.duration,this._actions.push(t),this},r.prototype.to=function(t,e,r){return void 0===r&&(r=void 0),(isNaN(e)||0>e)&&(e=0),this._addStep({d:e||0,p0:this._cloneProps(this._curQueueProps),e:r,p1:this._cloneProps(this._appendQueueProps(t))})},r.prototype.call=function(t,e,r){return void 0===e&&(e=void 0),void 0===r&&(r=void 0),this._addAction({f:t,p:r?r:[],o:e?e:this._target})},r.prototype.tick=function(t){this.paused||this.setPosition(this._prevPosition+t)},r._tweens=[],r.IGNORE={},r._plugins={},r._inited=!1,r._lastTime=0,r}(t.EventDispatcher);t.ScrollTween=r,__reflect(r.prototype,"egret.ScrollTween")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(r){void 0===r&&(r=null);var i=e.call(this)||this;return i.scrollBeginThreshold=10,i.scrollSpeed=1,i._content=null,i.delayTouchBeginEvent=null,i.touchBeginTimer=null,i.touchEnabled=!0,i._ScrV_Props_=new t.ScrollViewProperties,r&&i.setContent(r),i}return __extends(r,e),Object.defineProperty(r.prototype,"bounces",{get:function(){return this._ScrV_Props_._bounces},set:function(t){this._ScrV_Props_._bounces=!!t},enumerable:!0,configurable:!0}),r.prototype.setContent=function(t){this._content!==t&&(this.removeContent(),t&&(this._content=t,e.prototype.addChild.call(this,t),this._addEvents()))},r.prototype.removeContent=function(){this._content&&(this._removeEvents(),e.prototype.removeChildAt.call(this,0)),this._content=null},Object.defineProperty(r.prototype,"verticalScrollPolicy",{get:function(){return this._ScrV_Props_._verticalScrollPolicy},set:function(t){t!=this._ScrV_Props_._verticalScrollPolicy&&(this._ScrV_Props_._verticalScrollPolicy=t)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"horizontalScrollPolicy",{get:function(){return this._ScrV_Props_._horizontalScrollPolicy},set:function(t){t!=this._ScrV_Props_._horizontalScrollPolicy&&(this._ScrV_Props_._horizontalScrollPolicy=t)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scrollLeft",{get:function(){return this._ScrV_Props_._scrollLeft},set:function(t){t!=this._ScrV_Props_._scrollLeft&&(this._ScrV_Props_._scrollLeft=t,this._validatePosition(!1,!0),this._updateContentPosition())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scrollTop",{get:function(){return this._ScrV_Props_._scrollTop},set:function(t){t!=this._ScrV_Props_._scrollTop&&(this._ScrV_Props_._scrollTop=t,this._validatePosition(!0,!1),this._updateContentPosition())},enumerable:!0,configurable:!0}),r.prototype.setScrollPosition=function(t,e,r){if(void 0===r&&(r=!1),(!r||0!=t||0!=e)&&(r||this._ScrV_Props_._scrollTop!=t||this._ScrV_Props_._scrollLeft!=e)){var i=this._ScrV_Props_._scrollTop,o=this._ScrV_Props_._scrollLeft;if(r){var n=this.getMaxScrollLeft(),s=this.getMaxScrollTop();(0>=i||i>=s)&&(t/=2),(0>=o||o>=n)&&(e/=2);var a=i+t,c=o+e,l=this._ScrV_Props_._bounces;l||((0>=a||a>=s)&&(a=Math.max(0,Math.min(a,s))),(0>=c||c>=n)&&(c=Math.max(0,Math.min(c,n)))),this._ScrV_Props_._scrollTop=a,this._ScrV_Props_._scrollLeft=c}else this._ScrV_Props_._scrollTop=t,this._ScrV_Props_._scrollLeft=e;this._validatePosition(!0,!0),this._updateContentPosition()}},r.prototype._validatePosition=function(t,e){if(void 0===t&&(t=!1),void 0===e&&(e=!1),t){var r=this.height,i=this._getContentHeight();this._ScrV_Props_._scrollTop=Math.max(this._ScrV_Props_._scrollTop,(0-r)/2),this._ScrV_Props_._scrollTop=Math.min(this._ScrV_Props_._scrollTop,i>r?i-r/2:r/2)}if(e){var o=this.width,n=this._getContentWidth();this._ScrV_Props_._scrollLeft=Math.max(this._ScrV_Props_._scrollLeft,(0-o)/2),this._ScrV_Props_._scrollLeft=Math.min(this._ScrV_Props_._scrollLeft,n>o?n-o/2:o/2)}},r.prototype.$setWidth=function(t){this.$explicitWidth!=t&&(e.prototype.$setWidth.call(this,t),this._updateContentPosition())},r.prototype.$setHeight=function(t){this.$explicitHeight!=t&&(e.prototype.$setHeight.call(this,t),this._updateContentPosition())},r.prototype._updateContentPosition=function(){var e=this.height,r=this.width;this.scrollRect=new t.Rectangle(Math.round(this._ScrV_Props_._scrollLeft),Math.round(this._ScrV_Props_._scrollTop),r,e),this.dispatchEvent(new t.Event(t.Event.CHANGE))},r.prototype._checkScrollPolicy=function(){var t=this._ScrV_Props_._horizontalScrollPolicy,e=this.__checkScrollPolicy(t,this._getContentWidth(),this.width);this._ScrV_Props_._hCanScroll=e;var r=this._ScrV_Props_._verticalScrollPolicy,i=this.__checkScrollPolicy(r,this._getContentHeight(),this.height);return this._ScrV_Props_._vCanScroll=i,e||i},r.prototype.__checkScrollPolicy=function(t,e,r){return"on"==t?!0:"off"==t?!1:e>r},r.prototype._addEvents=function(){this.addEventListener(t.TouchEvent.TOUCH_BEGIN,this._onTouchBegin,this),this.addEventListener(t.TouchEvent.TOUCH_BEGIN,this._onTouchBeginCapture,this,!0),this.addEventListener(t.TouchEvent.TOUCH_END,this._onTouchEndCapture,this,!0)},r.prototype._removeEvents=function(){this.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this._onTouchBegin,this),this.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this._onTouchBeginCapture,this,!0),this.removeEventListener(t.TouchEvent.TOUCH_END,this._onTouchEndCapture,this,!0)},r.prototype._onTouchBegin=function(e){if(!e.$isDefaultPrevented){var r=this._checkScrollPolicy();r&&(this._ScrV_Props_._touchStartPosition.x=e.stageX,this._ScrV_Props_._touchStartPosition.y=e.stageY,(this._ScrV_Props_._isHTweenPlaying||this._ScrV_Props_._isVTweenPlaying)&&this._onScrollFinished(),this._tempStage=this.stage,this._tempStage.addEventListener(t.TouchEvent.TOUCH_MOVE,this._onTouchMove,this),this._tempStage.addEventListener(t.TouchEvent.TOUCH_END,this._onTouchEnd,this),this._tempStage.addEventListener(t.TouchEvent.LEAVE_STAGE,this._onTouchEnd,this),this.addEventListener(t.Event.ENTER_FRAME,this._onEnterFrame,this),this._logTouchEvent(e),e.preventDefault())}},r.prototype._onTouchBeginCapture=function(e){var r=this._checkScrollPolicy();if(r){for(var i=e.target;i!=this;){if("_checkScrollPolicy"in i&&(r=i._checkScrollPolicy()))return;i=i.parent}e.stopPropagation();var o=this.cloneTouchEvent(e);this.delayTouchBeginEvent=o,this.touchBeginTimer||(this.touchBeginTimer=new t.Timer(100,1),this.touchBeginTimer.addEventListener(t.TimerEvent.TIMER_COMPLETE,this._onTouchBeginTimer,this)),this.touchBeginTimer.start(),this._onTouchBegin(e)}},r.prototype._onTouchEndCapture=function(e){var r=this;if(this.delayTouchBeginEvent){this._onTouchBeginTimer(),e.stopPropagation();var i=this.cloneTouchEvent(e);t.callLater(function(){r.stage&&r.dispatchPropagationEvent(i)},this)}},r.prototype._onTouchBeginTimer=function(){this.touchBeginTimer.stop();var t=this.delayTouchBeginEvent;this.delayTouchBeginEvent=null,this.stage&&this.dispatchPropagationEvent(t)},r.prototype.dispatchPropagationEvent=function(e){for(var r=e.$target,i=this.$getPropagationList(r),o=i.length,n=.5*i.length,s=-1,a=0;o>a;a++)if(i[a]===this._content){s=a;break}i.splice(0,s+1),n-=s+1,this.$dispatchPropagationEvent(e,i,n),t.Event.release(e)},r.prototype._onTouchMove=function(t){if(this._ScrV_Props_._lastTouchPosition.x!=t.stageX||this._ScrV_Props_._lastTouchPosition.y!=t.stageY){if(!this._ScrV_Props_._scrollStarted){var e=t.stageX-this._ScrV_Props_._touchStartPosition.x,r=t.stageY-this._ScrV_Props_._touchStartPosition.y,i=Math.sqrt(e*e+r*r);if(i100&&r-this._ScrV_Props_._lastTouchTime<300&&this._calcVelocitys(this._ScrV_Props_._lastTouchEvent)},r.prototype._logTouchEvent=function(e){this._ScrV_Props_._lastTouchPosition.x=e.stageX,this._ScrV_Props_._lastTouchPosition.y=e.stageY,this._ScrV_Props_._lastTouchEvent=this.cloneTouchEvent(e),this._ScrV_Props_._lastTouchTime=t.getTimer()},r.prototype._getPointChange=function(t){return{x:this._ScrV_Props_._hCanScroll===!1?0:this._ScrV_Props_._lastTouchPosition.x-t.stageX,y:this._ScrV_Props_._vCanScroll===!1?0:this._ScrV_Props_._lastTouchPosition.y-t.stageY}},r.prototype._calcVelocitys=function(e){var r=t.getTimer();if(0==this._ScrV_Props_._lastTouchTime)return void(this._ScrV_Props_._lastTouchTime=r);var i=this._getPointChange(e),o=r-this._ScrV_Props_._lastTouchTime;i.x/=o,i.y/=o,this._ScrV_Props_._velocitys.push(i),this._ScrV_Props_._velocitys.length>5&&this._ScrV_Props_._velocitys.shift(),this._ScrV_Props_._lastTouchPosition.x=e.stageX,this._ScrV_Props_._lastTouchPosition.y=e.stageY},r.prototype._getContentWidth=function(){return this._content.$explicitWidth||this._content.width},r.prototype._getContentHeight=function(){return this._content.$explicitHeight||this._content.height},r.prototype.getMaxScrollLeft=function(){var t=this._getContentWidth()-this.width;return Math.max(0,t)},r.prototype.getMaxScrollTop=function(){var t=this._getContentHeight()-this.height;return Math.max(0,t)},r.prototype._moveAfterTouchEnd=function(){if(0!=this._ScrV_Props_._velocitys.length){for(var t={x:0,y:0},e=0,i=0;i.02?this.getAnimationDatas(s,this._ScrV_Props_._scrollLeft,h):{position:this._ScrV_Props_._scrollLeft,duration:1},_=l>.02?this.getAnimationDatas(a,this._ScrV_Props_._scrollTop,u):{position:this._ScrV_Props_._scrollTop,duration:1};this.setScrollLeft(p.position,p.duration),this.setScrollTop(_.position,_.duration)}},r.prototype.onTweenFinished=function(t){t==this._ScrV_Props_._vScrollTween&&(this._ScrV_Props_._isVTweenPlaying=!1),t==this._ScrV_Props_._hScrollTween&&(this._ScrV_Props_._isHTweenPlaying=!1),0==this._ScrV_Props_._isHTweenPlaying&&0==this._ScrV_Props_._isVTweenPlaying&&this._onScrollFinished()},r.prototype._onScrollStarted=function(){},r.prototype._onScrollFinished=function(){t.ScrollTween.removeTweens(this),this._ScrV_Props_._hScrollTween=null,this._ScrV_Props_._vScrollTween=null,this._ScrV_Props_._isHTweenPlaying=!1,this._ScrV_Props_._isVTweenPlaying=!1,this.dispatchEvent(new t.Event(t.Event.COMPLETE))},r.prototype.setScrollTop=function(e,r){void 0===r&&(r=0);var i=Math.min(this.getMaxScrollTop(),Math.max(e,0));if(0==r)return void(this.scrollTop=i);0==this._ScrV_Props_._bounces&&(e=i);var o=t.ScrollTween.get(this).to({scrollTop:e},r,t.ScrollEase.quartOut);i!=e&&o.to({scrollTop:i},300,t.ScrollEase.quintOut),this._ScrV_Props_._isVTweenPlaying=!0,this._ScrV_Props_._vScrollTween=o,o.call(this.onTweenFinished,this,[o]),this._ScrV_Props_._isHTweenPlaying||this._onScrollStarted()},r.prototype.setScrollLeft=function(e,r){void 0===r&&(r=0);var i=Math.min(this.getMaxScrollLeft(),Math.max(e,0));if(0==r)return void(this.scrollLeft=i);0==this._ScrV_Props_._bounces&&(e=i);var o=t.ScrollTween.get(this).to({scrollLeft:e},r,t.ScrollEase.quartOut);i!=e&&o.to({scrollLeft:i},300,t.ScrollEase.quintOut),this._ScrV_Props_._isHTweenPlaying=!0,this._ScrV_Props_._hScrollTween=o,o.call(this.onTweenFinished,this,[o]),this._ScrV_Props_._isVTweenPlaying||this._onScrollStarted()},r.prototype.getAnimationDatas=function(t,e,r){var i=Math.abs(t),o=.95,n=0,s=.998,a=.02,c=e+500*t;if(0>c||c>r)for(c=e;Math.abs(t)!=1/0&&Math.abs(t)>a;)c+=t,t*=0>c||c>r?s*o:s,n++;else n=500*-Math.log(a/i);var l={position:Math.min(r+50,Math.max(c,-50)),duration:n};return l},r.prototype.cloneTouchEvent=function(e){var r=new t.TouchEvent(e.type,e.bubbles,e.cancelable);return r.touchPointID=e.touchPointID,r.$stageX=e.stageX,r.$stageY=e.stageY,r.touchDown=e.touchDown,r.$isDefaultPrevented=!1,r.$target=e.target,r},r.prototype.throwNotSupportedError=function(){t.$error(1023)},r.prototype.addChild=function(t){return this.throwNotSupportedError(),null},r.prototype.addChildAt=function(t,e){return this.throwNotSupportedError(),null},r.prototype.removeChild=function(t){return this.throwNotSupportedError(),null},r.prototype.removeChildAt=function(t){return this.throwNotSupportedError(),null},r.prototype.setChildIndex=function(t,e){this.throwNotSupportedError()},r.prototype.swapChildren=function(t,e){this.throwNotSupportedError()},r.prototype.swapChildrenAt=function(t,e){this.throwNotSupportedError()},r.weight=[1,1.33,1.66,2,2.33],r}(t.DisplayObjectContainer);t.ScrollView=e,__reflect(e.prototype,"egret.ScrollView")}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){this._verticalScrollPolicy="auto",this._horizontalScrollPolicy="auto",this._scrollLeft=0,this._scrollTop=0,this._hCanScroll=!1,this._vCanScroll=!1,this._lastTouchPosition=new t.Point(0,0),this._touchStartPosition=new t.Point(0,0),this._scrollStarted=!1,this._lastTouchTime=0,this._lastTouchEvent=null,this._velocitys=[],this._isHTweenPlaying=!1,this._isVTweenPlaying=!1,this._hScrollTween=null,this._vScrollTween=null,this._bounces=!0}return e}();t.ScrollViewProperties=e,__reflect(e.prototype,"egret.ScrollViewProperties")}(egret||(egret={}));var egret;!function(t){function e(e){var r=e.url;return-1==r.indexOf("?")&&e.method==t.URLRequestMethod.GET&&e.data&&e.data instanceof t.URLVariables&&(r=r+"?"+e.data.toString()),r}var r=function(r){function i(e){void 0===e&&(e=null);var i=r.call(this)||this;return i.dataFormat=t.URLLoaderDataFormat.TEXT,i.data=null,i._request=null,i._status=-1,e&&i.load(e),i}return __extends(i,r),i.prototype.load=function(r){this._request=r,this.data=null;var i=this;if(i.dataFormat==t.URLLoaderDataFormat.TEXTURE)return void this.loadTexture(i);if(i.dataFormat==t.URLLoaderDataFormat.SOUND)return void this.loadSound(i);var o=e(r),n=new t.HttpRequest;n.open(o,r.method==t.URLRequestMethod.POST?t.HttpMethod.POST:t.HttpMethod.GET);var s;if(r.method!=t.URLRequestMethod.GET&&r.data)if(r.data instanceof t.URLVariables){n.setRequestHeader("Content-Type","application/x-www-form-urlencoded");var a=r.data;s=a.toString()}else n.setRequestHeader("Content-Type","multipart/form-data"),s=r.data;else;for(var c=r.requestHeaders.length,l=0;c>l;l++){var h=r.requestHeaders[l];n.setRequestHeader(h.name,h.value)}n.addEventListener(t.Event.COMPLETE,function(){i.data=n.response,t.Event.dispatchEvent(i,t.Event.COMPLETE)},this),n.addEventListener(t.IOErrorEvent.IO_ERROR,function(){t.IOErrorEvent.dispatchIOErrorEvent(i)},this),n.responseType=i.dataFormat==t.URLLoaderDataFormat.BINARY?t.HttpResponseType.ARRAY_BUFFER:t.HttpResponseType.TEXT,n.send(s)},i.prototype.getResponseType=function(e){switch(e){case t.URLLoaderDataFormat.TEXT:case t.URLLoaderDataFormat.VARIABLES:return t.URLLoaderDataFormat.TEXT;case t.URLLoaderDataFormat.BINARY:return"arraybuffer";default:return e}},i.prototype.loadSound=function(e){function r(t){e.dispatchEvent(t)}function i(t){n(),e.dispatchEvent(t)}function o(r){n(),e.data=c,window.setTimeout(function(){e.dispatchEventWith(t.Event.COMPLETE)},0)}function n(){c.removeEventListener(t.Event.COMPLETE,o,s),c.removeEventListener(t.IOErrorEvent.IO_ERROR,i,s),c.removeEventListener(t.ProgressEvent.PROGRESS,r,s)}var s=this,a=e._request.url,c=new t.Sound;c.addEventListener(t.Event.COMPLETE,o,s),c.addEventListener(t.IOErrorEvent.IO_ERROR,i,s),c.addEventListener(t.ProgressEvent.PROGRESS,r,s),c.load(a)},i.prototype.loadTexture=function(e){function r(t){e.dispatchEvent(t)}function i(t){n(),e.dispatchEvent(t)}function o(r){n();var i=c.data;i.source.setAttribute("bitmapSrc",a);var o=new t.Texture;o._setBitmapData(i),e.data=o,window.setTimeout(function(){e.dispatchEventWith(t.Event.COMPLETE)},s)}function n(){c.removeEventListener(t.Event.COMPLETE,o,s),c.removeEventListener(t.IOErrorEvent.IO_ERROR,i,s),c.removeEventListener(t.ProgressEvent.PROGRESS,r,s)}var s=this,a=e._request.url,c=new t.ImageLoader;c.addEventListener(t.Event.COMPLETE,o,s),c.addEventListener(t.IOErrorEvent.IO_ERROR,i,s),c.addEventListener(t.ProgressEvent.PROGRESS,r,s),c.load(a)},i.prototype.__recycle=function(){this._request=null,this.data=null},i}(t.EventDispatcher);t.URLLoader=r,__reflect(r.prototype,"egret.URLLoader")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(r){var i=e.call(this)||this;return i.$texture=null,i.offsetPoint=t.Point.create(0,0),i.$movieClipData=null,i.frames=null,i.$totalFrames=0,i.frameLabels=null,i.$frameLabelStart=0,i.$frameLabelEnd=0,i.frameEvents=null,i.frameIntervalTime=0,i.$eventPool=null,i.$isPlaying=!1,i.isStopped=!0,i.playTimes=0,i.$currentFrameNum=0,i.$nextFrameNum=1,i.displayedKeyFrameNum=0,i.passedTime=0,i.$frameRate=0/0,i.lastTime=0,i.$smoothing=t.Bitmap.defaultSmoothing,i.setMovieClipData(r),t.nativeRender||(i.$renderNode=new t.sys.NormalBitmapNode),i}return __extends(r,e),r.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(11)},Object.defineProperty(r.prototype,"smoothing",{get:function(){return this.$smoothing},set:function(t){t!=this.$smoothing&&(this.$smoothing=t)},enumerable:!0,configurable:!0}),r.prototype.$init=function(){this.$reset();var t=this.$movieClipData;t&&t.$isDataValid()&&(this.frames=t.frames,this.$totalFrames=t.numFrames,this.frameLabels=t.labels,this.frameEvents=t.events,this.$frameRate=t.frameRate,this.frameIntervalTime=1e3/this.$frameRate,this._initFrame())},r.prototype.$reset=function(){this.frames=null,this.playTimes=0,this.$isPlaying=!1,this.setIsStopped(!0),this.$currentFrameNum=0,this.$nextFrameNum=1,this.displayedKeyFrameNum=0,this.passedTime=0,this.$eventPool=[]},r.prototype._initFrame=function(){this.$movieClipData.$isTextureValid()&&(this.advanceFrame(),this.constructFrame())},r.prototype.$updateRenderNode=function(){var e=this.$texture;if(e){var r=Math.round(this.offsetPoint.x),i=Math.round(this.offsetPoint.y),o=e.$bitmapWidth,n=e.$bitmapHeight,s=e.$getTextureWidth(),a=e.$getTextureHeight(),c=Math.round(e.$getScaleBitmapWidth()),l=Math.round(e.$getScaleBitmapHeight()),h=e.$sourceWidth,u=e.$sourceHeight;t.sys.BitmapNode.$updateTextureData(this.$renderNode,e.$bitmapData,e.$bitmapX,e.$bitmapY,o,n,r,i,s,a,c,l,h,u,t.BitmapFillMode.SCALE,this.$smoothing)}},r.prototype.$measureContentBounds=function(t){var e=this.$texture;if(e){var r=this.offsetPoint.x,i=this.offsetPoint.y,o=e.$getTextureWidth(),n=e.$getTextureHeight();t.setTo(r,i,o,n)}else t.setEmpty()},r.prototype.$onAddToStage=function(t,r){e.prototype.$onAddToStage.call(this,t,r),this.$isPlaying&&this.$totalFrames>1&&this.setIsStopped(!1)},r.prototype.$onRemoveFromStage=function(){e.prototype.$onRemoveFromStage.call(this),this.setIsStopped(!0)},r.prototype.getFrameLabelByName=function(t,e){void 0===e&&(e=!1),e&&(t=t.toLowerCase());var r=this.frameLabels;if(r)for(var i=null,o=0;ot)return e;e=r}return e},r.prototype.play=function(e){void 0===e&&(e=0),this.lastTime=t.getTimer(),this.passedTime=0,this.$isPlaying=!0,this.setPlayTimes(e),this.$totalFrames>1&&this.$stage&&this.setIsStopped(!1)},r.prototype.stop=function(){this.$isPlaying=!1,this.setIsStopped(!0)},r.prototype.prevFrame=function(){this.gotoAndStop(this.$currentFrameNum-1)},r.prototype.nextFrame=function(){this.gotoAndStop(this.$currentFrameNum+1)},r.prototype.gotoAndPlay=function(e,r){void 0===r&&(r=0),(0==arguments.length||arguments.length>2)&&t.$error(1022,"MovieClip.gotoAndPlay()"),"string"==typeof e?this.getFrameStartEnd(e):(this.$frameLabelStart=0,this.$frameLabelEnd=0),this.play(r),this.gotoFrame(e)},r.prototype.gotoAndStop=function(e){1!=arguments.length&&t.$error(1022,"MovieClip.gotoAndStop()"),this.stop(),this.gotoFrame(e)},r.prototype.gotoFrame=function(e){var r;"string"==typeof e?r=this.getFrameLabelByName(e).frame:(r=parseInt(e+"",10),r!=e&&t.$error(1022,"Frame Label Not Found")),1>r?r=1:r>this.$totalFrames&&(r=this.$totalFrames),r!=this.$nextFrameNum&&(this.$nextFrameNum=r,this.advanceFrame(),this.constructFrame(),this.handlePendingEvent())},r.prototype.advanceTime=function(e){var r=this,i=e-r.lastTime;r.lastTime=e;var o=r.frameIntervalTime,n=r.passedTime+i;r.passedTime=n%o;var s=n/o;if(1>s)return!1;for(;s>=1;){if(s--,r.$nextFrameNum++,r.$nextFrameNum>r.$totalFrames||r.$frameLabelStart>0&&r.$nextFrameNum>r.$frameLabelEnd)if(-1==r.playTimes)r.$eventPool.push(t.Event.LOOP_COMPLETE),r.$nextFrameNum=1;else{if(r.playTimes--,!(r.playTimes>0)){r.$nextFrameNum=r.$totalFrames,r.$eventPool.push(t.Event.COMPLETE),r.stop();break}r.$eventPool.push(t.Event.LOOP_COMPLETE),r.$nextFrameNum=1}r.$currentFrameNum==r.$frameLabelEnd&&(r.$nextFrameNum=r.$frameLabelStart),r.advanceFrame()}return r.constructFrame(),r.handlePendingEvent(),!1},r.prototype.advanceFrame=function(){this.$currentFrameNum=this.$nextFrameNum;var e=this.frameEvents[this.$nextFrameNum];e&&""!=e&&t.MovieClipEvent.dispatchMovieClipEvent(this,t.MovieClipEvent.FRAME_LABEL,e)},r.prototype.constructFrame=function(){var e=this,r=e.$currentFrameNum;if(e.displayedKeyFrameNum!=r){var i=e.$movieClipData.getTextureByFrame(r);if(e.$texture=i,e.$movieClipData.$getOffsetByFrame(r,e.offsetPoint),e.displayedKeyFrameNum=r,e.$renderDirty=!0,t.nativeRender)e.$nativeDisplayObject.setDataToBitmapNode(e.$nativeDisplayObject.id,i,[i.$bitmapX,i.$bitmapY,i.$bitmapWidth,i.$bitmapHeight,e.offsetPoint.x,e.offsetPoint.y,i.$getScaleBitmapWidth(),i.$getScaleBitmapHeight(),i.$sourceWidth,i.$sourceHeight]),e.$nativeDisplayObject.setWidth(i.$getTextureWidth()+e.offsetPoint.x),e.$nativeDisplayObject.setHeight(i.$getTextureHeight()+e.offsetPoint.y);else{var o=e.$parent;o&&!o.$cacheDirty&&(o.$cacheDirty=!0,o.$cacheDirtyUp()); -var n=e.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}}},r.prototype.$renderFrame=function(){var t=this;t.$texture=t.$movieClipData.getTextureByFrame(t.$currentFrameNum),t.$renderDirty=!0;var e=t.$parent;e&&!e.$cacheDirty&&(e.$cacheDirty=!0,e.$cacheDirtyUp());var r=t.$maskedObject;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp())},r.prototype.handlePendingEvent=function(){if(0!=this.$eventPool.length){this.$eventPool.reverse();for(var e=this.$eventPool,r=e.length,i=!1,o=!1,n=0;r>n;n++){var s=e.pop();s==t.Event.LOOP_COMPLETE?o=!0:s==t.Event.COMPLETE?i=!0:this.dispatchEventWith(s)}o&&this.dispatchEventWith(t.Event.LOOP_COMPLETE),i&&this.dispatchEventWith(t.Event.COMPLETE)}},Object.defineProperty(r.prototype,"totalFrames",{get:function(){return this.$totalFrames},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"currentFrame",{get:function(){return this.$currentFrameNum},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"currentFrameLabel",{get:function(){var t=this.getFrameLabelByFrame(this.$currentFrameNum);return t&&t.name},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"currentLabel",{get:function(){var t=this.getFrameLabelForFrame(this.$currentFrameNum);return t?t.name:null},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"frameRate",{get:function(){return this.$frameRate},set:function(t){t!=this.$frameRate&&(this.$frameRate=t,this.frameIntervalTime=1e3/this.$frameRate)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isPlaying",{get:function(){return this.$isPlaying},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"movieClipData",{get:function(){return this.$movieClipData},set:function(t){this.setMovieClipData(t)},enumerable:!0,configurable:!0}),r.prototype.setMovieClipData=function(t){this.$movieClipData!=t&&(this.$movieClipData=t,this.$init())},r.prototype.setPlayTimes=function(t){(0>t||t>=1)&&(this.playTimes=0>t?-1:Math.floor(t))},r.prototype.setIsStopped=function(e){this.isStopped!=e&&(this.isStopped=e,e?t.ticker.$stopTick(this.advanceTime,this):(this.playTimes=0==this.playTimes?1:this.playTimes,this.lastTime=t.getTimer(),t.ticker.$startTick(this.advanceTime,this)))},r}(t.DisplayObject);t.MovieClip=e,__reflect(e.prototype,"egret.MovieClip")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(r){void 0===r&&(r=null);var i=e.call(this)||this;return i.data=null,i.method=t.URLRequestMethod.GET,i.url="",i.requestHeaders=[],i.url=r,i}return __extends(r,e),r}(t.HashObject);t.URLRequest=e,__reflect(e.prototype,"egret.URLRequest")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(t,e){this.name="",this.value="",this.name=t,this.value=e}return t}();t.URLRequestHeader=e,__reflect(e.prototype,"egret.URLRequestHeader")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.GET="get",t.POST="post",t}();t.URLRequestMethod=e,__reflect(e.prototype,"egret.URLRequestMethod")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e){void 0===e&&(e=null);var r=t.call(this)||this;return r.variables=null,null!==e&&r.decode(e),r}return __extends(e,t),e.prototype.decode=function(t){this.variables||(this.variables={}),t=t.split("+").join(" ");for(var e,r=/[?&]?([^=]+)=([^&]*)/g;e=r.exec(t);){var i=decodeURIComponent(e[1]),o=decodeURIComponent(e[2]);if(i in this.variables!=0){var n=this.variables[i];n instanceof Array?n.push(o):this.variables[i]=[n,o]}else this.variables[i]=o}},e.prototype.toString=function(){if(!this.variables)return"";var t=this.variables,e=[];for(var r in t)e.push(this.encodeValue(r,t[r]));return e.join("&")},e.prototype.encodeValue=function(t,e){return e instanceof Array?this.encodeArray(t,e):encodeURIComponent(t)+"="+encodeURIComponent(e)},e.prototype.encodeArray=function(t,e){return t?0==e.length?encodeURIComponent(t)+"=":e.map(function(e){return encodeURIComponent(t)+"="+encodeURIComponent(e)}).join("&"):""},e}(t.HashObject);t.URLVariables=e,__reflect(e.prototype,"egret.URLVariables")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(){var i=e.call(this)||this;return i._timeScale=1,i._paused=!1,i._callIndex=-1,i._lastTime=0,i.callBackList=[],null!=r.instance,t.ticker.$startTick(i.update,i),i._lastTime=t.getTimer(),i}return __extends(r,e),r.prototype.update=function(t){var e=t-this._lastTime;if(this._lastTime=t,this._paused)return!1;var r=e*this._timeScale;for(this._callList=this.callBackList.concat(),this._callIndex=0;this._callIndext&&(t=1),r.autoDisposeTime=t,r.frameCount=0,r}return __extends(r,e),r.$init=function(){t.ticker.$startTick(r.onUpdate,r)},r.onUpdate=function(t){for(var e=r._callBackList,i=e.length-1;i>=0;i--)e[i].$checkFrame();return!1},r.prototype.$checkFrame=function(){this.frameCount--,this.frameCount<=0&&this.dispose()},Object.defineProperty(r.prototype,"length",{get:function(){return this._length},enumerable:!0,configurable:!0}),r.prototype.push=function(t){var e=this.objectPool;-1==e.indexOf(t)&&(e.push(t),t.__recycle&&t.__recycle(),this._length++,0==this.frameCount&&(this.frameCount=this.autoDisposeTime,r._callBackList.push(this)))},r.prototype.pop=function(){return 0==this._length?null:(this._length--,this.objectPool.pop())},r.prototype.dispose=function(){this._length>0&&(this.objectPool=[],this._length=0),this.frameCount=0;var t=r._callBackList,e=t.indexOf(this);-1!=e&&t.splice(e,1)},r._callBackList=[],r}(t.HashObject);t.Recycler=e,__reflect(e.prototype,"egret.Recycler"),e.$init()}(egret||(egret={}));var egret;!function(t){function e(e,r,c){for(var l=[],h=3;h(a: Array, b: Array): Array; - static splice(array: Array, index: number, howMany: number): void; - static extend(a: any, b: any): void; - static defaults(options: any, defaults: any): any; - - } - - export class Island { - - equations: Equation[]; - bodies: Body[]; - - reset(): void; - getBodies(): Body[]; - wantsToSleep(): boolean; - sleep(): void; - - } - - export class IslandManager extends Solver { - - static getUnvisitedNode(nodes: Node[]): IslandNode; // IslandNode | boolean - - constructor(options?: Object); - - islands: Island[]; - nodes: IslandNode[]; - islandPool: IslandPool; - nodePool: IslandNodePool; - - visit(node: IslandNode, bds: Body[], eqs: Equation[]): void; - bfs(root: IslandNode, bds: Body[], eqs: Equation[]): void; - split(world: World): Island[]; - - } - - export class IslandNode { - - constructor(body: Body); - - body: Body; - neighbors: IslandNode[]; - equations: Equation[]; - visited: boolean; - - reset(): void; - - } - - /** - * world,包含所有刚体 - * - * @class World - * @constructor - * @param {Object} [options] - * @param {Solver} [options.solver] 默认值 GSSolver. - * @param {Array} [options.gravity] 默认值 [0,-9.78] - * @param {Broadphase} [options.broadphase] 默认值 NaiveBroadphase - * @param {Boolean} [options.islandSplit=false] - * @param {Boolean} [options.doProfiling=false] - * @extends EventEmitter - * - * @example - * var world = new World({ - * gravity: [0, -9.81], - * broadphase: new SAPBroadphase() - * }); - */ - export class World extends EventEmitter { - - /** - * step() 执行之后调用 - * @event postStep - */ - postStepEvent: { - type: string; - }; - - /** - * Body 加入时调用 - * @event addBody - * @param {Body} body - */ - addBodyEvent: { - type: string; - body: Body; - }; - - /** - * Body移除时调用 - * @event removeBody - * @param {Body} body - */ - removeBodyEvent: { - type: string; - body: Body; - }; - - /** - * Spring 加入时调用 - * @event addSpring - * @param {Spring} spring - */ - addSpringEvent: { - type: string; - spring: Spring; - }; - - /** - * 当两个刚体第一次碰撞时调用。调用时碰撞步骤已经完成 - * @event impact - * @param {Body} bodyA - * @param {Body} bodyB - */ - impactEvent: { - type: string; - bodyA: Body; - bodyB: Body; - shapeA: Shape; - shapeB: Shape; - contactEquation: ContactEquation; - }; - - /** - * 当 Broadphase 手机对碰之后被调用 - * @event postBroadphase - * @param {Array} 对碰数组 - */ - postBroadphaseEvent: { - type: string; - pairs: Body[]; - }; - - /** - * 当两个形状重叠时调用 - * @event beginContact - * @param {Shape} shapeA - * @param {Shape} shapeB - * @param {Body} bodyA - * @param {Body} bodyB - * @param {Array} contactEquations - */ - beginContactEvent: { - type: string; - shapeA: Shape; - shapeB: Shape; - bodyA: Body; - bodyB: Body; - contactEquations: ContactEquation[]; - }; - - /** - * 当两个形状停止重叠时调用 - * @event endContact - * @param {Shape} shapeA - * @param {Shape} shapeB - * @param {Body} bodyA - * @param {Body} bodyB - */ - endContactEvent: { - type: string; - shapeA: Shape; - shapeB: Shape; - bodyA: Body; - bodyB: Body; - }; - - /** - * Fired just before equations are added to the solver to be solved. Can be used to control what equations goes into the solver. - * @event preSolve - * @param {Array} contactEquations An array of contacts to be solved. - * @param {Array} frictionEquations An array of friction equations to be solved. - */ - preSolveEvent: { - type: string; - contactEquations: ContactEquation[]; - frictionEquations: FrictionEquation[]; - }; - - /** - * 从不让刚体睡眠 - * @static - * @property {number} NO_SLEEPING - */ - static NO_SLEEPING: number; - /** - * 刚体睡眠 - * @static - * @property {number} BODY_SLEEPING - */ - static BODY_SLEEPING: number; - /** - * 取消激活在接触中的刚体,如果所有刚体都接近睡眠。必须设置 World.islandSplit - * @static - * @property {number} ISLAND_SLEEPING - */ - static ISLAND_SLEEPING: number; - - constructor(options?: { - solver?: Solver; - gravity?: number[]; - broadphase?: Broadphase; - islandSplit?: boolean; - }); - - /** - * For keeping track of what time step size we used last step - * @property lastTimeStep - * @type {number} - */ - lastTimeStep: number; - overlapKeeper: OverlapKeeper; - /** - * If the length of .gravity is zero, and .useWorldGravityAsFrictionGravity=true, then switch to using .frictionGravity for friction instead. This fallback is useful for gravityless games. - * @property {boolean} useFrictionGravityOnZeroGravity - * @default true - */ - useFrictionGravityOnZeroGravity: boolean; - - - /** - * 所有 Spring - * @property springs - * @type {Array} - */ - springs: Spring[]; - /** - * 所有 Body - * @property {Array} bodies - */ - bodies: Body[]; - /** - * 所使用的求解器,以满足约束条件和接触。 默认值是 GSSolver - * @property {Solver} solver - */ - solver: Solver; - /** - * @property narrowphase - * @type {Narrowphase} - */ - narrowphase: Narrowphase; - /** - * The island manager of this world. - * @property {IslandManager} islandManager - */ - islandManager: IslandManager; - /** - * 重力。在每个 step() 开始对所有刚体生效 - * - * @property gravity - * @type {Array} - */ - gravity: number[]; - /** - * 重力摩擦 - * @property {Number} frictionGravity - */ - frictionGravity: number; - /** - * 设置为true,frictionGravity 会被自动设置为 gravity 长度. - * @property {Boolean} useWorldGravityAsFrictionGravity - */ - useWorldGravityAsFrictionGravity: boolean; - /** - * @property broadphase - * @type {Broadphase} - */ - broadphase: Broadphase; - /** - * 用户添加限制 - * - * @property constraints - * @type {Array} - */ - constraints: Constraint[]; - /** - * 默认材料,defaultContactMaterial 时使用 - * @property {Material} defaultMaterial - */ - defaultMaterial: Material; - /** - * 使用的默认接触材料,如果没有接触材料被设置为碰撞的材料 - * @property {ContactMaterial} defaultContactMaterial - */ - defaultContactMaterial: ContactMaterial; - /** - * 设置自动使用弹簧力 - * @property applySpringForces - * @type {Boolean} - */ - applySpringForces: boolean; - /** - * 设置自动使用阻尼 - * @property applyDamping - * @type {Boolean} - */ - applyDamping: boolean; - /** - * 设置自动使用重力 - * @property applyGravity - * @type {Boolean} - */ - applyGravity: boolean; - /** - * 使用约束求解 - * @property solveConstraints - * @type {Boolean} - */ - solveConstraints: boolean; - /** - * 接触材料 - * @property contactMaterials - * @type {Array} - */ - contactMaterials: ContactMaterial[]; - /** - * 世界时间 - * @property time - * @type {Number} - */ - time: number; - /** - * 是否正在 step 阶段 - * @property {Boolean} stepping - */ - stepping: boolean; - /** - * 是否启用岛内分裂 - * @property {Boolean} islandSplit - */ - islandSplit: boolean; - /** - * 设置为true,world会派发 impact 事件,关闭可以提高性能 - * @property emitImpactEvent - * @type {Boolean} - */ - emitImpactEvent: boolean; - /** - * 刚体睡眠策略。取值是 World.NO_SLEEPING,World.BODY_SLEEPING,World.ISLAND_SLEEPING 之一 - * @property sleepMode - * @type {number} - * @default World.NO_SLEEPING - */ - sleepMode: number; - - /** - * 添加约束 - * @method addConstraint - * @param {Constraint} constraint - */ - addConstraint(constraint: Constraint): void; - /** - * 添加触点材料 - * @method addContactMaterial - * @param {ContactMaterial} contactMaterial - */ - addContactMaterial(contactMaterial: ContactMaterial): void; - /** - * 移除触点材料 - * @method removeContactMaterial - * @param {ContactMaterial} cm - */ - removeContactMaterial(cm: ContactMaterial): void; - /** - * 通过2个材料获得触点材料 - * @method getContactMaterial - * @param {Material} materialA - * @param {Material} materialB - * @return {ContactMaterial} 获得的触点材料或者false - */ - getContactMaterial(materialA: Material, materialB: Material): ContactMaterial; - /** - * 移除约束 - * @method removeConstraint - * @param {Constraint} constraint - */ - removeConstraint(constraint: Constraint): void; - /** - * 使物理系统向前经过一定时间 - * - * @method step - * @param {Number} dt 时长 - * @param {Number} [timeSinceLastCalled=0] - * @param {Number} [maxSubSteps=10] - * - * @example - * var world = new World(); - * world.step(0.01); - */ - step(dt: number, timeSinceLastCalled?: number, maxSubSteps?: number): void; - /** - * 添加一个 Spring - * - * @method addSpring - * @param {Spring} spring - */ - addSpring(spring: Spring): void; - /** - * 移除一个 Spring - * - * @method removeSpring - * @param {Spring} spring - */ - removeSpring(spring: Spring): void; - /** - * 添加一个 Body - * - * @method addBody - * @param {Body} body - * - * @example - * var world = new World(), - * body = new Body(); - * world.addBody(body); - */ - addBody(body: Body): void; - /** - * 移除一个 Body。如果在 step()阶段调用,将会在阶段之后移除 - * - * @method removeBody - * @param {Body} body - */ - removeBody(body: Body): void; - /** - * 通过id获取一个 Body - * @method getBodyById - * @return {Body|Boolean} 得到的刚体或者false - */ - getBodyByID(id: number): Body; - /** - * 两个刚体之间禁用碰撞 - * @method disableBodyCollision - * @param {Body} bodyA - * @param {Body} bodyB - */ - disableBodyCollision(bodyA: Body, bodyB: Body): void; - /** - * 两个刚体之间启用碰撞 - * @method enableBodyCollision - * @param {Body} bodyA - * @param {Body} bodyB - */ - enableBodyCollision(bodyA: Body, bodyB: Body): void; - /** - * 重置 world - * @method clear - */ - clear(): void; - - /** - * Test if a world point overlaps bodies - * @method hitTest - * @param {Array} worldPoint Point to use for intersection tests - * @param {Array} bodies A list of objects to check for intersection - * @param {number} precision Used for matching against particles and lines. Adds some margin to these infinitesimal objects. - * @return {Array} Array of bodies that overlap the point - */ - hitTest(worldPoint: number[], bodies: Body[], precision: number): Body[]; - - /** - * Ray cast against all bodies in the world. - * @method raycast - * @param {RaycastResult} result - * @param {Ray} ray - * @return {boolean} True if any body was hit. - */ - raycast(result: RaycastResult, ray: Ray): boolean; - - /** - * Runs narrowphase for the shape pair i and j. - * @method runNarrowphase - * @param {Narrowphase} np - * @param {Body} bi - * @param {Shape} si - * @param {Array} xi - * @param {number} ai - * @param {Body} bj - * @param {Shape} sj - * @param {Array} xj - * @param {number} aj - * @param {number} mu - */ - runNarrowphase(np:Narrowphase, bi:Body, si:Shape, xi:number[], ai:number, bj:Body, sj:Shape, xj:number[], aj:number, mu:number): void; - - /** - * Set the relaxation for all equations and contact materials. - * @method setGlobalRelaxation - * @param {number} relaxation - */ - setGlobalRelaxation(relaxation: number): void; - - /** - * Set the stiffness for all equations and contact materials. - * @method setGlobalStiffness - * @param {Number} stiffness - */ - setGlobalStiffness(stiffness: number): void; - - } - -} \ No newline at end of file diff --git a/helloworld/libs/modules/physics/physics.js b/helloworld/libs/modules/physics/physics.js deleted file mode 100644 index fe2ef5c..0000000 --- a/helloworld/libs/modules/physics/physics.js +++ /dev/null @@ -1,972 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (c) 2015 p2.js authors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -!function (a) { if ("object" == typeof exports) - module.exports = a(); -else if ("function" == typeof define && false) - define(a); -else { - var b; - "undefined" != typeof window ? b = window : "undefined" != typeof global ? b = global : "undefined" != typeof self && (b = self), b.p2 = a(); -} }(function () { - return function a(b, c, d) { function e(g, h) { if (!c[g]) { - if (!b[g]) { - var i = "function" == typeof require && require; - if (!h && i) - return i(g, !0); - if (f) - return f(g, !0); - throw new Error("Cannot find module '" + g + "'"); - } - var j = c[g] = { exports: {} }; - b[g][0].call(j.exports, function (a) { var c = b[g][1][a]; return e(c ? c : a); }, j, j.exports, a, b, c, d); - } return c[g].exports; } for (var f = "function" == typeof require && require, g = 0; g < d.length; g++) - e(d[g]); return e; }({ 1: [function (a, b, c) { function d() { } var e = a("./Scalar"); b.exports = d, d.lineInt = function (a, b, c) { c = c || 0; var d, f, g, h, i, j, k, l = [0, 0]; return d = a[1][1] - a[0][1], f = a[0][0] - a[1][0], g = d * a[0][0] + f * a[0][1], h = b[1][1] - b[0][1], i = b[0][0] - b[1][0], j = h * b[0][0] + i * b[0][1], k = d * i - h * f, e.eq(k, 0, c) || (l[0] = (i * g - f * j) / k, l[1] = (d * j - h * g) / k), l; }, d.segmentsIntersect = function (a, b, c, d) { var e = b[0] - a[0], f = b[1] - a[1], g = d[0] - c[0], h = d[1] - c[1]; if (g * f - h * e == 0) - return !1; var i = (e * (c[1] - a[1]) + f * (a[0] - c[0])) / (g * f - h * e), j = (g * (a[1] - c[1]) + h * (c[0] - a[0])) / (h * e - g * f); return i >= 0 && 1 >= i && j >= 0 && 1 >= j; }; }, { "./Scalar": 4 }], 2: [function (a, b, c) { function d() { } b.exports = d, d.area = function (a, b, c) { return (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1]); }, d.left = function (a, b, c) { return d.area(a, b, c) > 0; }, d.leftOn = function (a, b, c) { return d.area(a, b, c) >= 0; }, d.right = function (a, b, c) { return d.area(a, b, c) < 0; }, d.rightOn = function (a, b, c) { return d.area(a, b, c) <= 0; }; var e = [], f = []; d.collinear = function (a, b, c, g) { if (g) { - var h = e, i = f; - h[0] = b[0] - a[0], h[1] = b[1] - a[1], i[0] = c[0] - b[0], i[1] = c[1] - b[1]; - var j = h[0] * i[0] + h[1] * i[1], k = Math.sqrt(h[0] * h[0] + h[1] * h[1]), l = Math.sqrt(i[0] * i[0] + i[1] * i[1]), m = Math.acos(j / (k * l)); - return g > m; - } return 0 == d.area(a, b, c); }, d.sqdist = function (a, b) { var c = b[0] - a[0], d = b[1] - a[1]; return c * c + d * d; }; }, {}], 3: [function (a, b, c) { function d() { this.vertices = []; } function e(a, b, c, d, e) { e = e || 0; var f = b[1] - a[1], g = a[0] - b[0], i = f * a[0] + g * a[1], j = d[1] - c[1], k = c[0] - d[0], l = j * c[0] + k * c[1], m = f * k - j * g; return h.eq(m, 0, e) ? [0, 0] : [(k * i - g * l) / m, (f * l - j * i) / m]; } var f = a("./Line"), g = a("./Point"), h = a("./Scalar"); b.exports = d, d.prototype.at = function (a) { var b = this.vertices, c = b.length; return b[0 > a ? a % c + c : a % c]; }, d.prototype.first = function () { return this.vertices[0]; }, d.prototype.last = function () { return this.vertices[this.vertices.length - 1]; }, d.prototype.clear = function () { this.vertices.length = 0; }, d.prototype.append = function (a, b, c) { if ("undefined" == typeof b) - throw new Error("From is not given!"); if ("undefined" == typeof c) - throw new Error("To is not given!"); if (b > c - 1) - throw new Error("lol1"); if (c > a.vertices.length) - throw new Error("lol2"); if (0 > b) - throw new Error("lol3"); for (var d = b; c > d; d++) - this.vertices.push(a.vertices[d]); }, d.prototype.makeCCW = function () { for (var a = 0, b = this.vertices, c = 1; c < this.vertices.length; ++c) - (b[c][1] < b[a][1] || b[c][1] == b[a][1] && b[c][0] > b[a][0]) && (a = c); g.left(this.at(a - 1), this.at(a), this.at(a + 1)) || this.reverse(); }, d.prototype.reverse = function () { for (var a = [], b = 0, c = this.vertices.length; b !== c; b++) - a.push(this.vertices.pop()); this.vertices = a; }, d.prototype.isReflex = function (a) { return g.right(this.at(a - 1), this.at(a), this.at(a + 1)); }; var i = [], j = []; d.prototype.canSee = function (a, b) { var c, d, e = i, h = j; if (g.leftOn(this.at(a + 1), this.at(a), this.at(b)) && g.rightOn(this.at(a - 1), this.at(a), this.at(b))) - return !1; d = g.sqdist(this.at(a), this.at(b)); for (var k = 0; k !== this.vertices.length; ++k) - if ((k + 1) % this.vertices.length !== a && k !== a && g.leftOn(this.at(a), this.at(b), this.at(k + 1)) && g.rightOn(this.at(a), this.at(b), this.at(k)) && (e[0] = this.at(a), e[1] = this.at(b), h[0] = this.at(k), h[1] = this.at(k + 1), c = f.lineInt(e, h), g.sqdist(this.at(a), c) < d)) - return !1; return !0; }, d.prototype.copy = function (a, b, c) { var e = c || new d; if (e.clear(), b > a) - for (var f = a; b >= f; f++) - e.vertices.push(this.vertices[f]); - else { - for (var f = 0; b >= f; f++) - e.vertices.push(this.vertices[f]); - for (var f = a; f < this.vertices.length; f++) - e.vertices.push(this.vertices[f]); - } return e; }, d.prototype.getCutEdges = function () { for (var a = [], b = [], c = [], e = new d, f = Number.MAX_VALUE, g = 0; g < this.vertices.length; ++g) - if (this.isReflex(g)) - for (var h = 0; h < this.vertices.length; ++h) - if (this.canSee(g, h)) { - b = this.copy(g, h, e).getCutEdges(), c = this.copy(h, g, e).getCutEdges(); - for (var i = 0; i < c.length; i++) - b.push(c[i]); - b.length < f && (a = b, f = b.length, a.push([this.at(g), this.at(h)])); - } return a; }, d.prototype.decomp = function () { var a = this.getCutEdges(); return a.length > 0 ? this.slice(a) : [this]; }, d.prototype.slice = function (a) { if (0 == a.length) - return [this]; if (a instanceof Array && a.length && a[0] instanceof Array && 2 == a[0].length && a[0][0] instanceof Array) { - for (var b = [this], c = 0; c < a.length; c++) - for (var d = a[c], e = 0; e < b.length; e++) { - var f = b[e], g = f.slice(d); - if (g) { - b.splice(e, 1), b.push(g[0], g[1]); - break; - } - } - return b; - } var d = a, c = this.vertices.indexOf(d[0]), e = this.vertices.indexOf(d[1]); return -1 != c && -1 != e ? [this.copy(c, e), this.copy(e, c)] : !1; }, d.prototype.isSimple = function () { for (var a = this.vertices, b = 0; b < a.length - 1; b++) - for (var c = 0; b - 1 > c; c++) - if (f.segmentsIntersect(a[b], a[b + 1], a[c], a[c + 1])) - return !1; for (var b = 1; b < a.length - 2; b++) - if (f.segmentsIntersect(a[0], a[a.length - 1], a[b], a[b + 1])) - return !1; return !0; }, d.prototype.quickDecomp = function (a, b, c, f, h, i) { h = h || 100, i = i || 0, f = f || 25, a = "undefined" != typeof a ? a : [], b = b || [], c = c || []; var j = [0, 0], k = [0, 0], l = [0, 0], m = 0, n = 0, o = 0, p = 0, q = 0, r = 0, s = 0, t = new d, u = new d, v = this, w = this.vertices; if (w.length < 3) - return a; if (i++, i > h) - return console.warn("quickDecomp: max level (" + h + ") reached."), a; for (var x = 0; x < this.vertices.length; ++x) - if (v.isReflex(x)) { - b.push(v.vertices[x]), m = n = Number.MAX_VALUE; - for (var y = 0; y < this.vertices.length; ++y) - g.left(v.at(x - 1), v.at(x), v.at(y)) && g.rightOn(v.at(x - 1), v.at(x), v.at(y - 1)) && (l = e(v.at(x - 1), v.at(x), v.at(y), v.at(y - 1)), g.right(v.at(x + 1), v.at(x), l) && (o = g.sqdist(v.vertices[x], l), n > o && (n = o, k = l, r = y))), g.left(v.at(x + 1), v.at(x), v.at(y + 1)) && g.rightOn(v.at(x + 1), v.at(x), v.at(y)) && (l = e(v.at(x + 1), v.at(x), v.at(y), v.at(y + 1)), g.left(v.at(x - 1), v.at(x), l) && (o = g.sqdist(v.vertices[x], l), m > o && (m = o, j = l, q = y))); - if (r == (q + 1) % this.vertices.length) - l[0] = (k[0] + j[0]) / 2, l[1] = (k[1] + j[1]) / 2, c.push(l), q > x ? (t.append(v, x, q + 1), t.vertices.push(l), u.vertices.push(l), 0 != r && u.append(v, r, v.vertices.length), u.append(v, 0, x + 1)) : (0 != x && t.append(v, x, v.vertices.length), t.append(v, 0, q + 1), t.vertices.push(l), u.vertices.push(l), u.append(v, r, x + 1)); - else { - if (r > q && (q += this.vertices.length), p = Number.MAX_VALUE, r > q) - return a; - for (var y = r; q >= y; ++y) - g.leftOn(v.at(x - 1), v.at(x), v.at(y)) && g.rightOn(v.at(x + 1), v.at(x), v.at(y)) && (o = g.sqdist(v.at(x), v.at(y)), p > o && (p = o, s = y % this.vertices.length)); - s > x ? (t.append(v, x, s + 1), 0 != s && u.append(v, s, w.length), u.append(v, 0, x + 1)) : (0 != x && t.append(v, x, w.length), t.append(v, 0, s + 1), u.append(v, s, x + 1)); - } - return t.vertices.length < u.vertices.length ? (t.quickDecomp(a, b, c, f, h, i), u.quickDecomp(a, b, c, f, h, i)) : (u.quickDecomp(a, b, c, f, h, i), t.quickDecomp(a, b, c, f, h, i)), a; - } return a.push(this), a; }, d.prototype.removeCollinearPoints = function (a) { for (var b = 0, c = this.vertices.length - 1; this.vertices.length > 3 && c >= 0; --c) - g.collinear(this.at(c - 1), this.at(c), this.at(c + 1), a) && (this.vertices.splice(c % this.vertices.length, 1), c--, b++); return b; }; }, { "./Line": 1, "./Point": 2, "./Scalar": 4 }], 4: [function (a, b, c) { function d() { } b.exports = d, d.eq = function (a, b, c) { return c = c || 0, Math.abs(a - b) < c; }; }, {}], 5: [function (a, b, c) { b.exports = { Polygon: a("./Polygon"), Point: a("./Point") }; }, { "./Point": 2, "./Polygon": 3 }], 6: [function (a, b, c) { b.exports = { name: "p2", version: "0.7.0", description: "A JavaScript 2D physics engine.", author: "Stefan Hedman (http://steffe.se)", keywords: ["p2.js", "p2", "physics", "engine", "2d"], main: "./src/p2.js", engines: { node: "*" }, repository: { type: "git", url: "https://github.com/schteppe/p2.js.git" }, bugs: { url: "https://github.com/schteppe/p2.js/issues" }, licenses: [{ type: "MIT" }], devDependencies: { grunt: "^0.4.5", "grunt-contrib-jshint": "^0.11.2", "grunt-contrib-nodeunit": "^0.4.1", "grunt-contrib-uglify": "~0.4.0", "grunt-contrib-watch": "~0.5.0", "grunt-browserify": "~2.0.1", "grunt-contrib-concat": "^0.4.0" }, dependencies: { "poly-decomp": "0.1.0" } }; }, {}], 7: [function (a, b, c) { function d(a) { this.lowerBound = e.create(), a && a.lowerBound && e.copy(this.lowerBound, a.lowerBound), this.upperBound = e.create(), a && a.upperBound && e.copy(this.upperBound, a.upperBound); } var e = a("../math/vec2"); a("../utils/Utils"); b.exports = d; var f = e.create(); d.prototype.setFromPoints = function (a, b, c, d) { var g = this.lowerBound, h = this.upperBound; "number" != typeof c && (c = 0), 0 !== c ? e.rotate(g, a[0], c) : e.copy(g, a[0]), e.copy(h, g); for (var i = Math.cos(c), j = Math.sin(c), k = 1; k < a.length; k++) { - var l = a[k]; - if (0 !== c) { - var m = l[0], n = l[1]; - f[0] = i * m - j * n, f[1] = j * m + i * n, l = f; - } - for (var o = 0; 2 > o; o++) - l[o] > h[o] && (h[o] = l[o]), l[o] < g[o] && (g[o] = l[o]); - } b && (e.add(this.lowerBound, this.lowerBound, b), e.add(this.upperBound, this.upperBound, b)), d && (this.lowerBound[0] -= d, this.lowerBound[1] -= d, this.upperBound[0] += d, this.upperBound[1] += d); }, d.prototype.copy = function (a) { e.copy(this.lowerBound, a.lowerBound), e.copy(this.upperBound, a.upperBound); }, d.prototype.extend = function (a) { for (var b = 2; b--;) { - var c = a.lowerBound[b]; - this.lowerBound[b] > c && (this.lowerBound[b] = c); - var d = a.upperBound[b]; - this.upperBound[b] < d && (this.upperBound[b] = d); - } }, d.prototype.overlaps = function (a) { var b = this.lowerBound, c = this.upperBound, d = a.lowerBound, e = a.upperBound; return (d[0] <= c[0] && c[0] <= e[0] || b[0] <= e[0] && e[0] <= c[0]) && (d[1] <= c[1] && c[1] <= e[1] || b[1] <= e[1] && e[1] <= c[1]); }, d.prototype.containsPoint = function (a) { var b = this.lowerBound, c = this.upperBound; return b[0] <= a[0] && a[0] <= c[0] && b[1] <= a[1] && a[1] <= c[1]; }, d.prototype.overlapsRay = function (a) { var b = 1 / a.direction[0], c = 1 / a.direction[1], d = (this.lowerBound[0] - a.from[0]) * b, e = (this.upperBound[0] - a.from[0]) * b, f = (this.lowerBound[1] - a.from[1]) * c, g = (this.upperBound[1] - a.from[1]) * c, h = Math.max(Math.max(Math.min(d, e), Math.min(f, g))), i = Math.min(Math.min(Math.max(d, e), Math.max(f, g))); return 0 > i ? -1 : h > i ? -1 : h; }; }, { "../math/vec2": 30, "../utils/Utils": 57 }], 8: [function (a, b, c) { function d(a) { this.type = a, this.result = [], this.world = null, this.boundingVolumeType = d.AABB; } var e = a("../math/vec2"), f = a("../objects/Body"); b.exports = d, d.AABB = 1, d.BOUNDING_CIRCLE = 2, d.prototype.setWorld = function (a) { this.world = a; }, d.prototype.getCollisionPairs = function (a) { }; var g = e.create(); d.boundingRadiusCheck = function (a, b) { e.sub(g, a.position, b.position); var c = e.squaredLength(g), d = a.boundingRadius + b.boundingRadius; return d * d >= c; }, d.aabbCheck = function (a, b) { return a.getAABB().overlaps(b.getAABB()); }, d.prototype.boundingVolumeCheck = function (a, b) { var c; switch (this.boundingVolumeType) { - case d.BOUNDING_CIRCLE: - c = d.boundingRadiusCheck(a, b); - break; - case d.AABB: - c = d.aabbCheck(a, b); - break; - default: throw new Error("Bounding volume type not recognized: " + this.boundingVolumeType); - } return c; }, d.canCollide = function (a, b) { var c = f.KINEMATIC, d = f.STATIC; return a.type === d && b.type === d ? !1 : a.type === c && b.type === d || a.type === d && b.type === c ? !1 : a.type === c && b.type === c ? !1 : a.sleepState === f.SLEEPING && b.sleepState === f.SLEEPING ? !1 : a.sleepState === f.SLEEPING && b.type === d || b.sleepState === f.SLEEPING && a.type === d ? !1 : !0; }, d.NAIVE = 1, d.SAP = 2; }, { "../math/vec2": 30, "../objects/Body": 31 }], 9: [function (a, b, c) { function d() { e.call(this, e.NAIVE); } var e = (a("../shapes/Circle"), a("../shapes/Plane"), a("../shapes/Shape"), a("../shapes/Particle"), a("../collision/Broadphase")); a("../math/vec2"); b.exports = d, d.prototype = new e, d.prototype.constructor = d, d.prototype.getCollisionPairs = function (a) { var b = a.bodies, c = this.result; c.length = 0; for (var d = 0, f = b.length; d !== f; d++) - for (var g = b[d], h = 0; d > h; h++) { - var i = b[h]; - e.canCollide(g, i) && this.boundingVolumeCheck(g, i) && c.push(g, i); - } return c; }, d.prototype.aabbQuery = function (a, b, c) { c = c || []; for (var d = a.bodies, e = 0; e < d.length; e++) { - var f = d[e]; - f.aabbNeedsUpdate && f.updateAABB(), f.aabb.overlaps(b) && c.push(f); - } return c; }; }, { "../collision/Broadphase": 8, "../math/vec2": 30, "../shapes/Circle": 39, "../shapes/Particle": 43, "../shapes/Plane": 44, "../shapes/Shape": 45 }], 10: [function (a, b, c) { - function d() { this.contactEquations = [], this.frictionEquations = [], this.enableFriction = !0, this.enabledEquations = !0, this.slipForce = 10, this.frictionCoefficient = .3, this.surfaceVelocity = 0, this.contactEquationPool = new k({ size: 32 }), this.frictionEquationPool = new l({ size: 64 }), this.restitution = 0, this.stiffness = n.DEFAULT_STIFFNESS, this.relaxation = n.DEFAULT_RELAXATION, this.frictionStiffness = n.DEFAULT_STIFFNESS, this.frictionRelaxation = n.DEFAULT_RELAXATION, this.enableFrictionReduction = !0, this.collidingBodiesLastStep = new m, this.contactSkinSize = .01; } - function e(a, b) { g.set(a.vertices[0], .5 * -b.length, -b.radius), g.set(a.vertices[1], .5 * b.length, -b.radius), g.set(a.vertices[2], .5 * b.length, b.radius), g.set(a.vertices[3], .5 * -b.length, b.radius); } - function f(a, b, c, d) { for (var e = T, f = U, j = V, k = W, l = a, m = b.vertices, n = null, o = 0; o !== m.length + 1; o++) { - var p = m[o % m.length], q = m[(o + 1) % m.length]; - g.rotate(e, p, d), g.rotate(f, q, d), i(e, e, c), i(f, f, c), h(j, e, l), h(k, f, l); - var r = g.crossLength(j, k); - if (null === n && (n = r), 0 >= r * n) - return !1; - n = r; - } return !0; } - var g = a("../math/vec2"), h = g.sub, i = g.add, j = g.dot, k = (a("../utils/Utils"), a("../utils/ContactEquationPool")), l = a("../utils/FrictionEquationPool"), m = a("../utils/TupleDictionary"), n = a("../equations/Equation"), o = (a("../equations/ContactEquation"), a("../equations/FrictionEquation"), a("../shapes/Circle")), p = a("../shapes/Convex"), q = a("../shapes/Shape"), r = (a("../objects/Body"), a("../shapes/Box")); - b.exports = d; - var s = g.fromValues(0, 1), t = g.fromValues(0, 0), u = g.fromValues(0, 0), v = g.fromValues(0, 0), w = g.fromValues(0, 0), x = g.fromValues(0, 0), y = g.fromValues(0, 0), z = g.fromValues(0, 0), A = g.fromValues(0, 0), B = g.fromValues(0, 0), C = g.fromValues(0, 0), D = g.fromValues(0, 0), E = g.fromValues(0, 0), F = g.fromValues(0, 0), G = g.fromValues(0, 0), H = g.fromValues(0, 0), I = g.fromValues(0, 0), J = g.fromValues(0, 0), K = g.fromValues(0, 0), L = [], M = g.create(), N = g.create(); - d.prototype.bodiesOverlap = function (a, b) { for (var c = M, d = N, e = 0, f = a.shapes.length; e !== f; e++) { - var g = a.shapes[e]; - a.toWorldFrame(c, g.position); - for (var h = 0, i = b.shapes.length; h !== i; h++) { - var j = b.shapes[h]; - if (b.toWorldFrame(d, j.position), this[g.type | j.type](a, g, c, g.angle + a.angle, b, j, d, j.angle + b.angle, !0)) - return !0; - } - } return !1; }, d.prototype.collidedLastStep = function (a, b) { var c = 0 | a.id, d = 0 | b.id; return !!this.collidingBodiesLastStep.get(c, d); }, d.prototype.reset = function () { this.collidingBodiesLastStep.reset(); for (var a = this.contactEquations, b = a.length; b--;) { - var c = a[b], d = c.bodyA.id, e = c.bodyB.id; - this.collidingBodiesLastStep.set(d, e, !0); - } for (var f = this.contactEquations, g = this.frictionEquations, h = 0; h < f.length; h++) - this.contactEquationPool.release(f[h]); for (var h = 0; h < g.length; h++) - this.frictionEquationPool.release(g[h]); this.contactEquations.length = this.frictionEquations.length = 0; }, d.prototype.createContactEquation = function (a, b, c, d) { var e = this.contactEquationPool.get(); return e.bodyA = a, e.bodyB = b, e.shapeA = c, e.shapeB = d, e.restitution = this.restitution, e.firstImpact = !this.collidedLastStep(a, b), e.stiffness = this.stiffness, e.relaxation = this.relaxation, e.needsUpdate = !0, e.enabled = this.enabledEquations, e.offset = this.contactSkinSize, e; }, d.prototype.createFrictionEquation = function (a, b, c, d) { var e = this.frictionEquationPool.get(); return e.bodyA = a, e.bodyB = b, e.shapeA = c, e.shapeB = d, e.setSlipForce(this.slipForce), e.frictionCoefficient = this.frictionCoefficient, e.relativeVelocity = this.surfaceVelocity, e.enabled = this.enabledEquations, e.needsUpdate = !0, e.stiffness = this.frictionStiffness, e.relaxation = this.frictionRelaxation, e.contactEquations.length = 0, e; }, d.prototype.createFrictionFromContact = function (a) { var b = this.createFrictionEquation(a.bodyA, a.bodyB, a.shapeA, a.shapeB); return g.copy(b.contactPointA, a.contactPointA), g.copy(b.contactPointB, a.contactPointB), g.rotate90cw(b.t, a.normalA), b.contactEquations.push(a), b; }, d.prototype.createFrictionFromAverage = function (a) { var b = this.contactEquations[this.contactEquations.length - 1], c = this.createFrictionEquation(b.bodyA, b.bodyB, b.shapeA, b.shapeB), d = b.bodyA; b.bodyB; g.set(c.contactPointA, 0, 0), g.set(c.contactPointB, 0, 0), g.set(c.t, 0, 0); for (var e = 0; e !== a; e++) - b = this.contactEquations[this.contactEquations.length - 1 - e], b.bodyA === d ? (g.add(c.t, c.t, b.normalA), g.add(c.contactPointA, c.contactPointA, b.contactPointA), g.add(c.contactPointB, c.contactPointB, b.contactPointB)) : (g.sub(c.t, c.t, b.normalA), g.add(c.contactPointA, c.contactPointA, b.contactPointB), g.add(c.contactPointB, c.contactPointB, b.contactPointA)), c.contactEquations.push(b); var f = 1 / a; return g.scale(c.contactPointA, c.contactPointA, f), g.scale(c.contactPointB, c.contactPointB, f), g.normalize(c.t, c.t), g.rotate90cw(c.t, c.t), c; }, d.prototype[q.LINE | q.CONVEX] = d.prototype.convexLine = function (a, b, c, d, e, f, g, h, i) { return i ? !1 : 0; }, d.prototype[q.LINE | q.BOX] = d.prototype.lineBox = function (a, b, c, d, e, f, g, h, i) { return i ? !1 : 0; }; - var O = new r({ width: 1, height: 1 }), P = g.create(); - d.prototype[q.CAPSULE | q.CONVEX] = d.prototype[q.CAPSULE | q.BOX] = d.prototype.convexCapsule = function (a, b, c, d, f, h, i, j, k) { var l = P; g.set(l, h.length / 2, 0), g.rotate(l, l, j), g.add(l, l, i); var m = this.circleConvex(f, h, l, j, a, b, c, d, k, h.radius); g.set(l, -h.length / 2, 0), g.rotate(l, l, j), g.add(l, l, i); var n = this.circleConvex(f, h, l, j, a, b, c, d, k, h.radius); if (k && (m || n)) - return !0; var o = O; e(o, h); var p = this.convexConvex(a, b, c, d, f, o, i, j, k); return p + m + n; }, d.prototype[q.CAPSULE | q.LINE] = d.prototype.lineCapsule = function (a, b, c, d, e, f, g, h, i) { return i ? !1 : 0; }; - var Q = g.create(), R = g.create(), S = new r({ width: 1, height: 1 }); - d.prototype[q.CAPSULE | q.CAPSULE] = d.prototype.capsuleCapsule = function (a, b, c, d, f, h, i, j, k) { for (var l, m = Q, n = R, o = 0, p = 0; 2 > p; p++) { - g.set(m, (0 === p ? -1 : 1) * b.length / 2, 0), g.rotate(m, m, d), g.add(m, m, c); - for (var q = 0; 2 > q; q++) { - g.set(n, (0 === q ? -1 : 1) * h.length / 2, 0), g.rotate(n, n, j), g.add(n, n, i), this.enableFrictionReduction && (l = this.enableFriction, this.enableFriction = !1); - var r = this.circleCircle(a, b, m, d, f, h, n, j, k, b.radius, h.radius); - if (this.enableFrictionReduction && (this.enableFriction = l), k && r) - return !0; - o += r; - } - } this.enableFrictionReduction && (l = this.enableFriction, this.enableFriction = !1); var s = S; e(s, b); var t = this.convexCapsule(a, s, c, d, f, h, i, j, k); if (this.enableFrictionReduction && (this.enableFriction = l), k && t) - return !0; if (o += t, this.enableFrictionReduction) { - var l = this.enableFriction; - this.enableFriction = !1; - } e(s, h); var u = this.convexCapsule(f, s, i, j, a, b, c, d, k); return this.enableFrictionReduction && (this.enableFriction = l), k && u ? !0 : (o += u, this.enableFrictionReduction && o && this.enableFriction && this.frictionEquations.push(this.createFrictionFromAverage(o)), o); }, d.prototype[q.LINE | q.LINE] = d.prototype.lineLine = function (a, b, c, d, e, f, g, h, i) { return i ? !1 : 0; }, d.prototype[q.PLANE | q.LINE] = d.prototype.planeLine = function (a, b, c, d, e, f, k, l, m) { var n = t, o = u, p = v, q = w, r = x, C = y, D = z, E = A, F = B, G = L, H = 0; g.set(n, -f.length / 2, 0), g.set(o, f.length / 2, 0), g.rotate(p, n, l), g.rotate(q, o, l), i(p, p, k), i(q, q, k), g.copy(n, p), g.copy(o, q), h(r, o, n), g.normalize(C, r), g.rotate90cw(F, C), g.rotate(E, s, d), G[0] = n, G[1] = o; for (var I = 0; I < G.length; I++) { - var J = G[I]; - h(D, J, c); - var K = j(D, E); - if (0 > K) { - if (m) - return !0; - var M = this.createContactEquation(a, e, b, f); - H++, g.copy(M.normalA, E), g.normalize(M.normalA, M.normalA), g.scale(D, E, K), h(M.contactPointA, J, D), h(M.contactPointA, M.contactPointA, a.position), h(M.contactPointB, J, k), i(M.contactPointB, M.contactPointB, k), h(M.contactPointB, M.contactPointB, e.position), this.contactEquations.push(M), this.enableFrictionReduction || this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(M)); - } - } return m ? !1 : (this.enableFrictionReduction || H && this.enableFriction && this.frictionEquations.push(this.createFrictionFromAverage(H)), H); }, d.prototype[q.PARTICLE | q.CAPSULE] = d.prototype.particleCapsule = function (a, b, c, d, e, f, g, h, i) { return this.circleLine(a, b, c, d, e, f, g, h, i, f.radius, 0); }, d.prototype[q.CIRCLE | q.LINE] = d.prototype.circleLine = function (a, b, c, d, e, f, k, l, m, n, o) { var n = n || 0, o = "undefined" != typeof o ? o : b.radius, p = t, q = u, r = v, s = w, H = x, I = y, J = z, K = A, M = B, N = C, O = D, P = E, Q = F, R = G, S = L; g.set(K, -f.length / 2, 0), g.set(M, f.length / 2, 0), g.rotate(N, K, l), g.rotate(O, M, l), i(N, N, k), i(O, O, k), g.copy(K, N), g.copy(M, O), h(I, M, K), g.normalize(J, I), g.rotate90cw(H, J), h(P, c, K); var T = j(P, H); h(s, K, k), h(Q, c, k); var U = o + n; if (Math.abs(T) < U) { - g.scale(p, H, T), h(r, c, p), g.scale(q, H, j(H, Q)), g.normalize(q, q), g.scale(q, q, n), i(r, r, q); - var V = j(J, r), W = j(J, K), X = j(J, M); - if (V > W && X > V) { - if (m) - return !0; - var Y = this.createContactEquation(a, e, b, f); - return g.scale(Y.normalA, p, -1), g.normalize(Y.normalA, Y.normalA), g.scale(Y.contactPointA, Y.normalA, o), i(Y.contactPointA, Y.contactPointA, c), h(Y.contactPointA, Y.contactPointA, a.position), h(Y.contactPointB, r, k), i(Y.contactPointB, Y.contactPointB, k), h(Y.contactPointB, Y.contactPointB, e.position), this.contactEquations.push(Y), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(Y)), 1; - } - } S[0] = K, S[1] = M; for (var Z = 0; Z < S.length; Z++) { - var $ = S[Z]; - if (h(P, $, c), g.squaredLength(P) < Math.pow(U, 2)) { - if (m) - return !0; - var Y = this.createContactEquation(a, e, b, f); - return g.copy(Y.normalA, P), g.normalize(Y.normalA, Y.normalA), g.scale(Y.contactPointA, Y.normalA, o), i(Y.contactPointA, Y.contactPointA, c), h(Y.contactPointA, Y.contactPointA, a.position), h(Y.contactPointB, $, k), g.scale(R, Y.normalA, -n), i(Y.contactPointB, Y.contactPointB, R), i(Y.contactPointB, Y.contactPointB, k), h(Y.contactPointB, Y.contactPointB, e.position), this.contactEquations.push(Y), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(Y)), 1; - } - } return 0; }, d.prototype[q.CIRCLE | q.CAPSULE] = d.prototype.circleCapsule = function (a, b, c, d, e, f, g, h, i) { return this.circleLine(a, b, c, d, e, f, g, h, i, f.radius); }, d.prototype[q.CIRCLE | q.CONVEX] = d.prototype[q.CIRCLE | q.BOX] = d.prototype.circleConvex = function (a, b, c, d, e, j, k, l, m, n) { for (var n = "number" == typeof n ? n : b.radius, o = t, p = u, q = v, r = w, s = x, y = C, z = D, A = F, B = G, E = H, J = I, K = !1, L = Number.MAX_VALUE, M = j.vertices, N = 0; N !== M.length + 1; N++) { - var O = M[N % M.length], P = M[(N + 1) % M.length]; - if (g.rotate(o, O, l), g.rotate(p, P, l), i(o, o, k), i(p, p, k), h(q, p, o), g.normalize(r, q), g.rotate90cw(s, r), g.scale(B, s, -b.radius), i(B, B, c), f(B, j, k, l)) { - g.sub(E, o, B); - var Q = Math.abs(g.dot(E, s)); - L > Q && (g.copy(J, B), L = Q, g.scale(A, s, Q), g.add(A, A, B), K = !0); - } - } if (K) { - if (m) - return !0; - var R = this.createContactEquation(a, e, b, j); - return g.sub(R.normalA, J, c), g.normalize(R.normalA, R.normalA), g.scale(R.contactPointA, R.normalA, n), i(R.contactPointA, R.contactPointA, c), h(R.contactPointA, R.contactPointA, a.position), h(R.contactPointB, A, k), i(R.contactPointB, R.contactPointB, k), h(R.contactPointB, R.contactPointB, e.position), this.contactEquations.push(R), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(R)), 1; - } if (n > 0) - for (var N = 0; N < M.length; N++) { - var S = M[N]; - if (g.rotate(z, S, l), i(z, z, k), h(y, z, c), g.squaredLength(y) < Math.pow(n, 2)) { - if (m) - return !0; - var R = this.createContactEquation(a, e, b, j); - return g.copy(R.normalA, y), g.normalize(R.normalA, R.normalA), g.scale(R.contactPointA, R.normalA, n), i(R.contactPointA, R.contactPointA, c), h(R.contactPointA, R.contactPointA, a.position), h(R.contactPointB, z, k), i(R.contactPointB, R.contactPointB, k), h(R.contactPointB, R.contactPointB, e.position), this.contactEquations.push(R), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(R)), 1; - } - } return 0; }; - var T = g.create(), U = g.create(), V = g.create(), W = g.create(); - d.prototype[q.PARTICLE | q.CONVEX] = d.prototype[q.PARTICLE | q.BOX] = d.prototype.particleConvex = function (a, b, c, d, e, k, l, m, n) { var o = t, p = u, q = v, r = w, s = x, A = y, B = z, D = C, E = F, G = J, H = K, I = Number.MAX_VALUE, L = !1, M = k.vertices; if (!f(c, k, l, m)) - return 0; if (n) - return !0; for (var N = 0; N !== M.length + 1; N++) { - var O = M[N % M.length], P = M[(N + 1) % M.length]; - g.rotate(o, O, m), g.rotate(p, P, m), i(o, o, l), i(p, p, l), h(q, p, o), g.normalize(r, q), g.rotate90cw(s, r), h(D, c, o); - j(D, s); - h(A, o, l), h(B, c, l), g.sub(G, o, c); - var Q = Math.abs(g.dot(G, s)); - I > Q && (I = Q, g.scale(E, s, Q), g.add(E, E, c), g.copy(H, s), L = !0); - } if (L) { - var R = this.createContactEquation(a, e, b, k); - return g.scale(R.normalA, H, -1), g.normalize(R.normalA, R.normalA), g.set(R.contactPointA, 0, 0), i(R.contactPointA, R.contactPointA, c), h(R.contactPointA, R.contactPointA, a.position), h(R.contactPointB, E, l), i(R.contactPointB, R.contactPointB, l), h(R.contactPointB, R.contactPointB, e.position), this.contactEquations.push(R), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(R)), 1; - } return 0; }, d.prototype[q.CIRCLE] = d.prototype.circleCircle = function (a, b, c, d, e, f, j, k, l, m, n) { var o = t, m = m || b.radius, n = n || f.radius; h(o, c, j); var p = m + n; if (g.squaredLength(o) > Math.pow(p, 2)) - return 0; if (l) - return !0; var q = this.createContactEquation(a, e, b, f); return h(q.normalA, j, c), g.normalize(q.normalA, q.normalA), g.scale(q.contactPointA, q.normalA, m), g.scale(q.contactPointB, q.normalA, -n), i(q.contactPointA, q.contactPointA, c), h(q.contactPointA, q.contactPointA, a.position), i(q.contactPointB, q.contactPointB, j), h(q.contactPointB, q.contactPointB, e.position), this.contactEquations.push(q), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(q)), 1; }, d.prototype[q.PLANE | q.CONVEX] = d.prototype[q.PLANE | q.BOX] = d.prototype.planeConvex = function (a, b, c, d, e, f, k, l, m) { var n = t, o = u, p = v, q = 0; g.rotate(o, s, d); for (var r = 0; r !== f.vertices.length; r++) { - var w = f.vertices[r]; - if (g.rotate(n, w, l), i(n, n, k), h(p, n, c), j(p, o) <= 0) { - if (m) - return !0; - q++; - var x = this.createContactEquation(a, e, b, f); - h(p, n, c), g.copy(x.normalA, o); - var y = j(p, x.normalA); - g.scale(p, x.normalA, y), h(x.contactPointB, n, e.position), h(x.contactPointA, n, p), h(x.contactPointA, x.contactPointA, a.position), this.contactEquations.push(x), this.enableFrictionReduction || this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(x)); - } - } return this.enableFrictionReduction && this.enableFriction && q && this.frictionEquations.push(this.createFrictionFromAverage(q)), q; }, d.prototype[q.PARTICLE | q.PLANE] = d.prototype.particlePlane = function (a, b, c, d, e, f, i, k, l) { var m = t, n = u; k = k || 0, h(m, c, i), g.rotate(n, s, k); var o = j(m, n); if (o > 0) - return 0; if (l) - return !0; var p = this.createContactEquation(e, a, f, b); return g.copy(p.normalA, n), g.scale(m, p.normalA, o), h(p.contactPointA, c, m), h(p.contactPointA, p.contactPointA, e.position), h(p.contactPointB, c, a.position), this.contactEquations.push(p), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(p)), 1; }, d.prototype[q.CIRCLE | q.PARTICLE] = d.prototype.circleParticle = function (a, b, c, d, e, f, j, k, l) { var m = t; if (h(m, j, c), g.squaredLength(m) > Math.pow(b.radius, 2)) - return 0; if (l) - return !0; var n = this.createContactEquation(a, e, b, f); return g.copy(n.normalA, m), g.normalize(n.normalA, n.normalA), g.scale(n.contactPointA, n.normalA, b.radius), i(n.contactPointA, n.contactPointA, c), h(n.contactPointA, n.contactPointA, a.position), h(n.contactPointB, j, e.position), this.contactEquations.push(n), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(n)), 1; }; - var X = new o({ radius: 1 }), Y = g.create(), Z = g.create(); - g.create(); - d.prototype[q.PLANE | q.CAPSULE] = d.prototype.planeCapsule = function (a, b, c, d, e, f, h, j, k) { var l = Y, m = Z, n = X; g.set(l, -f.length / 2, 0), g.rotate(l, l, j), i(l, l, h), g.set(m, f.length / 2, 0), g.rotate(m, m, j), i(m, m, h), n.radius = f.radius; var o; this.enableFrictionReduction && (o = this.enableFriction, this.enableFriction = !1); var p = this.circlePlane(e, n, l, 0, a, b, c, d, k), q = this.circlePlane(e, n, m, 0, a, b, c, d, k); if (this.enableFrictionReduction && (this.enableFriction = o), k) - return p || q; var r = p + q; return this.enableFrictionReduction && r && this.frictionEquations.push(this.createFrictionFromAverage(r)), r; }, d.prototype[q.CIRCLE | q.PLANE] = d.prototype.circlePlane = function (a, b, c, d, e, f, k, l, m) { var n = a, o = b, p = c, q = e, r = k, w = l; w = w || 0; var x = t, y = u, z = v; h(x, p, r), g.rotate(y, s, w); var A = j(y, x); if (A > o.radius) - return 0; if (m) - return !0; var B = this.createContactEquation(q, n, f, b); return g.copy(B.normalA, y), g.scale(B.contactPointB, B.normalA, -o.radius), i(B.contactPointB, B.contactPointB, p), h(B.contactPointB, B.contactPointB, n.position), g.scale(z, B.normalA, A), h(B.contactPointA, x, z), i(B.contactPointA, B.contactPointA, r), h(B.contactPointA, B.contactPointA, q.position), this.contactEquations.push(B), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(B)), 1; }, d.prototype[q.CONVEX] = d.prototype[q.CONVEX | q.BOX] = d.prototype[q.BOX] = d.prototype.convexConvex = function (a, b, c, e, f, k, l, m, n, o) { var p = t, q = u, r = v, s = w, y = x, C = z, D = A, E = B, F = 0, o = "number" == typeof o ? o : 0, G = d.findSeparatingAxis(b, c, e, k, l, m, p); if (!G) - return 0; h(D, l, c), j(p, D) > 0 && g.scale(p, p, -1); var H = d.getClosestEdge(b, e, p, !0), I = d.getClosestEdge(k, m, p); if (-1 === H || -1 === I) - return 0; for (var J = 0; 2 > J; J++) { - var K = H, L = I, M = b, N = k, O = c, P = l, Q = e, R = m, S = a, T = f; - if (0 === J) { - var U; - U = K, K = L, L = U, U = M, M = N, N = U, U = O, O = P, P = U, U = Q, Q = R, R = U, U = S, S = T, T = U; - } - for (var V = L; L + 2 > V; V++) { - var W = N.vertices[(V + N.vertices.length) % N.vertices.length]; - g.rotate(q, W, R), i(q, q, P); - for (var X = 0, Y = K - 1; K + 2 > Y; Y++) { - var Z = M.vertices[(Y + M.vertices.length) % M.vertices.length], $ = M.vertices[(Y + 1 + M.vertices.length) % M.vertices.length]; - g.rotate(r, Z, Q), g.rotate(s, $, Q), i(r, r, O), i(s, s, O), h(y, s, r), g.rotate90cw(E, y), g.normalize(E, E), h(D, q, r); - var _ = j(E, D); - (Y === K && o >= _ || Y !== K && 0 >= _) && X++; - } - if (X >= 3) { - if (n) - return !0; - var aa = this.createContactEquation(S, T, M, N); - F++; - var Z = M.vertices[K % M.vertices.length], $ = M.vertices[(K + 1) % M.vertices.length]; - g.rotate(r, Z, Q), g.rotate(s, $, Q), i(r, r, O), i(s, s, O), h(y, s, r), g.rotate90cw(aa.normalA, y), g.normalize(aa.normalA, aa.normalA), h(D, q, r); - var _ = j(aa.normalA, D); - g.scale(C, aa.normalA, _), h(aa.contactPointA, q, O), h(aa.contactPointA, aa.contactPointA, C), i(aa.contactPointA, aa.contactPointA, O), h(aa.contactPointA, aa.contactPointA, S.position), h(aa.contactPointB, q, P), i(aa.contactPointB, aa.contactPointB, P), h(aa.contactPointB, aa.contactPointB, T.position), this.contactEquations.push(aa), this.enableFrictionReduction || this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(aa)); - } - } - } return this.enableFrictionReduction && this.enableFriction && F && this.frictionEquations.push(this.createFrictionFromAverage(F)), F; }; - var $ = g.fromValues(0, 0); - d.projectConvexOntoAxis = function (a, b, c, d, e) { var f, h, i = null, k = null, l = $; g.rotate(l, d, -c); for (var m = 0; m < a.vertices.length; m++) - f = a.vertices[m], h = j(f, l), (null === i || h > i) && (i = h), (null === k || k > h) && (k = h); if (k > i) { - var n = k; - k = i, i = n; - } var o = j(b, d); g.set(e, k + o, i + o); }; - var _ = g.fromValues(0, 0), aa = g.fromValues(0, 0), ba = g.fromValues(0, 0), ca = g.fromValues(0, 0), da = g.fromValues(0, 0), ea = g.fromValues(0, 0); - d.findSeparatingAxis = function (a, b, c, e, f, i, j) { var k = null, l = !1, m = !1, n = _, o = aa, p = ba, q = ca, s = da, t = ea; if (a instanceof r && e instanceof r) - for (var u = 0; 2 !== u; u++) { - var v = a, w = c; - 1 === u && (v = e, w = i); - for (var x = 0; 2 !== x; x++) { - 0 === x ? g.set(q, 0, 1) : 1 === x && g.set(q, 1, 0), 0 !== w && g.rotate(q, q, w), d.projectConvexOntoAxis(a, b, c, q, s), d.projectConvexOntoAxis(e, f, i, q, t); - var y = s, z = t, A = !1; - s[0] > t[0] && (z = s, y = t, A = !0); - var B = z[0] - y[1]; - l = 0 >= B, (null === k || B > k) && (g.copy(j, q), k = B, m = l); - } - } - else - for (var u = 0; 2 !== u; u++) { - var v = a, w = c; - 1 === u && (v = e, w = i); - for (var x = 0; x !== v.vertices.length; x++) { - g.rotate(o, v.vertices[x], w), g.rotate(p, v.vertices[(x + 1) % v.vertices.length], w), h(n, p, o), g.rotate90cw(q, n), g.normalize(q, q), d.projectConvexOntoAxis(a, b, c, q, s), d.projectConvexOntoAxis(e, f, i, q, t); - var y = s, z = t, A = !1; - s[0] > t[0] && (z = s, y = t, A = !0); - var B = z[0] - y[1]; - l = 0 >= B, (null === k || B > k) && (g.copy(j, q), k = B, m = l); - } - } return m; }; - var fa = g.fromValues(0, 0), ga = g.fromValues(0, 0), ha = g.fromValues(0, 0); - d.getClosestEdge = function (a, b, c, d) { var e = fa, f = ga, i = ha; g.rotate(e, c, -b), d && g.scale(e, e, -1); for (var k = -1, l = a.vertices.length, m = -1, n = 0; n !== l; n++) { - h(f, a.vertices[(n + 1) % l], a.vertices[n % l]), g.rotate90cw(i, f), g.normalize(i, i); - var o = j(i, e); - (-1 === k || o > m) && (k = n % l, m = o); - } return k; }; - var ia = g.create(), ja = g.create(), ka = g.create(), la = g.create(), ma = g.create(), na = g.create(), oa = g.create(); - d.prototype[q.CIRCLE | q.HEIGHTFIELD] = d.prototype.circleHeightfield = function (a, b, c, d, e, f, j, k, l, m) { - var n = f.heights, m = m || b.radius, o = f.elementWidth, p = ja, q = ia, r = ma, s = oa, t = na, u = ka, v = la, w = Math.floor((c[0] - m - j[0]) / o), x = Math.ceil((c[0] + m - j[0]) / o); - 0 > w && (w = 0), x >= n.length && (x = n.length - 1); - for (var y = n[w], z = n[x], A = w; x > A; A++) - n[A] < z && (z = n[A]), n[A] > y && (y = n[A]); - if (c[1] - m > y) - return l ? !1 : 0; - for (var B = !1, A = w; x > A; A++) { - g.set(u, A * o, n[A]), g.set(v, (A + 1) * o, n[A + 1]), g.add(u, u, j), g.add(v, v, j), g.sub(t, v, u), g.rotate(t, t, Math.PI / 2), g.normalize(t, t), g.scale(q, t, -m), g.add(q, q, c), g.sub(p, q, u); - var C = g.dot(p, t); - if (q[0] >= u[0] && q[0] < v[0] && 0 >= C) { - if (l) - return !0; - B = !0, g.scale(p, t, -C), g.add(r, q, p), g.copy(s, t); - var D = this.createContactEquation(e, a, f, b); - g.copy(D.normalA, s), g.scale(D.contactPointB, D.normalA, -m), i(D.contactPointB, D.contactPointB, c), h(D.contactPointB, D.contactPointB, a.position), g.copy(D.contactPointA, r), g.sub(D.contactPointA, D.contactPointA, e.position), this.contactEquations.push(D), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(D)); - } - } - if (B = !1, m > 0) - for (var A = w; x >= A; A++) - if (g.set(u, A * o, n[A]), g.add(u, u, j), g.sub(p, c, u), g.squaredLength(p) < Math.pow(m, 2)) { - if (l) - return !0; - B = !0; - var D = this.createContactEquation(e, a, f, b); - g.copy(D.normalA, p), g.normalize(D.normalA, D.normalA), g.scale(D.contactPointB, D.normalA, -m), i(D.contactPointB, D.contactPointB, c), h(D.contactPointB, D.contactPointB, a.position), h(D.contactPointA, u, j), i(D.contactPointA, D.contactPointA, j), h(D.contactPointA, D.contactPointA, e.position), this.contactEquations.push(D), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(D)); - } - return B ? 1 : 0; - }; - var pa = g.create(), qa = g.create(), ra = g.create(), sa = new p({ vertices: [g.create(), g.create(), g.create(), g.create()] }); - d.prototype[q.BOX | q.HEIGHTFIELD] = d.prototype[q.CONVEX | q.HEIGHTFIELD] = d.prototype.convexHeightfield = function (a, b, c, d, e, f, h, i, j) { var k = f.heights, l = f.elementWidth, m = pa, n = qa, o = ra, p = sa, q = Math.floor((a.aabb.lowerBound[0] - h[0]) / l), r = Math.ceil((a.aabb.upperBound[0] - h[0]) / l); 0 > q && (q = 0), r >= k.length && (r = k.length - 1); for (var s = k[q], t = k[r], u = q; r > u; u++) - k[u] < t && (t = k[u]), k[u] > s && (s = k[u]); if (a.aabb.lowerBound[1] > s) - return j ? !1 : 0; for (var v = 0, u = q; r > u; u++) { - g.set(m, u * l, k[u]), g.set(n, (u + 1) * l, k[u + 1]), g.add(m, m, h), g.add(n, n, h); - var w = 100; - g.set(o, .5 * (n[0] + m[0]), .5 * (n[1] + m[1] - w)), g.sub(p.vertices[0], n, o), g.sub(p.vertices[1], m, o), g.copy(p.vertices[2], p.vertices[1]), g.copy(p.vertices[3], p.vertices[0]), p.vertices[2][1] -= w, p.vertices[3][1] -= w, v += this.convexConvex(a, b, c, d, e, p, o, 0, j); - } return v; }; - }, { "../equations/ContactEquation": 21, "../equations/Equation": 22, "../equations/FrictionEquation": 23, "../math/vec2": 30, "../objects/Body": 31, "../shapes/Box": 37, "../shapes/Circle": 39, "../shapes/Convex": 40, "../shapes/Shape": 45, "../utils/ContactEquationPool": 48, "../utils/FrictionEquationPool": 49, "../utils/TupleDictionary": 56, "../utils/Utils": 57 }], 11: [function (a, b, c) { function d(a) { a = a || {}, this.from = a.from ? f.fromValues(a.from[0], a.from[1]) : f.create(), this.to = a.to ? f.fromValues(a.to[0], a.to[1]) : f.create(), this.checkCollisionResponse = void 0 !== a.checkCollisionResponse ? a.checkCollisionResponse : !0, this.skipBackfaces = !!a.skipBackfaces, this.collisionMask = void 0 !== a.collisionMask ? a.collisionMask : -1, this.collisionGroup = void 0 !== a.collisionGroup ? a.collisionGroup : -1, this.mode = void 0 !== a.mode ? a.mode : d.ANY, this.callback = a.callback || function (a) { }, this.direction = f.create(), this.length = 1, this.update(); } function e(a, b, c) { f.sub(h, c, a); var d = f.dot(h, b); return f.scale(i, b, d), f.add(i, i, a), f.squaredDistance(c, i); } b.exports = d; var f = a("../math/vec2"); a("../collision/RaycastResult"), a("../shapes/Shape"), a("../collision/AABB"); d.prototype.constructor = d, d.CLOSEST = 1, d.ANY = 2, d.ALL = 4, d.prototype.update = function () { var a = this.direction; f.sub(a, this.to, this.from), this.length = f.length(a), f.normalize(a, a); }, d.prototype.intersectBodies = function (a, b) { for (var c = 0, d = b.length; !a.shouldStop(this) && d > c; c++) { - var e = b[c], f = e.getAABB(); - (f.overlapsRay(this) >= 0 || f.containsPoint(this.from)) && this.intersectBody(a, e); - } }; var g = f.create(); d.prototype.intersectBody = function (a, b) { var c = this.checkCollisionResponse; if (!c || b.collisionResponse) - for (var d = g, e = 0, h = b.shapes.length; h > e; e++) { - var i = b.shapes[e]; - if ((!c || i.collisionResponse) && 0 !== (this.collisionGroup & i.collisionMask) && 0 !== (i.collisionGroup & this.collisionMask)) { - f.rotate(d, i.position, b.angle), f.add(d, d, b.position); - var j = i.angle + b.angle; - if (this.intersectShape(a, i, j, d, b), a.shouldStop(this)) - break; - } - } }, d.prototype.intersectShape = function (a, b, c, d, f) { var g = this.from, h = e(g, this.direction, d); h > b.boundingRadius * b.boundingRadius || (this._currentBody = f, this._currentShape = b, b.raycast(a, this, d, c), this._currentBody = this._currentShape = null); }, d.prototype.getAABB = function (a) { var b = this.to, c = this.from; f.set(a.lowerBound, Math.min(b[0], c[0]), Math.min(b[1], c[1])), f.set(a.upperBound, Math.max(b[0], c[0]), Math.max(b[1], c[1])); }; f.create(); d.prototype.reportIntersection = function (a, b, c, e) { var g = (this.from, this.to, this._currentShape), h = this._currentBody; if (!(this.skipBackfaces && f.dot(c, this.direction) > 0)) - switch (this.mode) { - case d.ALL: - a.set(c, g, h, b, e), this.callback(a); - break; - case d.CLOSEST: - (b < a.fraction || !a.hasHit()) && a.set(c, g, h, b, e); - break; - case d.ANY: a.set(c, g, h, b, e); - } }; var h = f.create(), i = f.create(); }, { "../collision/AABB": 7, "../collision/RaycastResult": 12, "../math/vec2": 30, "../shapes/Shape": 45 }], 12: [function (a, b, c) { function d() { this.normal = e.create(), this.shape = null, this.body = null, this.faceIndex = -1, this.fraction = -1, this.isStopped = !1; } var e = a("../math/vec2"), f = a("../collision/Ray"); b.exports = d, d.prototype.reset = function () { e.set(this.normal, 0, 0), this.shape = null, this.body = null, this.faceIndex = -1, this.fraction = -1, this.isStopped = !1; }, d.prototype.getHitDistance = function (a) { return e.distance(a.from, a.to) * this.fraction; }, d.prototype.hasHit = function () { return -1 !== this.fraction; }, d.prototype.getHitPoint = function (a, b) { e.lerp(a, b.from, b.to, this.fraction); }, d.prototype.stop = function () { this.isStopped = !0; }, d.prototype.shouldStop = function (a) { return this.isStopped || -1 !== this.fraction && a.mode === f.ANY; }, d.prototype.set = function (a, b, c, d, f) { e.copy(this.normal, a), this.shape = b, this.body = c, this.fraction = d, this.faceIndex = f; }; }, { "../collision/Ray": 11, "../math/vec2": 30 }], 13: [function (a, b, c) { function d() { f.call(this, f.SAP), this.axisList = [], this.axisIndex = 0; var a = this; this._addBodyHandler = function (b) { a.axisList.push(b.body); }, this._removeBodyHandler = function (b) { var c = a.axisList.indexOf(b.body); -1 !== c && a.axisList.splice(c, 1); }; } var e = a("../utils/Utils"), f = a("../collision/Broadphase"); b.exports = d, d.prototype = new f, d.prototype.constructor = d, d.prototype.setWorld = function (a) { this.axisList.length = 0, e.appendArray(this.axisList, a.bodies), a.off("addBody", this._addBodyHandler).off("removeBody", this._removeBodyHandler), a.on("addBody", this._addBodyHandler).on("removeBody", this._removeBodyHandler), this.world = a; }, d.sortAxisList = function (a, b) { b = 0 | b; for (var c = 1, d = a.length; d > c; c++) { - for (var e = a[c], f = c - 1; f >= 0 && !(a[f].aabb.lowerBound[b] <= e.aabb.lowerBound[b]); f--) - a[f + 1] = a[f]; - a[f + 1] = e; - } return a; }, d.prototype.sortList = function () { var a = this.axisList, b = this.axisIndex; d.sortAxisList(a, b); }, d.prototype.getCollisionPairs = function (a) { var b = this.axisList, c = this.result, d = this.axisIndex; c.length = 0; for (var e = b.length; e--;) { - var g = b[e]; - g.aabbNeedsUpdate && g.updateAABB(); - } this.sortList(); for (var h = 0, i = 0 | b.length; h !== i; h++) - for (var j = b[h], k = h + 1; i > k; k++) { - var l = b[k], m = l.aabb.lowerBound[d] <= j.aabb.upperBound[d]; - if (!m) - break; - f.canCollide(j, l) && this.boundingVolumeCheck(j, l) && c.push(j, l); - } return c; }, d.prototype.aabbQuery = function (a, b, c) { c = c || [], this.sortList(); var d = this.axisIndex, e = "x"; 1 === d && (e = "y"), 2 === d && (e = "z"); for (var f = this.axisList, g = (b.lowerBound[e], b.upperBound[e], 0); g < f.length; g++) { - var h = f[g]; - h.aabbNeedsUpdate && h.updateAABB(), h.aabb.overlaps(b) && c.push(h); - } return c; }; }, { "../collision/Broadphase": 8, "../utils/Utils": 57 }], 14: [function (a, b, c) { function d(a, b, c, d) { this.type = c, d = e.defaults(d, { collideConnected: !0, wakeUpBodies: !0 }), this.equations = [], this.bodyA = a, this.bodyB = b, this.collideConnected = d.collideConnected, d.wakeUpBodies && (a && a.wakeUp(), b && b.wakeUp()); } b.exports = d; var e = a("../utils/Utils"); d.prototype.update = function () { throw new Error("method update() not implmemented in this Constraint subclass!"); }, d.DISTANCE = 1, d.GEAR = 2, d.LOCK = 3, d.PRISMATIC = 4, d.REVOLUTE = 5, d.prototype.setStiffness = function (a) { for (var b = this.equations, c = 0; c !== b.length; c++) { - var d = b[c]; - d.stiffness = a, d.needsUpdate = !0; - } }, d.prototype.setRelaxation = function (a) { for (var b = this.equations, c = 0; c !== b.length; c++) { - var d = b[c]; - d.relaxation = a, d.needsUpdate = !0; - } }; }, { "../utils/Utils": 57 }], 15: [function (a, b, c) { function d(a, b, c) { c = h.defaults(c, { localAnchorA: [0, 0], localAnchorB: [0, 0] }), e.call(this, a, b, e.DISTANCE, c), this.localAnchorA = g.fromValues(c.localAnchorA[0], c.localAnchorA[1]), this.localAnchorB = g.fromValues(c.localAnchorB[0], c.localAnchorB[1]); var d = this.localAnchorA, i = this.localAnchorB; if (this.distance = 0, "number" == typeof c.distance) - this.distance = c.distance; - else { - var j = g.create(), k = g.create(), l = g.create(); - g.rotate(j, d, a.angle), g.rotate(k, i, b.angle), g.add(l, b.position, k), g.sub(l, l, j), g.sub(l, l, a.position), this.distance = g.length(l); - } var m; m = "undefined" == typeof c.maxForce ? Number.MAX_VALUE : c.maxForce; var n = new f(a, b, -m, m); this.equations = [n], this.maxForce = m; var l = g.create(), o = g.create(), p = g.create(), q = this; n.computeGq = function () { var a = this.bodyA, b = this.bodyB, c = a.position, e = b.position; return g.rotate(o, d, a.angle), g.rotate(p, i, b.angle), g.add(l, e, p), g.sub(l, l, o), g.sub(l, l, c), g.length(l) - q.distance; }, this.setMaxForce(m), this.upperLimitEnabled = !1, this.upperLimit = 1, this.lowerLimitEnabled = !1, this.lowerLimit = 0, this.position = 0; } var e = a("./Constraint"), f = a("../equations/Equation"), g = a("../math/vec2"), h = a("../utils/Utils"); b.exports = d, d.prototype = new e, d.prototype.constructor = d; var i = g.create(), j = g.create(), k = g.create(); d.prototype.update = function () { var a = this.equations[0], b = this.bodyA, c = this.bodyB, d = (this.distance, b.position), e = c.position, f = this.equations[0], h = a.G; g.rotate(j, this.localAnchorA, b.angle), g.rotate(k, this.localAnchorB, c.angle), g.add(i, e, k), g.sub(i, i, j), g.sub(i, i, d), this.position = g.length(i); var l = !1; if (this.upperLimitEnabled && this.position > this.upperLimit && (f.maxForce = 0, f.minForce = -this.maxForce, this.distance = this.upperLimit, l = !0), this.lowerLimitEnabled && this.position < this.lowerLimit && (f.maxForce = this.maxForce, f.minForce = 0, this.distance = this.lowerLimit, l = !0), (this.lowerLimitEnabled || this.upperLimitEnabled) && !l) - return void (f.enabled = !1); f.enabled = !0, g.normalize(i, i); var m = g.crossLength(j, i), n = g.crossLength(k, i); h[0] = -i[0], h[1] = -i[1], h[2] = -m, h[3] = i[0], h[4] = i[1], h[5] = n; }, d.prototype.setMaxForce = function (a) { var b = this.equations[0]; b.minForce = -a, b.maxForce = a; }, d.prototype.getMaxForce = function () { var a = this.equations[0]; return a.maxForce; }; }, { "../equations/Equation": 22, "../math/vec2": 30, "../utils/Utils": 57, "./Constraint": 14 }], 16: [function (a, b, c) { function d(a, b, c) { c = c || {}, e.call(this, a, b, e.GEAR, c), this.ratio = void 0 !== c.ratio ? c.ratio : 1, this.angle = void 0 !== c.angle ? c.angle : b.angle - this.ratio * a.angle, c.angle = this.angle, c.ratio = this.ratio, this.equations = [new f(a, b, c)], void 0 !== c.maxTorque && this.setMaxTorque(c.maxTorque); } var e = a("./Constraint"), f = (a("../equations/Equation"), a("../equations/AngleLockEquation")); a("../math/vec2"); b.exports = d, d.prototype = new e, d.prototype.constructor = d, d.prototype.update = function () { var a = this.equations[0]; a.ratio !== this.ratio && a.setRatio(this.ratio), a.angle = this.angle; }, d.prototype.setMaxTorque = function (a) { this.equations[0].setMaxTorque(a); }, d.prototype.getMaxTorque = function (a) { return this.equations[0].maxForce; }; }, { "../equations/AngleLockEquation": 20, "../equations/Equation": 22, "../math/vec2": 30, "./Constraint": 14 }], 17: [function (a, b, c) { function d(a, b, c) { c = c || {}, e.call(this, a, b, e.LOCK, c); var d = "undefined" == typeof c.maxForce ? Number.MAX_VALUE : c.maxForce, h = (c.localAngleB || 0, new g(a, b, -d, d)), i = new g(a, b, -d, d), j = new g(a, b, -d, d), k = f.create(), l = f.create(), m = this; h.computeGq = function () { return f.rotate(k, m.localOffsetB, a.angle), f.sub(l, b.position, a.position), f.sub(l, l, k), l[0]; }, i.computeGq = function () { return f.rotate(k, m.localOffsetB, a.angle), f.sub(l, b.position, a.position), f.sub(l, l, k), l[1]; }; var n = f.create(), o = f.create(); j.computeGq = function () { return f.rotate(n, m.localOffsetB, b.angle - m.localAngleB), f.scale(n, n, -1), f.sub(l, a.position, b.position), f.add(l, l, n), f.rotate(o, n, -Math.PI / 2), f.normalize(o, o), f.dot(l, o); }, this.localOffsetB = f.create(), c.localOffsetB ? f.copy(this.localOffsetB, c.localOffsetB) : (f.sub(this.localOffsetB, b.position, a.position), f.rotate(this.localOffsetB, this.localOffsetB, -a.angle)), this.localAngleB = 0, "number" == typeof c.localAngleB ? this.localAngleB = c.localAngleB : this.localAngleB = b.angle - a.angle, this.equations.push(h, i, j), this.setMaxForce(d); } var e = a("./Constraint"), f = a("../math/vec2"), g = a("../equations/Equation"); b.exports = d, d.prototype = new e, d.prototype.constructor = d, d.prototype.setMaxForce = function (a) { for (var b = this.equations, c = 0; c < this.equations.length; c++) - b[c].maxForce = a, b[c].minForce = -a; }, d.prototype.getMaxForce = function () { return this.equations[0].maxForce; }; var h = f.create(), i = f.create(), j = f.create(), k = f.fromValues(1, 0), l = f.fromValues(0, 1); d.prototype.update = function () { var a = this.equations[0], b = this.equations[1], c = this.equations[2], d = this.bodyA, e = this.bodyB; f.rotate(h, this.localOffsetB, d.angle), f.rotate(i, this.localOffsetB, e.angle - this.localAngleB), f.scale(i, i, -1), f.rotate(j, i, Math.PI / 2), f.normalize(j, j), a.G[0] = -1, a.G[1] = 0, a.G[2] = -f.crossLength(h, k), a.G[3] = 1, b.G[0] = 0, b.G[1] = -1, b.G[2] = -f.crossLength(h, l), b.G[4] = 1, c.G[0] = -j[0], c.G[1] = -j[1], c.G[3] = j[0], c.G[4] = j[1], c.G[5] = f.crossLength(i, j); }; }, { "../equations/Equation": 22, "../math/vec2": 30, "./Constraint": 14 }], 18: [function (a, b, c) { function d(a, b, c) { c = c || {}, e.call(this, a, b, e.PRISMATIC, c); var d = h.fromValues(0, 0), j = h.fromValues(1, 0), k = h.fromValues(0, 0); c.localAnchorA && h.copy(d, c.localAnchorA), c.localAxisA && h.copy(j, c.localAxisA), c.localAnchorB && h.copy(k, c.localAnchorB), this.localAnchorA = d, this.localAnchorB = k, this.localAxisA = j; var l = this.maxForce = "undefined" != typeof c.maxForce ? c.maxForce : Number.MAX_VALUE, m = new g(a, b, -l, l), n = new h.create, o = new h.create, p = new h.create, q = new h.create; if (m.computeGq = function () { return h.dot(p, q); }, m.updateJacobian = function () { var c = this.G, e = a.position, f = b.position; h.rotate(n, d, a.angle), h.rotate(o, k, b.angle), h.add(p, f, o), h.sub(p, p, e), h.sub(p, p, n), h.rotate(q, j, a.angle + Math.PI / 2), c[0] = -q[0], c[1] = -q[1], c[2] = -h.crossLength(n, q) + h.crossLength(q, p), c[3] = q[0], c[4] = q[1], c[5] = h.crossLength(o, q); }, this.equations.push(m), !c.disableRotationalLock) { - var r = new i(a, b, -l, l); - this.equations.push(r); - } this.position = 0, this.velocity = 0, this.lowerLimitEnabled = "undefined" != typeof c.lowerLimit ? !0 : !1, this.upperLimitEnabled = "undefined" != typeof c.upperLimit ? !0 : !1, this.lowerLimit = "undefined" != typeof c.lowerLimit ? c.lowerLimit : 0, this.upperLimit = "undefined" != typeof c.upperLimit ? c.upperLimit : 1, this.upperLimitEquation = new f(a, b), this.lowerLimitEquation = new f(a, b), this.upperLimitEquation.minForce = this.lowerLimitEquation.minForce = 0, this.upperLimitEquation.maxForce = this.lowerLimitEquation.maxForce = l, this.motorEquation = new g(a, b), this.motorEnabled = !1, this.motorSpeed = 0; var s = this, t = this.motorEquation; t.computeGW; t.computeGq = function () { return 0; }, t.computeGW = function () { var a = this.G, b = this.bodyA, c = this.bodyB, d = b.velocity, e = c.velocity, f = b.angularVelocity, g = c.angularVelocity; return this.gmult(a, d, f, e, g) + s.motorSpeed; }; } var e = a("./Constraint"), f = a("../equations/ContactEquation"), g = a("../equations/Equation"), h = a("../math/vec2"), i = a("../equations/RotationalLockEquation"); b.exports = d, d.prototype = new e, d.prototype.constructor = d; var j = h.create(), k = h.create(), l = h.create(), m = h.create(), n = h.create(), o = h.create(); d.prototype.update = function () { var a = this.equations, b = a[0], c = this.upperLimit, d = this.lowerLimit, e = this.upperLimitEquation, f = this.lowerLimitEquation, g = this.bodyA, i = this.bodyB, p = this.localAxisA, q = this.localAnchorA, r = this.localAnchorB; b.updateJacobian(), h.rotate(j, p, g.angle), h.rotate(m, q, g.angle), h.add(k, m, g.position), h.rotate(n, r, i.angle), h.add(l, n, i.position); var s = this.position = h.dot(l, j) - h.dot(k, j); if (this.motorEnabled) { - var t = this.motorEquation.G; - t[0] = j[0], t[1] = j[1], t[2] = h.crossLength(j, n), t[3] = -j[0], t[4] = -j[1], t[5] = -h.crossLength(j, m); - } if (this.upperLimitEnabled && s > c) - h.scale(e.normalA, j, -1), h.sub(e.contactPointA, k, g.position), h.sub(e.contactPointB, l, i.position), h.scale(o, j, c), h.add(e.contactPointA, e.contactPointA, o), -1 === a.indexOf(e) && a.push(e); - else { - var u = a.indexOf(e); - -1 !== u && a.splice(u, 1); - } if (this.lowerLimitEnabled && d > s) - h.scale(f.normalA, j, 1), h.sub(f.contactPointA, k, g.position), h.sub(f.contactPointB, l, i.position), h.scale(o, j, d), h.sub(f.contactPointB, f.contactPointB, o), -1 === a.indexOf(f) && a.push(f); - else { - var u = a.indexOf(f); - -1 !== u && a.splice(u, 1); - } }, d.prototype.enableMotor = function () { this.motorEnabled || (this.equations.push(this.motorEquation), this.motorEnabled = !0); }, d.prototype.disableMotor = function () { if (this.motorEnabled) { - var a = this.equations.indexOf(this.motorEquation); - this.equations.splice(a, 1), this.motorEnabled = !1; - } }, d.prototype.setLimits = function (a, b) { "number" == typeof a ? (this.lowerLimit = a, this.lowerLimitEnabled = !0) : (this.lowerLimit = a, this.lowerLimitEnabled = !1), "number" == typeof b ? (this.upperLimit = b, this.upperLimitEnabled = !0) : (this.upperLimit = b, this.upperLimitEnabled = !1); }; }, { "../equations/ContactEquation": 21, "../equations/Equation": 22, "../equations/RotationalLockEquation": 24, "../math/vec2": 30, "./Constraint": 14 }], 19: [function (a, b, c) { function d(a, b, c) { c = c || {}, e.call(this, a, b, e.REVOLUTE, c); var d = this.maxForce = "undefined" != typeof c.maxForce ? c.maxForce : Number.MAX_VALUE; this.pivotA = i.create(), this.pivotB = i.create(), c.worldPivot ? (i.sub(this.pivotA, c.worldPivot, a.position), i.sub(this.pivotB, c.worldPivot, b.position), i.rotate(this.pivotA, this.pivotA, -a.angle), i.rotate(this.pivotB, this.pivotB, -b.angle)) : (i.copy(this.pivotA, c.localPivotA), i.copy(this.pivotB, c.localPivotB)); var o = this.equations = [new f(a, b, -d, d), new f(a, b, -d, d)], p = o[0], q = o[1], r = this; p.computeGq = function () { return i.rotate(j, r.pivotA, a.angle), i.rotate(k, r.pivotB, b.angle), i.add(n, b.position, k), i.sub(n, n, a.position), i.sub(n, n, j), i.dot(n, l); }, q.computeGq = function () { return i.rotate(j, r.pivotA, a.angle), i.rotate(k, r.pivotB, b.angle), i.add(n, b.position, k), i.sub(n, n, a.position), i.sub(n, n, j), i.dot(n, m); }, q.minForce = p.minForce = -d, q.maxForce = p.maxForce = d, this.motorEquation = new g(a, b), this.motorEnabled = !1, this.angle = 0, this.lowerLimitEnabled = !1, this.upperLimitEnabled = !1, this.lowerLimit = 0, this.upperLimit = 0, this.upperLimitEquation = new h(a, b), this.lowerLimitEquation = new h(a, b), this.upperLimitEquation.minForce = 0, this.lowerLimitEquation.maxForce = 0; } var e = a("./Constraint"), f = a("../equations/Equation"), g = a("../equations/RotationalVelocityEquation"), h = a("../equations/RotationalLockEquation"), i = a("../math/vec2"); b.exports = d; var j = i.create(), k = i.create(), l = i.fromValues(1, 0), m = i.fromValues(0, 1), n = i.create(); d.prototype = new e, d.prototype.constructor = d, d.prototype.setLimits = function (a, b) { "number" == typeof a ? (this.lowerLimit = a, this.lowerLimitEnabled = !0) : (this.lowerLimit = a, this.lowerLimitEnabled = !1), "number" == typeof b ? (this.upperLimit = b, this.upperLimitEnabled = !0) : (this.upperLimit = b, this.upperLimitEnabled = !1); }, d.prototype.update = function () { var a = this.bodyA, b = this.bodyB, c = this.pivotA, d = this.pivotB, e = this.equations, f = (e[0], e[1], e[0]), g = e[1], h = this.upperLimit, n = this.lowerLimit, o = this.upperLimitEquation, p = this.lowerLimitEquation, q = this.angle = b.angle - a.angle; if (this.upperLimitEnabled && q > h) - o.angle = h, -1 === e.indexOf(o) && e.push(o); - else { - var r = e.indexOf(o); - -1 !== r && e.splice(r, 1); - } if (this.lowerLimitEnabled && n > q) - p.angle = n, -1 === e.indexOf(p) && e.push(p); - else { - var r = e.indexOf(p); - -1 !== r && e.splice(r, 1); - } i.rotate(j, c, a.angle), i.rotate(k, d, b.angle), f.G[0] = -1, f.G[1] = 0, f.G[2] = -i.crossLength(j, l), f.G[3] = 1, f.G[4] = 0, f.G[5] = i.crossLength(k, l), g.G[0] = 0, g.G[1] = -1, g.G[2] = -i.crossLength(j, m), g.G[3] = 0, g.G[4] = 1, g.G[5] = i.crossLength(k, m); }, d.prototype.enableMotor = function () { this.motorEnabled || (this.equations.push(this.motorEquation), this.motorEnabled = !0); }, d.prototype.disableMotor = function () { if (this.motorEnabled) { - var a = this.equations.indexOf(this.motorEquation); - this.equations.splice(a, 1), this.motorEnabled = !1; - } }, d.prototype.motorIsEnabled = function () { return !!this.motorEnabled; }, d.prototype.setMotorSpeed = function (a) { if (this.motorEnabled) { - var b = this.equations.indexOf(this.motorEquation); - this.equations[b].relativeVelocity = a; - } }, d.prototype.getMotorSpeed = function () { return this.motorEnabled ? this.motorEquation.relativeVelocity : !1; }; }, { "../equations/Equation": 22, "../equations/RotationalLockEquation": 24, "../equations/RotationalVelocityEquation": 25, "../math/vec2": 30, "./Constraint": 14 }], 20: [function (a, b, c) { function d(a, b, c) { c = c || {}, e.call(this, a, b, -Number.MAX_VALUE, Number.MAX_VALUE), this.angle = c.angle || 0, this.ratio = "number" == typeof c.ratio ? c.ratio : 1, this.setRatio(this.ratio); } var e = a("./Equation"); a("../math/vec2"); b.exports = d, d.prototype = new e, d.prototype.constructor = d, d.prototype.computeGq = function () { return this.ratio * this.bodyA.angle - this.bodyB.angle + this.angle; }, d.prototype.setRatio = function (a) { var b = this.G; b[2] = a, b[5] = -1, this.ratio = a; }, d.prototype.setMaxTorque = function (a) { this.maxForce = a, this.minForce = -a; }; }, { "../math/vec2": 30, "./Equation": 22 }], 21: [function (a, b, c) { function d(a, b) { e.call(this, a, b, 0, Number.MAX_VALUE), this.contactPointA = f.create(), this.penetrationVec = f.create(), this.contactPointB = f.create(), this.normalA = f.create(), this.restitution = 0, this.firstImpact = !1, this.shapeA = null, this.shapeB = null; } var e = a("./Equation"), f = a("../math/vec2"); b.exports = d, d.prototype = new e, d.prototype.constructor = d, d.prototype.computeB = function (a, b, c) { var d = this.bodyA, e = this.bodyB, g = this.contactPointA, h = this.contactPointB, i = d.position, j = e.position, k = this.penetrationVec, l = this.normalA, m = this.G, n = f.crossLength(g, l), o = f.crossLength(h, l); m[0] = -l[0], m[1] = -l[1], m[2] = -n, m[3] = l[0], m[4] = l[1], m[5] = o, f.add(k, j, h), f.sub(k, k, i), f.sub(k, k, g); var p, q; this.firstImpact && 0 !== this.restitution ? (q = 0, p = 1 / b * (1 + this.restitution) * this.computeGW()) : (q = f.dot(l, k) + this.offset, p = this.computeGW()); var r = this.computeGiMf(), s = -q * a - p * b - c * r; return s; }; }, { "../math/vec2": 30, "./Equation": 22 }], 22: [function (a, b, c) { function d(a, b, c, e) { this.minForce = "undefined" == typeof c ? -Number.MAX_VALUE : c, this.maxForce = "undefined" == typeof e ? Number.MAX_VALUE : e, this.bodyA = a, this.bodyB = b, this.stiffness = d.DEFAULT_STIFFNESS, this.relaxation = d.DEFAULT_RELAXATION, this.G = new f.ARRAY_TYPE(6); for (var g = 0; 6 > g; g++) - this.G[g] = 0; this.offset = 0, this.a = 0, this.b = 0, this.epsilon = 0, this.timeStep = 1 / 60, this.needsUpdate = !0, this.multiplier = 0, this.relativeVelocity = 0, this.enabled = !0; } b.exports = d; var e = a("../math/vec2"), f = a("../utils/Utils"); a("../objects/Body"); d.prototype.constructor = d, d.DEFAULT_STIFFNESS = 1e6, d.DEFAULT_RELAXATION = 4, d.prototype.update = function () { var a = this.stiffness, b = this.relaxation, c = this.timeStep; this.a = 4 / (c * (1 + 4 * b)), this.b = 4 * b / (1 + 4 * b), this.epsilon = 4 / (c * c * a * (1 + 4 * b)), this.needsUpdate = !1; }, d.prototype.gmult = function (a, b, c, d, e) { return a[0] * b[0] + a[1] * b[1] + a[2] * c + a[3] * d[0] + a[4] * d[1] + a[5] * e; }, d.prototype.computeB = function (a, b, c) { var d = this.computeGW(), e = this.computeGq(), f = this.computeGiMf(); return -e * a - d * b - f * c; }; var g = e.create(), h = e.create(); d.prototype.computeGq = function () { var a = this.G, b = this.bodyA, c = this.bodyB, d = (b.position, c.position, b.angle), e = c.angle; return this.gmult(a, g, d, h, e) + this.offset; }, d.prototype.computeGW = function () { var a = this.G, b = this.bodyA, c = this.bodyB, d = b.velocity, e = c.velocity, f = b.angularVelocity, g = c.angularVelocity; return this.gmult(a, d, f, e, g) + this.relativeVelocity; }, d.prototype.computeGWlambda = function () { var a = this.G, b = this.bodyA, c = this.bodyB, d = b.vlambda, e = c.vlambda, f = b.wlambda, g = c.wlambda; return this.gmult(a, d, f, e, g); }; var i = e.create(), j = e.create(); d.prototype.computeGiMf = function () { var a = this.bodyA, b = this.bodyB, c = a.force, d = a.angularForce, f = b.force, g = b.angularForce, h = a.invMassSolve, k = b.invMassSolve, l = a.invInertiaSolve, m = b.invInertiaSolve, n = this.G; return e.scale(i, c, h), e.multiply(i, a.massMultiplier, i), e.scale(j, f, k), e.multiply(j, b.massMultiplier, j), this.gmult(n, i, d * l, j, g * m); }, d.prototype.computeGiMGt = function () { var a = this.bodyA, b = this.bodyB, c = a.invMassSolve, d = b.invMassSolve, e = a.invInertiaSolve, f = b.invInertiaSolve, g = this.G; return g[0] * g[0] * c * a.massMultiplier[0] + g[1] * g[1] * c * a.massMultiplier[1] + g[2] * g[2] * e + g[3] * g[3] * d * b.massMultiplier[0] + g[4] * g[4] * d * b.massMultiplier[1] + g[5] * g[5] * f; }; var k = e.create(), l = e.create(), m = e.create(); e.create(), e.create(), e.create(); d.prototype.addToWlambda = function (a) { var b = this.bodyA, c = this.bodyB, d = k, f = l, g = m, h = b.invMassSolve, i = c.invMassSolve, j = b.invInertiaSolve, n = c.invInertiaSolve, o = this.G; f[0] = o[0], f[1] = o[1], g[0] = o[3], g[1] = o[4], e.scale(d, f, h * a), e.multiply(d, d, b.massMultiplier), e.add(b.vlambda, b.vlambda, d), b.wlambda += j * o[2] * a, e.scale(d, g, i * a), e.multiply(d, d, c.massMultiplier), e.add(c.vlambda, c.vlambda, d), c.wlambda += n * o[5] * a; }, d.prototype.computeInvC = function (a) { return 1 / (this.computeGiMGt() + a); }; }, { "../math/vec2": 30, "../objects/Body": 31, "../utils/Utils": 57 }], 23: [function (a, b, c) { function d(a, b, c) { f.call(this, a, b, -c, c), this.contactPointA = e.create(), this.contactPointB = e.create(), this.t = e.create(), this.contactEquations = [], this.shapeA = null, this.shapeB = null, this.frictionCoefficient = .3; } var e = a("../math/vec2"), f = a("./Equation"); a("../utils/Utils"); b.exports = d, d.prototype = new f, d.prototype.constructor = d, d.prototype.setSlipForce = function (a) { this.maxForce = a, this.minForce = -a; }, d.prototype.getSlipForce = function () { return this.maxForce; }, d.prototype.computeB = function (a, b, c) { var d = (this.bodyA, this.bodyB, this.contactPointA), f = this.contactPointB, g = this.t, h = this.G; h[0] = -g[0], h[1] = -g[1], h[2] = -e.crossLength(d, g), h[3] = g[0], h[4] = g[1], h[5] = e.crossLength(f, g); var i = this.computeGW(), j = this.computeGiMf(), k = -i * b - c * j; return k; }; }, { "../math/vec2": 30, "../utils/Utils": 57, "./Equation": 22 }], 24: [function (a, b, c) { function d(a, b, c) { c = c || {}, e.call(this, a, b, -Number.MAX_VALUE, Number.MAX_VALUE), this.angle = c.angle || 0; var d = this.G; d[2] = 1, d[5] = -1; } var e = a("./Equation"), f = a("../math/vec2"); b.exports = d, d.prototype = new e, d.prototype.constructor = d; var g = f.create(), h = f.create(), i = f.fromValues(1, 0), j = f.fromValues(0, 1); d.prototype.computeGq = function () { return f.rotate(g, i, this.bodyA.angle + this.angle), f.rotate(h, j, this.bodyB.angle), f.dot(g, h); }; }, { "../math/vec2": 30, "./Equation": 22 }], 25: [function (a, b, c) { function d(a, b) { e.call(this, a, b, -Number.MAX_VALUE, Number.MAX_VALUE), this.relativeVelocity = 1, this.ratio = 1; } var e = a("./Equation"); a("../math/vec2"); b.exports = d, d.prototype = new e, d.prototype.constructor = d, d.prototype.computeB = function (a, b, c) { var d = this.G; d[2] = -1, d[5] = this.ratio; var e = this.computeGiMf(), f = this.computeGW(), g = -f * b - c * e; return g; }; }, { "../math/vec2": 30, "./Equation": 22 }], 26: [function (a, b, c) { var d = function () { }; b.exports = d, d.prototype = { constructor: d, on: function (a, b, c) { b.context = c || this, void 0 === this._listeners && (this._listeners = {}); var d = this._listeners; return void 0 === d[a] && (d[a] = []), -1 === d[a].indexOf(b) && d[a].push(b), this; }, has: function (a, b) { if (void 0 === this._listeners) - return !1; var c = this._listeners; if (b) { - if (void 0 !== c[a] && -1 !== c[a].indexOf(b)) - return !0; - } - else if (void 0 !== c[a]) - return !0; return !1; }, off: function (a, b) { if (void 0 === this._listeners) - return this; var c = this._listeners, d = c[a].indexOf(b); return -1 !== d && c[a].splice(d, 1), this; }, emit: function (a) { if (void 0 === this._listeners) - return this; var b = this._listeners, c = b[a.type]; if (void 0 !== c) { - a.target = this; - for (var d = 0, e = c.length; e > d; d++) { - var f = c[d]; - f.call(f.context, a); - } - } return this; } }; }, {}], 27: [function (a, b, c) { function d(a, b, c) { if (c = c || {}, !(a instanceof e && b instanceof e)) - throw new Error("First two arguments must be Material instances."); this.id = d.idCounter++, this.materialA = a, this.materialB = b, this.friction = "undefined" != typeof c.friction ? Number(c.friction) : .3, this.restitution = "undefined" != typeof c.restitution ? Number(c.restitution) : 0, this.stiffness = "undefined" != typeof c.stiffness ? Number(c.stiffness) : f.DEFAULT_STIFFNESS, this.relaxation = "undefined" != typeof c.relaxation ? Number(c.relaxation) : f.DEFAULT_RELAXATION, this.frictionStiffness = "undefined" != typeof c.frictionStiffness ? Number(c.frictionStiffness) : f.DEFAULT_STIFFNESS, this.frictionRelaxation = "undefined" != typeof c.frictionRelaxation ? Number(c.frictionRelaxation) : f.DEFAULT_RELAXATION, this.surfaceVelocity = "undefined" != typeof c.surfaceVelocity ? Number(c.surfaceVelocity) : 0, this.contactSkinSize = .005; } var e = a("./Material"), f = a("../equations/Equation"); b.exports = d, d.idCounter = 0; }, { "../equations/Equation": 22, "./Material": 28 }], 28: [function (a, b, c) { function d(a) { this.id = a || d.idCounter++; } b.exports = d, d.idCounter = 0; }, {}], 29: [function (a, b, c) { var d = {}; d.GetArea = function (a) { if (a.length < 6) - return 0; for (var b = a.length - 2, c = 0, d = 0; b > d; d += 2) - c += (a[d + 2] - a[d]) * (a[d + 1] + a[d + 3]); return c += (a[0] - a[b]) * (a[b + 1] + a[1]), .5 * -c; }, d.Triangulate = function (a) { var b = a.length >> 1; if (3 > b) - return []; for (var c = [], e = [], f = 0; b > f; f++) - e.push(f); for (var f = 0, g = b; g > 3;) { - var h = e[(f + 0) % g], i = e[(f + 1) % g], j = e[(f + 2) % g], k = a[2 * h], l = a[2 * h + 1], m = a[2 * i], n = a[2 * i + 1], o = a[2 * j], p = a[2 * j + 1], q = !1; - if (d._convex(k, l, m, n, o, p)) { - q = !0; - for (var r = 0; g > r; r++) { - var s = e[r]; - if (s != h && s != i && s != j && d._PointInTriangle(a[2 * s], a[2 * s + 1], k, l, m, n, o, p)) { - q = !1; - break; - } - } - } - if (q) - c.push(h, i, j), e.splice((f + 1) % g, 1), g--, f = 0; - else if (f++ > 3 * g) - break; - } return c.push(e[0], e[1], e[2]), c; }, d._PointInTriangle = function (a, b, c, d, e, f, g, h) { var i = g - c, j = h - d, k = e - c, l = f - d, m = a - c, n = b - d, o = i * i + j * j, p = i * k + j * l, q = i * m + j * n, r = k * k + l * l, s = k * m + l * n, t = 1 / (o * r - p * p), u = (r * q - p * s) * t, v = (o * s - p * q) * t; return u >= 0 && v >= 0 && 1 > u + v; }, d._convex = function (a, b, c, d, e, f) { return (b - d) * (e - c) + (c - a) * (f - d) >= 0; }, b.exports = d; }, {}], 30: [function (a, b, c) { var d = b.exports = {}, e = a("../utils/Utils"); d.crossLength = function (a, b) { return a[0] * b[1] - a[1] * b[0]; }, d.crossVZ = function (a, b, c) { return d.rotate(a, b, -Math.PI / 2), d.scale(a, a, c), a; }, d.crossZV = function (a, b, c) { return d.rotate(a, c, Math.PI / 2), d.scale(a, a, b), a; }, d.rotate = function (a, b, c) { if (0 !== c) { - var d = Math.cos(c), e = Math.sin(c), f = b[0], g = b[1]; - a[0] = d * f - e * g, a[1] = e * f + d * g; - } - else - a[0] = b[0], a[1] = b[1]; }, d.rotate90cw = function (a, b) { var c = b[0], d = b[1]; a[0] = d, a[1] = -c; }, d.toLocalFrame = function (a, b, c, e) { d.copy(a, b), d.sub(a, a, c), d.rotate(a, a, -e); }, d.toGlobalFrame = function (a, b, c, e) { d.copy(a, b), d.rotate(a, a, e), d.add(a, a, c); }, d.vectorToLocalFrame = function (a, b, c) { d.rotate(a, b, -c); }, d.vectorToGlobalFrame = function (a, b, c) { d.rotate(a, b, c); }, d.centroid = function (a, b, c, e) { return d.add(a, b, c), d.add(a, a, e), d.scale(a, a, 1 / 3), a; }, d.create = function () { var a = new e.ARRAY_TYPE(2); return a[0] = 0, a[1] = 0, a; }, d.clone = function (a) { var b = new e.ARRAY_TYPE(2); return b[0] = a[0], b[1] = a[1], b; }, d.fromValues = function (a, b) { var c = new e.ARRAY_TYPE(2); return c[0] = a, c[1] = b, c; }, d.copy = function (a, b) { return a[0] = b[0], a[1] = b[1], a; }, d.set = function (a, b, c) { return a[0] = b, a[1] = c, a; }, d.add = function (a, b, c) { return a[0] = b[0] + c[0], a[1] = b[1] + c[1], a; }, d.subtract = function (a, b, c) { return a[0] = b[0] - c[0], a[1] = b[1] - c[1], a; }, d.sub = d.subtract, d.multiply = function (a, b, c) { return a[0] = b[0] * c[0], a[1] = b[1] * c[1], a; }, d.mul = d.multiply, d.divide = function (a, b, c) { return a[0] = b[0] / c[0], a[1] = b[1] / c[1], a; }, d.div = d.divide, d.scale = function (a, b, c) { return a[0] = b[0] * c, a[1] = b[1] * c, a; }, d.distance = function (a, b) { var c = b[0] - a[0], d = b[1] - a[1]; return Math.sqrt(c * c + d * d); }, d.dist = d.distance, d.squaredDistance = function (a, b) { var c = b[0] - a[0], d = b[1] - a[1]; return c * c + d * d; }, d.sqrDist = d.squaredDistance, d.length = function (a) { var b = a[0], c = a[1]; return Math.sqrt(b * b + c * c); }, d.len = d.length, d.squaredLength = function (a) { var b = a[0], c = a[1]; return b * b + c * c; }, d.sqrLen = d.squaredLength, d.negate = function (a, b) { return a[0] = -b[0], a[1] = -b[1], a; }, d.normalize = function (a, b) { var c = b[0], d = b[1], e = c * c + d * d; return e > 0 && (e = 1 / Math.sqrt(e), a[0] = b[0] * e, a[1] = b[1] * e), a; }, d.dot = function (a, b) { return a[0] * b[0] + a[1] * b[1]; }, d.str = function (a) { return "vec2(" + a[0] + ", " + a[1] + ")"; }, d.lerp = function (a, b, c, d) { var e = b[0], f = b[1]; return a[0] = e + d * (c[0] - e), a[1] = f + d * (c[1] - f), a; }, d.reflect = function (a, b, c) { var d = b[0] * c[0] + b[1] * c[1]; a[0] = b[0] - 2 * c[0] * d, a[1] = b[1] - 2 * c[1] * d; }, d.getLineSegmentsIntersection = function (a, b, c, e, f) { var g = d.getLineSegmentsIntersectionFraction(b, c, e, f); return 0 > g ? !1 : (a[0] = b[0] + g * (c[0] - b[0]), a[1] = b[1] + g * (c[1] - b[1]), !0); }, d.getLineSegmentsIntersectionFraction = function (a, b, c, d) { var e, f, g = b[0] - a[0], h = b[1] - a[1], i = d[0] - c[0], j = d[1] - c[1]; return e = (-h * (a[0] - c[0]) + g * (a[1] - c[1])) / (-i * h + g * j), f = (i * (a[1] - c[1]) - j * (a[0] - c[0])) / (-i * h + g * j), e >= 0 && 1 >= e && f >= 0 && 1 >= f ? f : -1; }; }, { "../utils/Utils": 57 }], 31: [function (a, b, c) { - function d(a) { - a = a || {}, k.call(this), this.id = a.id || ++d._idCounter, this.world = null, this.shapes = [], this.mass = a.mass || 0, this.invMass = 0, this.inertia = 0, this.invInertia = 0, this.invMassSolve = 0, this.invInertiaSolve = 0, this.fixedRotation = !!a.fixedRotation, this.fixedX = !!a.fixedX, this.fixedY = !!a.fixedY, this.massMultiplier = e.create(), this.position = e.fromValues(0, 0), a.position && e.copy(this.position, a.position), this.interpolatedPosition = e.fromValues(0, 0), this.interpolatedAngle = 0, this.previousPosition = e.fromValues(0, 0), this.previousAngle = 0, this.velocity = e.fromValues(0, 0), a.velocity && e.copy(this.velocity, a.velocity), this.vlambda = e.fromValues(0, 0), this.wlambda = 0, this.angle = a.angle || 0, this.angularVelocity = a.angularVelocity || 0, this.force = e.create(), a.force && e.copy(this.force, a.force), this.angularForce = a.angularForce || 0, this.damping = "number" == typeof a.damping ? a.damping : .1, this.angularDamping = "number" == typeof a.angularDamping ? a.angularDamping : .1, this.type = d.STATIC, "undefined" != typeof a.type ? this.type = a.type : a.mass ? this.type = d.DYNAMIC : this.type = d.STATIC, this.boundingRadius = 0, this.aabb = new j, this.aabbNeedsUpdate = !0, - this.allowSleep = void 0 !== a.allowSleep ? a.allowSleep : !0, this.wantsToSleep = !1, this.sleepState = d.AWAKE, this.sleepSpeedLimit = void 0 !== a.sleepSpeedLimit ? a.sleepSpeedLimit : .2, this.sleepTimeLimit = void 0 !== a.sleepTimeLimit ? a.sleepTimeLimit : 1, this.gravityScale = void 0 !== a.gravityScale ? a.gravityScale : 1, this.collisionResponse = void 0 !== a.collisionResponse ? a.collisionResponse : !0, this.idleTime = 0, this.timeLastSleepy = 0, this.ccdSpeedThreshold = void 0 !== a.ccdSpeedThreshold ? a.ccdSpeedThreshold : -1, this.ccdIterations = void 0 !== a.ccdIterations ? a.ccdIterations : 10, this.concavePath = null, this._wakeUpAfterNarrowphase = !1, this.updateMassProperties(); - } - var e = a("../math/vec2"), f = a("poly-decomp"), g = a("../shapes/Convex"), h = a("../collision/RaycastResult"), i = a("../collision/Ray"), j = a("../collision/AABB"), k = a("../events/EventEmitter"); - b.exports = d, d.prototype = new k, d.prototype.constructor = d, d._idCounter = 0, d.prototype.updateSolveMassProperties = function () { this.sleepState === d.SLEEPING || this.type === d.KINEMATIC ? (this.invMassSolve = 0, this.invInertiaSolve = 0) : (this.invMassSolve = this.invMass, this.invInertiaSolve = this.invInertia); }, d.prototype.setDensity = function (a) { var b = this.getArea(); this.mass = b * a, this.updateMassProperties(); }, d.prototype.getArea = function () { for (var a = 0, b = 0; b < this.shapes.length; b++) - a += this.shapes[b].area; return a; }, d.prototype.getAABB = function () { return this.aabbNeedsUpdate && this.updateAABB(), this.aabb; }; - var l = new j, m = e.create(); - d.prototype.updateAABB = function () { for (var a = this.shapes, b = a.length, c = m, d = this.angle, f = 0; f !== b; f++) { - var g = a[f], h = g.angle + d; - e.rotate(c, g.position, d), e.add(c, c, this.position), g.computeAABB(l, c, h), 0 === f ? this.aabb.copy(l) : this.aabb.extend(l); - } this.aabbNeedsUpdate = !1; }, d.prototype.updateBoundingRadius = function () { for (var a = this.shapes, b = a.length, c = 0, d = 0; d !== b; d++) { - var f = a[d], g = e.length(f.position), h = f.boundingRadius; - g + h > c && (c = g + h); - } this.boundingRadius = c; }, d.prototype.addShape = function (a, b, c) { if (a.body) - throw new Error("A shape can only be added to one body."); a.body = this, b ? e.copy(a.position, b) : e.set(a.position, 0, 0), a.angle = c || 0, this.shapes.push(a), this.updateMassProperties(), this.updateBoundingRadius(), this.aabbNeedsUpdate = !0; }, d.prototype.removeShape = function (a) { var b = this.shapes.indexOf(a); return -1 !== b ? (this.shapes.splice(b, 1), this.aabbNeedsUpdate = !0, a.body = null, !0) : !1; }, d.prototype.updateMassProperties = function () { if (this.type === d.STATIC || this.type === d.KINEMATIC) - this.mass = Number.MAX_VALUE, this.invMass = 0, this.inertia = Number.MAX_VALUE, this.invInertia = 0; - else { - var a = this.shapes, b = a.length, c = this.mass / b, f = 0; - if (this.fixedRotation) - this.inertia = Number.MAX_VALUE, this.invInertia = 0; - else { - for (var g = 0; b > g; g++) { - var h = a[g], i = e.squaredLength(h.position), j = h.computeMomentOfInertia(c); - f += j + c * i; - } - this.inertia = f, this.invInertia = f > 0 ? 1 / f : 0; - } - this.invMass = 1 / this.mass, e.set(this.massMultiplier, this.fixedX ? 0 : 1, this.fixedY ? 0 : 1); - } }; - e.create(); - d.prototype.applyForce = function (a, b) { if (e.add(this.force, this.force, a), b) { - var c = e.crossLength(b, a); - this.angularForce += c; - } }; - var n = e.create(), o = e.create(), p = e.create(); - d.prototype.applyForceLocal = function (a, b) { b = b || p; var c = n, d = o; this.vectorToWorldFrame(c, a), this.vectorToWorldFrame(d, b), this.applyForce(c, d); }; - var q = e.create(); - d.prototype.applyImpulse = function (a, b) { if (this.type === d.DYNAMIC) { - var c = q; - if (e.scale(c, a, this.invMass), e.multiply(c, this.massMultiplier, c), e.add(this.velocity, c, this.velocity), b) { - var f = e.crossLength(b, a); - f *= this.invInertia, this.angularVelocity += f; - } - } }; - var r = e.create(), s = e.create(), t = e.create(); - d.prototype.applyImpulseLocal = function (a, b) { b = b || t; var c = r, d = s; this.vectorToWorldFrame(c, a), this.vectorToWorldFrame(d, b), this.applyImpulse(c, d); }, d.prototype.toLocalFrame = function (a, b) { e.toLocalFrame(a, b, this.position, this.angle); }, d.prototype.toWorldFrame = function (a, b) { e.toGlobalFrame(a, b, this.position, this.angle); }, d.prototype.vectorToLocalFrame = function (a, b) { e.vectorToLocalFrame(a, b, this.angle); }, d.prototype.vectorToWorldFrame = function (a, b) { e.vectorToGlobalFrame(a, b, this.angle); }, d.prototype.fromPolygon = function (a, b) { b = b || {}; for (var c = this.shapes.length; c >= 0; --c) - this.removeShape(this.shapes[c]); var d = new f.Polygon; if (d.vertices = a, d.makeCCW(), "number" == typeof b.removeCollinearPoints && d.removeCollinearPoints(b.removeCollinearPoints), "undefined" == typeof b.skipSimpleCheck && !d.isSimple()) - return !1; this.concavePath = d.vertices.slice(0); for (var c = 0; c < this.concavePath.length; c++) { - var h = [0, 0]; - e.copy(h, this.concavePath[c]), this.concavePath[c] = h; - } var i; i = b.optimalDecomp ? d.decomp() : d.quickDecomp(); for (var j = e.create(), c = 0; c !== i.length; c++) { - for (var k = new g({ vertices: i[c].vertices }), l = 0; l !== k.vertices.length; l++) { - var h = k.vertices[l]; - e.sub(h, h, k.centerOfMass); - } - e.scale(j, k.centerOfMass, 1), k.updateTriangles(), k.updateCenterOfMass(), k.updateBoundingRadius(), this.addShape(k, j); - } return this.adjustCenterOfMass(), this.aabbNeedsUpdate = !0, !0; }; - var u = (e.fromValues(0, 0), e.fromValues(0, 0)), v = e.fromValues(0, 0), w = e.fromValues(0, 0); - d.prototype.adjustCenterOfMass = function () { var a = u, b = v, c = w, d = 0; e.set(b, 0, 0); for (var f = 0; f !== this.shapes.length; f++) { - var g = this.shapes[f]; - e.scale(a, g.position, g.area), e.add(b, b, a), d += g.area; - } e.scale(c, b, 1 / d); for (var f = 0; f !== this.shapes.length; f++) { - var g = this.shapes[f]; - e.sub(g.position, g.position, c); - } e.add(this.position, this.position, c); for (var f = 0; this.concavePath && f < this.concavePath.length; f++) - e.sub(this.concavePath[f], this.concavePath[f], c); this.updateMassProperties(), this.updateBoundingRadius(); }, d.prototype.setZeroForce = function () { e.set(this.force, 0, 0), this.angularForce = 0; }, d.prototype.resetConstraintVelocity = function () { var a = this, b = a.vlambda; e.set(b, 0, 0), a.wlambda = 0; }, d.prototype.addConstraintVelocity = function () { var a = this, b = a.velocity; e.add(b, b, a.vlambda), a.angularVelocity += a.wlambda; }, d.prototype.applyDamping = function (a) { if (this.type === d.DYNAMIC) { - var b = this.velocity; - e.scale(b, b, Math.pow(1 - this.damping, a)), this.angularVelocity *= Math.pow(1 - this.angularDamping, a); - } }, d.prototype.wakeUp = function () { var a = this.sleepState; this.sleepState = d.AWAKE, this.idleTime = 0, a !== d.AWAKE && this.emit(d.wakeUpEvent); }, d.prototype.sleep = function () { this.sleepState = d.SLEEPING, this.angularVelocity = 0, this.angularForce = 0, e.set(this.velocity, 0, 0), e.set(this.force, 0, 0), this.emit(d.sleepEvent); }, d.prototype.sleepTick = function (a, b, c) { if (this.allowSleep && this.type !== d.SLEEPING) { - this.wantsToSleep = !1; - var f = (this.sleepState, e.squaredLength(this.velocity) + Math.pow(this.angularVelocity, 2)), g = Math.pow(this.sleepSpeedLimit, 2); - f >= g ? (this.idleTime = 0, this.sleepState = d.AWAKE) : (this.idleTime += c, this.sleepState = d.SLEEPY), this.idleTime > this.sleepTimeLimit && (b ? this.wantsToSleep = !0 : this.sleep()); - } }, d.prototype.overlaps = function (a) { return this.world.overlapKeeper.bodiesAreOverlapping(this, a); }; - var x = e.create(), y = e.create(); - d.prototype.integrate = function (a) { var b = this.invMass, c = this.force, d = this.position, f = this.velocity; e.copy(this.previousPosition, this.position), this.previousAngle = this.angle, this.fixedRotation || (this.angularVelocity += this.angularForce * this.invInertia * a), e.scale(x, c, a * b), e.multiply(x, this.massMultiplier, x), e.add(f, x, f), this.integrateToTimeOfImpact(a) || (e.scale(y, f, a), e.add(d, d, y), this.fixedRotation || (this.angle += this.angularVelocity * a)), this.aabbNeedsUpdate = !0; }; - var z = new h, A = new i({ mode: i.ALL }), B = e.create(), C = e.create(), D = e.create(), E = e.create(); - d.prototype.integrateToTimeOfImpact = function (a) { if (this.ccdSpeedThreshold < 0 || e.squaredLength(this.velocity) < Math.pow(this.ccdSpeedThreshold, 2)) - return !1; e.normalize(B, this.velocity), e.scale(C, this.velocity, a), e.add(C, C, this.position), e.sub(D, C, this.position); var b, c = this.angularVelocity * a, d = e.length(D), f = 1, g = this; if (z.reset(), A.callback = function (a) { a.body !== g && (b = a.body, a.getHitPoint(C, A), e.sub(D, C, g.position), f = e.length(D) / d, a.stop()); }, e.copy(A.from, this.position), e.copy(A.to, C), A.update(), this.world.raycast(z, A), !b) - return !1; var h = this.angle; e.copy(E, this.position); for (var i = 0, j = 0, k = 0, l = f; l >= j && i < this.ccdIterations;) { - i++, k = (l - j) / 2, e.scale(y, D, f), e.add(this.position, E, y), this.angle = h + c * f, this.updateAABB(); - var m = this.aabb.overlaps(b.aabb) && this.world.narrowphase.bodiesOverlap(this, b); - m ? j = k : l = k; - } return f = k, e.copy(this.position, E), this.angle = h, e.scale(y, D, f), e.add(this.position, this.position, y), this.fixedRotation || (this.angle += c * f), !0; }, d.prototype.getVelocityAtPoint = function (a, b) { return e.crossVZ(a, b, this.angularVelocity), e.subtract(a, this.velocity, a), a; }, d.sleepyEvent = { type: "sleepy" }, d.sleepEvent = { type: "sleep" }, d.wakeUpEvent = { type: "wakeup" }, d.DYNAMIC = 1, d.STATIC = 2, d.KINEMATIC = 4, d.AWAKE = 0, d.SLEEPY = 1, d.SLEEPING = 2; - }, { "../collision/AABB": 7, "../collision/Ray": 11, "../collision/RaycastResult": 12, "../events/EventEmitter": 26, "../math/vec2": 30, "../shapes/Convex": 40, "poly-decomp": 5 }], 32: [function (a, b, c) { function d(a, b, c) { c = c || {}, f.call(this, a, b, c), this.localAnchorA = e.fromValues(0, 0), this.localAnchorB = e.fromValues(0, 0), c.localAnchorA && e.copy(this.localAnchorA, c.localAnchorA), c.localAnchorB && e.copy(this.localAnchorB, c.localAnchorB), c.worldAnchorA && this.setWorldAnchorA(c.worldAnchorA), c.worldAnchorB && this.setWorldAnchorB(c.worldAnchorB); var d = e.create(), g = e.create(); this.getWorldAnchorA(d), this.getWorldAnchorB(g); var h = e.distance(d, g); this.restLength = "number" == typeof c.restLength ? c.restLength : h; } var e = a("../math/vec2"), f = a("./Spring"); a("../utils/Utils"); b.exports = d, d.prototype = new f, d.prototype.constructor = d, d.prototype.setWorldAnchorA = function (a) { this.bodyA.toLocalFrame(this.localAnchorA, a); }, d.prototype.setWorldAnchorB = function (a) { this.bodyB.toLocalFrame(this.localAnchorB, a); }, d.prototype.getWorldAnchorA = function (a) { this.bodyA.toWorldFrame(a, this.localAnchorA); }, d.prototype.getWorldAnchorB = function (a) { this.bodyB.toWorldFrame(a, this.localAnchorB); }; var g = e.create(), h = e.create(), i = e.create(), j = e.create(), k = e.create(), l = e.create(), m = e.create(), n = e.create(), o = e.create(); d.prototype.applyForce = function () { var a = this.stiffness, b = this.damping, c = this.restLength, d = this.bodyA, f = this.bodyB, p = g, q = h, r = i, s = j, t = o, u = k, v = l, w = m, x = n; this.getWorldAnchorA(u), this.getWorldAnchorB(v), e.sub(w, u, d.position), e.sub(x, v, f.position), e.sub(p, v, u); var y = e.len(p); e.normalize(q, p), e.sub(r, f.velocity, d.velocity), e.crossZV(t, f.angularVelocity, x), e.add(r, r, t), e.crossZV(t, d.angularVelocity, w), e.sub(r, r, t), e.scale(s, q, -a * (y - c) - b * e.dot(r, q)), e.sub(d.force, d.force, s), e.add(f.force, f.force, s); var z = e.crossLength(w, s), A = e.crossLength(x, s); d.angularForce -= z, f.angularForce += A; }; }, { "../math/vec2": 30, "../utils/Utils": 57, "./Spring": 34 }], 33: [function (a, b, c) { function d(a, b, c) { c = c || {}, e.call(this, a, b, c), this.restAngle = "number" == typeof c.restAngle ? c.restAngle : b.angle - a.angle; } var e = (a("../math/vec2"), a("./Spring")); b.exports = d, d.prototype = new e, d.prototype.constructor = d, d.prototype.applyForce = function () { var a = this.stiffness, b = this.damping, c = this.restAngle, d = this.bodyA, e = this.bodyB, f = e.angle - d.angle, g = e.angularVelocity - d.angularVelocity, h = -a * (f - c) - b * g * 0; d.angularForce -= h, e.angularForce += h; }; }, { "../math/vec2": 30, "./Spring": 34 }], 34: [function (a, b, c) { function d(a, b, c) { c = e.defaults(c, { stiffness: 100, damping: 1 }), this.stiffness = c.stiffness, this.damping = c.damping, this.bodyA = a, this.bodyB = b; } var e = (a("../math/vec2"), a("../utils/Utils")); b.exports = d, d.prototype.applyForce = function () { }; }, { "../math/vec2": 30, "../utils/Utils": 57 }], 35: [function (a, b, c) { function d(a, b) { b = b || {}, this.chassisBody = a, this.wheels = [], this.groundBody = new i({ mass: 0 }), this.world = null; var c = this; this.preStepCallback = function () { c.update(); }; } function e(a, b) { b = b || {}, this.vehicle = a, this.forwardEquation = new h(a.chassisBody, a.groundBody), this.sideEquation = new h(a.chassisBody, a.groundBody), this.steerValue = 0, this.engineForce = 0, this.setSideFriction(void 0 !== b.sideFriction ? b.sideFriction : 5), this.localForwardVector = f.fromValues(0, 1), b.localForwardVector && f.copy(this.localForwardVector, b.localForwardVector), this.localPosition = f.fromValues(0, 0), b.localPosition && f.copy(this.localPosition, b.localPosition), g.apply(this, a.chassisBody, a.groundBody), this.equations.push(this.forwardEquation, this.sideEquation), this.setBrakeForce(0); } var f = a("../math/vec2"), g = (a("../utils/Utils"), a("../constraints/Constraint")), h = a("../equations/FrictionEquation"), i = a("../objects/Body"); b.exports = d, d.prototype.addToWorld = function (a) { this.world = a, a.addBody(this.groundBody), a.on("preStep", this.preStepCallback); for (var b = 0; b < this.wheels.length; b++) { - var c = this.wheels[b]; - a.addConstraint(c); - } }, d.prototype.removeFromWorld = function () { var a = this.world; a.removeBody(this.groundBody), a.off("preStep", this.preStepCallback); for (var b = 0; b < this.wheels.length; b++) { - var c = this.wheels[b]; - a.removeConstraint(c); - } this.world = null; }, d.prototype.addWheel = function (a) { var b = new e(this, a); return this.wheels.push(b), b; }, d.prototype.update = function () { for (var a = 0; a < this.wheels.length; a++) - this.wheels[a].update(); }, e.prototype = new g, e.prototype.setBrakeForce = function (a) { this.forwardEquation.setSlipForce(a); }, e.prototype.setSideFriction = function (a) { this.sideEquation.setSlipForce(a); }; var j = f.create(), k = f.create(); e.prototype.getSpeed = function () { return this.vehicle.chassisBody.vectorToWorldFrame(k, this.localForwardVector), this.vehicle.chassisBody.getVelocityAtPoint(j, k), f.dot(j, k); }; var l = f.create(); e.prototype.update = function () { this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.t, this.localForwardVector), f.rotate(this.sideEquation.t, this.localForwardVector, Math.PI / 2), this.vehicle.chassisBody.vectorToWorldFrame(this.sideEquation.t, this.sideEquation.t), f.rotate(this.forwardEquation.t, this.forwardEquation.t, this.steerValue), f.rotate(this.sideEquation.t, this.sideEquation.t, this.steerValue), this.vehicle.chassisBody.toWorldFrame(this.forwardEquation.contactPointB, this.localPosition), f.copy(this.sideEquation.contactPointB, this.forwardEquation.contactPointB), this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.contactPointA, this.localPosition), f.copy(this.sideEquation.contactPointA, this.forwardEquation.contactPointA), f.normalize(l, this.forwardEquation.t), f.scale(l, l, this.engineForce), this.vehicle.chassisBody.applyForce(l, this.forwardEquation.contactPointA); }; }, { "../constraints/Constraint": 14, "../equations/FrictionEquation": 23, "../math/vec2": 30, "../objects/Body": 31, "../utils/Utils": 57 }], 36: [function (a, b, c) { var d = b.exports = { AABB: a("./collision/AABB"), AngleLockEquation: a("./equations/AngleLockEquation"), Body: a("./objects/Body"), Broadphase: a("./collision/Broadphase"), Capsule: a("./shapes/Capsule"), Circle: a("./shapes/Circle"), Constraint: a("./constraints/Constraint"), ContactEquation: a("./equations/ContactEquation"), ContactEquationPool: a("./utils/ContactEquationPool"), ContactMaterial: a("./material/ContactMaterial"), Convex: a("./shapes/Convex"), DistanceConstraint: a("./constraints/DistanceConstraint"), Equation: a("./equations/Equation"), EventEmitter: a("./events/EventEmitter"), FrictionEquation: a("./equations/FrictionEquation"), FrictionEquationPool: a("./utils/FrictionEquationPool"), GearConstraint: a("./constraints/GearConstraint"), GSSolver: a("./solver/GSSolver"), Heightfield: a("./shapes/Heightfield"), Line: a("./shapes/Line"), LockConstraint: a("./constraints/LockConstraint"), Material: a("./material/Material"), Narrowphase: a("./collision/Narrowphase"), NaiveBroadphase: a("./collision/NaiveBroadphase"), Particle: a("./shapes/Particle"), Plane: a("./shapes/Plane"), Pool: a("./utils/Pool"), RevoluteConstraint: a("./constraints/RevoluteConstraint"), PrismaticConstraint: a("./constraints/PrismaticConstraint"), Ray: a("./collision/Ray"), RaycastResult: a("./collision/RaycastResult"), Box: a("./shapes/Box"), RotationalVelocityEquation: a("./equations/RotationalVelocityEquation"), SAPBroadphase: a("./collision/SAPBroadphase"), Shape: a("./shapes/Shape"), Solver: a("./solver/Solver"), Spring: a("./objects/Spring"), TopDownVehicle: a("./objects/TopDownVehicle"), LinearSpring: a("./objects/LinearSpring"), RotationalSpring: a("./objects/RotationalSpring"), Utils: a("./utils/Utils"), World: a("./world/World"), vec2: a("./math/vec2"), version: a("../package.json").version }; Object.defineProperty(d, "Rectangle", { get: function () { return console.warn("The Rectangle class has been renamed to Box."), this.Box; } }); }, { "../package.json": 6, "./collision/AABB": 7, "./collision/Broadphase": 8, "./collision/NaiveBroadphase": 9, "./collision/Narrowphase": 10, "./collision/Ray": 11, "./collision/RaycastResult": 12, "./collision/SAPBroadphase": 13, "./constraints/Constraint": 14, "./constraints/DistanceConstraint": 15, "./constraints/GearConstraint": 16, "./constraints/LockConstraint": 17, "./constraints/PrismaticConstraint": 18, "./constraints/RevoluteConstraint": 19, "./equations/AngleLockEquation": 20, "./equations/ContactEquation": 21, "./equations/Equation": 22, "./equations/FrictionEquation": 23, "./equations/RotationalVelocityEquation": 25, "./events/EventEmitter": 26, "./material/ContactMaterial": 27, "./material/Material": 28, "./math/vec2": 30, "./objects/Body": 31, "./objects/LinearSpring": 32, "./objects/RotationalSpring": 33, "./objects/Spring": 34, "./objects/TopDownVehicle": 35, "./shapes/Box": 37, "./shapes/Capsule": 38, "./shapes/Circle": 39, "./shapes/Convex": 40, "./shapes/Heightfield": 41, "./shapes/Line": 42, "./shapes/Particle": 43, "./shapes/Plane": 44, "./shapes/Shape": 45, "./solver/GSSolver": 46, "./solver/Solver": 47, "./utils/ContactEquationPool": 48, "./utils/FrictionEquationPool": 49, "./utils/Pool": 55, "./utils/Utils": 57, "./world/World": 61 }], 37: [function (a, b, c) { function d(a) { "number" == typeof arguments[0] && "number" == typeof arguments[1] && (a = { width: arguments[0], height: arguments[1] }, console.warn("The Rectangle has been renamed to Box and its constructor signature has changed. Please use the following format: new Box({ width: 1, height: 1, ... })")), a = a || {}; var b = this.width = a.width || 1, c = this.height = a.height || 1, d = [e.fromValues(-b / 2, -c / 2), e.fromValues(b / 2, -c / 2), e.fromValues(b / 2, c / 2), e.fromValues(-b / 2, c / 2)], h = [e.fromValues(1, 0), e.fromValues(0, 1)]; a.vertices = d, a.axes = h, a.type = f.BOX, g.call(this, a); } var e = a("../math/vec2"), f = a("./Shape"), g = a("./Convex"); b.exports = d, d.prototype = new g, d.prototype.constructor = d, d.prototype.computeMomentOfInertia = function (a) { var b = this.width, c = this.height; return a * (c * c + b * b) / 12; }, d.prototype.updateBoundingRadius = function () { var a = this.width, b = this.height; this.boundingRadius = Math.sqrt(a * a + b * b) / 2; }; e.create(), e.create(), e.create(), e.create(); d.prototype.computeAABB = function (a, b, c) { a.setFromPoints(this.vertices, b, c, 0); }, d.prototype.updateArea = function () { this.area = this.width * this.height; }; }, { "../math/vec2": 30, "./Convex": 40, "./Shape": 45 }], 38: [function (a, b, c) { function d(a) { "number" == typeof arguments[0] && "number" == typeof arguments[1] && (a = { length: arguments[0], radius: arguments[1] }, console.warn("The Capsule constructor signature has changed. Please use the following format: new Capsule({ radius: 1, length: 1 })")), a = a || {}, this.length = a.length || 1, this.radius = a.radius || 1, a.type = e.CAPSULE, e.call(this, a); } var e = a("./Shape"), f = a("../math/vec2"); b.exports = d, d.prototype = new e, d.prototype.constructor = d, d.prototype.computeMomentOfInertia = function (a) { var b = this.radius, c = this.length + b, d = 2 * b; return a * (d * d + c * c) / 12; }, d.prototype.updateBoundingRadius = function () { this.boundingRadius = this.radius + this.length / 2; }, d.prototype.updateArea = function () { this.area = Math.PI * this.radius * this.radius + 2 * this.radius * this.length; }; var g = f.create(); d.prototype.computeAABB = function (a, b, c) { var d = this.radius; f.set(g, this.length / 2, 0), 0 !== c && f.rotate(g, g, c), f.set(a.upperBound, Math.max(g[0] + d, -g[0] + d), Math.max(g[1] + d, -g[1] + d)), f.set(a.lowerBound, Math.min(g[0] - d, -g[0] - d), Math.min(g[1] - d, -g[1] - d)), f.add(a.lowerBound, a.lowerBound, b), f.add(a.upperBound, a.upperBound, b); }; var h = f.create(), i = f.create(), j = f.create(), k = f.create(), l = f.fromValues(0, 1); d.prototype.raycast = function (a, b, c, d) { for (var e = b.from, g = b.to, m = (b.direction, h), n = i, o = j, p = k, q = this.length / 2, r = 0; 2 > r; r++) { - var s = this.radius * (2 * r - 1); - f.set(o, -q, s), f.set(p, q, s), f.toGlobalFrame(o, o, c, d), f.toGlobalFrame(p, p, c, d); - var t = f.getLineSegmentsIntersectionFraction(e, g, o, p); - if (t >= 0 && (f.rotate(n, l, d), f.scale(n, n, 2 * r - 1), b.reportIntersection(a, t, n, -1), a.shouldStop(b))) - return; - } for (var u = Math.pow(this.radius, 2) + Math.pow(q, 2), r = 0; 2 > r; r++) { - f.set(o, q * (2 * r - 1), 0), f.toGlobalFrame(o, o, c, d); - var v = Math.pow(g[0] - e[0], 2) + Math.pow(g[1] - e[1], 2), w = 2 * ((g[0] - e[0]) * (e[0] - o[0]) + (g[1] - e[1]) * (e[1] - o[1])), x = Math.pow(e[0] - o[0], 2) + Math.pow(e[1] - o[1], 2) - Math.pow(this.radius, 2), t = Math.pow(w, 2) - 4 * v * x; - if (!(0 > t)) - if (0 === t) { - if (f.lerp(m, e, g, t), f.squaredDistance(m, c) > u && (f.sub(n, m, o), f.normalize(n, n), b.reportIntersection(a, t, n, -1), a.shouldStop(b))) - return; - } - else { - var y = Math.sqrt(t), z = 1 / (2 * v), A = (-w - y) * z, B = (-w + y) * z; - if (A >= 0 && 1 >= A && (f.lerp(m, e, g, A), f.squaredDistance(m, c) > u && (f.sub(n, m, o), f.normalize(n, n), b.reportIntersection(a, A, n, -1), a.shouldStop(b)))) - return; - if (B >= 0 && 1 >= B && (f.lerp(m, e, g, B), f.squaredDistance(m, c) > u && (f.sub(n, m, o), f.normalize(n, n), b.reportIntersection(a, B, n, -1), a.shouldStop(b)))) - return; - } - } }; }, { "../math/vec2": 30, "./Shape": 45 }], 39: [function (a, b, c) { function d(a) { "number" == typeof arguments[0] && (a = { radius: arguments[0] }, console.warn("The Circle constructor signature has changed. Please use the following format: new Circle({ radius: 1 })")), a = a || {}, this.radius = a.radius || 1, a.type = e.CIRCLE, e.call(this, a); } var e = a("./Shape"), f = a("../math/vec2"); b.exports = d, d.prototype = new e, d.prototype.constructor = d, d.prototype.computeMomentOfInertia = function (a) { var b = this.radius; return a * b * b / 2; }, d.prototype.updateBoundingRadius = function () { this.boundingRadius = this.radius; }, d.prototype.updateArea = function () { this.area = Math.PI * this.radius * this.radius; }, d.prototype.computeAABB = function (a, b, c) { var d = this.radius; f.set(a.upperBound, d, d), f.set(a.lowerBound, -d, -d), b && (f.add(a.lowerBound, a.lowerBound, b), f.add(a.upperBound, a.upperBound, b)); }; var g = f.create(), h = f.create(); d.prototype.raycast = function (a, b, c, d) { var e = b.from, i = b.to, j = this.radius, k = Math.pow(i[0] - e[0], 2) + Math.pow(i[1] - e[1], 2), l = 2 * ((i[0] - e[0]) * (e[0] - c[0]) + (i[1] - e[1]) * (e[1] - c[1])), m = Math.pow(e[0] - c[0], 2) + Math.pow(e[1] - c[1], 2) - Math.pow(j, 2), n = Math.pow(l, 2) - 4 * k * m, o = g, p = h; if (!(0 > n)) - if (0 === n) - f.lerp(o, e, i, n), f.sub(p, o, c), f.normalize(p, p), b.reportIntersection(a, n, p, -1); - else { - var q = Math.sqrt(n), r = 1 / (2 * k), s = (-l - q) * r, t = (-l + q) * r; - if (s >= 0 && 1 >= s && (f.lerp(o, e, i, s), f.sub(p, o, c), f.normalize(p, p), b.reportIntersection(a, s, p, -1), a.shouldStop(b))) - return; - t >= 0 && 1 >= t && (f.lerp(o, e, i, t), f.sub(p, o, c), f.normalize(p, p), b.reportIntersection(a, t, p, -1)); - } }; }, { "../math/vec2": 30, "./Shape": 45 }], 40: [function (a, b, c) { function d(a) { Array.isArray(arguments[0]) && (a = { vertices: arguments[0], axes: arguments[1] }, console.warn("The Convex constructor signature has changed. Please use the following format: new Convex({ vertices: [...], ... })")), a = a || {}, this.vertices = []; for (var b = void 0 !== a.vertices ? a.vertices : [], c = 0; c < b.length; c++) { - var d = f.create(); - f.copy(d, b[c]), this.vertices.push(d); - } if (this.axes = [], a.axes) - for (var c = 0; c < a.axes.length; c++) { - var g = f.create(); - f.copy(g, a.axes[c]), this.axes.push(g); - } - else - for (var c = 0; c < this.vertices.length; c++) { - var h = this.vertices[c], i = this.vertices[(c + 1) % this.vertices.length], j = f.create(); - f.sub(j, i, h), f.rotate90cw(j, j), f.normalize(j, j), this.axes.push(j); - } if (this.centerOfMass = f.fromValues(0, 0), this.triangles = [], this.vertices.length && (this.updateTriangles(), this.updateCenterOfMass()), this.boundingRadius = 0, a.type = e.CONVEX, e.call(this, a), this.updateBoundingRadius(), this.updateArea(), this.area < 0) - throw new Error("Convex vertices must be given in conter-clockwise winding."); } var e = a("./Shape"), f = a("../math/vec2"), g = a("../math/polyk"); a("poly-decomp"); b.exports = d, d.prototype = new e, d.prototype.constructor = d; var h = f.create(), i = f.create(); d.prototype.projectOntoLocalAxis = function (a, b) { for (var c, d, e = null, g = null, a = h, i = 0; i < this.vertices.length; i++) - c = this.vertices[i], d = f.dot(c, a), (null === e || d > e) && (e = d), (null === g || g > d) && (g = d); if (g > e) { - var j = g; - g = e, e = j; - } f.set(b, g, e); }, d.prototype.projectOntoWorldAxis = function (a, b, c, d) { var e = i; this.projectOntoLocalAxis(a, d), 0 !== c ? f.rotate(e, a, c) : e = a; var g = f.dot(b, e); f.set(d, d[0] + g, d[1] + g); }, d.prototype.updateTriangles = function () { this.triangles.length = 0; for (var a = [], b = 0; b < this.vertices.length; b++) { - var c = this.vertices[b]; - a.push(c[0], c[1]); - } for (var d = g.Triangulate(a), b = 0; b < d.length; b += 3) { - var e = d[b], f = d[b + 1], h = d[b + 2]; - this.triangles.push([e, f, h]); - } }; var j = f.create(), k = f.create(), l = f.create(), m = f.create(), n = f.create(); f.create(), f.create(), f.create(), f.create(); d.prototype.updateCenterOfMass = function () { var a = this.triangles, b = this.vertices, c = this.centerOfMass, e = j, g = l, h = m, i = n, o = k; f.set(c, 0, 0); for (var p = 0, q = 0; q !== a.length; q++) { - var r = a[q], g = b[r[0]], h = b[r[1]], i = b[r[2]]; - f.centroid(e, g, h, i); - var s = d.triangleArea(g, h, i); - p += s, f.scale(o, e, s), f.add(c, c, o); - } f.scale(c, c, 1 / p); }, d.prototype.computeMomentOfInertia = function (a) { for (var b = 0, c = 0, d = this.vertices.length, e = d - 1, g = 0; d > g; e = g, g++) { - var h = this.vertices[e], i = this.vertices[g], j = Math.abs(f.crossLength(h, i)), k = f.dot(i, i) + f.dot(i, h) + f.dot(h, h); - b += j * k, c += j; - } return a / 6 * (b / c); }, d.prototype.updateBoundingRadius = function () { for (var a = this.vertices, b = 0, c = 0; c !== a.length; c++) { - var d = f.squaredLength(a[c]); - d > b && (b = d); - } this.boundingRadius = Math.sqrt(b); }, d.triangleArea = function (a, b, c) { return .5 * ((b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1])); }, d.prototype.updateArea = function () { this.updateTriangles(), this.area = 0; for (var a = this.triangles, b = this.vertices, c = 0; c !== a.length; c++) { - var e = a[c], f = b[e[0]], g = b[e[1]], h = b[e[2]], i = d.triangleArea(f, g, h); - this.area += i; - } }, d.prototype.computeAABB = function (a, b, c) { a.setFromPoints(this.vertices, b, c, 0); }; var o = f.create(), p = f.create(), q = f.create(); d.prototype.raycast = function (a, b, c, d) { var e = o, g = p, h = q, i = this.vertices; f.toLocalFrame(e, b.from, c, d), f.toLocalFrame(g, b.to, c, d); for (var j = i.length, k = 0; j > k && !a.shouldStop(b); k++) { - var l = i[k], m = i[(k + 1) % j], n = f.getLineSegmentsIntersectionFraction(e, g, l, m); - n >= 0 && (f.sub(h, m, l), f.rotate(h, h, -Math.PI / 2 + d), f.normalize(h, h), b.reportIntersection(a, n, h, k)); - } }; }, { "../math/polyk": 29, "../math/vec2": 30, "./Shape": 45, "poly-decomp": 5 }], 41: [function (a, b, c) { function d(a) { if (Array.isArray(arguments[0])) { - if (a = { heights: arguments[0] }, "object" == typeof arguments[1]) - for (var b in arguments[1]) - a[b] = arguments[1][b]; - console.warn("The Heightfield constructor signature has changed. Please use the following format: new Heightfield({ heights: [...], ... })"); - } a = a || {}, this.heights = a.heights ? a.heights.slice(0) : [], this.maxValue = a.maxValue || null, this.minValue = a.minValue || null, this.elementWidth = a.elementWidth || .1, (void 0 === a.maxValue || void 0 === a.minValue) && this.updateMaxMinValues(), a.type = e.HEIGHTFIELD, e.call(this, a); } var e = a("./Shape"), f = a("../math/vec2"); a("../utils/Utils"); b.exports = d, d.prototype = new e, d.prototype.constructor = d, d.prototype.updateMaxMinValues = function () { for (var a = this.heights, b = a[0], c = a[0], d = 0; d !== a.length; d++) { - var e = a[d]; - e > b && (b = e), c > e && (c = e); - } this.maxValue = b, this.minValue = c; }, d.prototype.computeMomentOfInertia = function (a) { return Number.MAX_VALUE; }, d.prototype.updateBoundingRadius = function () { this.boundingRadius = Number.MAX_VALUE; }, d.prototype.updateArea = function () { for (var a = this.heights, b = 0, c = 0; c < a.length - 1; c++) - b += (a[c] + a[c + 1]) / 2 * this.elementWidth; this.area = b; }; var g = [f.create(), f.create(), f.create(), f.create()]; d.prototype.computeAABB = function (a, b, c) { f.set(g[0], 0, this.maxValue), f.set(g[1], this.elementWidth * this.heights.length, this.maxValue), f.set(g[2], this.elementWidth * this.heights.length, this.minValue), f.set(g[3], 0, this.minValue), a.setFromPoints(g, b, c); }, d.prototype.getLineSegment = function (a, b, c) { var d = this.heights, e = this.elementWidth; f.set(a, c * e, d[c]), f.set(b, (c + 1) * e, d[c + 1]); }, d.prototype.getSegmentIndex = function (a) { return Math.floor(a[0] / this.elementWidth); }, d.prototype.getClampedSegmentIndex = function (a) { var b = this.getSegmentIndex(a); return b = Math.min(this.heights.length, Math.max(b, 0)); }; var h = (f.create(), f.create()), i = f.create(), j = f.create(), k = f.create(), l = f.create(); f.fromValues(0, 1); d.prototype.raycast = function (a, b, c, d) { var e = b.from, g = b.to, m = (b.direction, h), n = i, o = j, p = k, q = l; f.toLocalFrame(p, e, c, d), f.toLocalFrame(q, g, c, d); var r = this.getClampedSegmentIndex(p), s = this.getClampedSegmentIndex(q); if (r > s) { - var t = r; - r = s, s = t; - } for (var u = 0; u < this.heights.length - 1; u++) { - this.getLineSegment(n, o, u); - var v = f.getLineSegmentsIntersectionFraction(p, q, n, o); - if (v >= 0 && (f.sub(m, o, n), f.rotate(m, m, d + Math.PI / 2), f.normalize(m, m), b.reportIntersection(a, v, m, -1), a.shouldStop(b))) - return; - } }; }, { "../math/vec2": 30, "../utils/Utils": 57, "./Shape": 45 }], 42: [function (a, b, c) { function d(a) { "number" == typeof arguments[0] && (a = { length: arguments[0] }, console.warn("The Line constructor signature has changed. Please use the following format: new Line({ length: 1, ... })")), a = a || {}, this.length = a.length || 1, a.type = e.LINE, e.call(this, a); } var e = a("./Shape"), f = a("../math/vec2"); b.exports = d, d.prototype = new e, d.prototype.constructor = d, d.prototype.computeMomentOfInertia = function (a) { return a * Math.pow(this.length, 2) / 12; }, d.prototype.updateBoundingRadius = function () { this.boundingRadius = this.length / 2; }; var g = [f.create(), f.create()]; d.prototype.computeAABB = function (a, b, c) { var d = this.length / 2; f.set(g[0], -d, 0), f.set(g[1], d, 0), a.setFromPoints(g, b, c, 0); }; var h = (f.create(), f.create()), i = f.create(), j = f.create(), k = f.fromValues(0, 1); d.prototype.raycast = function (a, b, c, d) { var e = b.from, g = b.to, l = i, m = j, n = this.length / 2; f.set(l, -n, 0), f.set(m, n, 0), f.toGlobalFrame(l, l, c, d), f.toGlobalFrame(m, m, c, d); var o = f.getLineSegmentsIntersectionFraction(l, m, e, g); if (o >= 0) { - var p = h; - f.rotate(p, k, d), b.reportIntersection(a, o, p, -1); - } }; }, { "../math/vec2": 30, "./Shape": 45 }], 43: [function (a, b, c) { function d(a) { a = a || {}, a.type = e.PARTICLE, e.call(this, a); } var e = a("./Shape"), f = a("../math/vec2"); b.exports = d, d.prototype = new e, d.prototype.constructor = d, d.prototype.computeMomentOfInertia = function (a) { return 0; }, d.prototype.updateBoundingRadius = function () { this.boundingRadius = 0; }, d.prototype.computeAABB = function (a, b, c) { f.copy(a.lowerBound, b), f.copy(a.upperBound, b); }; }, { "../math/vec2": 30, "./Shape": 45 }], 44: [function (a, b, c) { function d(a) { a = a || {}, a.type = e.PLANE, e.call(this, a); } var e = a("./Shape"), f = a("../math/vec2"); a("../utils/Utils"); b.exports = d, d.prototype = new e, d.prototype.constructor = d, d.prototype.computeMomentOfInertia = function (a) { return 0; }, d.prototype.updateBoundingRadius = function () { this.boundingRadius = Number.MAX_VALUE; }, d.prototype.computeAABB = function (a, b, c) { var d = c % (2 * Math.PI), e = f.set, g = Number.MAX_VALUE, h = a.lowerBound, i = a.upperBound; 0 === d ? (e(h, -g, -g), e(i, g, 0)) : d === Math.PI / 2 ? (e(h, 0, -g), e(i, g, g)) : d === Math.PI ? (e(h, -g, 0), e(i, g, g)) : d === 3 * Math.PI / 2 ? (e(h, -g, -g), e(i, 0, g)) : (e(h, -g, -g), e(i, g, g)), f.add(h, h, b), f.add(i, i, b); }, d.prototype.updateArea = function () { this.area = Number.MAX_VALUE; }; var g = f.create(), h = (f.create(), f.create(), f.create()), i = f.create(); d.prototype.raycast = function (a, b, c, d) { var e = b.from, j = b.to, k = b.direction, l = g, m = h, n = i; f.set(m, 0, 1), f.rotate(m, m, d), f.sub(n, e, c); var o = f.dot(n, m); f.sub(n, j, c); var p = f.dot(n, m); if (!(o * p > 0 || f.squaredDistance(e, j) < o * o)) { - var q = f.dot(m, k); - f.sub(l, e, c); - var r = -f.dot(m, l) / q / b.length; - b.reportIntersection(a, r, m, -1); - } }; }, { "../math/vec2": 30, "../utils/Utils": 57, "./Shape": 45 }], 45: [function (a, b, c) { function d(a) { a = a || {}, this.body = null, this.position = e.fromValues(0, 0), a.position && e.copy(this.position, a.position), this.angle = a.angle || 0, this.type = a.type || 0, this.id = d.idCounter++, this.boundingRadius = 0, this.collisionGroup = void 0 !== a.collisionGroup ? a.collisionGroup : 1, this.collisionResponse = void 0 !== a.collisionResponse ? a.collisionResponse : !0, this.collisionMask = void 0 !== a.collisionMask ? a.collisionMask : 1, this.material = a.material || null, this.area = 0, this.sensor = void 0 !== a.sensor ? a.sensor : !1, this.type && this.updateBoundingRadius(), this.updateArea(); } b.exports = d; var e = a("../math/vec2"); d.idCounter = 0, d.CIRCLE = 1, d.PARTICLE = 2, d.PLANE = 4, d.CONVEX = 8, d.LINE = 16, d.BOX = 32, Object.defineProperty(d, "RECTANGLE", { get: function () { return console.warn("Shape.RECTANGLE is deprecated, use Shape.BOX instead."), d.BOX; } }), d.CAPSULE = 64, d.HEIGHTFIELD = 128, d.prototype.computeMomentOfInertia = function (a) { }, d.prototype.updateBoundingRadius = function () { }, d.prototype.updateArea = function () { }, d.prototype.computeAABB = function (a, b, c) { }, d.prototype.raycast = function (a, b, c, d) { }; }, { "../math/vec2": 30 }], 46: [function (a, b, c) { - function d(a) { - g.call(this, a, g.GS), a = a || {}, this.iterations = a.iterations || 10, this.tolerance = a.tolerance || 1e-7, this.arrayStep = 30, this.lambda = new h.ARRAY_TYPE(this.arrayStep), this.Bs = new h.ARRAY_TYPE(this.arrayStep), this.invCs = new h.ARRAY_TYPE(this.arrayStep), this.useZeroRHS = !1, this.frictionIterations = 0, this.usedIterations = 0; - } - function e(a) { for (var b = a.length; b--;) - a[b] = 0; } - var f = a("../math/vec2"), g = a("./Solver"), h = a("../utils/Utils"), i = a("../equations/FrictionEquation"); - b.exports = d, d.prototype = new g, d.prototype.constructor = d, d.prototype.solve = function (a, b) { this.sortEquations(); var c = 0, g = this.iterations, j = this.frictionIterations, k = this.equations, l = k.length, m = Math.pow(this.tolerance * l, 2), n = b.bodies, o = b.bodies.length, p = (f.add, f.set, this.useZeroRHS), q = this.lambda; if (this.usedIterations = 0, l) - for (var r = 0; r !== o; r++) { - var s = n[r]; - s.updateSolveMassProperties(); - } q.length < l && (q = this.lambda = new h.ARRAY_TYPE(l + this.arrayStep), this.Bs = new h.ARRAY_TYPE(l + this.arrayStep), this.invCs = new h.ARRAY_TYPE(l + this.arrayStep)), e(q); for (var t = this.invCs, u = this.Bs, q = this.lambda, r = 0; r !== k.length; r++) { - var v = k[r]; - (v.timeStep !== a || v.needsUpdate) && (v.timeStep = a, v.update()), u[r] = v.computeB(v.a, v.b, a), t[r] = v.computeInvC(v.epsilon); - } var v, w, r, x; if (0 !== l) { - for (r = 0; r !== o; r++) { - var s = n[r]; - s.resetConstraintVelocity(); - } - if (j) { - for (c = 0; c !== j; c++) { - for (w = 0, x = 0; x !== l; x++) { - v = k[x]; - var y = d.iterateEquation(x, v, v.epsilon, u, t, q, p, a, c); - w += Math.abs(y); - } - if (this.usedIterations++, m >= w * w) - break; - } - for (d.updateMultipliers(k, q, 1 / a), x = 0; x !== l; x++) { - var z = k[x]; - if (z instanceof i) { - for (var A = 0, B = 0; B !== z.contactEquations.length; B++) - A += z.contactEquations[B].multiplier; - A *= z.frictionCoefficient / z.contactEquations.length, z.maxForce = A, z.minForce = -A; - } - } - } - for (c = 0; c !== g; c++) { - for (w = 0, x = 0; x !== l; x++) { - v = k[x]; - var y = d.iterateEquation(x, v, v.epsilon, u, t, q, p, a, c); - w += Math.abs(y); - } - if (this.usedIterations++, m >= w * w) - break; - } - for (r = 0; r !== o; r++) - n[r].addConstraintVelocity(); - d.updateMultipliers(k, q, 1 / a); - } }, d.updateMultipliers = function (a, b, c) { for (var d = a.length; d--;) - a[d].multiplier = b[d] * c; }, d.iterateEquation = function (a, b, c, d, e, f, g, h, i) { var j = d[a], k = e[a], l = f[a], m = b.computeGWlambda(), n = b.maxForce, o = b.minForce; g && (j = 0); var p = k * (j - m - c * l), q = l + p; return o * h > q ? p = o * h - l : q > n * h && (p = n * h - l), f[a] += p, b.addToWlambda(p), p; }; - }, { "../equations/FrictionEquation": 23, "../math/vec2": 30, "../utils/Utils": 57, "./Solver": 47 }], 47: [function (a, b, c) { function d(a, b) { a = a || {}, e.call(this), this.type = b, this.equations = [], this.equationSortFunction = a.equationSortFunction || !1; } var e = (a("../utils/Utils"), a("../events/EventEmitter")); b.exports = d, d.prototype = new e, d.prototype.constructor = d, d.prototype.solve = function (a, b) { throw new Error("Solver.solve should be implemented by subclasses!"); }; var f = { bodies: [] }; d.prototype.solveIsland = function (a, b) { this.removeAllEquations(), b.equations.length && (this.addEquations(b.equations), f.bodies.length = 0, b.getBodies(f.bodies), f.bodies.length && this.solve(a, f)); }, d.prototype.sortEquations = function () { this.equationSortFunction && this.equations.sort(this.equationSortFunction); }, d.prototype.addEquation = function (a) { a.enabled && this.equations.push(a); }, d.prototype.addEquations = function (a) { for (var b = 0, c = a.length; b !== c; b++) { - var d = a[b]; - d.enabled && this.equations.push(d); - } }, d.prototype.removeEquation = function (a) { var b = this.equations.indexOf(a); -1 !== b && this.equations.splice(b, 1); }, d.prototype.removeAllEquations = function () { this.equations.length = 0; }, d.GS = 1, d.ISLAND = 2; }, { "../events/EventEmitter": 26, "../utils/Utils": 57 }], 48: [function (a, b, c) { function d() { f.apply(this, arguments); } var e = a("../equations/ContactEquation"), f = a("./Pool"); b.exports = d, d.prototype = new f, d.prototype.constructor = d, d.prototype.create = function () { return new e; }, d.prototype.destroy = function (a) { return a.bodyA = a.bodyB = null, this; }; }, { "../equations/ContactEquation": 21, "./Pool": 55 }], 49: [function (a, b, c) { function d() { f.apply(this, arguments); } var e = a("../equations/FrictionEquation"), f = a("./Pool"); b.exports = d, d.prototype = new f, d.prototype.constructor = d, d.prototype.create = function () { return new e; }, d.prototype.destroy = function (a) { return a.bodyA = a.bodyB = null, this; }; }, { "../equations/FrictionEquation": 23, "./Pool": 55 }], 50: [function (a, b, c) { function d() { f.apply(this, arguments); } var e = a("../world/IslandNode"), f = a("./Pool"); b.exports = d, d.prototype = new f, d.prototype.constructor = d, d.prototype.create = function () { return new e; }, d.prototype.destroy = function (a) { return a.reset(), this; }; }, { "../world/IslandNode": 60, "./Pool": 55 }], 51: [function (a, b, c) { function d() { f.apply(this, arguments); } var e = a("../world/Island"), f = a("./Pool"); b.exports = d, d.prototype = new f, d.prototype.constructor = d, d.prototype.create = function () { return new e; }, d.prototype.destroy = function (a) { return a.reset(), this; }; }, { "../world/Island": 58, "./Pool": 55 }], 52: [function (a, b, c) { function d() { this.overlappingShapesLastState = new e, this.overlappingShapesCurrentState = new e, this.recordPool = new f({ size: 16 }), this.tmpDict = new e, this.tmpArray1 = []; } var e = a("./TupleDictionary"), f = (a("./OverlapKeeperRecord"), a("./OverlapKeeperRecordPool")); a("./Utils"); b.exports = d, d.prototype.tick = function () { for (var a = this.overlappingShapesLastState, b = this.overlappingShapesCurrentState, c = a.keys.length; c--;) { - var d = a.keys[c], e = a.getByKey(d); - b.getByKey(d); - e && this.recordPool.release(e); - } a.reset(), a.copy(b), b.reset(); }, d.prototype.setOverlapping = function (a, b, c, d) { var e = (this.overlappingShapesLastState, this.overlappingShapesCurrentState); if (!e.get(b.id, d.id)) { - var f = this.recordPool.get(); - f.set(a, b, c, d), e.set(b.id, d.id, f); - } }, d.prototype.getNewOverlaps = function (a) { return this.getDiff(this.overlappingShapesLastState, this.overlappingShapesCurrentState, a); }, d.prototype.getEndOverlaps = function (a) { return this.getDiff(this.overlappingShapesCurrentState, this.overlappingShapesLastState, a); }, d.prototype.bodiesAreOverlapping = function (a, b) { for (var c = this.overlappingShapesCurrentState, d = c.keys.length; d--;) { - var e = c.keys[d], f = c.data[e]; - if (f.bodyA === a && f.bodyB === b || f.bodyA === b && f.bodyB === a) - return !0; - } return !1; }, d.prototype.getDiff = function (a, b, c) { var c = c || [], d = a, e = b; c.length = 0; for (var f = e.keys.length; f--;) { - var g = e.keys[f], h = e.data[g]; - if (!h) - throw new Error("Key " + g + " had no data!"); - var i = d.data[g]; - i || c.push(h); - } return c; }, d.prototype.isNewOverlap = function (a, b) { var c = 0 | a.id, d = 0 | b.id, e = this.overlappingShapesLastState, f = this.overlappingShapesCurrentState; return !e.get(c, d) && !!f.get(c, d); }, d.prototype.getNewBodyOverlaps = function (a) { this.tmpArray1.length = 0; var b = this.getNewOverlaps(this.tmpArray1); return this.getBodyDiff(b, a); }, d.prototype.getEndBodyOverlaps = function (a) { this.tmpArray1.length = 0; var b = this.getEndOverlaps(this.tmpArray1); return this.getBodyDiff(b, a); }, d.prototype.getBodyDiff = function (a, b) { b = b || []; for (var c = this.tmpDict, d = a.length; d--;) { - var e = a[d]; - c.set(0 | e.bodyA.id, 0 | e.bodyB.id, e); - } for (d = c.keys.length; d--;) { - var e = c.getByKey(c.keys[d]); - e && b.push(e.bodyA, e.bodyB); - } return c.reset(), b; }; }, { "./OverlapKeeperRecord": 53, "./OverlapKeeperRecordPool": 54, "./TupleDictionary": 56, "./Utils": 57 }], 53: [function (a, b, c) { function d(a, b, c, d) { this.shapeA = b, this.shapeB = d, this.bodyA = a, this.bodyB = c; } b.exports = d, d.prototype.set = function (a, b, c, e) { d.call(this, a, b, c, e); }; }, {}], 54: [function (a, b, c) { function d() { f.apply(this, arguments); } var e = a("./OverlapKeeperRecord"), f = a("./Pool"); b.exports = d, d.prototype = new f, d.prototype.constructor = d, d.prototype.create = function () { return new e; }, d.prototype.destroy = function (a) { return a.bodyA = a.bodyB = a.shapeA = a.shapeB = null, this; }; }, { "./OverlapKeeperRecord": 53, "./Pool": 55 }], 55: [function (a, b, c) { function d(a) { a = a || {}, this.objects = [], void 0 !== a.size && this.resize(a.size); } b.exports = d, d.prototype.resize = function (a) { for (var b = this.objects; b.length > a;) - b.pop(); for (; b.length < a;) - b.push(this.create()); return this; }, d.prototype.get = function () { var a = this.objects; return a.length ? a.pop() : this.create(); }, d.prototype.release = function (a) { return this.destroy(a), this.objects.push(a), this; }; }, {}], 56: [function (a, b, c) { function d() { this.data = {}, this.keys = []; } var e = a("./Utils"); b.exports = d, d.prototype.getKey = function (a, b) { return a = 0 | a, b = 0 | b, (0 | a) === (0 | b) ? -1 : 0 | ((0 | a) > (0 | b) ? a << 16 | 65535 & b : b << 16 | 65535 & a); }, d.prototype.getByKey = function (a) { return a = 0 | a, this.data[a]; }, d.prototype.get = function (a, b) { return this.data[this.getKey(a, b)]; }, d.prototype.set = function (a, b, c) { if (!c) - throw new Error("No data!"); var d = this.getKey(a, b); return this.data[d] || this.keys.push(d), this.data[d] = c, d; }, d.prototype.reset = function () { for (var a = this.data, b = this.keys, c = b.length; c--;) - delete a[b[c]]; b.length = 0; }, d.prototype.copy = function (a) { this.reset(), e.appendArray(this.keys, a.keys); for (var b = a.keys.length; b--;) { - var c = a.keys[b]; - this.data[c] = a.data[c]; - } }; }, { "./Utils": 57 }], 57: [function (a, b, c) { function d() { } b.exports = d, d.appendArray = function (a, b) { if (b.length < 15e4) - a.push.apply(a, b); - else - for (var c = 0, d = b.length; c !== d; ++c) - a.push(b[c]); }, d.splice = function (a, b, c) { c = c || 1; for (var d = b, e = a.length - c; e > d; d++) - a[d] = a[d + c]; a.length = e; }, "undefined" != typeof P2_ARRAY_TYPE ? d.ARRAY_TYPE = P2_ARRAY_TYPE : "undefined" != typeof Float32Array ? d.ARRAY_TYPE = Float32Array : d.ARRAY_TYPE = Array, d.extend = function (a, b) { for (var c in b) - a[c] = b[c]; }, d.defaults = function (a, b) { a = a || {}; for (var c in b) - c in a || (a[c] = b[c]); return a; }; }, {}], 58: [function (a, b, c) { function d() { this.equations = [], this.bodies = []; } var e = a("../objects/Body"); b.exports = d, d.prototype.reset = function () { this.equations.length = this.bodies.length = 0; }; var f = []; d.prototype.getBodies = function (a) { var b = a || [], c = this.equations; f.length = 0; for (var d = 0; d !== c.length; d++) { - var e = c[d]; - -1 === f.indexOf(e.bodyA.id) && (b.push(e.bodyA), f.push(e.bodyA.id)), -1 === f.indexOf(e.bodyB.id) && (b.push(e.bodyB), f.push(e.bodyB.id)); - } return b; }, d.prototype.wantsToSleep = function () { for (var a = 0; a < this.bodies.length; a++) { - var b = this.bodies[a]; - if (b.type === e.DYNAMIC && !b.wantsToSleep) - return !1; - } return !0; }, d.prototype.sleep = function () { for (var a = 0; a < this.bodies.length; a++) { - var b = this.bodies[a]; - b.sleep(); - } return !0; }; }, { "../objects/Body": 31 }], 59: [function (a, b, c) { function d(a) { this.nodePool = new e({ size: 16 }), this.islandPool = new f({ size: 8 }), this.equations = [], this.islands = [], this.nodes = [], this.queue = []; } var e = (a("../math/vec2"), a("./Island"), a("./IslandNode"), a("./../utils/IslandNodePool")), f = a("./../utils/IslandPool"), g = a("../objects/Body"); b.exports = d, d.getUnvisitedNode = function (a) { for (var b = a.length, c = 0; c !== b; c++) { - var d = a[c]; - if (!d.visited && d.body.type === g.DYNAMIC) - return d; - } return !1; }, d.prototype.visit = function (a, b, c) { b.push(a.body); for (var d = a.equations.length, e = 0; e !== d; e++) { - var f = a.equations[e]; - -1 === c.indexOf(f) && c.push(f); - } }, d.prototype.bfs = function (a, b, c) { var e = this.queue; for (e.length = 0, e.push(a), a.visited = !0, this.visit(a, b, c); e.length;) - for (var f, h = e.pop(); f = d.getUnvisitedNode(h.neighbors);) - f.visited = !0, this.visit(f, b, c), f.body.type === g.DYNAMIC && e.push(f); }, d.prototype.split = function (a) { for (var b = a.bodies, c = this.nodes, e = this.equations; c.length;) - this.nodePool.release(c.pop()); for (var f = 0; f !== b.length; f++) { - var g = this.nodePool.get(); - g.body = b[f], c.push(g); - } for (var h = 0; h !== e.length; h++) { - var i = e[h], f = b.indexOf(i.bodyA), j = b.indexOf(i.bodyB), k = c[f], l = c[j]; - k.neighbors.push(l), l.neighbors.push(k), k.equations.push(i), l.equations.push(i); - } for (var m = this.islands, f = 0; f < m.length; f++) - this.islandPool.release(m[f]); m.length = 0; for (var n; n = d.getUnvisitedNode(c);) { - var o = this.islandPool.get(); - this.bfs(n, o.bodies, o.equations), m.push(o); - } return m; }; }, { "../math/vec2": 30, "../objects/Body": 31, "./../utils/IslandNodePool": 50, "./../utils/IslandPool": 51, "./Island": 58, "./IslandNode": 60 }], 60: [function (a, b, c) { function d(a) { this.body = a, this.neighbors = [], this.equations = [], this.visited = !1; } b.exports = d, d.prototype.reset = function () { this.equations.length = 0, this.neighbors.length = 0, this.visited = !1, this.body = null; }; }, {}], 61: [function (a, b, c) { function d(a) { l.apply(this), a = a || {}, this.springs = [], this.bodies = [], this.disabledBodyCollisionPairs = [], this.solver = a.solver || new e, this.narrowphase = new r(this), this.islandManager = new u, this.gravity = f.fromValues(0, -9.78), a.gravity && f.copy(this.gravity, a.gravity), this.frictionGravity = f.length(this.gravity) || 10, this.useWorldGravityAsFrictionGravity = !0, this.useFrictionGravityOnZeroGravity = !0, this.broadphase = a.broadphase || new q, this.broadphase.setWorld(this), this.constraints = [], this.defaultMaterial = new n, this.defaultContactMaterial = new o(this.defaultMaterial, this.defaultMaterial), this.lastTimeStep = 1 / 60, this.applySpringForces = !0, this.applyDamping = !0, this.applyGravity = !0, this.solveConstraints = !0, this.contactMaterials = [], this.time = 0, this.accumulator = 0, this.stepping = !1, this.bodiesToBeRemoved = [], this.islandSplit = "undefined" != typeof a.islandSplit ? !!a.islandSplit : !0, this.emitImpactEvent = !0, this._constraintIdCounter = 0, this._bodyIdCounter = 0, this.postStepEvent = { type: "postStep" }, this.addBodyEvent = { type: "addBody", body: null }, this.removeBodyEvent = { type: "removeBody", body: null }, this.addSpringEvent = { type: "addSpring", spring: null }, this.impactEvent = { type: "impact", bodyA: null, bodyB: null, shapeA: null, shapeB: null, contactEquation: null }, this.postBroadphaseEvent = { type: "postBroadphase", pairs: null }, this.sleepMode = d.NO_SLEEPING, this.beginContactEvent = { type: "beginContact", shapeA: null, shapeB: null, bodyA: null, bodyB: null, contactEquations: [] }, this.endContactEvent = { type: "endContact", shapeA: null, shapeB: null, bodyA: null, bodyB: null }, this.preSolveEvent = { type: "preSolve", contactEquations: null, frictionEquations: null }, this.overlappingShapesLastState = { keys: [] }, this.overlappingShapesCurrentState = { keys: [] }, this.overlapKeeper = new t; } var e = a("../solver/GSSolver"), f = (a("../solver/Solver"), a("../collision/Ray"), a("../math/vec2")), g = a("../shapes/Circle"), h = a("../shapes/Convex"), i = (a("../shapes/Line"), a("../shapes/Plane")), j = a("../shapes/Capsule"), k = a("../shapes/Particle"), l = a("../events/EventEmitter"), m = a("../objects/Body"), n = (a("../shapes/Shape"), a("../objects/LinearSpring"), a("../material/Material")), o = a("../material/ContactMaterial"), p = (a("../constraints/DistanceConstraint"), a("../constraints/Constraint"), a("../constraints/LockConstraint"), a("../constraints/RevoluteConstraint"), a("../constraints/PrismaticConstraint"), a("../constraints/GearConstraint"), a("../../package.json"), a("../collision/Broadphase"), a("../collision/AABB")), q = a("../collision/SAPBroadphase"), r = a("../collision/Narrowphase"), s = a("../utils/Utils"), t = a("../utils/OverlapKeeper"), u = a("./IslandManager"); a("../objects/RotationalSpring"); b.exports = d, d.prototype = new Object(l.prototype), d.prototype.constructor = d, d.NO_SLEEPING = 1, d.BODY_SLEEPING = 2, d.ISLAND_SLEEPING = 4, d.prototype.addConstraint = function (a) { this.constraints.push(a); }, d.prototype.addContactMaterial = function (a) { this.contactMaterials.push(a); }, d.prototype.removeContactMaterial = function (a) { var b = this.contactMaterials.indexOf(a); -1 !== b && s.splice(this.contactMaterials, b, 1); }, d.prototype.getContactMaterial = function (a, b) { for (var c = this.contactMaterials, d = 0, e = c.length; d !== e; d++) { - var f = c[d]; - if (f.materialA.id === a.id && f.materialB.id === b.id || f.materialA.id === b.id && f.materialB.id === a.id) - return f; - } return !1; }, d.prototype.removeConstraint = function (a) { var b = this.constraints.indexOf(a); -1 !== b && s.splice(this.constraints, b, 1); }; var v = (f.create(), f.create(), f.create(), f.create(), f.create(), f.create(), f.create()), w = f.fromValues(0, 0), x = f.fromValues(0, 0); f.fromValues(0, 0), f.fromValues(0, 0); d.prototype.step = function (a, b, c) { if (c = c || 10, b = b || 0, 0 === b) - this.internalStep(a), this.time += a; - else { - this.accumulator += b; - for (var d = 0; this.accumulator >= a && c > d;) - this.internalStep(a), this.time += a, this.accumulator -= a, d++; - for (var e = this.accumulator % a / a, g = 0; g !== this.bodies.length; g++) { - var h = this.bodies[g]; - f.lerp(h.interpolatedPosition, h.previousPosition, h.position, e), h.interpolatedAngle = h.previousAngle + e * (h.angle - h.previousAngle); - } - } }; var y = []; d.prototype.internalStep = function (a) { this.stepping = !0; var b = this.springs.length, c = this.springs, e = this.bodies, g = this.gravity, h = this.solver, i = this.bodies.length, j = this.broadphase, k = this.narrowphase, l = this.constraints, n = v, o = (f.scale, f.add), p = (f.rotate, this.islandManager); if (this.overlapKeeper.tick(), this.lastTimeStep = a, this.useWorldGravityAsFrictionGravity) { - var q = f.length(this.gravity); - 0 === q && this.useFrictionGravityOnZeroGravity || (this.frictionGravity = q); - } if (this.applyGravity) - for (var r = 0; r !== i; r++) { - var t = e[r], u = t.force; - t.type === m.DYNAMIC && t.sleepState !== m.SLEEPING && (f.scale(n, g, t.mass * t.gravityScale), o(u, u, n)); - } if (this.applySpringForces) - for (var r = 0; r !== b; r++) { - var w = c[r]; - w.applyForce(); - } if (this.applyDamping) - for (var r = 0; r !== i; r++) { - var t = e[r]; - t.type === m.DYNAMIC && t.applyDamping(a); - } for (var x = j.getCollisionPairs(this), z = this.disabledBodyCollisionPairs, r = z.length - 2; r >= 0; r -= 2) - for (var A = x.length - 2; A >= 0; A -= 2) - (z[r] === x[A] && z[r + 1] === x[A + 1] || z[r + 1] === x[A] && z[r] === x[A + 1]) && x.splice(A, 2); var B = l.length; for (r = 0; r !== B; r++) { - var C = l[r]; - if (!C.collideConnected) - for (var A = x.length - 2; A >= 0; A -= 2) - (C.bodyA === x[A] && C.bodyB === x[A + 1] || C.bodyB === x[A] && C.bodyA === x[A + 1]) && x.splice(A, 2); - } this.postBroadphaseEvent.pairs = x, this.emit(this.postBroadphaseEvent), this.postBroadphaseEvent.pairs = null, k.reset(this); for (var r = 0, D = x.length; r !== D; r += 2) - for (var E = x[r], F = x[r + 1], G = 0, H = E.shapes.length; G !== H; G++) - for (var I = E.shapes[G], J = I.position, K = I.angle, L = 0, M = F.shapes.length; L !== M; L++) { - var N = F.shapes[L], O = N.position, P = N.angle, Q = this.defaultContactMaterial; - if (I.material && N.material) { - var R = this.getContactMaterial(I.material, N.material); - R && (Q = R); - } - this.runNarrowphase(k, E, I, J, K, F, N, O, P, Q, this.frictionGravity); - } for (var r = 0; r !== i; r++) { - var S = e[r]; - S._wakeUpAfterNarrowphase && (S.wakeUp(), S._wakeUpAfterNarrowphase = !1); - } if (this.has("endContact")) { - this.overlapKeeper.getEndOverlaps(y); - for (var T = this.endContactEvent, L = y.length; L--;) { - var U = y[L]; - T.shapeA = U.shapeA, T.shapeB = U.shapeB, T.bodyA = U.bodyA, T.bodyB = U.bodyB, this.emit(T); - } - y.length = 0; - } var V = this.preSolveEvent; V.contactEquations = k.contactEquations, V.frictionEquations = k.frictionEquations, this.emit(V), V.contactEquations = V.frictionEquations = null; var B = l.length; for (r = 0; r !== B; r++) - l[r].update(); if (k.contactEquations.length || k.frictionEquations.length || B) - if (this.islandSplit) { - for (p.equations.length = 0, s.appendArray(p.equations, k.contactEquations), s.appendArray(p.equations, k.frictionEquations), r = 0; r !== B; r++) - s.appendArray(p.equations, l[r].equations); - p.split(this); - for (var r = 0; r !== p.islands.length; r++) { - var W = p.islands[r]; - W.equations.length && h.solveIsland(a, W); - } - } - else { - for (h.addEquations(k.contactEquations), h.addEquations(k.frictionEquations), r = 0; r !== B; r++) - h.addEquations(l[r].equations); - this.solveConstraints && h.solve(a, this), h.removeAllEquations(); - } for (var r = 0; r !== i; r++) { - var S = e[r]; - S.integrate(a); - } for (var r = 0; r !== i; r++) - e[r].setZeroForce(); if (this.emitImpactEvent && this.has("impact")) - for (var X = this.impactEvent, r = 0; r !== k.contactEquations.length; r++) { - var Y = k.contactEquations[r]; - Y.firstImpact && (X.bodyA = Y.bodyA, X.bodyB = Y.bodyB, X.shapeA = Y.shapeA, X.shapeB = Y.shapeB, X.contactEquation = Y, this.emit(X)); - } if (this.sleepMode === d.BODY_SLEEPING) - for (r = 0; r !== i; r++) - e[r].sleepTick(this.time, !1, a); - else if (this.sleepMode === d.ISLAND_SLEEPING && this.islandSplit) { - for (r = 0; r !== i; r++) - e[r].sleepTick(this.time, !0, a); - for (var r = 0; r < this.islandManager.islands.length; r++) { - var W = this.islandManager.islands[r]; - W.wantsToSleep() && W.sleep(); - } - } this.stepping = !1; for (var Z = this.bodiesToBeRemoved, r = 0; r !== Z.length; r++) - this.removeBody(Z[r]); Z.length = 0, this.emit(this.postStepEvent); }, d.prototype.runNarrowphase = function (a, b, c, d, e, g, h, i, j, k, l) { if (0 !== (c.collisionGroup & h.collisionMask) && 0 !== (h.collisionGroup & c.collisionMask)) { - f.rotate(w, d, b.angle), f.rotate(x, i, g.angle), f.add(w, w, b.position), f.add(x, x, g.position); - var n = e + b.angle, o = j + g.angle; - a.enableFriction = k.friction > 0, a.frictionCoefficient = k.friction; - var p; - p = b.type === m.STATIC || b.type === m.KINEMATIC ? g.mass : g.type === m.STATIC || g.type === m.KINEMATIC ? b.mass : b.mass * g.mass / (b.mass + g.mass), a.slipForce = k.friction * l * p, a.restitution = k.restitution, a.surfaceVelocity = k.surfaceVelocity, a.frictionStiffness = k.frictionStiffness, a.frictionRelaxation = k.frictionRelaxation, a.stiffness = k.stiffness, a.relaxation = k.relaxation, a.contactSkinSize = k.contactSkinSize, a.enabledEquations = b.collisionResponse && g.collisionResponse && c.collisionResponse && h.collisionResponse; - var q = a[c.type | h.type], r = 0; - if (q) { - var s = c.sensor || h.sensor, t = a.frictionEquations.length; - r = c.type < h.type ? q.call(a, b, c, w, n, g, h, x, o, s) : q.call(a, g, h, x, o, b, c, w, n, s); - var u = a.frictionEquations.length - t; - if (r) { - if (b.allowSleep && b.type === m.DYNAMIC && b.sleepState === m.SLEEPING && g.sleepState === m.AWAKE && g.type !== m.STATIC) { - var v = f.squaredLength(g.velocity) + Math.pow(g.angularVelocity, 2), y = Math.pow(g.sleepSpeedLimit, 2); - v >= 2 * y && (b._wakeUpAfterNarrowphase = !0); - } - if (g.allowSleep && g.type === m.DYNAMIC && g.sleepState === m.SLEEPING && b.sleepState === m.AWAKE && b.type !== m.STATIC) { - var z = f.squaredLength(b.velocity) + Math.pow(b.angularVelocity, 2), A = Math.pow(b.sleepSpeedLimit, 2); - z >= 2 * A && (g._wakeUpAfterNarrowphase = !0); - } - if (this.overlapKeeper.setOverlapping(b, c, g, h), this.has("beginContact") && this.overlapKeeper.isNewOverlap(c, h)) { - var B = this.beginContactEvent; - if (B.shapeA = c, B.shapeB = h, B.bodyA = b, B.bodyB = g, B.contactEquations.length = 0, "number" == typeof r) - for (var C = a.contactEquations.length - r; C < a.contactEquations.length; C++) - B.contactEquations.push(a.contactEquations[C]); - this.emit(B); - } - if ("number" == typeof r && u > 1) - for (var C = a.frictionEquations.length - u; C < a.frictionEquations.length; C++) { - var D = a.frictionEquations[C]; - D.setSlipForce(D.getSlipForce() / u); - } - } - } - } }, d.prototype.addSpring = function (a) { this.springs.push(a); var b = this.addSpringEvent; b.spring = a, this.emit(b), b.spring = null; }, d.prototype.removeSpring = function (a) { var b = this.springs.indexOf(a); -1 !== b && s.splice(this.springs, b, 1); }, d.prototype.addBody = function (a) { if (-1 === this.bodies.indexOf(a)) { - this.bodies.push(a), a.world = this; - var b = this.addBodyEvent; - b.body = a, this.emit(b), b.body = null; - } }, d.prototype.removeBody = function (a) { if (this.stepping) - this.bodiesToBeRemoved.push(a); - else { - a.world = null; - var b = this.bodies.indexOf(a); - -1 !== b && (s.splice(this.bodies, b, 1), this.removeBodyEvent.body = a, a.resetConstraintVelocity(), this.emit(this.removeBodyEvent), this.removeBodyEvent.body = null); - } }, d.prototype.getBodyById = function (a) { for (var b = this.bodies, c = 0; c < b.length; c++) { - var d = b[c]; - if (d.id === a) - return d; - } return !1; }, d.prototype.disableBodyCollision = function (a, b) { this.disabledBodyCollisionPairs.push(a, b); }, d.prototype.enableBodyCollision = function (a, b) { for (var c = this.disabledBodyCollisionPairs, d = 0; d < c.length; d += 2) - if (c[d] === a && c[d + 1] === b || c[d + 1] === a && c[d] === b) - return void c.splice(d, 2); }, d.prototype.clear = function () { this.time = 0, this.solver && this.solver.equations.length && this.solver.removeAllEquations(); for (var a = this.constraints, b = a.length - 1; b >= 0; b--) - this.removeConstraint(a[b]); for (var c = this.bodies, b = c.length - 1; b >= 0; b--) - this.removeBody(c[b]); for (var e = this.springs, b = e.length - 1; b >= 0; b--) - this.removeSpring(e[b]); for (var f = this.contactMaterials, b = f.length - 1; b >= 0; b--) - this.removeContactMaterial(f[b]); d.apply(this); }; var z = f.create(), A = (f.fromValues(0, 0), f.fromValues(0, 0)); d.prototype.hitTest = function (a, b, c) { c = c || 0; var d = new m({ position: a }), e = new k, l = a, n = 0, o = z, p = A; d.addShape(e); for (var q = this.narrowphase, r = [], s = 0, t = b.length; s !== t; s++) - for (var u = b[s], v = 0, w = u.shapes.length; v !== w; v++) { - var x = u.shapes[v]; - f.rotate(o, x.position, u.angle), f.add(o, o, u.position); - var y = x.angle + u.angle; - (x instanceof g && q.circleParticle(u, x, o, y, d, e, l, n, !0) || x instanceof h && q.particleConvex(d, e, l, n, u, x, o, y, !0) || x instanceof i && q.particlePlane(d, e, l, n, u, x, o, y, !0) || x instanceof j && q.particleCapsule(d, e, l, n, u, x, o, y, !0) || x instanceof k && f.squaredLength(f.sub(p, o, a)) < c * c) && r.push(u); - } return r; }, d.prototype.setGlobalStiffness = function (a) { for (var b = this.constraints, c = 0; c !== b.length; c++) - for (var d = b[c], e = 0; e !== d.equations.length; e++) { - var f = d.equations[e]; - f.stiffness = a, f.needsUpdate = !0; - } for (var g = this.contactMaterials, c = 0; c !== g.length; c++) { - var d = g[c]; - d.stiffness = d.frictionStiffness = a; - } var d = this.defaultContactMaterial; d.stiffness = d.frictionStiffness = a; }, d.prototype.setGlobalRelaxation = function (a) { for (var b = 0; b !== this.constraints.length; b++) - for (var c = this.constraints[b], d = 0; d !== c.equations.length; d++) { - var e = c.equations[d]; - e.relaxation = a, e.needsUpdate = !0; - } for (var b = 0; b !== this.contactMaterials.length; b++) { - var c = this.contactMaterials[b]; - c.relaxation = c.frictionRelaxation = a; - } var c = this.defaultContactMaterial; c.relaxation = c.frictionRelaxation = a; }; var B = new p, C = []; d.prototype.raycast = function (a, b) { return b.getAABB(B), this.broadphase.aabbQuery(this, B, C), b.intersectBodies(a, C), C.length = 0, a.hasHit(); }; }, { "../../package.json": 6, "../collision/AABB": 7, "../collision/Broadphase": 8, "../collision/Narrowphase": 10, "../collision/Ray": 11, "../collision/SAPBroadphase": 13, "../constraints/Constraint": 14, "../constraints/DistanceConstraint": 15, "../constraints/GearConstraint": 16, "../constraints/LockConstraint": 17, "../constraints/PrismaticConstraint": 18, "../constraints/RevoluteConstraint": 19, "../events/EventEmitter": 26, "../material/ContactMaterial": 27, "../material/Material": 28, "../math/vec2": 30, "../objects/Body": 31, "../objects/LinearSpring": 32, "../objects/RotationalSpring": 33, "../shapes/Capsule": 38, "../shapes/Circle": 39, "../shapes/Convex": 40, "../shapes/Line": 42, "../shapes/Particle": 43, "../shapes/Plane": 44, "../shapes/Shape": 45, "../solver/GSSolver": 46, "../solver/Solver": 47, "../utils/OverlapKeeper": 52, "../utils/Utils": 57, "./IslandManager": 59 }] }, {}, [36])(36); -}); diff --git a/helloworld/libs/modules/physics/physics.min.js b/helloworld/libs/modules/physics/physics.min.js deleted file mode 100644 index d4c18f2..0000000 --- a/helloworld/libs/modules/physics/physics.min.js +++ /dev/null @@ -1,4 +0,0 @@ -!function(t){if("object"==typeof exports)module.exports=t();else if("function"==typeof define,1){var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.p2=t()}else define(t)}(function(){return function t(e,o,i){function n(a,s){if(!o[a]){if(!e[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(r)return r(a,!0);throw new Error("Cannot find module '"+a+"'")}var h=o[a]={exports:{}};e[a][0].call(h.exports,function(t){var o=e[a][1][t];return n(o?o:t)},h,h.exports,t,e,o,i)}return o[a].exports}for(var r="function"==typeof require&&require,a=0;a=0&&1>=c&&h>=0&&1>=h}},{"./Scalar":4}],2:[function(t,e,o){function i(){}e.exports=i,i.area=function(t,e,o){return(e[0]-t[0])*(o[1]-t[1])-(o[0]-t[0])*(e[1]-t[1])},i.left=function(t,e,o){return i.area(t,e,o)>0},i.leftOn=function(t,e,o){return i.area(t,e,o)>=0},i.right=function(t,e,o){return i.area(t,e,o)<0},i.rightOn=function(t,e,o){return i.area(t,e,o)<=0};var n=[],r=[];i.collinear=function(t,e,o,a){if(a){var s=n,c=r;s[0]=e[0]-t[0],s[1]=e[1]-t[1],c[0]=o[0]-e[0],c[1]=o[1]-e[1];var h=s[0]*c[0]+s[1]*c[1],l=Math.sqrt(s[0]*s[0]+s[1]*s[1]),p=Math.sqrt(c[0]*c[0]+c[1]*c[1]),u=Math.acos(h/(l*p));return a>u}return 0==i.area(t,e,o)},i.sqdist=function(t,e){var o=e[0]-t[0],i=e[1]-t[1];return o*o+i*i}},{}],3:[function(t,e,o){function i(){this.vertices=[]}function n(t,e,o,i,n){n=n||0;var r=e[1]-t[1],a=t[0]-e[0],c=r*t[0]+a*t[1],h=i[1]-o[1],l=o[0]-i[0],p=h*o[0]+l*o[1],u=r*l-h*a;return s.eq(u,0,n)?[0,0]:[(l*c-a*p)/u,(r*p-h*c)/u]}var r=t("./Line"),a=t("./Point"),s=t("./Scalar");e.exports=i,i.prototype.at=function(t){var e=this.vertices,o=e.length;return e[0>t?t%o+o:t%o]},i.prototype.first=function(){return this.vertices[0]},i.prototype.last=function(){return this.vertices[this.vertices.length-1]},i.prototype.clear=function(){this.vertices.length=0},i.prototype.append=function(t,e,o){if("undefined"==typeof e)throw new Error("From is not given!");if("undefined"==typeof o)throw new Error("To is not given!");if(e>o-1)throw new Error("lol1");if(o>t.vertices.length)throw new Error("lol2");if(0>e)throw new Error("lol3");for(var i=e;o>i;i++)this.vertices.push(t.vertices[i])},i.prototype.makeCCW=function(){for(var t=0,e=this.vertices,o=1;oe[t][0])&&(t=o);a.left(this.at(t-1),this.at(t),this.at(t+1))||this.reverse()},i.prototype.reverse=function(){for(var t=[],e=0,o=this.vertices.length;e!==o;e++)t.push(this.vertices.pop());this.vertices=t},i.prototype.isReflex=function(t){return a.right(this.at(t-1),this.at(t),this.at(t+1))};var c=[],h=[];i.prototype.canSee=function(t,e){var o,i,n=c,s=h;if(a.leftOn(this.at(t+1),this.at(t),this.at(e))&&a.rightOn(this.at(t-1),this.at(t),this.at(e)))return!1;i=a.sqdist(this.at(t),this.at(e));for(var l=0;l!==this.vertices.length;++l)if((l+1)%this.vertices.length!==t&&l!==t&&a.leftOn(this.at(t),this.at(e),this.at(l+1))&&a.rightOn(this.at(t),this.at(e),this.at(l))&&(n[0]=this.at(t),n[1]=this.at(e),s[0]=this.at(l),s[1]=this.at(l+1),o=r.lineInt(n,s),a.sqdist(this.at(t),o)t)for(var r=t;e>=r;r++)n.vertices.push(this.vertices[r]);else{for(var r=0;e>=r;r++)n.vertices.push(this.vertices[r]);for(var r=t;r0?this.slice(t):[this]},i.prototype.slice=function(t){if(0==t.length)return[this];if(t instanceof Array&&t.length&&t[0]instanceof Array&&2==t[0].length&&t[0][0]instanceof Array){for(var e=[this],o=0;oo;o++)if(r.segmentsIntersect(t[e],t[e+1],t[o],t[o+1]))return!1;for(var e=1;es)return console.warn("quickDecomp: max level ("+s+") reached."),t;for(var q=0;qf&&(d=f,l=p,m=P))),a.left(E.at(q+1),E.at(q),E.at(P+1))&&a.rightOn(E.at(q+1),E.at(q),E.at(P))&&(p=n(E.at(q+1),E.at(q),E.at(P),E.at(P+1)),a.left(E.at(q-1),E.at(q),p)&&(f=a.sqdist(E.vertices[q],p),u>f&&(u=f,h=p,y=P)));if(m==(y+1)%this.vertices.length)p[0]=(l[0]+h[0])/2,p[1]=(l[1]+h[1])/2,o.push(p),y>q?(A.append(E,q,y+1),A.vertices.push(p),b.vertices.push(p),0!=m&&b.append(E,m,E.vertices.length),b.append(E,0,q+1)):(0!=q&&A.append(E,q,E.vertices.length),A.append(E,0,y+1),A.vertices.push(p),b.vertices.push(p),b.append(E,m,q+1));else{if(m>y&&(y+=this.vertices.length),v=Number.MAX_VALUE,m>y)return t;for(var P=m;y>=P;++P)a.leftOn(E.at(q-1),E.at(q),E.at(P))&&a.rightOn(E.at(q+1),E.at(q),E.at(P))&&(f=a.sqdist(E.at(q),E.at(P)),v>f&&(v=f,g=P%this.vertices.length));g>q?(A.append(E,q,g+1),0!=g&&b.append(E,g,B.length),b.append(E,0,q+1)):(0!=q&&A.append(E,q,B.length),A.append(E,0,g+1),b.append(E,g,q+1))}return A.vertices.length3&&o>=0;--o)a.collinear(this.at(o-1),this.at(o),this.at(o+1),t)&&(this.vertices.splice(o%this.vertices.length,1),o--,e++);return e}},{"./Line":1,"./Point":2,"./Scalar":4}],4:[function(t,e,o){function i(){}e.exports=i,i.eq=function(t,e,o){return o=o||0,Math.abs(t-e) (http://steffe.se)",keywords:["p2.js","p2","physics","engine","2d"],main:"./src/p2.js",engines:{node:"*"},repository:{type:"git",url:"https://github.com/schteppe/p2.js.git"},bugs:{url:"https://github.com/schteppe/p2.js/issues"},licenses:[{type:"MIT"}],devDependencies:{grunt:"^0.4.5","grunt-contrib-jshint":"^0.11.2","grunt-contrib-nodeunit":"^0.4.1","grunt-contrib-uglify":"~0.4.0","grunt-contrib-watch":"~0.5.0","grunt-browserify":"~2.0.1","grunt-contrib-concat":"^0.4.0"},dependencies:{"poly-decomp":"0.1.0"}}},{}],7:[function(t,e,o){function i(t){this.lowerBound=n.create(),t&&t.lowerBound&&n.copy(this.lowerBound,t.lowerBound),this.upperBound=n.create(),t&&t.upperBound&&n.copy(this.upperBound,t.upperBound)}var n=t("../math/vec2");t("../utils/Utils"),e.exports=i;var r=n.create();i.prototype.setFromPoints=function(t,e,o,i){var a=this.lowerBound,s=this.upperBound;"number"!=typeof o&&(o=0),0!==o?n.rotate(a,t[0],o):n.copy(a,t[0]),n.copy(s,a);for(var c=Math.cos(o),h=Math.sin(o),l=1;lf;f++)p[f]>s[f]&&(s[f]=p[f]),p[f]o&&(this.lowerBound[e]=o);var i=t.upperBound[e];this.upperBound[e]c?-1:s>c?-1:s}},{"../math/vec2":30,"../utils/Utils":57}],8:[function(t,e,o){function i(t){this.type=t,this.result=[],this.world=null,this.boundingVolumeType=i.AABB}var n=t("../math/vec2"),r=t("../objects/Body");e.exports=i,i.AABB=1,i.BOUNDING_CIRCLE=2,i.prototype.setWorld=function(t){this.world=t},i.prototype.getCollisionPairs=function(t){};var a=n.create();i.boundingRadiusCheck=function(t,e){n.sub(a,t.position,e.position);var o=n.squaredLength(a),i=t.boundingRadius+e.boundingRadius;return i*i>=o},i.aabbCheck=function(t,e){return t.getAABB().overlaps(e.getAABB())},i.prototype.boundingVolumeCheck=function(t,e){var o;switch(this.boundingVolumeType){case i.BOUNDING_CIRCLE:o=i.boundingRadiusCheck(t,e);break;case i.AABB:o=i.aabbCheck(t,e);break;default:throw new Error("Bounding volume type not recognized: "+this.boundingVolumeType)}return o},i.canCollide=function(t,e){var o=r.KINEMATIC,i=r.STATIC;return t.type===i&&e.type===i?!1:t.type===o&&e.type===i||t.type===i&&e.type===o?!1:t.type===o&&e.type===o?!1:t.sleepState===r.SLEEPING&&e.sleepState===r.SLEEPING?!1:t.sleepState===r.SLEEPING&&e.type===i||e.sleepState===r.SLEEPING&&t.type===i?!1:!0},i.NAIVE=1,i.SAP=2},{"../math/vec2":30,"../objects/Body":31}],9:[function(t,e,o){function i(){n.call(this,n.NAIVE)}var n=(t("../shapes/Circle"),t("../shapes/Plane"),t("../shapes/Shape"),t("../shapes/Particle"),t("../collision/Broadphase"));t("../math/vec2"),e.exports=i,i.prototype=new n,i.prototype.constructor=i,i.prototype.getCollisionPairs=function(t){var e=t.bodies,o=this.result;o.length=0;for(var i=0,r=e.length;i!==r;i++)for(var a=e[i],s=0;i>s;s++){var c=e[s];n.canCollide(a,c)&&this.boundingVolumeCheck(a,c)&&o.push(a,c)}return o},i.prototype.aabbQuery=function(t,e,o){o=o||[];for(var i=t.bodies,n=0;n=m*d)return!1;d=m}return!0}var a=t("../math/vec2"),s=a.sub,c=a.add,h=a.dot,l=(t("../utils/Utils"),t("../utils/ContactEquationPool")),p=t("../utils/FrictionEquationPool"),u=t("../utils/TupleDictionary"),d=t("../equations/Equation"),f=(t("../equations/ContactEquation"),t("../equations/FrictionEquation"),t("../shapes/Circle")),v=t("../shapes/Convex"),y=t("../shapes/Shape"),m=(t("../objects/Body"),t("../shapes/Box"));e.exports=i;var g=a.fromValues(0,1),A=a.fromValues(0,0),b=a.fromValues(0,0),E=a.fromValues(0,0),B=a.fromValues(0,0),q=a.fromValues(0,0),P=a.fromValues(0,0),w=a.fromValues(0,0),S=a.fromValues(0,0),C=a.fromValues(0,0),L=a.fromValues(0,0),x=a.fromValues(0,0),F=a.fromValues(0,0),M=a.fromValues(0,0),I=a.fromValues(0,0),R=a.fromValues(0,0),V=a.fromValues(0,0),T=a.fromValues(0,0),N=a.fromValues(0,0),G=[],O=a.create(),U=a.create();i.prototype.bodiesOverlap=function(t,e){for(var o=O,i=U,n=0,r=t.shapes.length;n!==r;n++){var a=t.shapes[n];t.toWorldFrame(o,a.position);for(var s=0,c=e.shapes.length;s!==c;s++){var h=e.shapes[s];if(e.toWorldFrame(i,h.position),this[a.type|h.type](t,a,o,a.angle+t.angle,e,h,i,h.angle+e.angle,!0))return!0}}return!1},i.prototype.collidedLastStep=function(t,e){var o=0|t.id,i=0|e.id;return!!this.collidingBodiesLastStep.get(o,i)},i.prototype.reset=function(){this.collidingBodiesLastStep.reset();for(var t=this.contactEquations,e=t.length;e--;){var o=t[e],i=o.bodyA.id,n=o.bodyB.id;this.collidingBodiesLastStep.set(i,n,!0)}for(var r=this.contactEquations,a=this.frictionEquations,s=0;sv;v++){a.set(u,(0===v?-1:1)*e.length/2,0),a.rotate(u,u,i),a.add(u,u,o);for(var y=0;2>y;y++){a.set(d,(0===y?-1:1)*s.length/2,0),a.rotate(d,d,h),a.add(d,d,c),this.enableFrictionReduction&&(p=this.enableFriction,this.enableFriction=!1);var m=this.circleCircle(t,e,u,i,r,s,d,h,l,e.radius,s.radius);if(this.enableFrictionReduction&&(this.enableFriction=p),l&&m)return!0;f+=m}}this.enableFrictionReduction&&(p=this.enableFriction,this.enableFriction=!1);var g=X;n(g,e);var A=this.convexCapsule(t,g,o,i,r,s,c,h,l);if(this.enableFrictionReduction&&(this.enableFriction=p),l&&A)return!0;if(f+=A,this.enableFrictionReduction){var p=this.enableFriction;this.enableFriction=!1}n(g,s);var b=this.convexCapsule(r,g,c,h,t,e,o,i,l);return this.enableFrictionReduction&&(this.enableFriction=p),l&&b?!0:(f+=b,this.enableFrictionReduction&&f&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(f)),f)},i.prototype[y.LINE|y.LINE]=i.prototype.lineLine=function(t,e,o,i,n,r,a,s,c){return c?!1:0},i.prototype[y.PLANE|y.LINE]=i.prototype.planeLine=function(t,e,o,i,n,r,l,p,u){var d=A,f=b,v=E,y=B,m=q,L=P,x=w,F=S,M=C,I=G,R=0;a.set(d,-r.length/2,0),a.set(f,r.length/2,0),a.rotate(v,d,p),a.rotate(y,f,p),c(v,v,l),c(y,y,l),a.copy(d,v),a.copy(f,y),s(m,f,d),a.normalize(L,m),a.rotate90cw(M,L),a.rotate(F,g,i),I[0]=d,I[1]=f;for(var V=0;VN){if(u)return!0;var O=this.createContactEquation(t,n,e,r);R++,a.copy(O.normalA,F),a.normalize(O.normalA,O.normalA),a.scale(x,F,N),s(O.contactPointA,T,x),s(O.contactPointA,O.contactPointA,t.position),s(O.contactPointB,T,l),c(O.contactPointB,O.contactPointB,l),s(O.contactPointB,O.contactPointB,n.position),this.contactEquations.push(O),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(O))}}return u?!1:(this.enableFrictionReduction||R&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(R)),R)},i.prototype[y.PARTICLE|y.CAPSULE]=i.prototype.particleCapsule=function(t,e,o,i,n,r,a,s,c){return this.circleLine(t,e,o,i,n,r,a,s,c,r.radius,0)},i.prototype[y.CIRCLE|y.LINE]=i.prototype.circleLine=function(t,e,o,i,n,r,l,p,u,d,f){var d=d||0,f="undefined"!=typeof f?f:e.radius,v=A,y=b,m=E,g=B,R=q,V=P,T=w,N=S,O=C,U=L,k=x,_=F,D=M,W=I,X=G;a.set(N,-r.length/2,0),a.set(O,r.length/2,0),a.rotate(U,N,p),a.rotate(k,O,p),c(U,U,l),c(k,k,l),a.copy(N,U),a.copy(O,k),s(V,O,N),a.normalize(T,V),a.rotate90cw(R,T),s(_,o,N);var j=h(_,R);s(g,N,l),s(D,o,l);var z=f+d;if(Math.abs(j)K&&H>Y){if(u)return!0;var Z=this.createContactEquation(t,n,e,r);return a.scale(Z.normalA,v,-1),a.normalize(Z.normalA,Z.normalA),a.scale(Z.contactPointA,Z.normalA,f),c(Z.contactPointA,Z.contactPointA,o),s(Z.contactPointA,Z.contactPointA,t.position),s(Z.contactPointB,m,l),c(Z.contactPointB,Z.contactPointB,l),s(Z.contactPointB,Z.contactPointB,n.position),this.contactEquations.push(Z),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(Z)),1}}X[0]=N,X[1]=O;for(var J=0;JD&&(a.copy(T,C),G=D,a.scale(S,g,D),a.add(S,S,C),N=!0)}}if(N){if(u)return!0;var W=this.createContactEquation(t,n,e,h);return a.sub(W.normalA,T,o),a.normalize(W.normalA,W.normalA),a.scale(W.contactPointA,W.normalA,d),c(W.contactPointA,W.contactPointA,o),s(W.contactPointA,W.contactPointA,t.position),s(W.contactPointB,S,l),c(W.contactPointB,W.contactPointB,l),s(W.contactPointB,W.contactPointB,n.position),this.contactEquations.push(W),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(W)),1}if(d>0)for(var U=0;UD&&(V=D,a.scale(F,g,D),a.add(F,F,o),a.copy(R,g),G=!0)}if(G){var W=this.createContactEquation(t,n,e,l);return a.scale(W.normalA,R,-1),a.normalize(W.normalA,W.normalA),a.set(W.contactPointA,0,0),c(W.contactPointA,W.contactPointA,o),s(W.contactPointA,W.contactPointA,t.position),s(W.contactPointB,F,p),c(W.contactPointB,W.contactPointB,p),s(W.contactPointB,W.contactPointB,n.position),this.contactEquations.push(W),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(W)),1}return 0},i.prototype[y.CIRCLE]=i.prototype.circleCircle=function(t,e,o,i,n,r,h,l,p,u,d){var f=A,u=u||e.radius,d=d||r.radius;s(f,o,h);var v=u+d;if(a.squaredLength(f)>Math.pow(v,2))return 0;if(p)return!0;var y=this.createContactEquation(t,n,e,r);return s(y.normalA,h,o),a.normalize(y.normalA,y.normalA),a.scale(y.contactPointA,y.normalA,u),a.scale(y.contactPointB,y.normalA,-d),c(y.contactPointA,y.contactPointA,o),s(y.contactPointA,y.contactPointA,t.position),c(y.contactPointB,y.contactPointB,h),s(y.contactPointB,y.contactPointB,n.position),this.contactEquations.push(y),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(y)),1},i.prototype[y.PLANE|y.CONVEX]=i.prototype[y.PLANE|y.BOX]=i.prototype.planeConvex=function(t,e,o,i,n,r,l,p,u){var d=A,f=b,v=E,y=0;a.rotate(f,g,i);for(var m=0;m!==r.vertices.length;m++){var B=r.vertices[m];if(a.rotate(d,B,p),c(d,d,l),s(v,d,o),h(v,f)<=0){if(u)return!0;y++;var q=this.createContactEquation(t,n,e,r);s(v,d,o),a.copy(q.normalA,f);var P=h(v,q.normalA);a.scale(v,q.normalA,P),s(q.contactPointB,d,n.position),s(q.contactPointA,d,v),s(q.contactPointA,q.contactPointA,t.position),this.contactEquations.push(q),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(q))}}return this.enableFrictionReduction&&this.enableFriction&&y&&this.frictionEquations.push(this.createFrictionFromAverage(y)),y},i.prototype[y.PARTICLE|y.PLANE]=i.prototype.particlePlane=function(t,e,o,i,n,r,c,l,p){var u=A,d=b;l=l||0,s(u,o,c),a.rotate(d,g,l);var f=h(u,d);if(f>0)return 0;if(p)return!0;var v=this.createContactEquation(n,t,r,e);return a.copy(v.normalA,d),a.scale(u,v.normalA,f),s(v.contactPointA,o,u),s(v.contactPointA,v.contactPointA,n.position),s(v.contactPointB,o,t.position),this.contactEquations.push(v),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(v)),1},i.prototype[y.CIRCLE|y.PARTICLE]=i.prototype.circleParticle=function(t,e,o,i,n,r,h,l,p){var u=A;if(s(u,h,o),a.squaredLength(u)>Math.pow(e.radius,2))return 0;if(p)return!0;var d=this.createContactEquation(t,n,e,r);return a.copy(d.normalA,u),a.normalize(d.normalA,d.normalA),a.scale(d.contactPointA,d.normalA,e.radius),c(d.contactPointA,d.contactPointA,o),s(d.contactPointA,d.contactPointA,t.position),s(d.contactPointB,h,n.position),this.contactEquations.push(d),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(d)),1};var H=new f({radius:1}),Z=a.create(),J=a.create();a.create(),i.prototype[y.PLANE|y.CAPSULE]=i.prototype.planeCapsule=function(t,e,o,i,n,r,s,h,l){var p=Z,u=J,d=H;a.set(p,-r.length/2,0),a.rotate(p,p,h),c(p,p,s),a.set(u,r.length/2,0),a.rotate(u,u,h),c(u,u,s),d.radius=r.radius;var f;this.enableFrictionReduction&&(f=this.enableFriction,this.enableFriction=!1);var v=this.circlePlane(n,d,p,0,t,e,o,i,l),y=this.circlePlane(n,d,u,0,t,e,o,i,l);if(this.enableFrictionReduction&&(this.enableFriction=f),l)return v||y;var m=v+y;return this.enableFrictionReduction&&m&&this.frictionEquations.push(this.createFrictionFromAverage(m)),m},i.prototype[y.CIRCLE|y.PLANE]=i.prototype.circlePlane=function(t,e,o,i,n,r,l,p,u){var d=t,f=e,v=o,y=n,m=l,B=p;B=B||0;var q=A,P=b,w=E;s(q,v,m),a.rotate(P,g,B);var S=h(P,q);if(S>f.radius)return 0;if(u)return!0;var C=this.createContactEquation(y,d,r,e);return a.copy(C.normalA,P),a.scale(C.contactPointB,C.normalA,-f.radius),c(C.contactPointB,C.contactPointB,v),s(C.contactPointB,C.contactPointB,d.position),a.scale(w,C.normalA,S),s(C.contactPointA,q,w),c(C.contactPointA,C.contactPointA,m),s(C.contactPointA,C.contactPointA,y.position),this.contactEquations.push(C),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(C)),1},i.prototype[y.CONVEX]=i.prototype[y.CONVEX|y.BOX]=i.prototype[y.BOX]=i.prototype.convexConvex=function(t,e,o,n,r,l,p,u,d,f){var v=A,y=b,m=E,g=B,P=q,L=w,x=S,F=C,M=0,f="number"==typeof f?f:0,I=i.findSeparatingAxis(e,o,n,l,p,u,v);if(!I)return 0;s(x,p,o),h(v,x)>0&&a.scale(v,v,-1);var R=i.getClosestEdge(e,n,v,!0),V=i.getClosestEdge(l,u,v);if(-1===R||-1===V)return 0;for(var T=0;2>T;T++){var N=R,G=V,O=e,U=l,k=o,_=p,D=n,W=u,X=t,j=r;if(0===T){var z;z=N,N=G,G=z,z=O,O=U,U=z,z=k,k=_,_=z,z=D,D=W,W=z,z=X,X=j,j=z}for(var Y=G;G+2>Y;Y++){var K=U.vertices[(Y+U.vertices.length)%U.vertices.length];a.rotate(y,K,W),c(y,y,_);for(var H=0,Z=N-1;N+2>Z;Z++){var J=O.vertices[(Z+O.vertices.length)%O.vertices.length],Q=O.vertices[(Z+1+O.vertices.length)%O.vertices.length];a.rotate(m,J,D),a.rotate(g,Q,D),c(m,m,k),c(g,g,k),s(P,g,m),a.rotate90cw(F,P),a.normalize(F,F),s(x,y,m);var $=h(F,x);(Z===N&&f>=$||Z!==N&&0>=$)&&H++}if(H>=3){if(d)return!0;var te=this.createContactEquation(X,j,O,U);M++;var J=O.vertices[N%O.vertices.length],Q=O.vertices[(N+1)%O.vertices.length];a.rotate(m,J,D),a.rotate(g,Q,D),c(m,m,k),c(g,g,k),s(P,g,m),a.rotate90cw(te.normalA,P),a.normalize(te.normalA,te.normalA),s(x,y,m);var $=h(te.normalA,x);a.scale(L,te.normalA,$),s(te.contactPointA,y,k),s(te.contactPointA,te.contactPointA,L),c(te.contactPointA,te.contactPointA,k),s(te.contactPointA,te.contactPointA,X.position),s(te.contactPointB,y,_),c(te.contactPointB,te.contactPointB,_),s(te.contactPointB,te.contactPointB,j.position),this.contactEquations.push(te),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(te))}}}return this.enableFrictionReduction&&this.enableFriction&&M&&this.frictionEquations.push(this.createFrictionFromAverage(M)),M};var Q=a.fromValues(0,0);i.projectConvexOntoAxis=function(t,e,o,i,n){var r,s,c=null,l=null,p=Q;a.rotate(p,i,-o);for(var u=0;uc)&&(c=s),(null===l||l>s)&&(l=s);if(l>c){var d=l;l=c,c=d}var f=h(e,i);a.set(n,l+f,c+f)};var $=a.fromValues(0,0),te=a.fromValues(0,0),ee=a.fromValues(0,0),oe=a.fromValues(0,0),ie=a.fromValues(0,0),ne=a.fromValues(0,0);i.findSeparatingAxis=function(t,e,o,n,r,c,h){var l=null,p=!1,u=!1,d=$,f=te,v=ee,y=oe,g=ie,A=ne;if(t instanceof m&&n instanceof m)for(var b=0;2!==b;b++){var E=t,B=o;1===b&&(E=n,B=c);for(var q=0;2!==q;q++){0===q?a.set(y,0,1):1===q&&a.set(y,1,0),0!==B&&a.rotate(y,y,B),i.projectConvexOntoAxis(t,e,o,y,g),i.projectConvexOntoAxis(n,r,c,y,A);var P=g,w=A,S=!1;g[0]>A[0]&&(w=g,P=A,S=!0);var C=w[0]-P[1];p=0>=C,(null===l||C>l)&&(a.copy(h,y),l=C,u=p)}}else for(var b=0;2!==b;b++){var E=t,B=o;1===b&&(E=n,B=c);for(var q=0;q!==E.vertices.length;q++){a.rotate(f,E.vertices[q],B),a.rotate(v,E.vertices[(q+1)%E.vertices.length],B),s(d,v,f),a.rotate90cw(y,d),a.normalize(y,y),i.projectConvexOntoAxis(t,e,o,y,g),i.projectConvexOntoAxis(n,r,c,y,A);var P=g,w=A,S=!1;g[0]>A[0]&&(w=g,P=A,S=!0);var C=w[0]-P[1];p=0>=C,(null===l||C>l)&&(a.copy(h,y),l=C,u=p)}}return u};var re=a.fromValues(0,0),ae=a.fromValues(0,0),se=a.fromValues(0,0);i.getClosestEdge=function(t,e,o,i){var n=re,r=ae,c=se;a.rotate(n,o,-e),i&&a.scale(n,n,-1);for(var l=-1,p=t.vertices.length,u=-1,d=0;d!==p;d++){s(r,t.vertices[(d+1)%p],t.vertices[d%p]),a.rotate90cw(c,r),a.normalize(c,c);var f=h(c,n);(-1===l||f>u)&&(l=d%p,u=f)}return l};var ce=a.create(),he=a.create(),le=a.create(),pe=a.create(),ue=a.create(),de=a.create(),fe=a.create();i.prototype[y.CIRCLE|y.HEIGHTFIELD]=i.prototype.circleHeightfield=function(t,e,o,i,n,r,h,l,p,u){var d=r.heights,u=u||e.radius,f=r.elementWidth,v=he,y=ce,m=ue,g=fe,A=de,b=le,E=pe,B=Math.floor((o[0]-u-h[0])/f),q=Math.ceil((o[0]+u-h[0])/f);0>B&&(B=0),q>=d.length&&(q=d.length-1);for(var P=d[B],w=d[q],S=B;q>S;S++)d[S]P&&(P=d[S]);if(o[1]-u>P)return p?!1:0;for(var C=!1,S=B;q>S;S++){a.set(b,S*f,d[S]),a.set(E,(S+1)*f,d[S+1]),a.add(b,b,h),a.add(E,E,h),a.sub(A,E,b),a.rotate(A,A,Math.PI/2),a.normalize(A,A),a.scale(y,A,-u),a.add(y,y,o),a.sub(v,y,b);var L=a.dot(v,A);if(y[0]>=b[0]&&y[0]=L){if(p)return!0;C=!0,a.scale(v,A,-L),a.add(m,y,v),a.copy(g,A);var x=this.createContactEquation(n,t,r,e);a.copy(x.normalA,g),a.scale(x.contactPointB,x.normalA,-u),c(x.contactPointB,x.contactPointB,o),s(x.contactPointB,x.contactPointB,t.position),a.copy(x.contactPointA,m),a.sub(x.contactPointA,x.contactPointA,n.position),this.contactEquations.push(x),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(x))}}if(C=!1,u>0)for(var S=B;q>=S;S++)if(a.set(b,S*f,d[S]),a.add(b,b,h),a.sub(v,o,b),a.squaredLength(v)y&&(y=0),m>=l.length&&(m=l.length-1);for(var g=l[y],A=l[m],b=y;m>b;b++)l[b]g&&(g=l[b]);if(t.aabb.lowerBound[1]>g)return h?!1:0;for(var E=0,b=y;m>b;b++){a.set(u,b*p,l[b]),a.set(d,(b+1)*p,l[b+1]),a.add(u,u,s),a.add(d,d,s);var B=100;a.set(f,.5*(d[0]+u[0]),.5*(d[1]+u[1]-B)),a.sub(v.vertices[0],d,f),a.sub(v.vertices[1],u,f),a.copy(v.vertices[2],v.vertices[1]),a.copy(v.vertices[3],v.vertices[0]),v.vertices[2][1]-=B,v.vertices[3][1]-=B,E+=this.convexConvex(t,e,o,i,n,v,f,0,h)}return E}},{"../equations/ContactEquation":21,"../equations/Equation":22,"../equations/FrictionEquation":23,"../math/vec2":30,"../objects/Body":31,"../shapes/Box":37,"../shapes/Circle":39,"../shapes/Convex":40,"../shapes/Shape":45,"../utils/ContactEquationPool":48,"../utils/FrictionEquationPool":49,"../utils/TupleDictionary":56,"../utils/Utils":57}],11:[function(t,e,o){function i(t){t=t||{},this.from=t.from?r.fromValues(t.from[0],t.from[1]):r.create(),this.to=t.to?r.fromValues(t.to[0],t.to[1]):r.create(),this.checkCollisionResponse=void 0!==t.checkCollisionResponse?t.checkCollisionResponse:!0,this.skipBackfaces=!!t.skipBackfaces,this.collisionMask=void 0!==t.collisionMask?t.collisionMask:-1,this.collisionGroup=void 0!==t.collisionGroup?t.collisionGroup:-1,this.mode=void 0!==t.mode?t.mode:i.ANY,this.callback=t.callback||function(t){},this.direction=r.create(),this.length=1,this.update()}function n(t,e,o){r.sub(s,o,t);var i=r.dot(s,e);return r.scale(c,e,i),r.add(c,c,t),r.squaredDistance(o,c)}e.exports=i;var r=t("../math/vec2");t("../collision/RaycastResult"),t("../shapes/Shape"),t("../collision/AABB"),i.prototype.constructor=i,i.CLOSEST=1,i.ANY=2,i.ALL=4,i.prototype.update=function(){var t=this.direction;r.sub(t,this.to,this.from),this.length=r.length(t),r.normalize(t,t)},i.prototype.intersectBodies=function(t,e){for(var o=0,i=e.length;!t.shouldStop(this)&&i>o;o++){var n=e[o],r=n.getAABB();(r.overlapsRay(this)>=0||r.containsPoint(this.from))&&this.intersectBody(t,n)}};var a=r.create();i.prototype.intersectBody=function(t,e){var o=this.checkCollisionResponse;if(!o||e.collisionResponse)for(var i=a,n=0,s=e.shapes.length;s>n;n++){var c=e.shapes[n];if((!o||c.collisionResponse)&&0!==(this.collisionGroup&c.collisionMask)&&0!==(c.collisionGroup&this.collisionMask)){r.rotate(i,c.position,e.angle),r.add(i,i,e.position);var h=c.angle+e.angle;if(this.intersectShape(t,c,h,i,e),t.shouldStop(this))break}}},i.prototype.intersectShape=function(t,e,o,i,r){var a=this.from,s=n(a,this.direction,i);s>e.boundingRadius*e.boundingRadius||(this._currentBody=r,this._currentShape=e,e.raycast(t,this,i,o),this._currentBody=this._currentShape=null)},i.prototype.getAABB=function(t){var e=this.to,o=this.from;r.set(t.lowerBound,Math.min(e[0],o[0]),Math.min(e[1],o[1])),r.set(t.upperBound,Math.max(e[0],o[0]),Math.max(e[1],o[1]))},r.create(),i.prototype.reportIntersection=function(t,e,o,n){var a=(this.from,this.to,this._currentShape),s=this._currentBody;if(!(this.skipBackfaces&&r.dot(o,this.direction)>0))switch(this.mode){case i.ALL:t.set(o,a,s,e,n),this.callback(t);break;case i.CLOSEST:(eo;o++){for(var n=t[o],r=o-1;r>=0&&!(t[r].aabb.lowerBound[e]<=n.aabb.lowerBound[e]);r--)t[r+1]=t[r];t[r+1]=n}return t},i.prototype.sortList=function(){var t=this.axisList,e=this.axisIndex;i.sortAxisList(t,e)},i.prototype.getCollisionPairs=function(t){var e=this.axisList,o=this.result,i=this.axisIndex;o.length=0;for(var n=e.length;n--;){var a=e[n];a.aabbNeedsUpdate&&a.updateAABB()}this.sortList();for(var s=0,c=0|e.length;s!==c;s++)for(var h=e[s],l=s+1;c>l;l++){var p=e[l],u=p.aabb.lowerBound[i]<=h.aabb.upperBound[i];if(!u)break;r.canCollide(h,p)&&this.boundingVolumeCheck(h,p)&&o.push(h,p)}return o},i.prototype.aabbQuery=function(t,e,o){o=o||[],this.sortList();var i=this.axisIndex,n="x";1===i&&(n="y"),2===i&&(n="z");for(var r=this.axisList,a=(e.lowerBound[n],e.upperBound[n],0);athis.upperLimit&&(r.maxForce=0,r.minForce=-this.maxForce,this.distance=this.upperLimit,p=!0),this.lowerLimitEnabled&&this.positiono)s.scale(n.normalA,h,-1),s.sub(n.contactPointA,l,a.position),s.sub(n.contactPointB,p,c.position),s.scale(f,h,o),s.add(n.contactPointA,n.contactPointA,f),-1===t.indexOf(n)&&t.push(n);else{var b=t.indexOf(n);-1!==b&&t.splice(b,1)}if(this.lowerLimitEnabled&&i>g)s.scale(r.normalA,h,1),s.sub(r.contactPointA,l,a.position),s.sub(r.contactPointB,p,c.position),s.scale(f,h,i),s.sub(r.contactPointB,r.contactPointB,f),-1===t.indexOf(r)&&t.push(r);else{var b=t.indexOf(r);-1!==b&&t.splice(b,1)}},i.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)},i.prototype.disableMotor=function(){if(this.motorEnabled){var t=this.equations.indexOf(this.motorEquation);this.equations.splice(t,1),this.motorEnabled=!1}},i.prototype.setLimits=function(t,e){"number"==typeof t?(this.lowerLimit=t,this.lowerLimitEnabled=!0):(this.lowerLimit=t,this.lowerLimitEnabled=!1),"number"==typeof e?(this.upperLimit=e,this.upperLimitEnabled=!0):(this.upperLimit=e,this.upperLimitEnabled=!1)}},{"../equations/ContactEquation":21,"../equations/Equation":22,"../equations/RotationalLockEquation":24,"../math/vec2":30,"./Constraint":14}],19:[function(t,e,o){function i(t,e,o){o=o||{},n.call(this,t,e,n.REVOLUTE,o);var i=this.maxForce="undefined"!=typeof o.maxForce?o.maxForce:Number.MAX_VALUE;this.pivotA=c.create(),this.pivotB=c.create(),o.worldPivot?(c.sub(this.pivotA,o.worldPivot,t.position),c.sub(this.pivotB,o.worldPivot,e.position),c.rotate(this.pivotA,this.pivotA,-t.angle),c.rotate(this.pivotB,this.pivotB,-e.angle)):(c.copy(this.pivotA,o.localPivotA),c.copy(this.pivotB,o.localPivotB));var f=this.equations=[new r(t,e,-i,i),new r(t,e,-i,i)],v=f[0],y=f[1],m=this;v.computeGq=function(){return c.rotate(h,m.pivotA,t.angle),c.rotate(l,m.pivotB,e.angle),c.add(d,e.position,l),c.sub(d,d,t.position),c.sub(d,d,h),c.dot(d,p)},y.computeGq=function(){return c.rotate(h,m.pivotA,t.angle),c.rotate(l,m.pivotB,e.angle),c.add(d,e.position,l),c.sub(d,d,t.position),c.sub(d,d,h),c.dot(d,u)},y.minForce=v.minForce=-i,y.maxForce=v.maxForce=i,this.motorEquation=new a(t,e),this.motorEnabled=!1,this.angle=0,this.lowerLimitEnabled=!1,this.upperLimitEnabled=!1,this.lowerLimit=0,this.upperLimit=0,this.upperLimitEquation=new s(t,e),this.lowerLimitEquation=new s(t,e),this.upperLimitEquation.minForce=0,this.lowerLimitEquation.maxForce=0}var n=t("./Constraint"),r=t("../equations/Equation"),a=t("../equations/RotationalVelocityEquation"),s=t("../equations/RotationalLockEquation"),c=t("../math/vec2");e.exports=i;var h=c.create(),l=c.create(),p=c.fromValues(1,0),u=c.fromValues(0,1),d=c.create();i.prototype=new n,i.prototype.constructor=i,i.prototype.setLimits=function(t,e){"number"==typeof t?(this.lowerLimit=t,this.lowerLimitEnabled=!0):(this.lowerLimit=t,this.lowerLimitEnabled=!1),"number"==typeof e?(this.upperLimit=e,this.upperLimitEnabled=!0):(this.upperLimit=e,this.upperLimitEnabled=!1)},i.prototype.update=function(){var t=this.bodyA,e=this.bodyB,o=this.pivotA,i=this.pivotB,n=this.equations,r=(n[0],n[1],n[0]),a=n[1],s=this.upperLimit,d=this.lowerLimit,f=this.upperLimitEquation,v=this.lowerLimitEquation,y=this.angle=e.angle-t.angle;if(this.upperLimitEnabled&&y>s)f.angle=s,-1===n.indexOf(f)&&n.push(f);else{var m=n.indexOf(f);-1!==m&&n.splice(m,1)}if(this.lowerLimitEnabled&&d>y)v.angle=d,-1===n.indexOf(v)&&n.push(v);else{var m=n.indexOf(v);-1!==m&&n.splice(m,1)}c.rotate(h,o,t.angle),c.rotate(l,i,e.angle),r.G[0]=-1,r.G[1]=0,r.G[2]=-c.crossLength(h,p),r.G[3]=1,r.G[4]=0,r.G[5]=c.crossLength(l,p),a.G[0]=0,a.G[1]=-1,a.G[2]=-c.crossLength(h,u),a.G[3]=0,a.G[4]=1,a.G[5]=c.crossLength(l,u)},i.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)},i.prototype.disableMotor=function(){if(this.motorEnabled){var t=this.equations.indexOf(this.motorEquation);this.equations.splice(t,1),this.motorEnabled=!1}},i.prototype.motorIsEnabled=function(){return!!this.motorEnabled},i.prototype.setMotorSpeed=function(t){if(this.motorEnabled){var e=this.equations.indexOf(this.motorEquation);this.equations[e].relativeVelocity=t}},i.prototype.getMotorSpeed=function(){return this.motorEnabled?this.motorEquation.relativeVelocity:!1}},{"../equations/Equation":22,"../equations/RotationalLockEquation":24,"../equations/RotationalVelocityEquation":25,"../math/vec2":30,"./Constraint":14}],20:[function(t,e,o){function i(t,e,o){o=o||{},n.call(this,t,e,-Number.MAX_VALUE,Number.MAX_VALUE),this.angle=o.angle||0,this.ratio="number"==typeof o.ratio?o.ratio:1,this.setRatio(this.ratio)}var n=t("./Equation");t("../math/vec2"),e.exports=i,i.prototype=new n,i.prototype.constructor=i,i.prototype.computeGq=function(){return this.ratio*this.bodyA.angle-this.bodyB.angle+this.angle},i.prototype.setRatio=function(t){var e=this.G;e[2]=t,e[5]=-1,this.ratio=t},i.prototype.setMaxTorque=function(t){this.maxForce=t,this.minForce=-t}},{"../math/vec2":30,"./Equation":22}],21:[function(t,e,o){function i(t,e){n.call(this,t,e,0,Number.MAX_VALUE),this.contactPointA=r.create(),this.penetrationVec=r.create(),this.contactPointB=r.create(),this.normalA=r.create(),this.restitution=0,this.firstImpact=!1,this.shapeA=null,this.shapeB=null}var n=t("./Equation"),r=t("../math/vec2");e.exports=i,i.prototype=new n,i.prototype.constructor=i,i.prototype.computeB=function(t,e,o){var i=this.bodyA,n=this.bodyB,a=this.contactPointA,s=this.contactPointB,c=i.position,h=n.position,l=this.penetrationVec,p=this.normalA,u=this.G,d=r.crossLength(a,p),f=r.crossLength(s,p);u[0]=-p[0],u[1]=-p[1],u[2]=-d,u[3]=p[0],u[4]=p[1],u[5]=f,r.add(l,h,s),r.sub(l,l,c),r.sub(l,l,a);var v,y;this.firstImpact&&0!==this.restitution?(y=0,v=1/e*(1+this.restitution)*this.computeGW()):(y=r.dot(p,l)+this.offset,v=this.computeGW());var m=this.computeGiMf(),g=-y*t-v*e-o*m;return g}},{"../math/vec2":30,"./Equation":22}],22:[function(t,e,o){function i(t,e,o,n){this.minForce="undefined"==typeof o?-Number.MAX_VALUE:o,this.maxForce="undefined"==typeof n?Number.MAX_VALUE:n,this.bodyA=t,this.bodyB=e,this.stiffness=i.DEFAULT_STIFFNESS,this.relaxation=i.DEFAULT_RELAXATION,this.G=new r.ARRAY_TYPE(6);for(var a=0;6>a;a++)this.G[a]=0;this.offset=0,this.a=0,this.b=0,this.epsilon=0,this.timeStep=1/60,this.needsUpdate=!0,this.multiplier=0,this.relativeVelocity=0,this.enabled=!0}e.exports=i;var n=t("../math/vec2"),r=t("../utils/Utils");t("../objects/Body"),i.prototype.constructor=i,i.DEFAULT_STIFFNESS=1e6,i.DEFAULT_RELAXATION=4,i.prototype.update=function(){var t=this.stiffness,e=this.relaxation,o=this.timeStep;this.a=4/(o*(1+4*e)),this.b=4*e/(1+4*e),this.epsilon=4/(o*o*t*(1+4*e)),this.needsUpdate=!1},i.prototype.gmult=function(t,e,o,i,n){return t[0]*e[0]+t[1]*e[1]+t[2]*o+t[3]*i[0]+t[4]*i[1]+t[5]*n},i.prototype.computeB=function(t,e,o){var i=this.computeGW(),n=this.computeGq(),r=this.computeGiMf();return-n*t-i*e-r*o};var a=n.create(),s=n.create();i.prototype.computeGq=function(){var t=this.G,e=this.bodyA,o=this.bodyB,i=(e.position,o.position,e.angle),n=o.angle;return this.gmult(t,a,i,s,n)+this.offset},i.prototype.computeGW=function(){var t=this.G,e=this.bodyA,o=this.bodyB,i=e.velocity,n=o.velocity,r=e.angularVelocity,a=o.angularVelocity;return this.gmult(t,i,r,n,a)+this.relativeVelocity},i.prototype.computeGWlambda=function(){var t=this.G,e=this.bodyA,o=this.bodyB,i=e.vlambda,n=o.vlambda,r=e.wlambda,a=o.wlambda;return this.gmult(t,i,r,n,a)};var c=n.create(),h=n.create();i.prototype.computeGiMf=function(){var t=this.bodyA,e=this.bodyB,o=t.force,i=t.angularForce,r=e.force,a=e.angularForce,s=t.invMassSolve,l=e.invMassSolve,p=t.invInertiaSolve,u=e.invInertiaSolve,d=this.G;return n.scale(c,o,s),n.multiply(c,t.massMultiplier,c),n.scale(h,r,l),n.multiply(h,e.massMultiplier,h),this.gmult(d,c,i*p,h,a*u)},i.prototype.computeGiMGt=function(){var t=this.bodyA,e=this.bodyB,o=t.invMassSolve,i=e.invMassSolve,n=t.invInertiaSolve,r=e.invInertiaSolve,a=this.G;return a[0]*a[0]*o*t.massMultiplier[0]+a[1]*a[1]*o*t.massMultiplier[1]+a[2]*a[2]*n+a[3]*a[3]*i*e.massMultiplier[0]+a[4]*a[4]*i*e.massMultiplier[1]+a[5]*a[5]*r};var l=n.create(),p=n.create(),u=n.create();n.create(),n.create(),n.create(),i.prototype.addToWlambda=function(t){var e=this.bodyA,o=this.bodyB,i=l,r=p,a=u,s=e.invMassSolve,c=o.invMassSolve,h=e.invInertiaSolve,d=o.invInertiaSolve,f=this.G;r[0]=f[0],r[1]=f[1],a[0]=f[3],a[1]=f[4],n.scale(i,r,s*t),n.multiply(i,i,e.massMultiplier),n.add(e.vlambda,e.vlambda,i),e.wlambda+=h*f[2]*t,n.scale(i,a,c*t),n.multiply(i,i,o.massMultiplier),n.add(o.vlambda,o.vlambda,i),o.wlambda+=d*f[5]*t},i.prototype.computeInvC=function(t){return 1/(this.computeGiMGt()+t)}},{"../math/vec2":30,"../objects/Body":31,"../utils/Utils":57}],23:[function(t,e,o){function i(t,e,o){r.call(this,t,e,-o,o),this.contactPointA=n.create(),this.contactPointB=n.create(),this.t=n.create(),this.contactEquations=[],this.shapeA=null,this.shapeB=null,this.frictionCoefficient=.3}var n=t("../math/vec2"),r=t("./Equation");t("../utils/Utils"),e.exports=i,i.prototype=new r,i.prototype.constructor=i,i.prototype.setSlipForce=function(t){this.maxForce=t,this.minForce=-t},i.prototype.getSlipForce=function(){return this.maxForce},i.prototype.computeB=function(t,e,o){var i=(this.bodyA,this.bodyB,this.contactPointA),r=this.contactPointB,a=this.t,s=this.G;s[0]=-a[0],s[1]=-a[1],s[2]=-n.crossLength(i,a),s[3]=a[0],s[4]=a[1],s[5]=n.crossLength(r,a);var c=this.computeGW(),h=this.computeGiMf(),l=-c*e-o*h;return l}},{"../math/vec2":30,"../utils/Utils":57,"./Equation":22}],24:[function(t,e,o){function i(t,e,o){o=o||{},n.call(this,t,e,-Number.MAX_VALUE,Number.MAX_VALUE),this.angle=o.angle||0;var i=this.G;i[2]=1,i[5]=-1}var n=t("./Equation"),r=t("../math/vec2");e.exports=i,i.prototype=new n,i.prototype.constructor=i;var a=r.create(),s=r.create(),c=r.fromValues(1,0),h=r.fromValues(0,1);i.prototype.computeGq=function(){return r.rotate(a,c,this.bodyA.angle+this.angle),r.rotate(s,h,this.bodyB.angle),r.dot(a,s)}},{"../math/vec2":30,"./Equation":22}],25:[function(t,e,o){function i(t,e){n.call(this,t,e,-Number.MAX_VALUE,Number.MAX_VALUE),this.relativeVelocity=1,this.ratio=1}var n=t("./Equation");t("../math/vec2"),e.exports=i,i.prototype=new n,i.prototype.constructor=i,i.prototype.computeB=function(t,e,o){var i=this.G;i[2]=-1,i[5]=this.ratio;var n=this.computeGiMf(),r=this.computeGW(),a=-r*e-o*n;return a}},{"../math/vec2":30,"./Equation":22}],26:[function(t,e,o){var i=function(){};e.exports=i,i.prototype={constructor:i,on:function(t,e,o){e.context=o||this,void 0===this._listeners&&(this._listeners={});var i=this._listeners;return void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e),this},has:function(t,e){if(void 0===this._listeners)return!1;var o=this._listeners;if(e){if(void 0!==o[t]&&-1!==o[t].indexOf(e))return!0}else if(void 0!==o[t])return!0;return!1},off:function(t,e){if(void 0===this._listeners)return this;var o=this._listeners,i=o[t].indexOf(e);return-1!==i&&o[t].splice(i,1),this},emit:function(t){if(void 0===this._listeners)return this;var e=this._listeners,o=e[t.type];if(void 0!==o){t.target=this;for(var i=0,n=o.length;n>i;i++){var r=o[i];r.call(r.context,t)}}return this}}},{}],27:[function(t,e,o){function i(t,e,o){if(o=o||{},!(t instanceof n&&e instanceof n))throw new Error("First two arguments must be Material instances.");this.id=i.idCounter++,this.materialA=t,this.materialB=e,this.friction="undefined"!=typeof o.friction?Number(o.friction):.3,this.restitution="undefined"!=typeof o.restitution?Number(o.restitution):0,this.stiffness="undefined"!=typeof o.stiffness?Number(o.stiffness):r.DEFAULT_STIFFNESS,this.relaxation="undefined"!=typeof o.relaxation?Number(o.relaxation):r.DEFAULT_RELAXATION,this.frictionStiffness="undefined"!=typeof o.frictionStiffness?Number(o.frictionStiffness):r.DEFAULT_STIFFNESS,this.frictionRelaxation="undefined"!=typeof o.frictionRelaxation?Number(o.frictionRelaxation):r.DEFAULT_RELAXATION,this.surfaceVelocity="undefined"!=typeof o.surfaceVelocity?Number(o.surfaceVelocity):0,this.contactSkinSize=.005}var n=t("./Material"),r=t("../equations/Equation");e.exports=i,i.idCounter=0},{"../equations/Equation":22,"./Material":28}],28:[function(t,e,o){function i(t){this.id=t||i.idCounter++}e.exports=i,i.idCounter=0},{}],29:[function(t,e,o){var i={};i.GetArea=function(t){if(t.length<6)return 0;for(var e=t.length-2,o=0,i=0;e>i;i+=2)o+=(t[i+2]-t[i])*(t[i+1]+t[i+3]);return o+=(t[0]-t[e])*(t[e+1]+t[1]),.5*-o},i.Triangulate=function(t){var e=t.length>>1;if(3>e)return[];for(var o=[],n=[],r=0;e>r;r++)n.push(r);for(var r=0,a=e;a>3;){var s=n[(r+0)%a],c=n[(r+1)%a],h=n[(r+2)%a],l=t[2*s],p=t[2*s+1],u=t[2*c],d=t[2*c+1],f=t[2*h],v=t[2*h+1],y=!1;if(i._convex(l,p,u,d,f,v)){y=!0;for(var m=0;a>m;m++){var g=n[m];if(g!=s&&g!=c&&g!=h&&i._PointInTriangle(t[2*g],t[2*g+1],l,p,u,d,f,v)){y=!1;break}}}if(y)o.push(s,c,h),n.splice((r+1)%a,1),a--,r=0;else if(r++>3*a)break}return o.push(n[0],n[1],n[2]),o},i._PointInTriangle=function(t,e,o,i,n,r,a,s){var c=a-o,h=s-i,l=n-o,p=r-i,u=t-o,d=e-i,f=c*c+h*h,v=c*l+h*p,y=c*u+h*d,m=l*l+p*p,g=l*u+p*d,A=1/(f*m-v*v),b=(m*y-v*g)*A,E=(f*g-v*y)*A;return b>=0&&E>=0&&1>b+E},i._convex=function(t,e,o,i,n,r){return(e-i)*(n-o)+(o-t)*(r-i)>=0},e.exports=i},{}],30:[function(t,e,o){var i=e.exports={},n=t("../utils/Utils");i.crossLength=function(t,e){return t[0]*e[1]-t[1]*e[0]},i.crossVZ=function(t,e,o){return i.rotate(t,e,-Math.PI/2),i.scale(t,t,o),t},i.crossZV=function(t,e,o){return i.rotate(t,o,Math.PI/2),i.scale(t,t,e),t},i.rotate=function(t,e,o){if(0!==o){var i=Math.cos(o),n=Math.sin(o),r=e[0],a=e[1];t[0]=i*r-n*a,t[1]=n*r+i*a}else t[0]=e[0],t[1]=e[1]},i.rotate90cw=function(t,e){var o=e[0],i=e[1];t[0]=i,t[1]=-o},i.toLocalFrame=function(t,e,o,n){i.copy(t,e),i.sub(t,t,o),i.rotate(t,t,-n)},i.toGlobalFrame=function(t,e,o,n){i.copy(t,e),i.rotate(t,t,n),i.add(t,t,o)},i.vectorToLocalFrame=function(t,e,o){i.rotate(t,e,-o)},i.vectorToGlobalFrame=function(t,e,o){i.rotate(t,e,o)},i.centroid=function(t,e,o,n){return i.add(t,e,o),i.add(t,t,n),i.scale(t,t,1/3),t},i.create=function(){var t=new n.ARRAY_TYPE(2);return t[0]=0,t[1]=0,t},i.clone=function(t){var e=new n.ARRAY_TYPE(2);return e[0]=t[0],e[1]=t[1],e},i.fromValues=function(t,e){var o=new n.ARRAY_TYPE(2);return o[0]=t,o[1]=e,o},i.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},i.set=function(t,e,o){return t[0]=e,t[1]=o,t},i.add=function(t,e,o){return t[0]=e[0]+o[0],t[1]=e[1]+o[1],t},i.subtract=function(t,e,o){return t[0]=e[0]-o[0],t[1]=e[1]-o[1],t},i.sub=i.subtract,i.multiply=function(t,e,o){return t[0]=e[0]*o[0],t[1]=e[1]*o[1],t},i.mul=i.multiply,i.divide=function(t,e,o){return t[0]=e[0]/o[0],t[1]=e[1]/o[1],t},i.div=i.divide,i.scale=function(t,e,o){return t[0]=e[0]*o,t[1]=e[1]*o,t},i.distance=function(t,e){var o=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(o*o+i*i)},i.dist=i.distance,i.squaredDistance=function(t,e){var o=e[0]-t[0],i=e[1]-t[1];return o*o+i*i},i.sqrDist=i.squaredDistance,i.length=function(t){var e=t[0],o=t[1];return Math.sqrt(e*e+o*o)},i.len=i.length,i.squaredLength=function(t){var e=t[0],o=t[1];return e*e+o*o},i.sqrLen=i.squaredLength,i.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},i.normalize=function(t,e){var o=e[0],i=e[1],n=o*o+i*i;return n>0&&(n=1/Math.sqrt(n),t[0]=e[0]*n,t[1]=e[1]*n),t},i.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},i.str=function(t){return"vec2("+t[0]+", "+t[1]+")"},i.lerp=function(t,e,o,i){var n=e[0],r=e[1];return t[0]=n+i*(o[0]-n),t[1]=r+i*(o[1]-r),t},i.reflect=function(t,e,o){var i=e[0]*o[0]+e[1]*o[1];t[0]=e[0]-2*o[0]*i,t[1]=e[1]-2*o[1]*i},i.getLineSegmentsIntersection=function(t,e,o,n,r){var a=i.getLineSegmentsIntersectionFraction(e,o,n,r);return 0>a?!1:(t[0]=e[0]+a*(o[0]-e[0]),t[1]=e[1]+a*(o[1]-e[1]),!0)},i.getLineSegmentsIntersectionFraction=function(t,e,o,i){var n,r,a=e[0]-t[0],s=e[1]-t[1],c=i[0]-o[0],h=i[1]-o[1];return n=(-s*(t[0]-o[0])+a*(t[1]-o[1]))/(-c*s+a*h),r=(c*(t[1]-o[1])-h*(t[0]-o[0]))/(-c*s+a*h),n>=0&&1>=n&&r>=0&&1>=r?r:-1}},{"../utils/Utils":57}],31:[function(t,e,o){function i(t){t=t||{},l.call(this),this.id=t.id||++i._idCounter,this.world=null,this.shapes=[],this.mass=t.mass||0,this.invMass=0,this.inertia=0,this.invInertia=0,this.invMassSolve=0,this.invInertiaSolve=0,this.fixedRotation=!!t.fixedRotation,this.fixedX=!!t.fixedX,this.fixedY=!!t.fixedY,this.massMultiplier=n.create(),this.position=n.fromValues(0,0),t.position&&n.copy(this.position,t.position),this.interpolatedPosition=n.fromValues(0,0),this.interpolatedAngle=0,this.previousPosition=n.fromValues(0,0),this.previousAngle=0,this.velocity=n.fromValues(0,0),t.velocity&&n.copy(this.velocity,t.velocity),this.vlambda=n.fromValues(0,0),this.wlambda=0,this.angle=t.angle||0,this.angularVelocity=t.angularVelocity||0,this.force=n.create(),t.force&&n.copy(this.force,t.force),this.angularForce=t.angularForce||0,this.damping="number"==typeof t.damping?t.damping:.1,this.angularDamping="number"==typeof t.angularDamping?t.angularDamping:.1,this.type=i.STATIC,"undefined"!=typeof t.type?this.type=t.type:t.mass?this.type=i.DYNAMIC:this.type=i.STATIC,this.boundingRadius=0,this.aabb=new h,this.aabbNeedsUpdate=!0,this.allowSleep=void 0!==t.allowSleep?t.allowSleep:!0,this.wantsToSleep=!1,this.sleepState=i.AWAKE,this.sleepSpeedLimit=void 0!==t.sleepSpeedLimit?t.sleepSpeedLimit:.2,this.sleepTimeLimit=void 0!==t.sleepTimeLimit?t.sleepTimeLimit:1,this.gravityScale=void 0!==t.gravityScale?t.gravityScale:1,this.collisionResponse=void 0!==t.collisionResponse?t.collisionResponse:!0,this.idleTime=0,this.timeLastSleepy=0,this.ccdSpeedThreshold=void 0!==t.ccdSpeedThreshold?t.ccdSpeedThreshold:-1,this.ccdIterations=void 0!==t.ccdIterations?t.ccdIterations:10,this.concavePath=null,this._wakeUpAfterNarrowphase=!1,this.updateMassProperties() -}var n=t("../math/vec2"),r=t("poly-decomp"),a=t("../shapes/Convex"),s=t("../collision/RaycastResult"),c=t("../collision/Ray"),h=t("../collision/AABB"),l=t("../events/EventEmitter");e.exports=i,i.prototype=new l,i.prototype.constructor=i,i._idCounter=0,i.prototype.updateSolveMassProperties=function(){this.sleepState===i.SLEEPING||this.type===i.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve=0):(this.invMassSolve=this.invMass,this.invInertiaSolve=this.invInertia)},i.prototype.setDensity=function(t){var e=this.getArea();this.mass=e*t,this.updateMassProperties()},i.prototype.getArea=function(){for(var t=0,e=0;eo&&(o=a+s)}this.boundingRadius=o},i.prototype.addShape=function(t,e,o){if(t.body)throw new Error("A shape can only be added to one body.");t.body=this,e?n.copy(t.position,e):n.set(t.position,0,0),t.angle=o||0,this.shapes.push(t),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0},i.prototype.removeShape=function(t){var e=this.shapes.indexOf(t);return-1!==e?(this.shapes.splice(e,1),this.aabbNeedsUpdate=!0,t.body=null,!0):!1},i.prototype.updateMassProperties=function(){if(this.type===i.STATIC||this.type===i.KINEMATIC)this.mass=Number.MAX_VALUE,this.invMass=0,this.inertia=Number.MAX_VALUE,this.invInertia=0;else{var t=this.shapes,e=t.length,o=this.mass/e,r=0;if(this.fixedRotation)this.inertia=Number.MAX_VALUE,this.invInertia=0;else{for(var a=0;e>a;a++){var s=t[a],c=n.squaredLength(s.position),h=s.computeMomentOfInertia(o);r+=h+o*c}this.inertia=r,this.invInertia=r>0?1/r:0}this.invMass=1/this.mass,n.set(this.massMultiplier,this.fixedX?0:1,this.fixedY?0:1)}},n.create(),i.prototype.applyForce=function(t,e){if(n.add(this.force,this.force,t),e){var o=n.crossLength(e,t);this.angularForce+=o}};var d=n.create(),f=n.create(),v=n.create();i.prototype.applyForceLocal=function(t,e){e=e||v;var o=d,i=f;this.vectorToWorldFrame(o,t),this.vectorToWorldFrame(i,e),this.applyForce(o,i)};var y=n.create();i.prototype.applyImpulse=function(t,e){if(this.type===i.DYNAMIC){var o=y;if(n.scale(o,t,this.invMass),n.multiply(o,this.massMultiplier,o),n.add(this.velocity,o,this.velocity),e){var r=n.crossLength(e,t);r*=this.invInertia,this.angularVelocity+=r}}};var m=n.create(),g=n.create(),A=n.create();i.prototype.applyImpulseLocal=function(t,e){e=e||A;var o=m,i=g;this.vectorToWorldFrame(o,t),this.vectorToWorldFrame(i,e),this.applyImpulse(o,i)},i.prototype.toLocalFrame=function(t,e){n.toLocalFrame(t,e,this.position,this.angle)},i.prototype.toWorldFrame=function(t,e){n.toGlobalFrame(t,e,this.position,this.angle)},i.prototype.vectorToLocalFrame=function(t,e){n.vectorToLocalFrame(t,e,this.angle)},i.prototype.vectorToWorldFrame=function(t,e){n.vectorToGlobalFrame(t,e,this.angle)},i.prototype.fromPolygon=function(t,e){e=e||{};for(var o=this.shapes.length;o>=0;--o)this.removeShape(this.shapes[o]);var i=new r.Polygon;if(i.vertices=t,i.makeCCW(),"number"==typeof e.removeCollinearPoints&&i.removeCollinearPoints(e.removeCollinearPoints),"undefined"==typeof e.skipSimpleCheck&&!i.isSimple())return!1;this.concavePath=i.vertices.slice(0);for(var o=0;o=a?(this.idleTime=0,this.sleepState=i.AWAKE):(this.idleTime+=o,this.sleepState=i.SLEEPY),this.idleTime>this.sleepTimeLimit&&(e?this.wantsToSleep=!0:this.sleep())}},i.prototype.overlaps=function(t){return this.world.overlapKeeper.bodiesAreOverlapping(this,t)};var q=n.create(),P=n.create();i.prototype.integrate=function(t){var e=this.invMass,o=this.force,i=this.position,r=this.velocity;n.copy(this.previousPosition,this.position),this.previousAngle=this.angle,this.fixedRotation||(this.angularVelocity+=this.angularForce*this.invInertia*t),n.scale(q,o,t*e),n.multiply(q,this.massMultiplier,q),n.add(r,q,r),this.integrateToTimeOfImpact(t)||(n.scale(P,r,t),n.add(i,i,P),this.fixedRotation||(this.angle+=this.angularVelocity*t)),this.aabbNeedsUpdate=!0};var w=new s,S=new c({mode:c.ALL}),C=n.create(),L=n.create(),x=n.create(),F=n.create();i.prototype.integrateToTimeOfImpact=function(t){if(this.ccdSpeedThreshold<0||n.squaredLength(this.velocity)=h&&cm;m++){var g=this.radius*(2*m-1);r.set(f,-y,g),r.set(v,y,g),r.toGlobalFrame(f,f,o,i),r.toGlobalFrame(v,v,o,i);var A=r.getLineSegmentsIntersectionFraction(n,a,f,v);if(A>=0&&(r.rotate(d,p,i),r.scale(d,d,2*m-1),e.reportIntersection(t,A,d,-1),t.shouldStop(e)))return}for(var b=Math.pow(this.radius,2)+Math.pow(y,2),m=0;2>m;m++){r.set(f,y*(2*m-1),0),r.toGlobalFrame(f,f,o,i);var E=Math.pow(a[0]-n[0],2)+Math.pow(a[1]-n[1],2),B=2*((a[0]-n[0])*(n[0]-f[0])+(a[1]-n[1])*(n[1]-f[1])),q=Math.pow(n[0]-f[0],2)+Math.pow(n[1]-f[1],2)-Math.pow(this.radius,2),A=Math.pow(B,2)-4*E*q;if(!(0>A))if(0===A){if(r.lerp(u,n,a,A),r.squaredDistance(u,o)>b&&(r.sub(d,u,f),r.normalize(d,d),e.reportIntersection(t,A,d,-1),t.shouldStop(e)))return}else{var P=Math.sqrt(A),w=1/(2*E),S=(-B-P)*w,C=(-B+P)*w;if(S>=0&&1>=S&&(r.lerp(u,n,a,S),r.squaredDistance(u,o)>b&&(r.sub(d,u,f),r.normalize(d,d),e.reportIntersection(t,S,d,-1),t.shouldStop(e))))return;if(C>=0&&1>=C&&(r.lerp(u,n,a,C),r.squaredDistance(u,o)>b&&(r.sub(d,u,f),r.normalize(d,d),e.reportIntersection(t,C,d,-1),t.shouldStop(e))))return}}}},{"../math/vec2":30,"./Shape":45}],39:[function(t,e,o){function i(t){"number"==typeof arguments[0]&&(t={radius:arguments[0]},console.warn("The Circle constructor signature has changed. Please use the following format: new Circle({ radius: 1 })")),t=t||{},this.radius=t.radius||1,t.type=n.CIRCLE,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");e.exports=i,i.prototype=new n,i.prototype.constructor=i,i.prototype.computeMomentOfInertia=function(t){var e=this.radius;return t*e*e/2},i.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius},i.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius},i.prototype.computeAABB=function(t,e,o){var i=this.radius;r.set(t.upperBound,i,i),r.set(t.lowerBound,-i,-i),e&&(r.add(t.lowerBound,t.lowerBound,e),r.add(t.upperBound,t.upperBound,e))};var a=r.create(),s=r.create();i.prototype.raycast=function(t,e,o,i){var n=e.from,c=e.to,h=this.radius,l=Math.pow(c[0]-n[0],2)+Math.pow(c[1]-n[1],2),p=2*((c[0]-n[0])*(n[0]-o[0])+(c[1]-n[1])*(n[1]-o[1])),u=Math.pow(n[0]-o[0],2)+Math.pow(n[1]-o[1],2)-Math.pow(h,2),d=Math.pow(p,2)-4*l*u,f=a,v=s;if(!(0>d))if(0===d)r.lerp(f,n,c,d),r.sub(v,f,o),r.normalize(v,v),e.reportIntersection(t,d,v,-1);else{var y=Math.sqrt(d),m=1/(2*l),g=(-p-y)*m,A=(-p+y)*m;if(g>=0&&1>=g&&(r.lerp(f,n,c,g),r.sub(v,f,o),r.normalize(v,v),e.reportIntersection(t,g,v,-1),t.shouldStop(e)))return;A>=0&&1>=A&&(r.lerp(f,n,c,A),r.sub(v,f,o),r.normalize(v,v),e.reportIntersection(t,A,v,-1))}}},{"../math/vec2":30,"./Shape":45}],40:[function(t,e,o){function i(t){Array.isArray(arguments[0])&&(t={vertices:arguments[0],axes:arguments[1]},console.warn("The Convex constructor signature has changed. Please use the following format: new Convex({ vertices: [...], ... })")),t=t||{},this.vertices=[];for(var e=void 0!==t.vertices?t.vertices:[],o=0;on)&&(n=i),(null===a||a>i)&&(a=i);if(a>n){var h=a;a=n,n=h}r.set(e,a,n)},i.prototype.projectOntoWorldAxis=function(t,e,o,i){var n=c;this.projectOntoLocalAxis(t,i),0!==o?r.rotate(n,t,o):n=t;var a=r.dot(e,n);r.set(i,i[0]+a,i[1]+a)},i.prototype.updateTriangles=function(){this.triangles.length=0;for(var t=[],e=0;ea;n=a,a++){var s=this.vertices[n],c=this.vertices[a],h=Math.abs(r.crossLength(s,c)),l=r.dot(c,c)+r.dot(c,s)+r.dot(s,s);e+=h*l,o+=h}return t/6*(e/o)},i.prototype.updateBoundingRadius=function(){for(var t=this.vertices,e=0,o=0;o!==t.length;o++){var i=r.squaredLength(t[o]);i>e&&(e=i)}this.boundingRadius=Math.sqrt(e)},i.triangleArea=function(t,e,o){return.5*((e[0]-t[0])*(o[1]-t[1])-(o[0]-t[0])*(e[1]-t[1]))},i.prototype.updateArea=function(){this.updateTriangles(),this.area=0;for(var t=this.triangles,e=this.vertices,o=0;o!==t.length;o++){var n=t[o],r=e[n[0]],a=e[n[1]],s=e[n[2]],c=i.triangleArea(r,a,s);this.area+=c}},i.prototype.computeAABB=function(t,e,o){t.setFromPoints(this.vertices,e,o,0)};var f=r.create(),v=r.create(),y=r.create();i.prototype.raycast=function(t,e,o,i){var n=f,a=v,s=y,c=this.vertices;r.toLocalFrame(n,e.from,o,i),r.toLocalFrame(a,e.to,o,i);for(var h=c.length,l=0;h>l&&!t.shouldStop(e);l++){var p=c[l],u=c[(l+1)%h],d=r.getLineSegmentsIntersectionFraction(n,a,p,u);d>=0&&(r.sub(s,u,p),r.rotate(s,s,-Math.PI/2+i),r.normalize(s,s),e.reportIntersection(t,d,s,l))}}},{"../math/polyk":29,"../math/vec2":30,"./Shape":45,"poly-decomp":5}],41:[function(t,e,o){function i(t){if(Array.isArray(arguments[0])){if(t={heights:arguments[0]},"object"==typeof arguments[1])for(var e in arguments[1])t[e]=arguments[1][e];console.warn("The Heightfield constructor signature has changed. Please use the following format: new Heightfield({ heights: [...], ... })")}t=t||{},this.heights=t.heights?t.heights.slice(0):[],this.maxValue=t.maxValue||null,this.minValue=t.minValue||null,this.elementWidth=t.elementWidth||.1,(void 0===t.maxValue||void 0===t.minValue)&&this.updateMaxMinValues(),t.type=n.HEIGHTFIELD,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");t("../utils/Utils"),e.exports=i,i.prototype=new n,i.prototype.constructor=i,i.prototype.updateMaxMinValues=function(){for(var t=this.heights,e=t[0],o=t[0],i=0;i!==t.length;i++){var n=t[i];n>e&&(e=n),o>n&&(o=n)}this.maxValue=e,this.minValue=o},i.prototype.computeMomentOfInertia=function(t){return Number.MAX_VALUE},i.prototype.updateBoundingRadius=function(){this.boundingRadius=Number.MAX_VALUE},i.prototype.updateArea=function(){for(var t=this.heights,e=0,o=0;og){var A=m;m=g,g=A}for(var b=0;b=0&&(r.sub(u,f,d),r.rotate(u,u,i+Math.PI/2),r.normalize(u,u),e.reportIntersection(t,E,u,-1),t.shouldStop(e)))return}}},{"../math/vec2":30,"../utils/Utils":57,"./Shape":45}],42:[function(t,e,o){function i(t){"number"==typeof arguments[0]&&(t={length:arguments[0]},console.warn("The Line constructor signature has changed. Please use the following format: new Line({ length: 1, ... })")),t=t||{},this.length=t.length||1,t.type=n.LINE,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");e.exports=i,i.prototype=new n,i.prototype.constructor=i,i.prototype.computeMomentOfInertia=function(t){return t*Math.pow(this.length,2)/12},i.prototype.updateBoundingRadius=function(){this.boundingRadius=this.length/2};var a=[r.create(),r.create()];i.prototype.computeAABB=function(t,e,o){var i=this.length/2;r.set(a[0],-i,0),r.set(a[1],i,0),t.setFromPoints(a,e,o,0)};var s=(r.create(),r.create()),c=r.create(),h=r.create(),l=r.fromValues(0,1);i.prototype.raycast=function(t,e,o,i){var n=e.from,a=e.to,p=c,u=h,d=this.length/2;r.set(p,-d,0),r.set(u,d,0),r.toGlobalFrame(p,p,o,i),r.toGlobalFrame(u,u,o,i);var f=r.getLineSegmentsIntersectionFraction(p,u,n,a);if(f>=0){var v=s;r.rotate(v,l,i),e.reportIntersection(t,f,v,-1)}}},{"../math/vec2":30,"./Shape":45}],43:[function(t,e,o){function i(t){t=t||{},t.type=n.PARTICLE,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");e.exports=i,i.prototype=new n,i.prototype.constructor=i,i.prototype.computeMomentOfInertia=function(t){return 0},i.prototype.updateBoundingRadius=function(){this.boundingRadius=0},i.prototype.computeAABB=function(t,e,o){r.copy(t.lowerBound,e),r.copy(t.upperBound,e)}},{"../math/vec2":30,"./Shape":45}],44:[function(t,e,o){function i(t){t=t||{},t.type=n.PLANE,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");t("../utils/Utils"),e.exports=i,i.prototype=new n,i.prototype.constructor=i,i.prototype.computeMomentOfInertia=function(t){return 0},i.prototype.updateBoundingRadius=function(){this.boundingRadius=Number.MAX_VALUE},i.prototype.computeAABB=function(t,e,o){var i=o%(2*Math.PI),n=r.set,a=Number.MAX_VALUE,s=t.lowerBound,c=t.upperBound;0===i?(n(s,-a,-a),n(c,a,0)):i===Math.PI/2?(n(s,0,-a),n(c,a,a)):i===Math.PI?(n(s,-a,0),n(c,a,a)):i===3*Math.PI/2?(n(s,-a,-a),n(c,0,a)):(n(s,-a,-a),n(c,a,a)),r.add(s,s,e),r.add(c,c,e)},i.prototype.updateArea=function(){this.area=Number.MAX_VALUE};var a=r.create(),s=(r.create(),r.create(),r.create()),c=r.create();i.prototype.raycast=function(t,e,o,i){var n=e.from,h=e.to,l=e.direction,p=a,u=s,d=c;r.set(u,0,1),r.rotate(u,u,i),r.sub(d,n,o);var f=r.dot(d,u);r.sub(d,h,o);var v=r.dot(d,u);if(!(f*v>0||r.squaredDistance(n,h)=B*B)break}for(i.updateMultipliers(l,y,1/t),q=0;q!==p;q++){var w=l[q];if(w instanceof c){for(var S=0,C=0;C!==w.contactEquations.length;C++)S+=w.contactEquations[C].multiplier;S*=w.frictionCoefficient/w.contactEquations.length,w.maxForce=S,w.minForce=-S}}}for(o=0;o!==a;o++){for(B=0,q=0;q!==p;q++){E=l[q];var P=i.iterateEquation(q,E,E.epsilon,b,A,y,v,t,o);B+=Math.abs(P)}if(this.usedIterations++,u>=B*B)break}for(m=0;m!==f;m++)d[m].addConstraintVelocity();i.updateMultipliers(l,y,1/t)}},i.updateMultipliers=function(t,e,o){for(var i=t.length;i--;)t[i].multiplier=e[i]*o},i.iterateEquation=function(t,e,o,i,n,r,a,s,c){var h=i[t],l=n[t],p=r[t],u=e.computeGWlambda(),d=e.maxForce,f=e.minForce;a&&(h=0);var v=l*(h-u-o*p),y=p+v;return f*s>y?v=f*s-p:y>d*s&&(v=d*s-p),r[t]+=v,e.addToWlambda(v),v}},{"../equations/FrictionEquation":23,"../math/vec2":30,"../utils/Utils":57,"./Solver":47}],47:[function(t,e,o){function i(t,e){t=t||{},n.call(this),this.type=e,this.equations=[],this.equationSortFunction=t.equationSortFunction||!1}var n=(t("../utils/Utils"),t("../events/EventEmitter"));e.exports=i,i.prototype=new n,i.prototype.constructor=i,i.prototype.solve=function(t,e){throw new Error("Solver.solve should be implemented by subclasses!")};var r={bodies:[]};i.prototype.solveIsland=function(t,e){this.removeAllEquations(),e.equations.length&&(this.addEquations(e.equations),r.bodies.length=0,e.getBodies(r.bodies),r.bodies.length&&this.solve(t,r))},i.prototype.sortEquations=function(){this.equationSortFunction&&this.equations.sort(this.equationSortFunction)},i.prototype.addEquation=function(t){t.enabled&&this.equations.push(t)},i.prototype.addEquations=function(t){for(var e=0,o=t.length;e!==o;e++){var i=t[e];i.enabled&&this.equations.push(i)}},i.prototype.removeEquation=function(t){var e=this.equations.indexOf(t);-1!==e&&this.equations.splice(e,1)},i.prototype.removeAllEquations=function(){this.equations.length=0},i.GS=1,i.ISLAND=2},{"../events/EventEmitter":26,"../utils/Utils":57}],48:[function(t,e,o){function i(){r.apply(this,arguments)}var n=t("../equations/ContactEquation"),r=t("./Pool");e.exports=i,i.prototype=new r,i.prototype.constructor=i,i.prototype.create=function(){return new n},i.prototype.destroy=function(t){return t.bodyA=t.bodyB=null,this}},{"../equations/ContactEquation":21,"./Pool":55}],49:[function(t,e,o){function i(){r.apply(this,arguments)}var n=t("../equations/FrictionEquation"),r=t("./Pool");e.exports=i,i.prototype=new r,i.prototype.constructor=i,i.prototype.create=function(){return new n},i.prototype.destroy=function(t){return t.bodyA=t.bodyB=null,this}},{"../equations/FrictionEquation":23,"./Pool":55}],50:[function(t,e,o){function i(){r.apply(this,arguments)}var n=t("../world/IslandNode"),r=t("./Pool");e.exports=i,i.prototype=new r,i.prototype.constructor=i,i.prototype.create=function(){return new n},i.prototype.destroy=function(t){return t.reset(),this}},{"../world/IslandNode":60,"./Pool":55}],51:[function(t,e,o){function i(){r.apply(this,arguments)}var n=t("../world/Island"),r=t("./Pool");e.exports=i,i.prototype=new r,i.prototype.constructor=i,i.prototype.create=function(){return new n},i.prototype.destroy=function(t){return t.reset(),this}},{"../world/Island":58,"./Pool":55}],52:[function(t,e,o){function i(){this.overlappingShapesLastState=new n,this.overlappingShapesCurrentState=new n,this.recordPool=new r({size:16}),this.tmpDict=new n,this.tmpArray1=[]}var n=t("./TupleDictionary"),r=(t("./OverlapKeeperRecord"),t("./OverlapKeeperRecordPool"));t("./Utils"),e.exports=i,i.prototype.tick=function(){for(var t=this.overlappingShapesLastState,e=this.overlappingShapesCurrentState,o=t.keys.length;o--;){var i=t.keys[o],n=t.getByKey(i);e.getByKey(i),n&&this.recordPool.release(n)}t.reset(),t.copy(e),e.reset()},i.prototype.setOverlapping=function(t,e,o,i){var n=(this.overlappingShapesLastState,this.overlappingShapesCurrentState);if(!n.get(e.id,i.id)){var r=this.recordPool.get();r.set(t,e,o,i),n.set(e.id,i.id,r)}},i.prototype.getNewOverlaps=function(t){return this.getDiff(this.overlappingShapesLastState,this.overlappingShapesCurrentState,t)},i.prototype.getEndOverlaps=function(t){return this.getDiff(this.overlappingShapesCurrentState,this.overlappingShapesLastState,t)},i.prototype.bodiesAreOverlapping=function(t,e){for(var o=this.overlappingShapesCurrentState,i=o.keys.length;i--;){var n=o.keys[i],r=o.data[n];if(r.bodyA===t&&r.bodyB===e||r.bodyA===e&&r.bodyB===t)return!0}return!1},i.prototype.getDiff=function(t,e,o){var o=o||[],i=t,n=e;o.length=0;for(var r=n.keys.length;r--;){var a=n.keys[r],s=n.data[a];if(!s)throw new Error("Key "+a+" had no data!");var c=i.data[a];c||o.push(s)}return o},i.prototype.isNewOverlap=function(t,e){var o=0|t.id,i=0|e.id,n=this.overlappingShapesLastState,r=this.overlappingShapesCurrentState;return!n.get(o,i)&&!!r.get(o,i)},i.prototype.getNewBodyOverlaps=function(t){this.tmpArray1.length=0;var e=this.getNewOverlaps(this.tmpArray1);return this.getBodyDiff(e,t)},i.prototype.getEndBodyOverlaps=function(t){this.tmpArray1.length=0;var e=this.getEndOverlaps(this.tmpArray1);return this.getBodyDiff(e,t)},i.prototype.getBodyDiff=function(t,e){e=e||[];for(var o=this.tmpDict,i=t.length;i--;){var n=t[i];o.set(0|n.bodyA.id,0|n.bodyB.id,n)}for(i=o.keys.length;i--;){var n=o.getByKey(o.keys[i]);n&&e.push(n.bodyA,n.bodyB)}return o.reset(),e}},{"./OverlapKeeperRecord":53,"./OverlapKeeperRecordPool":54,"./TupleDictionary":56,"./Utils":57}],53:[function(t,e,o){function i(t,e,o,i){this.shapeA=e,this.shapeB=i,this.bodyA=t,this.bodyB=o}e.exports=i,i.prototype.set=function(t,e,o,n){i.call(this,t,e,o,n)}},{}],54:[function(t,e,o){function i(){r.apply(this,arguments)}var n=t("./OverlapKeeperRecord"),r=t("./Pool");e.exports=i,i.prototype=new r,i.prototype.constructor=i,i.prototype.create=function(){return new n},i.prototype.destroy=function(t){return t.bodyA=t.bodyB=t.shapeA=t.shapeB=null,this}},{"./OverlapKeeperRecord":53,"./Pool":55}],55:[function(t,e,o){function i(t){t=t||{},this.objects=[],void 0!==t.size&&this.resize(t.size)}e.exports=i,i.prototype.resize=function(t){for(var e=this.objects;e.length>t;)e.pop();for(;e.length(0|e)?t<<16|65535&e:e<<16|65535&t)},i.prototype.getByKey=function(t){return t=0|t,this.data[t]},i.prototype.get=function(t,e){return this.data[this.getKey(t,e)]},i.prototype.set=function(t,e,o){if(!o)throw new Error("No data!");var i=this.getKey(t,e);return this.data[i]||this.keys.push(i),this.data[i]=o,i},i.prototype.reset=function(){for(var t=this.data,e=this.keys,o=e.length;o--;)delete t[e[o]];e.length=0},i.prototype.copy=function(t){this.reset(),n.appendArray(this.keys,t.keys);for(var e=t.keys.length;e--;){var o=t.keys[e];this.data[o]=t.data[o]}}},{"./Utils":57}],57:[function(t,e,o){function i(){}e.exports=i,i.appendArray=function(t,e){if(e.length<15e4)t.push.apply(t,e);else for(var o=0,i=e.length;o!==i;++o)t.push(e[o])},i.splice=function(t,e,o){o=o||1;for(var i=e,n=t.length-o;n>i;i++)t[i]=t[i+o];t.length=n},"undefined"!=typeof P2_ARRAY_TYPE?i.ARRAY_TYPE=P2_ARRAY_TYPE:"undefined"!=typeof Float32Array?i.ARRAY_TYPE=Float32Array:i.ARRAY_TYPE=Array,i.extend=function(t,e){for(var o in e)t[o]=e[o]},i.defaults=function(t,e){t=t||{};for(var o in e)o in t||(t[o]=e[o]);return t}},{}],58:[function(t,e,o){function i(){this.equations=[],this.bodies=[]}var n=t("../objects/Body");e.exports=i,i.prototype.reset=function(){this.equations.length=this.bodies.length=0};var r=[];i.prototype.getBodies=function(t){var e=t||[],o=this.equations;r.length=0;for(var i=0;i!==o.length;i++){var n=o[i];-1===r.indexOf(n.bodyA.id)&&(e.push(n.bodyA),r.push(n.bodyA.id)),-1===r.indexOf(n.bodyB.id)&&(e.push(n.bodyB),r.push(n.bodyB.id))}return e},i.prototype.wantsToSleep=function(){for(var t=0;t=t&&o>i;)this.internalStep(t),this.time+=t,this.accumulator-=t,i++;for(var n=this.accumulator%t/t,a=0;a!==this.bodies.length;a++){var s=this.bodies[a];r.lerp(s.interpolatedPosition,s.previousPosition,s.position,n),s.interpolatedAngle=s.previousAngle+n*(s.angle-s.previousAngle)}}};var P=[];i.prototype.internalStep=function(t){this.stepping=!0;var e=this.springs.length,o=this.springs,n=this.bodies,a=this.gravity,s=this.solver,c=this.bodies.length,h=this.broadphase,l=this.narrowphase,p=this.constraints,d=E,f=(r.scale,r.add),v=(r.rotate,this.islandManager);if(this.overlapKeeper.tick(),this.lastTimeStep=t,this.useWorldGravityAsFrictionGravity){var y=r.length(this.gravity);0===y&&this.useFrictionGravityOnZeroGravity||(this.frictionGravity=y)}if(this.applyGravity)for(var m=0;m!==c;m++){var A=n[m],b=A.force;A.type===u.DYNAMIC&&A.sleepState!==u.SLEEPING&&(r.scale(d,a,A.mass*A.gravityScale),f(b,b,d))}if(this.applySpringForces)for(var m=0;m!==e;m++){var B=o[m];B.applyForce()}if(this.applyDamping)for(var m=0;m!==c;m++){var A=n[m];A.type===u.DYNAMIC&&A.applyDamping(t)}for(var q=h.getCollisionPairs(this),w=this.disabledBodyCollisionPairs,m=w.length-2;m>=0;m-=2)for(var S=q.length-2;S>=0;S-=2)(w[m]===q[S]&&w[m+1]===q[S+1]||w[m+1]===q[S]&&w[m]===q[S+1])&&q.splice(S,2);var C=p.length;for(m=0;m!==C;m++){var L=p[m];if(!L.collideConnected)for(var S=q.length-2;S>=0;S-=2)(L.bodyA===q[S]&&L.bodyB===q[S+1]||L.bodyB===q[S]&&L.bodyA===q[S+1])&&q.splice(S,2)}this.postBroadphaseEvent.pairs=q,this.emit(this.postBroadphaseEvent),this.postBroadphaseEvent.pairs=null,l.reset(this);for(var m=0,x=q.length;m!==x;m+=2)for(var F=q[m],M=q[m+1],I=0,R=F.shapes.length;I!==R;I++)for(var V=F.shapes[I],T=V.position,N=V.angle,G=0,O=M.shapes.length;G!==O;G++){var U=M.shapes[G],k=U.position,_=U.angle,D=this.defaultContactMaterial;if(V.material&&U.material){var W=this.getContactMaterial(V.material,U.material);W&&(D=W)}this.runNarrowphase(l,F,V,T,N,M,U,k,_,D,this.frictionGravity)}for(var m=0;m!==c;m++){var X=n[m];X._wakeUpAfterNarrowphase&&(X.wakeUp(),X._wakeUpAfterNarrowphase=!1)}if(this.has("endContact")){this.overlapKeeper.getEndOverlaps(P);for(var j=this.endContactEvent,G=P.length;G--;){var z=P[G];j.shapeA=z.shapeA,j.shapeB=z.shapeB,j.bodyA=z.bodyA,j.bodyB=z.bodyB,this.emit(j)}P.length=0}var Y=this.preSolveEvent;Y.contactEquations=l.contactEquations,Y.frictionEquations=l.frictionEquations,this.emit(Y),Y.contactEquations=Y.frictionEquations=null;var C=p.length;for(m=0;m!==C;m++)p[m].update();if(l.contactEquations.length||l.frictionEquations.length||C)if(this.islandSplit){for(v.equations.length=0,g.appendArray(v.equations,l.contactEquations),g.appendArray(v.equations,l.frictionEquations),m=0;m!==C;m++)g.appendArray(v.equations,p[m].equations);v.split(this);for(var m=0;m!==v.islands.length;m++){var K=v.islands[m];K.equations.length&&s.solveIsland(t,K)}}else{for(s.addEquations(l.contactEquations),s.addEquations(l.frictionEquations),m=0;m!==C;m++)s.addEquations(p[m].equations);this.solveConstraints&&s.solve(t,this),s.removeAllEquations()}for(var m=0;m!==c;m++){var X=n[m];X.integrate(t)}for(var m=0;m!==c;m++)n[m].setZeroForce();if(this.emitImpactEvent&&this.has("impact"))for(var H=this.impactEvent,m=0;m!==l.contactEquations.length;m++){var Z=l.contactEquations[m];Z.firstImpact&&(H.bodyA=Z.bodyA,H.bodyB=Z.bodyB,H.shapeA=Z.shapeA,H.shapeB=Z.shapeB,H.contactEquation=Z,this.emit(H))}if(this.sleepMode===i.BODY_SLEEPING)for(m=0;m!==c;m++)n[m].sleepTick(this.time,!1,t);else if(this.sleepMode===i.ISLAND_SLEEPING&&this.islandSplit){for(m=0;m!==c;m++)n[m].sleepTick(this.time,!0,t);for(var m=0;m0,t.frictionCoefficient=l.friction;var v;v=e.type===u.STATIC||e.type===u.KINEMATIC?a.mass:a.type===u.STATIC||a.type===u.KINEMATIC?e.mass:e.mass*a.mass/(e.mass+a.mass),t.slipForce=l.friction*p*v,t.restitution=l.restitution,t.surfaceVelocity=l.surfaceVelocity,t.frictionStiffness=l.frictionStiffness,t.frictionRelaxation=l.frictionRelaxation,t.stiffness=l.stiffness,t.relaxation=l.relaxation,t.contactSkinSize=l.contactSkinSize,t.enabledEquations=e.collisionResponse&&a.collisionResponse&&o.collisionResponse&&s.collisionResponse;var y=t[o.type|s.type],m=0;if(y){var g=o.sensor||s.sensor,A=t.frictionEquations.length;m=o.type=2*P&&(e._wakeUpAfterNarrowphase=!0)}if(a.allowSleep&&a.type===u.DYNAMIC&&a.sleepState===u.SLEEPING&&e.sleepState===u.AWAKE&&e.type!==u.STATIC){var w=r.squaredLength(e.velocity)+Math.pow(e.angularVelocity,2),S=Math.pow(e.sleepSpeedLimit,2);w>=2*S&&(a._wakeUpAfterNarrowphase=!0)}if(this.overlapKeeper.setOverlapping(e,o,a,s),this.has("beginContact")&&this.overlapKeeper.isNewOverlap(o,s)){var C=this.beginContactEvent;if(C.shapeA=o,C.shapeB=s,C.bodyA=e,C.bodyB=a,C.contactEquations.length=0,"number"==typeof m)for(var L=t.contactEquations.length-m;L1)for(var L=t.frictionEquations.length-b;L=0;e--)this.removeConstraint(t[e]);for(var o=this.bodies,e=o.length-1;e>=0;e--)this.removeBody(o[e]);for(var n=this.springs,e=n.length-1;e>=0;e--)this.removeSpring(n[e]);for(var r=this.contactMaterials,e=r.length-1;e>=0;e--)this.removeContactMaterial(r[e]);i.apply(this)};var w=r.create(),S=(r.fromValues(0,0),r.fromValues(0,0));i.prototype.hitTest=function(t,e,o){o=o||0;var i=new u({position:t}),n=new l,p=t,d=0,f=w,v=S;i.addShape(n);for(var y=this.narrowphase,m=[],g=0,A=e.length;g!==A;g++)for(var b=e[g],E=0,B=b.shapes.length;E!==B;E++){var q=b.shapes[E];r.rotate(f,q.position,b.angle),r.add(f,f,b.position);var P=q.angle+b.angle;(q instanceof a&&y.circleParticle(b,q,f,P,i,n,p,d,!0)||q instanceof s&&y.particleConvex(i,n,p,d,b,q,f,P,!0)||q instanceof c&&y.particlePlane(i,n,p,d,b,q,f,P,!0)||q instanceof h&&y.particleCapsule(i,n,p,d,b,q,f,P,!0)||q instanceof l&&r.squaredLength(r.sub(v,f,t)) postsJSON - values[1] // => commentsJSON - - return values; - }); - ``` - - @class Promise - @param {function} resolver - Useful for tooling. - @constructor -*/ -function Promise(resolver) { - this[PROMISE_ID] = nextId(); - this._result = this._state = undefined; - this._subscribers = []; - - if (noop !== resolver) { - typeof resolver !== 'function' && needsResolver(); - this instanceof Promise ? initializePromise(this, resolver) : needsNew(); - } -} - -Promise.all = all; -Promise.race = race; -Promise.resolve = resolve; -Promise.reject = reject; -Promise._setScheduler = setScheduler; -Promise._setAsap = setAsap; -Promise._asap = asap; - -Promise.prototype = { - constructor: Promise, - - /** - The primary way of interacting with a promise is through its `then` method, - which registers callbacks to receive either a promise's eventual value or the - reason why the promise cannot be fulfilled. - - ```js - findUser().then(function(user){ - // user is available - }, function(reason){ - // user is unavailable, and you are given the reason why - }); - ``` - - Chaining - -------- - - The return value of `then` is itself a promise. This second, 'downstream' - promise is resolved with the return value of the first promise's fulfillment - or rejection handler, or rejected if the handler throws an exception. - - ```js - findUser().then(function (user) { - return user.name; - }, function (reason) { - return 'default name'; - }).then(function (userName) { - // If `findUser` fulfilled, `userName` will be the user's name, otherwise it - // will be `'default name'` - }); - - findUser().then(function (user) { - throw new Error('Found user, but still unhappy'); - }, function (reason) { - throw new Error('`findUser` rejected and we're unhappy'); - }).then(function (value) { - // never reached - }, function (reason) { - // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. - // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. - }); - ``` - If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. - - ```js - findUser().then(function (user) { - throw new PedagogicalException('Upstream error'); - }).then(function (value) { - // never reached - }).then(function (value) { - // never reached - }, function (reason) { - // The `PedgagocialException` is propagated all the way down to here - }); - ``` - - Assimilation - ------------ - - Sometimes the value you want to propagate to a downstream promise can only be - retrieved asynchronously. This can be achieved by returning a promise in the - fulfillment or rejection handler. The downstream promise will then be pending - until the returned promise is settled. This is called *assimilation*. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // The user's comments are now available - }); - ``` - - If the assimliated promise rejects, then the downstream promise will also reject. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // If `findCommentsByAuthor` fulfills, we'll have the value here - }, function (reason) { - // If `findCommentsByAuthor` rejects, we'll have the reason here - }); - ``` - - Simple Example - -------------- - - Synchronous Example - - ```javascript - let result; - - try { - result = findResult(); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - findResult(function(result, err){ - if (err) { - // failure - } else { - // success - } - }); - ``` - - Promise Example; - - ```javascript - findResult().then(function(result){ - // success - }, function(reason){ - // failure - }); - ``` - - Advanced Example - -------------- - - Synchronous Example - - ```javascript - let author, books; - - try { - author = findAuthor(); - books = findBooksByAuthor(author); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - - function foundBooks(books) { - - } - - function failure(reason) { - - } - - findAuthor(function(author, err){ - if (err) { - failure(err); - // failure - } else { - try { - findBoooksByAuthor(author, function(books, err) { - if (err) { - failure(err); - } else { - try { - foundBooks(books); - } catch(reason) { - failure(reason); - } - } - }); - } catch(error) { - failure(err); - } - // success - } - }); - ``` - - Promise Example; - - ```javascript - findAuthor(). - then(findBooksByAuthor). - then(function(books){ - // found books - }).catch(function(reason){ - // something went wrong - }); - ``` - - @method then - @param {Function} onFulfilled - @param {Function} onRejected - Useful for tooling. - @return {Promise} - */ - then: then, - - /** - `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same - as the catch block of a try/catch statement. - - ```js - function findAuthor(){ - throw new Error('couldn't find that author'); - } - - // synchronous - try { - findAuthor(); - } catch(reason) { - // something went wrong - } - - // async with promises - findAuthor().catch(function(reason){ - // something went wrong - }); - ``` - - @method catch - @param {Function} onRejection - Useful for tooling. - @return {Promise} - */ - 'catch': function _catch(onRejection) { - return this.then(null, onRejection); - } -}; - -function polyfill() { - var local = undefined; - - if (typeof global !== 'undefined') { - local = global; - } else if (typeof self !== 'undefined') { - local = self; - } else { - try { - local = Function('return this')(); - } catch (e) { - throw new Error('polyfill failed because global object is unavailable in this environment'); - } - } - - var P = local.Promise; - - if (typeof egret_native != "undefined" && egret_native.capability && !egret_native.capability("Promise")) { - P = undefined; - } - - if (P) { - var promiseToString = null; - try { - promiseToString = Object.prototype.toString.call(P.resolve()); - } catch (e) { - // silently ignored - } - - if (promiseToString === '[object Promise]' && !P.cast) { - return; - } - } - - local.Promise = Promise; -} - -// Strange compat.. -Promise.polyfill = polyfill; -Promise.Promise = Promise; - -return Promise; - -}))); - -ES6Promise.polyfill(); \ No newline at end of file diff --git a/helloworld/libs/modules/promise/promise.min.js b/helloworld/libs/modules/promise/promise.min.js deleted file mode 100644 index 765fa21..0000000 --- a/helloworld/libs/modules/promise/promise.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.ES6Promise=e()}(this,function(){"use strict";function t(t){return"function"==typeof t||"object"==typeof t&&null!==t}function e(t){return"function"==typeof t}function n(t){I=t}function r(t){J=t}function o(){return function(){return process.nextTick(a)}}function i(){return"undefined"!=typeof H?function(){H(a)}:c()}function s(){var t=0,e=new V(a),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function u(){var t=new MessageChannel;return t.port1.onmessage=a,function(){return t.port2.postMessage(0)}}function c(){var t=setTimeout;return function(){return t(a,1)}}function a(){for(var t=0;G>t;t+=2){var e=$[t],n=$[t+1];e(n),$[t]=void 0,$[t+1]=void 0}G=0}function f(){try{var t=require,e=t("vertx");return H=e.runOnLoop||e.runOnContext,i()}catch(n){return c()}}function l(t,e){var n=arguments,r=this,o=new this.constructor(p);void 0===o[ee]&&k(o);var i=r._state;return i?!function(){var t=n[i-1];J(function(){return x(i,o,t,r._result)})}():E(r,o,t,e),o}function h(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var n=new e(p);return w(n,t),n}function p(){}function v(){return new TypeError("You cannot resolve a promise with itself")}function d(){return new TypeError("A promises callback cannot return that same promise.")}function _(t){try{return t.then}catch(e){return ie.error=e,ie}}function y(t,e,n,r){try{t.call(e,n,r)}catch(o){return o}}function m(t,e,n){J(function(t){var r=!1,o=y(n,e,function(n){r||(r=!0,e!==n?w(t,n):S(t,n))},function(e){r||(r=!0,j(t,e))},"Settle: "+(t._label||" unknown promise"));!r&&o&&(r=!0,j(t,o))},t)}function b(t,e){e._state===re?S(t,e._result):e._state===oe?j(t,e._result):E(e,void 0,function(e){return w(t,e)},function(e){return j(t,e)})}function g(t,n,r){n.constructor===t.constructor&&r===l&&n.constructor.resolve===h?b(t,n):r===ie?j(t,ie.error):void 0===r?S(t,n):e(r)?m(t,n,r):S(t,n)}function w(e,n){e===n?j(e,v()):t(n)?g(e,n,_(n)):S(e,n)}function A(t){t._onerror&&t._onerror(t._result),P(t)}function S(t,e){t._state===ne&&(t._result=e,t._state=re,0!==t._subscribers.length&&J(P,t))}function j(t,e){t._state===ne&&(t._state=oe,t._result=e,J(A,t))}function E(t,e,n,r){var o=t._subscribers,i=o.length;t._onerror=null,o[i]=e,o[i+re]=n,o[i+oe]=r,0===i&&t._state&&J(P,t)}function P(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r=void 0,o=void 0,i=t._result,s=0;si;i++)e.resolve(t[i]).then(n,r)}:function(t,e){return e(new TypeError("You must pass an array to race."))})}function K(t){var e=this,n=new e(p);return j(n,t),n}function L(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function N(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function U(t){this[ee]=O(),this._result=this._state=void 0,this._subscribers=[],p!==t&&("function"!=typeof t&&L(),this instanceof U?C(this,t):N())}function W(){var t=void 0;if("undefined"!=typeof global)t=global;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=t.Promise;if("undefined"!=typeof egret_native&&egret_native.capability&&!egret_native.capability("Promise")&&(n=void 0),n){var r=null;try{r=Object.prototype.toString.call(n.resolve())}catch(e){}if("[object Promise]"===r&&!n.cast)return}t.Promise=U}var z=void 0;z=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var B=z,G=0,H=void 0,I=void 0,J=function(t,e){$[G]=t,$[G+1]=e,G+=2,2===G&&(I?I(a):te())},Q="undefined"!=typeof window?window:void 0,R=Q||{},V=R.MutationObserver||R.WebKitMutationObserver,X="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),Z="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,$=new Array(1e3),te=void 0;te=X?o():V?s():Z?u():void 0===Q&&"function"==typeof require?f():c();var ee=Math.random().toString(36).substring(16),ne=void 0,re=1,oe=2,ie=new T,se=new T,ue=0;return Y.prototype._enumerate=function(){for(var t=this.length,e=this._input,n=0;this._state===ne&&t>n;n++)this._eachEntry(e[n],n)},Y.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===h){var o=_(t);if(o===l&&t._state!==ne)this._settledAt(t._state,e,t._result);else if("function"!=typeof o)this._remaining--,this._result[e]=t;else if(n===U){var i=new n(p);g(i,t,o),this._willSettleAt(i,e)}else this._willSettleAt(new n(function(e){return e(t)}),e)}else this._willSettleAt(r(t),e)},Y.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===ne&&(this._remaining--,t===oe?j(r,n):this._result[e]=n),0===this._remaining&&S(r,this._result)},Y.prototype._willSettleAt=function(t,e){var n=this;E(t,void 0,function(t){return n._settledAt(re,e,t)},function(t){return n._settledAt(oe,e,t)})},U.all=F,U.race=D,U.resolve=h,U.reject=K,U._setScheduler=n,U._setAsap=r,U._asap=J,U.prototype={constructor:U,then:l,"catch":function(t){return this.then(null,t)}},U.polyfill=W,U.Promise=U,U}),ES6Promise.polyfill(); \ No newline at end of file diff --git a/helloworld/libs/modules/tween/tween.d.ts b/helloworld/libs/modules/tween/tween.d.ts deleted file mode 100644 index 6a3093a..0000000 --- a/helloworld/libs/modules/tween/tween.d.ts +++ /dev/null @@ -1,1350 +0,0 @@ -declare namespace egret { - /** - * Easing function set. Different easing functions are used to make an animation proceed according to the corresponding equation - * @see http://edn.egret.com/cn/index.php/article/index/id/53 Easing effect Demo - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缓动函数集合,使用不同的缓动函数使得动画按照对应的方程进行 - * @see http://edn.egret.com/cn/index.php/article/index/id/53 缓动效果演示 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class Ease { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - /** - * get.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static get(amount: number): (t: number) => number; - /** - * get pow in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get pow in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getPowIn(pow: number): (t: number) => number; - /** - * get pow out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get pow out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getPowOut(pow: number): (t: number) => number; - /** - * get pow in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get pow in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getPowInOut(pow: number): (t: number) => number; - /** - * quad in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quad in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quadIn: (t: number) => number; - /** - * quad out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quad out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quadOut: (t: number) => number; - /** - * quad in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quad in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quadInOut: (t: number) => number; - /** - * cubic in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * cubic in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static cubicIn: (t: number) => number; - /** - * cubic out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * cubic out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static cubicOut: (t: number) => number; - /** - * cubic in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * cubic in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static cubicInOut: (t: number) => number; - /** - * quart in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quart in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quartIn: (t: number) => number; - /** - * quart out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quart out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quartOut: (t: number) => number; - /** - * quart in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quart in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quartInOut: (t: number) => number; - /** - * quint in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quint in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quintIn: (t: number) => number; - /** - * quint out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quint out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quintOut: (t: number) => number; - /** - * quint in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quint in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quintInOut: (t: number) => number; - /** - * sine in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * sine in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static sineIn(t: number): number; - /** - * sine out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * sine out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static sineOut(t: number): number; - /** - * sine in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * sine in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static sineInOut(t: number): number; - /** - * get back in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get back in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getBackIn(amount: number): (t: number) => number; - /** - * back in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * back in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static backIn: (t: number) => number; - /** - * get back out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get back out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getBackOut(amount: number): (t: any) => number; - /** - * back out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * back out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static backOut: (t: any) => number; - /** - * get back in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get back in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getBackInOut(amount: number): (t: number) => number; - /** - * back in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * back in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static backInOut: (t: number) => number; - /** - * circ in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * circ in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static circIn(t: number): number; - /** - * circ out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * circ out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static circOut(t: number): number; - /** - * circ in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * circ in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static circInOut(t: number): number; - /** - * bounce in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * bounce in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static bounceIn(t: number): number; - /** - * bounce out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * bounce out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static bounceOut(t: number): number; - /** - * bounce in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * bounce in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static bounceInOut(t: number): number; - /** - * get elastic in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get elastic in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getElasticIn(amplitude: number, period: number): (t: number) => number; - /** - * elastic in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * elastic in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static elasticIn: (t: number) => number; - /** - * get elastic out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get elastic out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getElasticOut(amplitude: number, period: number): (t: number) => number; - /** - * elastic out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * elastic out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static elasticOut: (t: number) => number; - /** - * get elastic in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get elastic in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getElasticInOut(amplitude: number, period: number): (t: number) => number; - /** - * elastic in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * elastic in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static elasticInOut: (t: number) => number; - } -} -declare namespace egret { - /** - * Tween is the animation easing class of Egret - * @see http://edn.egret.com/cn/docs/page/576 Tween ease animation - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/tween/Tween.ts - * @language en_US - */ - /** - * Tween是Egret的动画缓动类 - * @see http://edn.egret.com/cn/docs/page/576 Tween缓动动画 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/tween/Tween.ts - * @language zh_CN - */ - class Tween extends EventDispatcher { - /** - * 不做特殊处理 - * @constant {number} egret.Tween.NONE - * @private - */ - private static NONE; - /** - * 循环 - * @constant {number} egret.Tween.LOOP - * @private - */ - private static LOOP; - /** - * 倒序 - * @constant {number} egret.Tween.REVERSE - * @private - */ - private static REVERSE; - /** - * @private - */ - private static _tweens; - /** - * @private - */ - private static IGNORE; - /** - * @private - */ - private static _plugins; - /** - * @private - */ - private static _inited; - /** - * @private - */ - private _target; - /** - * @private - */ - private _useTicks; - /** - * @private - */ - private ignoreGlobalPause; - /** - * @private - */ - private loop; - /** - * @private - */ - private pluginData; - /** - * @private - */ - private _curQueueProps; - /** - * @private - */ - private _initQueueProps; - /** - * @private - */ - private _steps; - /** - * @private - */ - private paused; - /** - * @private - */ - private duration; - /** - * @private - */ - private _prevPos; - /** - * @private - */ - private position; - /** - * @private - */ - private _prevPosition; - /** - * @private - */ - private _stepPosition; - /** - * @private - */ - private passive; - /** - * Activate an object and add a Tween animation to the object - * @param target {any} The object to be activated - * @param props {any} Parameters, support loop onChange onChangeObj - * @param pluginData {any} Write realized - * @param override {boolean} Whether to remove the object before adding a tween, the default value false - * Not recommended, you can use Tween.removeTweens(target) instead. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 激活一个对象,对其添加 Tween 动画 - * @param target {any} 要激活 Tween 的对象 - * @param props {any} 参数,支持loop(循环播放) onChange(变化函数) onChangeObj(变化函数作用域) - * @param pluginData {any} 暂未实现 - * @param override {boolean} 是否移除对象之前添加的tween,默认值false。 - * 不建议使用,可使用 Tween.removeTweens(target) 代替。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static get(target: any, props?: { - loop?: boolean; - onChange?: Function; - onChangeObj?: any; - }, pluginData?: any, override?: boolean): Tween; - /** - * Delete all Tween animations from an object - * @param target The object whose Tween to be deleted - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 删除一个对象上的全部 Tween 动画 - * @param target 需要移除 Tween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static removeTweens(target: any): void; - /** - * Pause all Tween animations of a certain object - * @param target The object whose Tween to be paused - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停某个对象的所有 Tween - * @param target 要暂停 Tween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static pauseTweens(target: any): void; - /** - * Resume playing all easing of a certain object - * @param target The object whose Tween to be resumed - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 继续播放某个对象的所有缓动 - * @param target 要继续播放 Tween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static resumeTweens(target: any): void; - /** - * @private - * - * @param delta - * @param paused - */ - private static tick(timeStamp, paused?); - private static _lastTime; - /** - * @private - * - * @param tween - * @param value - */ - private static _register(tween, value); - /** - * Delete all Tween - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 删除所有 Tween - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static removeAllTweens(): void; - /** - * 创建一个 egret.Tween 对象 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(target: any, props: any, pluginData: any); - /** - * @private - * - * @param target - * @param props - * @param pluginData - */ - private initialize(target, props, pluginData); - /** - * @private - * - * @param value - * @param actionsMode - * @returns - */ - setPosition(value: number, actionsMode?: number): boolean; - /** - * @private - * - * @param startPos - * @param endPos - * @param includeStart - */ - private _runAction(action, startPos, endPos, includeStart?); - /** - * @private - * - * @param step - * @param ratio - */ - private _updateTargetProps(step, ratio); - /** - * Whether setting is paused - * @param value {boolean} Whether to pause - * @returns Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置是否暂停 - * @param value {boolean} 是否暂停 - * @returns Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setPaused(value: boolean): Tween; - /** - * @private - * - * @param props - * @returns - */ - private _cloneProps(props); - /** - * @private - * - * @param o - * @returns - */ - private _addStep(o); - /** - * @private - * - * @param o - * @returns - */ - private _appendQueueProps(o); - /** - * @private - * - * @param o - * @returns - */ - private _addAction(o); - /** - * @private - * - * @param props - * @param o - */ - private _set(props, o); - /** - * Wait the specified milliseconds before the execution of the next animation - * @param duration {number} Waiting time, in milliseconds - * @param passive {boolean} Whether properties are updated during the waiting time - * @returns Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等待指定毫秒后执行下一个动画 - * @param duration {number} 要等待的时间,以毫秒为单位 - * @param passive {boolean} 等待期间属性是否会更新 - * @returns Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - wait(duration: number, passive?: boolean): Tween; - /** - * Modify the property of the specified object to a specified value - * @param props {Object} Property set of an object - * @param duration {number} Duration - * @param ease {egret.Ease} Easing algorithm - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定对象的属性修改为指定值 - * @param props {Object} 对象的属性集合 - * @param duration {number} 持续时间 - * @param ease {egret.Ease} 缓动算法 - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - to(props: any, duration?: number, ease?: Function): Tween; - /** - * Execute callback function - * @param callback {Function} Callback method - * @param thisObj {any} this action scope of the callback method - * @param params {any[]} Parameter of the callback method - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @example - *
      -         *  egret.Tween.get(display).call(function (a:number, b:string) {
      -         *      console.log("a: " + a); // the first parameter passed 233
      -         *      console.log("b: " + b); // the second parameter passed “hello”
      -         *  }, this, [233, "hello"]);
      -         * 
      - * @language en_US - */ - /** - * 执行回调函数 - * @param callback {Function} 回调方法 - * @param thisObj {any} 回调方法this作用域 - * @param params {any[]} 回调方法参数 - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @example - *
      -         *  egret.Tween.get(display).call(function (a:number, b:string) {
      -         *      console.log("a: " + a); //对应传入的第一个参数 233
      -         *      console.log("b: " + b); //对应传入的第二个参数 “hello”
      -         *  }, this, [233, "hello"]);
      -         * 
      - * @language zh_CN - */ - call(callback: Function, thisObj?: any, params?: any[]): Tween; - /** - * Now modify the properties of the specified object to the specified value - * @param props {Object} Property set of an object - * @param target The object whose Tween to be resumed - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * 立即将指定对象的属性修改为指定值 - * @param props {Object} 对象的属性集合 - * @param target 要继续播放 Tween 的对象 - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - */ - set(props: any, target?: any): Tween; - /** - * Execute - * @param tween {egret.Tween} The Tween object to be operated. Default: this - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 执行 - * @param tween {egret.Tween} 需要操作的 Tween 对象,默认this - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - play(tween?: Tween): Tween; - /** - * Pause - * @param tween {egret.Tween} The Tween object to be operated. Default: this - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停 - * @param tween {egret.Tween} 需要操作的 Tween 对象,默认this - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - pause(tween?: Tween): Tween; - /** - * @method egret.Tween#tick - * @param delta {number} - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - $tick(delta: number): void; - } -} -declare namespace egret.tween { - type EaseType = 'quadIn' | 'quadOut' | 'quadOut' | 'quadInOut' | 'cubicIn' | 'cubicOut' | 'cubicInOut' | 'quartIn' | 'quartOut' | 'quartInOut' | 'quintIn' | 'quintOut' | 'quintInOut' | 'sineIn' | 'sineOut' | 'sineInOut' | 'backIn' | 'backOut' | 'backInOut' | 'circIn' | 'circOut' | 'circInOut' | 'bounceIn' | 'bounceOut' | 'bounceInOut' | 'elasticIn' | 'elasticOut' | 'elasticInOut'; - /** - * Abstract class, Indicate the base action. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 抽象类,表示一个基本动作 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - abstract class BasePath extends EventDispatcher { - /** - * the name of this action. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 动作的名称 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - name: string; - } - /** - * Indicate the to action. See Tween.to - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个to动作,参见Tween.to - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - class To extends BasePath { - /** - * Property set of an object - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 对象的属性集合 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - props: Object; - /** - * Duration - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 持续时间 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - duration: number; - /** - * Easing algorithm - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 缓动算法 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - ease: EaseType | Function; - } - /** - * Indicate the wait action. See Tween.wait - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个wait动作,参见Tween.wait - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - class Wait extends BasePath { - /** - * Duration - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 持续时间 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - duration: number; - /** - * Whether properties are updated during the waiting time - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 等待期间属性是否会更新 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - passive: boolean; - } - /** - * Indicate the set action. See Tween.set - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个set动作,参见Tween.set - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - class Set extends BasePath { - /** - * Property set of an object - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 对象的属性集合 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - props: Object; - } - /** - * Indicate the tick action. See Tween.tick - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个tick动作,参见Tween.tick - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - class Tick extends BasePath { - /** - * Delta time - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 增加的时间 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - delta: number; - } - /** - * TweenItem is a wrapper for Tween, which can set the behavior of Tween by setting attributes and adding Path. - * - * @event pathComplete Dispatched when some Path has complete. - * @event complete Dispatched when all Paths has complete. - * - * @defaultProperty props - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * TweenItem是对Tween的包装器,能通过设置属性和添加Path的方式设置Tween的行为。 - * 通常用于使用在EXML中定义组件的动画。 - * - * @event pathComplete 当某个Path执行完毕时会派发此事件。 - * @event complete 当所有Path执行完毕时会派发此事件。 - * - * @defaultProperty props - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - /** - * Use in exml: - * ``` - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * ``` - */ - class TweenItem extends EventDispatcher { - private tween; - constructor(); - /** - * @private - */ - private _props; - /** - * The Tween's props. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * Tween的props参数。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - props: any; - /** - * @private - */ - private _target; - /** - * The Tween's target. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * Tween的target参数。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - target: any; - /** - * @private - */ - private _paths; - /** - * The Actions in Tween. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * TweenItem中添加的行为。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - paths: BasePath[]; - /** - * Play the Tween - * @position The starting position, the default is from the last position to play - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 播放Tween - * @position 播放的起始位置, 默认为从上次位置继续播放 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - play(position?: number): void; - /** - * Pause the Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - pause(): void; - private isStop; - /** - * Stop the Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 停止Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - stop(): void; - private createTween(position); - private applyPaths(); - private applyPath(path); - private pathComplete(path); - } - /** - * TweenGroup is a collection of TweenItem that can be played in parallel with each Item - * - * @event itemComplete Dispatched when some TweenItem has complete. - * @event complete Dispatched when all TweenItems has complete. - * - * @version Egret 3.1.8 - * @platform Web,Native - * @includeExample extension/tween/TweenWrapper.ts - * @language en_US - */ - /** - * TweenGroup是TweenItem的集合,可以并行播放每一个Item - * @version Egret 3.1.8 - * @platform Web,Native - * @includeExample extension/tween/TweenWrapper.ts - * @language zh_CN - */ - class TweenGroup extends EventDispatcher { - private completeCount; - constructor(); - /** - * @private - */ - private _items; - /** - * The Array that TweenItems in TweenGroup. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * TweenGroup要控制的TweenItem集合。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - items: TweenItem[]; - private registerEvent(add); - /** - * Play the all TweenItems - * @time The starting position, the default is from the last position to play。If use 0, the group will play from the start position. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 播放所有的TweenItem - * @time 播放的起始位置, 默认为从上次位置继续播放。如果为0,则从起始位置开始播放。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - play(time?: number): void; - /** - * Pause the all TweenItems - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停播放所有的TweenItem - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - pause(): void; - /** - * Stop the all TweenItems - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 停止所有的TweenItem - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - stop(): void; - private itemComplete(e); - } -} diff --git a/helloworld/libs/modules/tween/tween.js b/helloworld/libs/modules/tween/tween.js deleted file mode 100644 index 7ac1d95..0000000 --- a/helloworld/libs/modules/tween/tween.js +++ /dev/null @@ -1,2095 +0,0 @@ -var __reflect = (this && this.__reflect) || function (p, c, t) { - p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; -}; -var __extends = this && this.__extends || function __extends(t, e) { - function r() { - this.constructor = t; -} -for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]); -r.prototype = e.prototype, t.prototype = new r(); -}; -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Easing function set. Different easing functions are used to make an animation proceed according to the corresponding equation - * @see http://edn.egret.com/cn/index.php/article/index/id/53 Easing effect Demo - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缓动函数集合,使用不同的缓动函数使得动画按照对应的方程进行 - * @see http://edn.egret.com/cn/index.php/article/index/id/53 缓动效果演示 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var Ease = (function () { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - function Ease() { - egret.$error(1014); - } - /** - * get.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.get = function (amount) { - if (amount < -1) { - amount = -1; - } - if (amount > 1) { - amount = 1; - } - return function (t) { - if (amount == 0) { - return t; - } - if (amount < 0) { - return t * (t * -amount + 1 + amount); - } - return t * ((2 - t) * amount + (1 - amount)); - }; - }; - /** - * get pow in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get pow in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.getPowIn = function (pow) { - return function (t) { - return Math.pow(t, pow); - }; - }; - /** - * get pow out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get pow out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.getPowOut = function (pow) { - return function (t) { - return 1 - Math.pow(1 - t, pow); - }; - }; - /** - * get pow in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get pow in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.getPowInOut = function (pow) { - return function (t) { - if ((t *= 2) < 1) - return 0.5 * Math.pow(t, pow); - return 1 - 0.5 * Math.abs(Math.pow(2 - t, pow)); - }; - }; - /** - * sine in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * sine in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.sineIn = function (t) { - return 1 - Math.cos(t * Math.PI / 2); - }; - /** - * sine out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * sine out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.sineOut = function (t) { - return Math.sin(t * Math.PI / 2); - }; - /** - * sine in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * sine in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.sineInOut = function (t) { - return -0.5 * (Math.cos(Math.PI * t) - 1); - }; - /** - * get back in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get back in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.getBackIn = function (amount) { - return function (t) { - return t * t * ((amount + 1) * t - amount); - }; - }; - /** - * get back out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get back out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.getBackOut = function (amount) { - return function (t) { - return (--t * t * ((amount + 1) * t + amount) + 1); - }; - }; - /** - * get back in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get back in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.getBackInOut = function (amount) { - amount *= 1.525; - return function (t) { - if ((t *= 2) < 1) - return 0.5 * (t * t * ((amount + 1) * t - amount)); - return 0.5 * ((t -= 2) * t * ((amount + 1) * t + amount) + 2); - }; - }; - /** - * circ in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * circ in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.circIn = function (t) { - return -(Math.sqrt(1 - t * t) - 1); - }; - /** - * circ out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * circ out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.circOut = function (t) { - return Math.sqrt(1 - (--t) * t); - }; - /** - * circ in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * circ in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.circInOut = function (t) { - if ((t *= 2) < 1) { - return -0.5 * (Math.sqrt(1 - t * t) - 1); - } - return 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1); - }; - /** - * bounce in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * bounce in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.bounceIn = function (t) { - return 1 - Ease.bounceOut(1 - t); - }; - /** - * bounce out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * bounce out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.bounceOut = function (t) { - if (t < 1 / 2.75) { - return (7.5625 * t * t); - } - else if (t < 2 / 2.75) { - return (7.5625 * (t -= 1.5 / 2.75) * t + 0.75); - } - else if (t < 2.5 / 2.75) { - return (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375); - } - else { - return (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375); - } - }; - /** - * bounce in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * bounce in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.bounceInOut = function (t) { - if (t < 0.5) - return Ease.bounceIn(t * 2) * .5; - return Ease.bounceOut(t * 2 - 1) * 0.5 + 0.5; - }; - /** - * get elastic in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get elastic in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.getElasticIn = function (amplitude, period) { - var pi2 = Math.PI * 2; - return function (t) { - if (t == 0 || t == 1) - return t; - var s = period / pi2 * Math.asin(1 / amplitude); - return -(amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * pi2 / period)); - }; - }; - /** - * get elastic out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get elastic out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.getElasticOut = function (amplitude, period) { - var pi2 = Math.PI * 2; - return function (t) { - if (t == 0 || t == 1) - return t; - var s = period / pi2 * Math.asin(1 / amplitude); - return (amplitude * Math.pow(2, -10 * t) * Math.sin((t - s) * pi2 / period) + 1); - }; - }; - /** - * get elastic in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get elastic in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.getElasticInOut = function (amplitude, period) { - var pi2 = Math.PI * 2; - return function (t) { - var s = period / pi2 * Math.asin(1 / amplitude); - if ((t *= 2) < 1) - return -0.5 * (amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * pi2 / period)); - return amplitude * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * pi2 / period) * 0.5 + 1; - }; - }; - /** - * quad in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quad in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.quadIn = Ease.getPowIn(2); - /** - * quad out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quad out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.quadOut = Ease.getPowOut(2); - /** - * quad in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quad in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.quadInOut = Ease.getPowInOut(2); - /** - * cubic in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * cubic in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.cubicIn = Ease.getPowIn(3); - /** - * cubic out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * cubic out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.cubicOut = Ease.getPowOut(3); - /** - * cubic in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * cubic in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.cubicInOut = Ease.getPowInOut(3); - /** - * quart in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quart in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.quartIn = Ease.getPowIn(4); - /** - * quart out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quart out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.quartOut = Ease.getPowOut(4); - /** - * quart in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quart in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.quartInOut = Ease.getPowInOut(4); - /** - * quint in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quint in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.quintIn = Ease.getPowIn(5); - /** - * quint out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quint out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.quintOut = Ease.getPowOut(5); - /** - * quint in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quint in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.quintInOut = Ease.getPowInOut(5); - /** - * back in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * back in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.backIn = Ease.getBackIn(1.7); - /** - * back out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * back out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.backOut = Ease.getBackOut(1.7); - /** - * back in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * back in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.backInOut = Ease.getBackInOut(1.7); - /** - * elastic in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * elastic in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.elasticIn = Ease.getElasticIn(1, 0.3); - /** - * elastic out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * elastic out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.elasticOut = Ease.getElasticOut(1, 0.3); - /** - * elastic in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * elastic in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.elasticInOut = Ease.getElasticInOut(1, 0.3 * 1.5); - return Ease; - }()); - egret.Ease = Ease; - __reflect(Ease.prototype, "egret.Ease"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Tween is the animation easing class of Egret - * @see http://edn.egret.com/cn/docs/page/576 Tween ease animation - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/tween/Tween.ts - * @language en_US - */ - /** - * Tween是Egret的动画缓动类 - * @see http://edn.egret.com/cn/docs/page/576 Tween缓动动画 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/tween/Tween.ts - * @language zh_CN - */ - var Tween = (function (_super) { - __extends(Tween, _super); - /** - * 创建一个 egret.Tween 对象 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - function Tween(target, props, pluginData) { - var _this = _super.call(this) || this; - /** - * @private - */ - _this._target = null; - /** - * @private - */ - _this._useTicks = false; - /** - * @private - */ - _this.ignoreGlobalPause = false; - /** - * @private - */ - _this.loop = false; - /** - * @private - */ - _this.pluginData = null; - /** - * @private - */ - _this._steps = null; - /** - * @private - */ - _this.paused = false; - /** - * @private - */ - _this.duration = 0; - /** - * @private - */ - _this._prevPos = -1; - /** - * @private - */ - _this.position = null; - /** - * @private - */ - _this._prevPosition = 0; - /** - * @private - */ - _this._stepPosition = 0; - /** - * @private - */ - _this.passive = false; - _this.initialize(target, props, pluginData); - return _this; - } - /** - * Activate an object and add a Tween animation to the object - * @param target {any} The object to be activated - * @param props {any} Parameters, support loop onChange onChangeObj - * @param pluginData {any} Write realized - * @param override {boolean} Whether to remove the object before adding a tween, the default value false - * Not recommended, you can use Tween.removeTweens(target) instead. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 激活一个对象,对其添加 Tween 动画 - * @param target {any} 要激活 Tween 的对象 - * @param props {any} 参数,支持loop(循环播放) onChange(变化函数) onChangeObj(变化函数作用域) - * @param pluginData {any} 暂未实现 - * @param override {boolean} 是否移除对象之前添加的tween,默认值false。 - * 不建议使用,可使用 Tween.removeTweens(target) 代替。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.get = function (target, props, pluginData, override) { - if (pluginData === void 0) { pluginData = null; } - if (override === void 0) { override = false; } - if (override) { - Tween.removeTweens(target); - } - return new Tween(target, props, pluginData); - }; - /** - * Delete all Tween animations from an object - * @param target The object whose Tween to be deleted - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 删除一个对象上的全部 Tween 动画 - * @param target 需要移除 Tween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.removeTweens = function (target) { - if (!target.tween_count) { - return; - } - var tweens = Tween._tweens; - for (var i = tweens.length - 1; i >= 0; i--) { - if (tweens[i]._target == target) { - tweens[i].paused = true; - tweens.splice(i, 1); - } - } - target.tween_count = 0; - }; - /** - * Pause all Tween animations of a certain object - * @param target The object whose Tween to be paused - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停某个对象的所有 Tween - * @param target 要暂停 Tween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.pauseTweens = function (target) { - if (!target.tween_count) { - return; - } - var tweens = egret.Tween._tweens; - for (var i = tweens.length - 1; i >= 0; i--) { - if (tweens[i]._target == target) { - tweens[i].paused = true; - } - } - }; - /** - * Resume playing all easing of a certain object - * @param target The object whose Tween to be resumed - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 继续播放某个对象的所有缓动 - * @param target 要继续播放 Tween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.resumeTweens = function (target) { - if (!target.tween_count) { - return; - } - var tweens = egret.Tween._tweens; - for (var i = tweens.length - 1; i >= 0; i--) { - if (tweens[i]._target == target) { - tweens[i].paused = false; - } - } - }; - /** - * @private - * - * @param delta - * @param paused - */ - Tween.tick = function (timeStamp, paused) { - if (paused === void 0) { paused = false; } - var delta = timeStamp - Tween._lastTime; - Tween._lastTime = timeStamp; - var tweens = Tween._tweens.concat(); - for (var i = tweens.length - 1; i >= 0; i--) { - var tween_1 = tweens[i]; - if ((paused && !tween_1.ignoreGlobalPause) || tween_1.paused) { - continue; - } - tween_1.$tick(tween_1._useTicks ? 1 : delta); - } - return false; - }; - /** - * @private - * - * @param tween - * @param value - */ - Tween._register = function (tween, value) { - var target = tween._target; - var tweens = Tween._tweens; - if (value) { - if (target) { - target.tween_count = target.tween_count > 0 ? target.tween_count + 1 : 1; - } - tweens.push(tween); - if (!Tween._inited) { - Tween._lastTime = egret.getTimer(); - egret.ticker.$startTick(Tween.tick, null); - Tween._inited = true; - } - } - else { - if (target) { - target.tween_count--; - } - var i = tweens.length; - while (i--) { - if (tweens[i] == tween) { - tweens.splice(i, 1); - return; - } - } - } - }; - /** - * Delete all Tween - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 删除所有 Tween - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.removeAllTweens = function () { - var tweens = Tween._tweens; - for (var i = 0, l = tweens.length; i < l; i++) { - var tween_2 = tweens[i]; - tween_2.paused = true; - tween_2._target.tween_count = 0; - } - tweens.length = 0; - }; - /** - * @private - * - * @param target - * @param props - * @param pluginData - */ - Tween.prototype.initialize = function (target, props, pluginData) { - this._target = target; - if (props) { - this._useTicks = props.useTicks; - this.ignoreGlobalPause = props.ignoreGlobalPause; - this.loop = props.loop; - props.onChange && this.addEventListener("change", props.onChange, props.onChangeObj); - if (props.override) { - Tween.removeTweens(target); - } - } - this.pluginData = pluginData || {}; - this._curQueueProps = {}; - this._initQueueProps = {}; - this._steps = []; - if (props && props.paused) { - this.paused = true; - } - else { - Tween._register(this, true); - } - if (props && props.position != null) { - this.setPosition(props.position, Tween.NONE); - } - }; - /** - * @private - * - * @param value - * @param actionsMode - * @returns - */ - Tween.prototype.setPosition = function (value, actionsMode) { - if (actionsMode === void 0) { actionsMode = 1; } - if (value < 0) { - value = 0; - } - //正常化位置 - var t = value; - var end = false; - if (t >= this.duration) { - if (this.loop) { - var newTime = t % this.duration; - if (t > 0 && newTime === 0) { - t = this.duration; - } - else { - t = newTime; - } - } - else { - t = this.duration; - end = true; - } - } - if (t == this._prevPos) { - return end; - } - if (end) { - this.setPaused(true); - } - var prevPos = this._prevPos; - this.position = this._prevPos = t; - this._prevPosition = value; - if (this._target) { - if (this._steps.length > 0) { - // 找到新的tween - var l = this._steps.length; - var stepIndex = -1; - for (var i = 0; i < l; i++) { - if (this._steps[i].type == "step") { - stepIndex = i; - if (this._steps[i].t <= t && this._steps[i].t + this._steps[i].d >= t) { - break; - } - } - } - for (var i = 0; i < l; i++) { - if (this._steps[i].type == "action") { - //执行actions - if (actionsMode != 0) { - if (this._useTicks) { - this._runAction(this._steps[i], t, t); - } - else if (actionsMode == 1 && t < prevPos) { - if (prevPos != this.duration) { - this._runAction(this._steps[i], prevPos, this.duration); - } - this._runAction(this._steps[i], 0, t, true); - } - else { - this._runAction(this._steps[i], prevPos, t); - } - } - } - else if (this._steps[i].type == "step") { - if (stepIndex == i) { - var step = this._steps[stepIndex]; - this._updateTargetProps(step, Math.min((this._stepPosition = t - step.t) / step.d, 1)); - } - } - } - } - } - this.dispatchEventWith("change"); - return end; - }; - /** - * @private - * - * @param startPos - * @param endPos - * @param includeStart - */ - Tween.prototype._runAction = function (action, startPos, endPos, includeStart) { - if (includeStart === void 0) { includeStart = false; } - var sPos = startPos; - var ePos = endPos; - if (startPos > endPos) { - //把所有的倒置 - sPos = endPos; - ePos = startPos; - } - var pos = action.t; - if (pos == ePos || (pos > sPos && pos < ePos) || (includeStart && pos == startPos)) { - action.f.apply(action.o, action.p); - } - }; - /** - * @private - * - * @param step - * @param ratio - */ - Tween.prototype._updateTargetProps = function (step, ratio) { - var p0, p1, v, v0, v1, arr; - if (!step && ratio == 1) { - this.passive = false; - p0 = p1 = this._curQueueProps; - } - else { - this.passive = !!step.v; - //不更新props. - if (this.passive) { - return; - } - //使用ease - if (step.e) { - ratio = step.e(ratio, 0, 1, 1); - } - p0 = step.p0; - p1 = step.p1; - } - for (var n in this._initQueueProps) { - if ((v0 = p0[n]) == null) { - p0[n] = v0 = this._initQueueProps[n]; - } - if ((v1 = p1[n]) == null) { - p1[n] = v1 = v0; - } - if (v0 == v1 || ratio == 0 || ratio == 1 || (typeof (v0) != "number")) { - v = ratio == 1 ? v1 : v0; - } - else { - v = v0 + (v1 - v0) * ratio; - } - var ignore = false; - if (arr = Tween._plugins[n]) { - for (var i = 0, l = arr.length; i < l; i++) { - var v2 = arr[i].tween(this, n, v, p0, p1, ratio, !!step && p0 == p1, !step); - if (v2 == Tween.IGNORE) { - ignore = true; - } - else { - v = v2; - } - } - } - if (!ignore) { - this._target[n] = v; - } - } - }; - /** - * Whether setting is paused - * @param value {boolean} Whether to pause - * @returns Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置是否暂停 - * @param value {boolean} 是否暂停 - * @returns Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.prototype.setPaused = function (value) { - if (this.paused == value) { - return this; - } - this.paused = value; - Tween._register(this, !value); - return this; - }; - /** - * @private - * - * @param props - * @returns - */ - Tween.prototype._cloneProps = function (props) { - var o = {}; - for (var n in props) { - o[n] = props[n]; - } - return o; - }; - /** - * @private - * - * @param o - * @returns - */ - Tween.prototype._addStep = function (o) { - if (o.d > 0) { - o.type = "step"; - this._steps.push(o); - o.t = this.duration; - this.duration += o.d; - } - return this; - }; - /** - * @private - * - * @param o - * @returns - */ - Tween.prototype._appendQueueProps = function (o) { - var arr, oldValue, i, l, injectProps; - for (var n in o) { - if (this._initQueueProps[n] === undefined) { - oldValue = this._target[n]; - //设置plugins - if (arr = Tween._plugins[n]) { - for (i = 0, l = arr.length; i < l; i++) { - oldValue = arr[i].init(this, n, oldValue); - } - } - this._initQueueProps[n] = this._curQueueProps[n] = (oldValue === undefined) ? null : oldValue; - } - else { - oldValue = this._curQueueProps[n]; - } - } - for (var n in o) { - oldValue = this._curQueueProps[n]; - if (arr = Tween._plugins[n]) { - injectProps = injectProps || {}; - for (i = 0, l = arr.length; i < l; i++) { - if (arr[i].step) { - arr[i].step(this, n, oldValue, o[n], injectProps); - } - } - } - this._curQueueProps[n] = o[n]; - } - if (injectProps) { - this._appendQueueProps(injectProps); - } - return this._curQueueProps; - }; - /** - * @private - * - * @param o - * @returns - */ - Tween.prototype._addAction = function (o) { - o.t = this.duration; - o.type = "action"; - this._steps.push(o); - return this; - }; - /** - * @private - * - * @param props - * @param o - */ - Tween.prototype._set = function (props, o) { - for (var n in props) { - o[n] = props[n]; - } - }; - /** - * Wait the specified milliseconds before the execution of the next animation - * @param duration {number} Waiting time, in milliseconds - * @param passive {boolean} Whether properties are updated during the waiting time - * @returns Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等待指定毫秒后执行下一个动画 - * @param duration {number} 要等待的时间,以毫秒为单位 - * @param passive {boolean} 等待期间属性是否会更新 - * @returns Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.prototype.wait = function (duration, passive) { - if (duration == null || duration <= 0) { - return this; - } - var o = this._cloneProps(this._curQueueProps); - return this._addStep({ d: duration, p0: o, p1: o, v: passive }); - }; - /** - * Modify the property of the specified object to a specified value - * @param props {Object} Property set of an object - * @param duration {number} Duration - * @param ease {egret.Ease} Easing algorithm - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定对象的属性修改为指定值 - * @param props {Object} 对象的属性集合 - * @param duration {number} 持续时间 - * @param ease {egret.Ease} 缓动算法 - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.prototype.to = function (props, duration, ease) { - if (ease === void 0) { ease = undefined; } - if (isNaN(duration) || duration < 0) { - duration = 0; - } - this._addStep({ d: duration || 0, p0: this._cloneProps(this._curQueueProps), e: ease, p1: this._cloneProps(this._appendQueueProps(props)) }); - //加入一步set,防止游戏极其卡顿时候,to后面的call取到的属性值不对 - return this.set(props); - }; - /** - * Execute callback function - * @param callback {Function} Callback method - * @param thisObj {any} this action scope of the callback method - * @param params {any[]} Parameter of the callback method - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @example - *
      -         *  egret.Tween.get(display).call(function (a:number, b:string) {
      -         *      console.log("a: " + a); // the first parameter passed 233
      -         *      console.log("b: " + b); // the second parameter passed “hello”
      -         *  }, this, [233, "hello"]);
      -         * 
      - * @language en_US - */ - /** - * 执行回调函数 - * @param callback {Function} 回调方法 - * @param thisObj {any} 回调方法this作用域 - * @param params {any[]} 回调方法参数 - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @example - *
      -         *  egret.Tween.get(display).call(function (a:number, b:string) {
      -         *      console.log("a: " + a); //对应传入的第一个参数 233
      -         *      console.log("b: " + b); //对应传入的第二个参数 “hello”
      -         *  }, this, [233, "hello"]);
      -         * 
      - * @language zh_CN - */ - Tween.prototype.call = function (callback, thisObj, params) { - if (thisObj === void 0) { thisObj = undefined; } - if (params === void 0) { params = undefined; } - return this._addAction({ f: callback, p: params ? params : [], o: thisObj ? thisObj : this._target }); - }; - /** - * Now modify the properties of the specified object to the specified value - * @param props {Object} Property set of an object - * @param target The object whose Tween to be resumed - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * 立即将指定对象的属性修改为指定值 - * @param props {Object} 对象的属性集合 - * @param target 要继续播放 Tween 的对象 - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - */ - Tween.prototype.set = function (props, target) { - if (target === void 0) { target = null; } - //更新当前数据,保证缓动流畅性 - this._appendQueueProps(props); - return this._addAction({ f: this._set, o: this, p: [props, target ? target : this._target] }); - }; - /** - * Execute - * @param tween {egret.Tween} The Tween object to be operated. Default: this - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 执行 - * @param tween {egret.Tween} 需要操作的 Tween 对象,默认this - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.prototype.play = function (tween) { - if (!tween) { - tween = this; - } - return this.call(tween.setPaused, tween, [false]); - }; - /** - * Pause - * @param tween {egret.Tween} The Tween object to be operated. Default: this - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停 - * @param tween {egret.Tween} 需要操作的 Tween 对象,默认this - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.prototype.pause = function (tween) { - if (!tween) { - tween = this; - } - return this.call(tween.setPaused, tween, [true]); - }; - /** - * @method egret.Tween#tick - * @param delta {number} - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - Tween.prototype.$tick = function (delta) { - if (this.paused) { - return; - } - this.setPosition(this._prevPosition + delta); - }; - /** - * 不做特殊处理 - * @constant {number} egret.Tween.NONE - * @private - */ - Tween.NONE = 0; - /** - * 循环 - * @constant {number} egret.Tween.LOOP - * @private - */ - Tween.LOOP = 1; - /** - * 倒序 - * @constant {number} egret.Tween.REVERSE - * @private - */ - Tween.REVERSE = 2; - /** - * @private - */ - Tween._tweens = []; - /** - * @private - */ - Tween.IGNORE = {}; - /** - * @private - */ - Tween._plugins = {}; - /** - * @private - */ - Tween._inited = false; - Tween._lastTime = 0; - return Tween; - }(egret.EventDispatcher)); - egret.Tween = Tween; - __reflect(Tween.prototype, "egret.Tween"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var tween; - (function (tween) { - /** - * Abstract class, Indicate the base action. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 抽象类,表示一个基本动作 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - var BasePath = (function (_super) { - __extends(BasePath, _super); - function BasePath() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * the name of this action. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 动作的名称 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - _this.name = ""; - return _this; - } - return BasePath; - }(egret.EventDispatcher)); - tween.BasePath = BasePath; - __reflect(BasePath.prototype, "egret.tween.BasePath"); - /** - * Indicate the to action. See Tween.to - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个to动作,参见Tween.to - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - var To = (function (_super) { - __extends(To, _super); - function To() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * Property set of an object - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 对象的属性集合 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - _this.props = undefined; - /** - * Duration - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 持续时间 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - _this.duration = 500; - /** - * Easing algorithm - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 缓动算法 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - _this.ease = undefined; - return _this; - } - return To; - }(BasePath)); - tween.To = To; - __reflect(To.prototype, "egret.tween.To"); - /** - * Indicate the wait action. See Tween.wait - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个wait动作,参见Tween.wait - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - var Wait = (function (_super) { - __extends(Wait, _super); - function Wait() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * Duration - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 持续时间 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - _this.duration = 500; - /** - * Whether properties are updated during the waiting time - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 等待期间属性是否会更新 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - _this.passive = undefined; - return _this; - } - return Wait; - }(BasePath)); - tween.Wait = Wait; - __reflect(Wait.prototype, "egret.tween.Wait"); - /** - * Indicate the set action. See Tween.set - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个set动作,参见Tween.set - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - var Set = (function (_super) { - __extends(Set, _super); - function Set() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * Property set of an object - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 对象的属性集合 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - _this.props = undefined; - return _this; - } - return Set; - }(BasePath)); - tween.Set = Set; - __reflect(Set.prototype, "egret.tween.Set"); - /** - * Indicate the tick action. See Tween.tick - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个tick动作,参见Tween.tick - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - var Tick = (function (_super) { - __extends(Tick, _super); - function Tick() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * Delta time - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 增加的时间 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - _this.delta = 0; - return _this; - } - return Tick; - }(BasePath)); - tween.Tick = Tick; - __reflect(Tick.prototype, "egret.tween.Tick"); - function convertEase(ease) { - if (typeof ease === 'function') { - return ease; - } - else { - var func = egret.Ease[ease]; - if (typeof func === 'function') { - return func; - } - } - return null; - } - /** - * TweenItem is a wrapper for Tween, which can set the behavior of Tween by setting attributes and adding Path. - * - * @event pathComplete Dispatched when some Path has complete. - * @event complete Dispatched when all Paths has complete. - * - * @defaultProperty props - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * TweenItem是对Tween的包装器,能通过设置属性和添加Path的方式设置Tween的行为。 - * 通常用于使用在EXML中定义组件的动画。 - * - * @event pathComplete 当某个Path执行完毕时会派发此事件。 - * @event complete 当所有Path执行完毕时会派发此事件。 - * - * @defaultProperty props - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - /** - * Use in exml: - * ``` - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * ``` - */ - var TweenItem = (function (_super) { - __extends(TweenItem, _super); - function TweenItem() { - var _this = _super.call(this) || this; - _this.isStop = false; - return _this; - } - Object.defineProperty(TweenItem.prototype, "props", { - /** - * The Tween's props. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * Tween的props参数。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._props; - }, - set: function (value) { - this._props = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TweenItem.prototype, "target", { - /** - * The Tween's target. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * Tween的target参数。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._target; - }, - set: function (value) { - this._target = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TweenItem.prototype, "paths", { - /** - * The Actions in Tween. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * TweenItem中添加的行为。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._paths; - }, - set: function (value) { - this._paths = value || []; - }, - enumerable: true, - configurable: true - }); - /** - * Play the Tween - * @position The starting position, the default is from the last position to play - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 播放Tween - * @position 播放的起始位置, 默认为从上次位置继续播放 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - TweenItem.prototype.play = function (position) { - if (!this.tween) { - this.createTween(position); - } - else { - this.tween.setPaused(false); - if (this.isStop && position == undefined) { - position = 0; - this.isStop = false; - } - if (position !== undefined && position !== null) { - this.tween.setPosition(position); - } - } - }; - /** - * Pause the Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - TweenItem.prototype.pause = function () { - if (this.tween) { - this.tween.setPaused(true); - } - }; - /** - * Stop the Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 停止Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - TweenItem.prototype.stop = function () { - this.pause(); - this.isStop = true; - }; - TweenItem.prototype.createTween = function (position) { - this.tween = egret.Tween.get(this._target, this._props); - if (this._paths) { - this.applyPaths(); - } - if (position !== undefined && position !== null) { - this.tween.setPosition(position); - } - }; - TweenItem.prototype.applyPaths = function () { - for (var i = 0; i < this._paths.length; i++) { - var path = this._paths[i]; - this.applyPath(path); - } - }; - TweenItem.prototype.applyPath = function (path) { - var _this = this; - if (path instanceof To) { - this.tween.to(path.props, path.duration, convertEase(path.ease)); - } - else if (path instanceof Wait) { - this.tween.wait(path.duration, path.passive); - } - else if (path instanceof Set) { - this.tween.set(path.props); - } - else if (path instanceof Tick) { - this.tween.$tick(path.delta); - } - this.tween.call(function () { return _this.pathComplete(path); }); - }; - TweenItem.prototype.pathComplete = function (path) { - path.dispatchEventWith('complete'); - this.dispatchEventWith('pathComplete', false, path); - var index = this._paths.indexOf(path); - if (index >= 0 && index === this._paths.length - 1) { - this.dispatchEventWith('complete'); - } - }; - return TweenItem; - }(egret.EventDispatcher)); - tween.TweenItem = TweenItem; - __reflect(TweenItem.prototype, "egret.tween.TweenItem"); - registerProperty(TweenItem, 'paths', 'Array', true); - /** - * TweenGroup is a collection of TweenItem that can be played in parallel with each Item - * - * @event itemComplete Dispatched when some TweenItem has complete. - * @event complete Dispatched when all TweenItems has complete. - * - * @version Egret 3.1.8 - * @platform Web,Native - * @includeExample extension/tween/TweenWrapper.ts - * @language en_US - */ - /** - * TweenGroup是TweenItem的集合,可以并行播放每一个Item - * @version Egret 3.1.8 - * @platform Web,Native - * @includeExample extension/tween/TweenWrapper.ts - * @language zh_CN - */ - var TweenGroup = (function (_super) { - __extends(TweenGroup, _super); - function TweenGroup() { - var _this = _super.call(this) || this; - _this.completeCount = 0; - return _this; - } - Object.defineProperty(TweenGroup.prototype, "items", { - /** - * The Array that TweenItems in TweenGroup. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * TweenGroup要控制的TweenItem集合。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._items; - }, - set: function (value) { - this.completeCount = 0; - this.registerEvent(false); - this._items = value; - this.registerEvent(true); - }, - enumerable: true, - configurable: true - }); - TweenGroup.prototype.registerEvent = function (add) { - var _this = this; - this._items && this._items.forEach(function (item) { - if (add) { - item.addEventListener('complete', _this.itemComplete, _this); - } - else { - item.removeEventListener('complete', _this.itemComplete, _this); - } - }); - }; - /** - * Play the all TweenItems - * @time The starting position, the default is from the last position to play。If use 0, the group will play from the start position. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 播放所有的TweenItem - * @time 播放的起始位置, 默认为从上次位置继续播放。如果为0,则从起始位置开始播放。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - TweenGroup.prototype.play = function (time) { - if (!this._items) { - return; - } - for (var i = 0; i < this._items.length; i++) { - var item = this._items[i]; - item.play(time); - } - }; - /** - * Pause the all TweenItems - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停播放所有的TweenItem - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - TweenGroup.prototype.pause = function () { - if (!this._items) { - return; - } - for (var i = 0; i < this._items.length; i++) { - var item = this._items[i]; - item.pause(); - } - }; - /** - * Stop the all TweenItems - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 停止所有的TweenItem - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - TweenGroup.prototype.stop = function () { - if (!this._items) { - return; - } - for (var i = 0; i < this._items.length; i++) { - var item = this._items[i]; - item.stop(); - } - }; - TweenGroup.prototype.itemComplete = function (e) { - var item = e.currentTarget; - this.completeCount++; - this.dispatchEventWith('itemComplete', false, item); - if (this.completeCount === this.items.length) { - this.dispatchEventWith('complete'); - this.completeCount = 0; - } - }; - return TweenGroup; - }(egret.EventDispatcher)); - tween.TweenGroup = TweenGroup; - __reflect(TweenGroup.prototype, "egret.tween.TweenGroup"); - registerProperty(TweenGroup, 'items', 'Array', true); - function registerProperty(classDefinition, property, type, asDefault) { - var prototype = classDefinition.prototype; - prototype.__meta__ = prototype.__meta__ || {}; - prototype.__meta__[property] = type; - if (asDefault) { - prototype.__defaultProperty__ = property; - } - } - })(tween = egret.tween || (egret.tween = {})); -})(egret || (egret = {})); diff --git a/helloworld/libs/modules/tween/tween.min.js b/helloworld/libs/modules/tween/tween.min.js deleted file mode 100644 index abe1c4b..0000000 --- a/helloworld/libs/modules/tween/tween.min.js +++ /dev/null @@ -1 +0,0 @@ -var __reflect=this&&this.__reflect||function(t,e,n){t.__class__=e,n?n.push(e):n=[e],t.__types__=t.__types__?n.concat(t.__types__):n},__extends=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);n.prototype=e.prototype,t.prototype=new n},egret;!function(t){var e=function(){function e(){t.$error(1014)}return e.get=function(t){return-1>t&&(t=-1),t>1&&(t=1),function(e){return 0==t?e:0>t?e*(e*-t+1+t):e*((2-e)*t+(1-t))}},e.getPowIn=function(t){return function(e){return Math.pow(e,t)}},e.getPowOut=function(t){return function(e){return 1-Math.pow(1-e,t)}},e.getPowInOut=function(t){return function(e){return(e*=2)<1?.5*Math.pow(e,t):1-.5*Math.abs(Math.pow(2-e,t))}},e.sineIn=function(t){return 1-Math.cos(t*Math.PI/2)},e.sineOut=function(t){return Math.sin(t*Math.PI/2)},e.sineInOut=function(t){return-.5*(Math.cos(Math.PI*t)-1)},e.getBackIn=function(t){return function(e){return e*e*((t+1)*e-t)}},e.getBackOut=function(t){return function(e){return--e*e*((t+1)*e+t)+1}},e.getBackInOut=function(t){return t*=1.525,function(e){return(e*=2)<1?.5*(e*e*((t+1)*e-t)):.5*((e-=2)*e*((t+1)*e+t)+2)}},e.circIn=function(t){return-(Math.sqrt(1-t*t)-1)},e.circOut=function(t){return Math.sqrt(1- --t*t)},e.circInOut=function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},e.bounceIn=function(t){return 1-e.bounceOut(1-t)},e.bounceOut=function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},e.bounceInOut=function(t){return.5>t?.5*e.bounceIn(2*t):.5*e.bounceOut(2*t-1)+.5},e.getElasticIn=function(t,e){var n=2*Math.PI;return function(i){if(0==i||1==i)return i;var s=e/n*Math.asin(1/t);return-(t*Math.pow(2,10*(i-=1))*Math.sin((i-s)*n/e))}},e.getElasticOut=function(t,e){var n=2*Math.PI;return function(i){if(0==i||1==i)return i;var s=e/n*Math.asin(1/t);return t*Math.pow(2,-10*i)*Math.sin((i-s)*n/e)+1}},e.getElasticInOut=function(t,e){var n=2*Math.PI;return function(i){var s=e/n*Math.asin(1/t);return(i*=2)<1?-.5*(t*Math.pow(2,10*(i-=1))*Math.sin((i-s)*n/e)):t*Math.pow(2,-10*(i-=1))*Math.sin((i-s)*n/e)*.5+1}},e.quadIn=e.getPowIn(2),e.quadOut=e.getPowOut(2),e.quadInOut=e.getPowInOut(2),e.cubicIn=e.getPowIn(3),e.cubicOut=e.getPowOut(3),e.cubicInOut=e.getPowInOut(3),e.quartIn=e.getPowIn(4),e.quartOut=e.getPowOut(4),e.quartInOut=e.getPowInOut(4),e.quintIn=e.getPowIn(5),e.quintOut=e.getPowOut(5),e.quintInOut=e.getPowInOut(5),e.backIn=e.getBackIn(1.7),e.backOut=e.getBackOut(1.7),e.backInOut=e.getBackInOut(1.7),e.elasticIn=e.getElasticIn(1,.3),e.elasticOut=e.getElasticOut(1,.3),e.elasticInOut=e.getElasticInOut(1,.3*1.5),e}();t.Ease=e,__reflect(e.prototype,"egret.Ease")}(egret||(egret={}));var egret;!function(t){var e=function(e){function n(t,n,i){var s=e.call(this)||this;return s._target=null,s._useTicks=!1,s.ignoreGlobalPause=!1,s.loop=!1,s.pluginData=null,s._steps=null,s.paused=!1,s.duration=0,s._prevPos=-1,s.position=null,s._prevPosition=0,s._stepPosition=0,s.passive=!1,s.initialize(t,n,i),s}return __extends(n,e),n.get=function(t,e,i,s){return void 0===i&&(i=null),void 0===s&&(s=!1),s&&n.removeTweens(t),new n(t,e,i)},n.removeTweens=function(t){if(t.tween_count){for(var e=n._tweens,i=e.length-1;i>=0;i--)e[i]._target==t&&(e[i].paused=!0,e.splice(i,1));t.tween_count=0}},n.pauseTweens=function(e){if(e.tween_count)for(var n=t.Tween._tweens,i=n.length-1;i>=0;i--)n[i]._target==e&&(n[i].paused=!0)},n.resumeTweens=function(e){if(e.tween_count)for(var n=t.Tween._tweens,i=n.length-1;i>=0;i--)n[i]._target==e&&(n[i].paused=!1)},n.tick=function(t,e){void 0===e&&(e=!1);var i=t-n._lastTime;n._lastTime=t;for(var s=n._tweens.concat(),r=s.length-1;r>=0;r--){var o=s[r];e&&!o.ignoreGlobalPause||o.paused||o.$tick(o._useTicks?1:i)}return!1},n._register=function(e,i){var s=e._target,r=n._tweens;if(i)s&&(s.tween_count=s.tween_count>0?s.tween_count+1:1),r.push(e),n._inited||(n._lastTime=t.getTimer(),t.ticker.$startTick(n.tick,null),n._inited=!0);else{s&&s.tween_count--;for(var o=r.length;o--;)if(r[o]==e)return void r.splice(o,1)}},n.removeAllTweens=function(){for(var t=n._tweens,e=0,i=t.length;i>e;e++){var s=t[e];s.paused=!0,s._target.tween_count=0}t.length=0},n.prototype.initialize=function(t,e,i){this._target=t,e&&(this._useTicks=e.useTicks,this.ignoreGlobalPause=e.ignoreGlobalPause,this.loop=e.loop,e.onChange&&this.addEventListener("change",e.onChange,e.onChangeObj),e.override&&n.removeTweens(t)),this.pluginData=i||{},this._curQueueProps={},this._initQueueProps={},this._steps=[],e&&e.paused?this.paused=!0:n._register(this,!0),e&&null!=e.position&&this.setPosition(e.position,n.NONE)},n.prototype.setPosition=function(t,e){void 0===e&&(e=1),0>t&&(t=0);var n=t,i=!1;if(n>=this.duration)if(this.loop){var s=n%this.duration;n=n>0&&0===s?this.duration:s}else n=this.duration,i=!0;if(n==this._prevPos)return i;i&&this.setPaused(!0);var r=this._prevPos;if(this.position=this._prevPos=n,this._prevPosition=t,this._target&&this._steps.length>0){for(var o=this._steps.length,u=-1,a=0;o>a&&!("step"==this._steps[a].type&&(u=a,this._steps[a].t<=n&&this._steps[a].t+this._steps[a].d>=n));a++);for(var a=0;o>a;a++)if("action"==this._steps[a].type)0!=e&&(this._useTicks?this._runAction(this._steps[a],n,n):1==e&&r>n?(r!=this.duration&&this._runAction(this._steps[a],r,this.duration),this._runAction(this._steps[a],0,n,!0)):this._runAction(this._steps[a],r,n));else if("step"==this._steps[a].type&&u==a){var p=this._steps[u];this._updateTargetProps(p,Math.min((this._stepPosition=n-p.t)/p.d,1))}}return this.dispatchEventWith("change"),i},n.prototype._runAction=function(t,e,n,i){void 0===i&&(i=!1);var s=e,r=n;e>n&&(s=n,r=e);var o=t.t;(o==r||o>s&&r>o||i&&o==e)&&t.f.apply(t.o,t.p)},n.prototype._updateTargetProps=function(t,e){var i,s,r,o,u,a;if(t||1!=e){if(this.passive=!!t.v,this.passive)return;t.e&&(e=t.e(e,0,1,1)),i=t.p0,s=t.p1}else this.passive=!1,i=s=this._curQueueProps;for(var p in this._initQueueProps){null==(o=i[p])&&(i[p]=o=this._initQueueProps[p]),null==(u=s[p])&&(s[p]=u=o),r=o==u||0==e||1==e||"number"!=typeof o?1==e?u:o:o+(u-o)*e;var h=!1;if(a=n._plugins[p])for(var c=0,_=a.length;_>c;c++){var f=a[c].tween(this,p,r,i,s,e,!!t&&i==s,!t);f==n.IGNORE?h=!0:r=f}h||(this._target[p]=r)}},n.prototype.setPaused=function(t){return this.paused==t?this:(this.paused=t,n._register(this,!t),this)},n.prototype._cloneProps=function(t){var e={};for(var n in t)e[n]=t[n];return e},n.prototype._addStep=function(t){return t.d>0&&(t.type="step",this._steps.push(t),t.t=this.duration,this.duration+=t.d),this},n.prototype._appendQueueProps=function(t){var e,i,s,r,o;for(var u in t)if(void 0===this._initQueueProps[u]){if(i=this._target[u],e=n._plugins[u])for(s=0,r=e.length;r>s;s++)i=e[s].init(this,u,i);this._initQueueProps[u]=this._curQueueProps[u]=void 0===i?null:i}else i=this._curQueueProps[u];for(var u in t){if(i=this._curQueueProps[u],e=n._plugins[u])for(o=o||{},s=0,r=e.length;r>s;s++)e[s].step&&e[s].step(this,u,i,t[u],o);this._curQueueProps[u]=t[u]}return o&&this._appendQueueProps(o),this._curQueueProps},n.prototype._addAction=function(t){return t.t=this.duration,t.type="action",this._steps.push(t),this},n.prototype._set=function(t,e){for(var n in t)e[n]=t[n]},n.prototype.wait=function(t,e){if(null==t||0>=t)return this;var n=this._cloneProps(this._curQueueProps);return this._addStep({d:t,p0:n,p1:n,v:e})},n.prototype.to=function(t,e,n){return void 0===n&&(n=void 0),(isNaN(e)||0>e)&&(e=0),this._addStep({d:e||0,p0:this._cloneProps(this._curQueueProps),e:n,p1:this._cloneProps(this._appendQueueProps(t))}),this.set(t)},n.prototype.call=function(t,e,n){return void 0===e&&(e=void 0),void 0===n&&(n=void 0),this._addAction({f:t,p:n?n:[],o:e?e:this._target})},n.prototype.set=function(t,e){return void 0===e&&(e=null),this._appendQueueProps(t),this._addAction({f:this._set,o:this,p:[t,e?e:this._target]})},n.prototype.play=function(t){return t||(t=this),this.call(t.setPaused,t,[!1])},n.prototype.pause=function(t){return t||(t=this),this.call(t.setPaused,t,[!0])},n.prototype.$tick=function(t){this.paused||this.setPosition(this._prevPosition+t)},n.NONE=0,n.LOOP=1,n.REVERSE=2,n._tweens=[],n.IGNORE={},n._plugins={},n._inited=!1,n._lastTime=0,n}(t.EventDispatcher);t.Tween=e,__reflect(e.prototype,"egret.Tween")}(egret||(egret={}));var egret;!function(t){var e;!function(e){function n(e){if("function"==typeof e)return e;var n=t.Ease[e];return"function"==typeof n?n:null}function i(t,e,n,i){var s=t.prototype;s.__meta__=s.__meta__||{},s.__meta__[e]=n,i&&(s.__defaultProperty__=e)}var s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="",e}return __extends(e,t),e}(t.EventDispatcher);e.BasePath=s,__reflect(s.prototype,"egret.tween.BasePath");var r=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.props=void 0,e.duration=500,e.ease=void 0,e}return __extends(e,t),e}(s);e.To=r,__reflect(r.prototype,"egret.tween.To");var o=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.duration=500,e.passive=void 0,e}return __extends(e,t),e}(s);e.Wait=o,__reflect(o.prototype,"egret.tween.Wait");var u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.props=void 0,e}return __extends(e,t),e}(s);e.Set=u,__reflect(u.prototype,"egret.tween.Set");var a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.delta=0,e}return __extends(e,t),e}(s);e.Tick=a,__reflect(a.prototype,"egret.tween.Tick");var p=function(e){function i(){var t=e.call(this)||this;return t.isStop=!1,t}return __extends(i,e),Object.defineProperty(i.prototype,"props",{get:function(){return this._props},set:function(t){this._props=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"target",{get:function(){return this._target},set:function(t){this._target=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"paths",{get:function(){return this._paths},set:function(t){this._paths=t||[]},enumerable:!0,configurable:!0}),i.prototype.play=function(t){this.tween?(this.tween.setPaused(!1),this.isStop&&void 0==t&&(t=0,this.isStop=!1),void 0!==t&&null!==t&&this.tween.setPosition(t)):this.createTween(t)},i.prototype.pause=function(){this.tween&&this.tween.setPaused(!0)},i.prototype.stop=function(){this.pause(),this.isStop=!0},i.prototype.createTween=function(e){this.tween=t.Tween.get(this._target,this._props),this._paths&&this.applyPaths(),void 0!==e&&null!==e&&this.tween.setPosition(e)},i.prototype.applyPaths=function(){for(var t=0;t=0&&e===this._paths.length-1&&this.dispatchEventWith("complete")},i}(t.EventDispatcher);e.TweenItem=p,__reflect(p.prototype,"egret.tween.TweenItem"),i(p,"paths","Array",!0);var h=function(t){function e(){var e=t.call(this)||this;return e.completeCount=0,e}return __extends(e,t),Object.defineProperty(e.prototype,"items",{get:function(){return this._items},set:function(t){this.completeCount=0,this.registerEvent(!1),this._items=t,this.registerEvent(!0)},enumerable:!0,configurable:!0}),e.prototype.registerEvent=function(t){var e=this;this._items&&this._items.forEach(function(n){t?n.addEventListener("complete",e.itemComplete,e):n.removeEventListener("complete",e.itemComplete,e)})},e.prototype.play=function(t){if(this._items)for(var e=0;eOpen-source
      ,Free,Multi-platform", - "Push Game Forward", - "HTML5 Game Engine" -] \ No newline at end of file diff --git a/helloworld/resource/default.res.json b/helloworld/resource/default.res.json deleted file mode 100644 index 4e8fbd3..0000000 --- a/helloworld/resource/default.res.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "groups": [ - { - "keys": "bg_jpg,egret_icon_png,description_json,circle_png,rect_png,break_mp3,hit_mp3", - "name": "preload" - } - ], - "resources": [ - { - "name": "bg_jpg", - "type": "image", - "url": "assets/bg.jpg" - }, - { - "name": "egret_icon_png", - "type": "image", - "url": "assets/egret_icon.png" - }, - { - "name": "description_json", - "type": "json", - "url": "config/description.json" - }, - { - "name": "circle_png", - "type": "image", - "url": "assets/circle.png" - }, - { - "name": "rect_png", - "type": "image", - "url": "assets/rect.png" - }, - { - "name": "break_mp3", - "type": "sound", - "url": "assets/break.mp3" - }, - { - "name": "hit_mp3", - "type": "sound", - "url": "assets/hit.mp3" - } - ] -} \ No newline at end of file diff --git a/helloworld/scripts/api.d.ts b/helloworld/scripts/api.d.ts deleted file mode 100644 index 2fe6c83..0000000 --- a/helloworld/scripts/api.d.ts +++ /dev/null @@ -1,415 +0,0 @@ - -/** - * ResourceManager 配置文件 - */ -type ResourceManagerConfig = { - /** - * 构建与发布配置 - */ - buildConfig: (param: BuildConfigParam) => UserConfig, - /** - * 设置资源类型 - */ - typeSelector: (path: string) => (string | null | undefined) - /** - * 设置资源的合并策略 - */ - mergeSelector?: (path: string) => (string | null | undefined), - /** - * 设置资源的命名策略 - * beta 功能,请勿随意使用 - */ - nameSelector?: (path: string) => (string | null | undefined) -} -/** - * 构建配置 - */ -type UserConfig = { - /** - * 输出路径 - */ - outputDir: string, - /** - * 插件 - */ - commands: (string | plugins.Command)[] -} - -type BuildConfigParam = { - - - /** - * 当前命令,build 或者 command - */ - readonly command: string; - - /** - * 发布平台 - */ - readonly target: string; - - /** - * 开发者指定的版本号 - */ - readonly version: string; - - /** - * 项目名称 - */ - readonly projectName: string; - - /** - * 项目路径 - */ - readonly projectRoot: string; - - /** - * 项目配置 - */ - readonly projectConfig: ProjectConfig; -} - -type ProjectConfig = { - entryClassName: string; - orientation: string; - frameRate: number; - scaleMode: string; - contentWidth: number; - contentHeight: number; - showFPS: boolean; - fpsStyles: string; - showLog: boolean; - maxTouches: number; -} -/** - * 匹配机制,将满足 from 的文件输出为 to 格式的文件 - * from 采用 glob 表达式 , to 包含 [path][name][hash][ext]四个变量 - * 示例:{ from:"resource/**.*" , to:"[path][name]_[hash].[ext]" } - */ -type Matcher = { - - from: string, - - to: string - -} - - -declare namespace plugins { - - interface CommandContext { - - /** - * 可以用此接口进行文件创建 - */ - createFile(relativeFilePath: string, contents: Buffer); - - /** - * 构建配置 - */ - buildConfig: BuildConfigParam; - - /** - * 项目绝对路径 - */ - projectRoot: string; - - /** - * 项目输出绝对路径 - */ - outputDir: string; - - } - - /** - * 构建管线命令 - */ - interface Command { - - /** - * 项目中的每个文件都会执行此函数,返回 file 表示保留此文件,返回 null 表示将此文件从构建管线中删除,即不会发布 - */ - onFile?(file: File): Promise - - /** - * 项目中所有文件均执行完后,最终会执行此函数。 - * 这个函数主要被用于创建新文件 - */ - onFinish?(pluginContext?: CommandContext): Promise - - [options: string]: any; - } - - interface File { - - /** - * 文件内容的二进制流,如果开发者需要修改文件内容,请修改此属性 - */ - contents: Buffer; - - - /** - * 文件绝对路径,如果开发者需要对文件进行重命名,请修改此属性 - */ - path: string; - - /** - * 文件所在的项目的项目路径 - */ - readonly base: string; - - /** - * 文件的相对于 base 属性的相对路径 - */ - readonly relative: string; - - - /** - * 文件变更历史,history[0] 即 origin 属性 - */ - readonly history: ReadonlyArray; - - - /** - * 文件所在的文件夹的绝对路径 - */ - readonly dirname: string; - - /** - * 文件的文件名 - */ - readonly basename: string; - - - /** - * 文件的扩展名 - */ - readonly extname: string; - - /** - * 文件的初始文件名 - */ - readonly origin: string; - - /** - * 其他自定义属性 - */ - [customProperty: string]: any; - - } - -} - - - - - - - - - - -declare module 'built-in' { - - /** - * 混淆插件参数,设置源代码和目标代码 - */ - type UglifyPluginOption = { sources: string[], target: string }; - - type UglifyPluginOptions = UglifyPluginOption[]; - - /** - * 混淆插件 - */ - export class UglifyPlugin implements plugins.Command { - - constructor(mergeSelector: UglifyPluginOptions); - - } - - - type LibraryType = "debug" | "release"; - - type CompilePluginOptions = { libraryType: LibraryType, defines?: any }; - /** - * 编译命令 - */ - export class CompilePlugin implements plugins.Command { - - constructor(options: CompilePluginOptions); - } - - /** - * EXML 插件,用于发布 EXML 文件 - */ - export class ExmlPlugin implements plugins.Command { - - constructor(publishPolicy: EXML_Publish_Policy); - - } - - /** - * 发布策略 - * * default : 使用 egretProperties.json 中的 exmlPublishPolicy 中的策略 - * * debug : 默认策略,用于开发环境 - * * contents : 将 EXML 的内容写入到主题文件中 - * * gjs : 将生成的JS文件写入到主题文件中 - * * commonjs : 将EXML合并为一个 CommonJS 风格的文件 - * * commonjs2 : 将EXML合并为一个含有解析方法和皮肤定义的文件,且皮肤抽离为一份配置 - */ - type EXML_Publish_Policy = "default" | "debug" | "contents" | "gjs" | "commonjs" | "commonjs2" - - - - - /** - * 生成 manifest 文件,这个文件会被用于记录 JavaScript 文件的版本号 - */ - export class ManifestPlugin implements plugins.Command { - constructor(options?: ManifestPluginOptions) - } - - /** - * 生成文件的文件名 - * 支持 json 与 js 两种格式 - */ - type ManifestPluginOptions = { - - output: string, - - hash?: "crc32", - - /** - * 是否输出转换过程 - */ - verbose?: boolean - - - } - - /** - * EmitResConfigFilePlugin 的参数 - * * output: 生成路径,可以指定生成为 *.res.js 文件或者 *.res.json 文件 - * * typeSelector: 根据文件路径决定文件类型 - * * nameSelector: 根据文件路径决定文件的资源名 - * * groupSelector: 根据文件路径决定资源所述的资源组 - */ - type EmitResConfigFilePluginOptions = { - output: string, - typeSelector: (path: string) => string | null | undefined, - nameSelector: (path: string) => string | null | undefined, - groupSelector: (path: string) => string | null | undefined, - } - - - /** - * 生成 res.json 文件或者 res.js 文件 - */ - export class EmitResConfigFilePlugin implements plugins.Command { - - constructor(options: EmitResConfigFilePluginOptions) - - } - - export type ConvertResourceConfigPluginOption = { - - resourceConfigFiles: { filename: string, root: string }[]; - - nameSelector: (url: string) => string - - - } - - export class ConvertResConfigFilePlugin implements plugins.Command { - - constructor(options: ConvertResourceConfigPluginOption); - } - - - /** - * 增量编译 - * 这个插件生成的 JavaScript 代码不会被添加到构建管线中,后续其他插件无法获取生成的 js 文件 - * 这个功能将会在未来被 watch 模式代替掉 - */ - export class IncrementCompilePlugin implements plugins.Command { - - } - - /** - * 使用 TextureMerger 实现纹理自动合并,依赖 TextureMerger 1.7 以上的版本 - */ - export class TextureMergerPlugin implements plugins.Command { - - constructor(); - - } - - type CleanPluginOptions = { - - matchers: string[] - } - - - export class CleanPlugin implements plugins.Command { - constructor(options: CleanPluginOptions); - } - - - type RenamePluginOptions = { - - /** - * 是否输出日志 - */ - verbose?: boolean - - /** - * 采用何种 hash 算法,目前暂时只支持 crc32 - */ - hash?: "crc32" - - - /** - * 设置匹配规则,将指定文件进行改名 - * 该参数是个数组,允许设置多个匹配规则 - */ - matchers: Matcher[] - } - - - /** - * 修改文件名插件 - */ - export class RenamePlugin implements plugins.Command { - constructor(options: RenamePluginOptions); - } - - type ResSplitPluginOptions = { - - /** - * 是否输出日志 - */ - verbose?: boolean - - /** - * 设置匹配规则,将指定文件拷贝至其他文件夹 - * 该参数是个数组,允许设置多个匹配规则 - */ - matchers: Matcher[] - } - - export class ResSplitPlugin implements plugins.Command { - constructor(options: ResSplitPluginOptions); - } - - - type ZipPluginOptions = { - - mergeSelector: (p: string) => string - } - - export class ZipPlugin implements plugins.Command { - - constructor(option: ZipPluginOptions); - } - -} \ No newline at end of file diff --git a/helloworld/scripts/bricks/bricks.ts b/helloworld/scripts/bricks/bricks.ts deleted file mode 100644 index abf2802..0000000 --- a/helloworld/scripts/bricks/bricks.ts +++ /dev/null @@ -1,51 +0,0 @@ -import * as fs from 'fs'; -import * as path from 'path'; - - -type ManifestConfig = { - - initial: string[], - - game: string[] - -} - -export class BricksPlugin implements plugins.Command { - - constructor() { - } - async onFile(file: plugins.File) { - const filename = file.origin; - if (filename == 'manifest.json') { - const contents = file.contents.toString(); - const jsonData: ManifestConfig = JSON.parse(contents); - - let content = ''; - content += `BK.Script.loadlib("GameRes://js/promise.js");\n`; - for (let item of jsonData.initial) { - if (item != 'js/promise.js' && item != 'js/promise.min.js') { - content += `BK.Script.loadlib("GameRes://${item}");\n` - } - if (item == "js/egret.js" || item == 'js/egret.min.js') { - content += `BK.Script.loadlib("GameRes://egret.bricks.js");\n` - } - } - for (let item of jsonData.game) { - content += `BK.Script.loadlib("GameRes://${item}");\n` - } - file.path = file.dirname + '/manifest.js' - file.contents = new Buffer(content); - } else if (filename == 'main.js') { - const content = file.contents.toString(); - let result = content.replace(/RES\.loadConfig\("resource\/default\.res\.json", "resource\/"\)/gm, 'RES.loadConfig("GameRes://resource/default.res.json", "GameRes://resource/")'); - result = result.replace(/eui\.Theme\("resource\/default\.thm\.json", _this\.stage\)/gm, 'eui.Theme("GameRes://resource/default.thm.json", _this.stage)'); - result += ";global.Main = Main;"; - file.path = file.dirname + '/main.js' - file.contents = new Buffer(result); - } - return file; - } - async onFinish(pluginContext) { - - } -} \ No newline at end of file diff --git a/helloworld/scripts/config.android.ts b/helloworld/scripts/config.android.ts deleted file mode 100644 index 510b904..0000000 --- a/helloworld/scripts/config.android.ts +++ /dev/null @@ -1,38 +0,0 @@ -/// 阅读 api.d.ts 查看文档 -/// - -import * as path from 'path'; -import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin } from 'built-in'; -import { BricksPlugin } from './bricks/bricks'; -import { CustomPlugin } from './myplugin'; -import * as defaultConfig from './config'; - -const config: ResourceManagerConfig = { - - buildConfig: (params) => { - - const { target, command, projectName, version } = params; - const outputDir = `../${projectName}_android/assets/game`; - return { - outputDir, - commands: [ - // new CompilePlugin({ libraryType: "debug", defines: { DEBUG: false, RELEASE: true } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), - new UglifyPlugin([{ - sources: ["main.js"], - target: "main.min.js" - }]), - new ManifestPlugin({ output: 'manifest.json' }) - ] - } - }, - - mergeSelector: defaultConfig.mergeSelector, - - typeSelector: defaultConfig.typeSelector -} - - - -export = config; diff --git a/helloworld/scripts/config.bricks.ts b/helloworld/scripts/config.bricks.ts deleted file mode 100644 index 588ec69..0000000 --- a/helloworld/scripts/config.bricks.ts +++ /dev/null @@ -1,34 +0,0 @@ -/// 阅读 api.d.ts 查看文档 -/// - -import * as path from 'path'; -import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin } from 'built-in'; -import { BricksPlugin } from './bricks/bricks'; -import { CustomPlugin } from './myplugin'; -import * as defaultConfig from './config'; - -const config: ResourceManagerConfig = { - - buildConfig: (params) => { - - const { target, command, projectName, version } = params; - const outputDir = `../${projectName}_bricks/PublicBrickEngineGame/Res`; - return { - outputDir, - commands: [ - new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new ManifestPlugin({ output: 'manifest.json' }), - new BricksPlugin() - ] - } - }, - - mergeSelector: defaultConfig.mergeSelector, - - typeSelector: defaultConfig.typeSelector -} - - - -export = config; diff --git a/helloworld/scripts/config.ios.ts b/helloworld/scripts/config.ios.ts deleted file mode 100644 index fe4e6a7..0000000 --- a/helloworld/scripts/config.ios.ts +++ /dev/null @@ -1,38 +0,0 @@ -/// 阅读 api.d.ts 查看文档 -/// - -import * as path from 'path'; -import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin } from 'built-in'; -import { BricksPlugin } from './bricks/bricks'; -import { CustomPlugin } from './myplugin'; -import * as defaultConfig from './config'; - -const config: ResourceManagerConfig = { - - buildConfig: (params) => { - - const { target, command, projectName, version } = params; - const outputDir = `../${projectName}_ios/assets/game`; - return { - outputDir, - commands: [ - new CompilePlugin({ libraryType: "debug", defines: { DEBUG: false, RELEASE: true } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), - new UglifyPlugin([{ - sources: ["main.js"], - target: "main.min.js" - }]), - new ManifestPlugin({ output: 'manifest.json' }) - ] - } - }, - - mergeSelector: defaultConfig.mergeSelector, - - typeSelector: defaultConfig.typeSelector -} - - - -export = config; diff --git a/helloworld/scripts/config.ts b/helloworld/scripts/config.ts deleted file mode 100644 index 71c5e99..0000000 --- a/helloworld/scripts/config.ts +++ /dev/null @@ -1,95 +0,0 @@ -/// 阅读 api.d.ts 查看文档 -/// - -import * as path from 'path'; -import { UglifyPlugin, IncrementCompilePlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, RenamePlugin } from 'built-in'; -import { WxgamePlugin } from './wxgame/wxgame'; -import { BricksPlugin } from './bricks/bricks'; -import { CustomPlugin } from './myplugin'; - -const config: ResourceManagerConfig = { - - - buildConfig: (params) => { - - const { target, command, projectName, version } = params; - - if (command == 'build') { - const outputDir = '.'; - return { - outputDir, - commands: [ - // new EmitResConfigFilePlugin({ - // output: "resource/default.res.json", - // typeSelector: config.typeSelector, - // nameSelector: p => path.basename(p).replace(/\./gi, "_"), - // groupSelector: p => "preload" - // }), - new ExmlPlugin('debug'), // 非 EUI 项目关闭此设置 - new IncrementCompilePlugin(), - ] - } - } - else if (command == 'publish') { - const outputDir = `bin-release/web/${version}`; - return { - outputDir, - commands: [ - new CustomPlugin(), - new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new UglifyPlugin([{ - sources: ["main.js"], - target: "main.min.js" - }]), - new RenamePlugin({ - verbose: true, hash: 'crc32', matchers: [ - { from: "**/*.js", to: "[path][name]_[hash].[ext]" } - ] - }), - new ManifestPlugin({ output: "manifest.json" }) - ] - } - } - else { - throw `unknown command : ${params.command}` - } - }, - - mergeSelector: (path) => { - if (path.indexOf("assets/bitmap/") >= 0) { - return "assets/bitmap/sheet.sheet" - } - else if (path.indexOf("armature") >= 0 && path.indexOf(".json") >= 0) { - return "assets/armature/1.zip"; - } - }, - - typeSelector: (path) => { - const ext = path.substr(path.lastIndexOf(".") + 1); - const typeMap = { - "jpg": "image", - "png": "image", - "webp": "image", - "json": "json", - "fnt": "font", - "pvr": "pvr", - "mp3": "sound", - "zip": "zip", - "sheet": "sheet", - "exml": "text" - } - let type = typeMap[ext]; - if (type == "json") { - if (path.indexOf("sheet") >= 0) { - type = "sheet"; - } else if (path.indexOf("movieclip") >= 0) { - type = "movieclip"; - }; - } - return type; - } -} - - -export = config; diff --git a/helloworld/scripts/config.wxgame.ts b/helloworld/scripts/config.wxgame.ts deleted file mode 100644 index 036f363..0000000 --- a/helloworld/scripts/config.wxgame.ts +++ /dev/null @@ -1,57 +0,0 @@ -/// 阅读 api.d.ts 查看文档 -/// - -import * as path from 'path'; -import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in'; -import { WxgamePlugin } from './wxgame/wxgame'; -import { CustomPlugin } from './myplugin'; -import * as defaultConfig from './config'; - -const config: ResourceManagerConfig = { - - buildConfig: (params) => { - - const { target, command, projectName, version } = params; - const outputDir = `../${projectName}_wxgame`; - if (command == 'build') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["js", "resource"] }), - new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new WxgamePlugin(), - new ManifestPlugin({ output: 'manifest.js' }) - ] - } - } - else if (command == 'publish') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["js", "resource"] }), - new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new WxgamePlugin(), - new UglifyPlugin([{ - sources: ["main.js"], - target: "main.min.js" - } - ]), - new ManifestPlugin({ output: 'manifest.js' }) - ] - } - } - else { - throw `unknown command : ${params.command}`; - } - }, - - mergeSelector: defaultConfig.mergeSelector, - - typeSelector: defaultConfig.typeSelector -} - - - -export = config; diff --git a/helloworld/scripts/myplugin.ts b/helloworld/scripts/myplugin.ts deleted file mode 100644 index f425f3a..0000000 --- a/helloworld/scripts/myplugin.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * 示例自定义插件,您可以查阅 http://developer.egret.com/cn/2d/projectConfig/cmdExtensionPluginin/ - * 了解如何开发一个自定义插件 - */ -export class CustomPlugin implements plugins.Command { - - constructor() { - } - - async onFile(file: plugins.File) { - return file; - } - - async onFinish(commandContext: plugins.CommandContext) { - - } -} \ No newline at end of file diff --git a/helloworld/scripts/node.d.ts b/helloworld/scripts/node.d.ts deleted file mode 100644 index 239fd38..0000000 --- a/helloworld/scripts/node.d.ts +++ /dev/null @@ -1,4209 +0,0 @@ -// Generated by typings -// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/a4a912a0cd1849fa7df0e5d909c8625fba04e49d/node/index.d.ts -interface Console { - Console: NodeJS.ConsoleConstructor; - assert(value: any, message?: string, ...optionalParams: any[]): void; - dir(obj: any, options?: {showHidden?: boolean, depth?: number, colors?: boolean}): void; - error(message?: any, ...optionalParams: any[]): void; - info(message?: any, ...optionalParams: any[]): void; - log(message?: any, ...optionalParams: any[]): void; - time(label: string): void; - timeEnd(label: string): void; - trace(message?: any, ...optionalParams: any[]): void; - warn(message?: any, ...optionalParams: any[]): void; -} - -interface Error { - stack?: string; -} - -interface ErrorConstructor { - captureStackTrace(targetObject: Object, constructorOpt?: Function): void; - stackTraceLimit: number; -} - -// compat for TypeScript 1.8 -// if you use with --target es3 or --target es5 and use below definitions, -// use the lib.es6.d.ts that is bundled with TypeScript 1.8. -interface MapConstructor { } -interface WeakMapConstructor { } -interface SetConstructor { } -interface WeakSetConstructor { } - -// Forward-declare needed types from lib.es2015.d.ts (in case users are using `--lib es5`) -interface Iterable {} -interface Iterator { - next(value?: any): IteratorResult; -} -interface IteratorResult {} -interface SymbolConstructor { - readonly iterator: symbol; -} -declare var Symbol: SymbolConstructor; - -/************************************************ -* * -* GLOBAL * -* * -************************************************/ -declare var process: NodeJS.Process; -declare var global: NodeJS.Global; -declare var console: Console; - -declare var __filename: string; -declare var __dirname: string; - -declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; -declare function clearTimeout(timeoutId: NodeJS.Timer): void; -declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; -declare function clearInterval(intervalId: NodeJS.Timer): void; -declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; -declare function clearImmediate(immediateId: any): void; - -interface NodeRequireFunction { - (id: string): any; -} - -interface NodeRequire extends NodeRequireFunction { - resolve(id: string): string; - cache: any; - extensions: any; - main: NodeModule | undefined; -} - -declare var require: NodeRequire; - -interface NodeModule { - exports: any; - require: NodeRequireFunction; - id: string; - filename: string; - loaded: boolean; - parent: NodeModule | null; - children: NodeModule[]; -} - -declare var module: NodeModule; - -// Same as module.exports -declare var exports: any; -declare var SlowBuffer: { - new (str: string, encoding?: string): Buffer; - new (size: number): Buffer; - new (size: Uint8Array): Buffer; - new (array: any[]): Buffer; - prototype: Buffer; - isBuffer(obj: any): boolean; - byteLength(string: string, encoding?: string): number; - concat(list: Buffer[], totalLength?: number): Buffer; -}; - - -// Buffer class -type BufferEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "binary" | "hex"; -interface Buffer extends NodeBuffer { } - -/** - * Raw data is stored in instances of the Buffer class. - * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized. - * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' - */ -declare var Buffer: { - /** - * Allocates a new buffer containing the given {str}. - * - * @param str String to store in buffer. - * @param encoding encoding to use, optional. Default is 'utf8' - */ - new (str: string, encoding?: string): Buffer; - /** - * Allocates a new buffer of {size} octets. - * - * @param size count of octets to allocate. - */ - new (size: number): Buffer; - /** - * Allocates a new buffer containing the given {array} of octets. - * - * @param array The octets to store. - */ - new (array: Uint8Array): Buffer; - /** - * Produces a Buffer backed by the same allocated memory as - * the given {ArrayBuffer}. - * - * - * @param arrayBuffer The ArrayBuffer with which to share memory. - */ - new (arrayBuffer: ArrayBuffer): Buffer; - /** - * Allocates a new buffer containing the given {array} of octets. - * - * @param array The octets to store. - */ - new (array: any[]): Buffer; - /** - * Copies the passed {buffer} data onto a new {Buffer} instance. - * - * @param buffer The buffer to copy. - */ - new (buffer: Buffer): Buffer; - prototype: Buffer; - /** - * Allocates a new Buffer using an {array} of octets. - * - * @param array - */ - from(array: any[]): Buffer; - /** - * When passed a reference to the .buffer property of a TypedArray instance, - * the newly created Buffer will share the same allocated memory as the TypedArray. - * The optional {byteOffset} and {length} arguments specify a memory range - * within the {arrayBuffer} that will be shared by the Buffer. - * - * @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer() - * @param byteOffset - * @param length - */ - from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer; - /** - * Copies the passed {buffer} data onto a new Buffer instance. - * - * @param buffer - */ - from(buffer: Buffer): Buffer; - /** - * Creates a new Buffer containing the given JavaScript string {str}. - * If provided, the {encoding} parameter identifies the character encoding. - * If not provided, {encoding} defaults to 'utf8'. - * - * @param str - */ - from(str: string, encoding?: string): Buffer; - /** - * Returns true if {obj} is a Buffer - * - * @param obj object to test. - */ - isBuffer(obj: any): obj is Buffer; - /** - * Returns true if {encoding} is a valid encoding argument. - * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' - * - * @param encoding string to test. - */ - isEncoding(encoding: string): boolean; - /** - * Gives the actual byte length of a string. encoding defaults to 'utf8'. - * This is not the same as String.prototype.length since that returns the number of characters in a string. - * - * @param string string to test. - * @param encoding encoding used to evaluate (defaults to 'utf8') - */ - byteLength(string: string, encoding?: string): number; - /** - * Returns a buffer which is the result of concatenating all the buffers in the list together. - * - * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer. - * If the list has exactly one item, then the first item of the list is returned. - * If the list has more than one item, then a new Buffer is created. - * - * @param list An array of Buffer objects to concatenate - * @param totalLength Total length of the buffers when concatenated. - * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly. - */ - concat(list: Buffer[], totalLength?: number): Buffer; - /** - * The same as buf1.compare(buf2). - */ - compare(buf1: Buffer, buf2: Buffer): number; - /** - * Allocates a new buffer of {size} octets. - * - * @param size count of octets to allocate. - * @param fill if specified, buffer will be initialized by calling buf.fill(fill). - * If parameter is omitted, buffer will be filled with zeros. - * @param encoding encoding used for call to buf.fill while initalizing - */ - alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer; - /** - * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents - * of the newly created Buffer are unknown and may contain sensitive data. - * - * @param size count of octets to allocate - */ - allocUnsafe(size: number): Buffer; - /** - * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents - * of the newly created Buffer are unknown and may contain sensitive data. - * - * @param size count of octets to allocate - */ - allocUnsafeSlow(size: number): Buffer; -}; - -/************************************************ -* * -* GLOBAL INTERFACES * -* * -************************************************/ -declare namespace NodeJS { - export interface ConsoleConstructor { - prototype: Console; - new(stdout: WritableStream, stderr?: WritableStream): Console; - } - - export interface ErrnoException extends Error { - errno?: number; - code?: string; - path?: string; - syscall?: string; - stack?: string; - } - - export class EventEmitter { - addListener(event: string | symbol, listener: Function): this; - on(event: string | symbol, listener: Function): this; - once(event: string | symbol, listener: Function): this; - removeListener(event: string | symbol, listener: Function): this; - removeAllListeners(event?: string | symbol): this; - setMaxListeners(n: number): this; - getMaxListeners(): number; - listeners(event: string | symbol): Function[]; - emit(event: string | symbol, ...args: any[]): boolean; - listenerCount(type: string | symbol): number; - // Added in Node 6... - prependListener(event: string | symbol, listener: Function): this; - prependOnceListener(event: string | symbol, listener: Function): this; - eventNames(): (string | symbol)[]; - } - - export interface ReadableStream extends EventEmitter { - readable: boolean; - isTTY?: boolean; - read(size?: number): string | Buffer; - setEncoding(encoding: string | null): this; - pause(): this; - resume(): this; - isPaused(): boolean; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): this; - unshift(chunk: string): void; - unshift(chunk: Buffer): void; - wrap(oldStream: ReadableStream): ReadableStream; - } - - export interface WritableStream extends EventEmitter { - writable: boolean; - isTTY?: boolean; - write(buffer: Buffer | string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - } - - export interface ReadWriteStream extends ReadableStream, WritableStream { } - - export interface Events extends EventEmitter { } - - export interface Domain extends Events { - run(fn: Function): void; - add(emitter: Events): void; - remove(emitter: Events): void; - bind(cb: (err: Error, data: any) => any): any; - intercept(cb: (data: any) => any): any; - dispose(): void; - - addListener(event: string, listener: Function): this; - on(event: string, listener: Function): this; - once(event: string, listener: Function): this; - removeListener(event: string, listener: Function): this; - removeAllListeners(event?: string): this; - } - - export interface MemoryUsage { - rss: number; - heapTotal: number; - heapUsed: number; - } - - export interface CpuUsage { - user: number; - system: number; - } - - export interface ProcessVersions { - http_parser: string; - node: string; - v8: string; - ares: string; - uv: string; - zlib: string; - modules: string; - openssl: string; - } - - type Platform = 'aix' - | 'android' - | 'darwin' - | 'freebsd' - | 'linux' - | 'openbsd' - | 'sunos' - | 'win32'; - - export interface Process extends EventEmitter { - stdout: WritableStream; - stderr: WritableStream; - stdin: ReadableStream; - argv: string[]; - argv0: string; - execArgv: string[]; - execPath: string; - abort(): void; - chdir(directory: string): void; - cwd(): string; - env: any; - exit(code?: number): void; - exitCode: number; - getgid(): number; - setgid(id: number): void; - setgid(id: string): void; - getuid(): number; - setuid(id: number): void; - setuid(id: string): void; - version: string; - versions: ProcessVersions; - config: { - target_defaults: { - cflags: any[]; - default_configuration: string; - defines: string[]; - include_dirs: string[]; - libraries: string[]; - }; - variables: { - clang: number; - host_arch: string; - node_install_npm: boolean; - node_install_waf: boolean; - node_prefix: string; - node_shared_openssl: boolean; - node_shared_v8: boolean; - node_shared_zlib: boolean; - node_use_dtrace: boolean; - node_use_etw: boolean; - node_use_openssl: boolean; - target_arch: string; - v8_no_strict_aliasing: number; - v8_use_snapshot: boolean; - visibility: string; - }; - }; - kill(pid: number, signal?: string | number): void; - pid: number; - title: string; - arch: string; - platform: Platform; - mainModule?: NodeModule; - memoryUsage(): MemoryUsage; - cpuUsage(previousValue?: CpuUsage): CpuUsage; - nextTick(callback: Function, ...args: any[]): void; - umask(mask?: number): number; - uptime(): number; - hrtime(time?: [number, number]): [number, number]; - domain: Domain; - - // Worker - send?(message: any, sendHandle?: any): void; - disconnect(): void; - connected: boolean; - } - - export interface Global { - Array: typeof Array; - ArrayBuffer: typeof ArrayBuffer; - Boolean: typeof Boolean; - Buffer: typeof Buffer; - DataView: typeof DataView; - Date: typeof Date; - Error: typeof Error; - EvalError: typeof EvalError; - Float32Array: typeof Float32Array; - Float64Array: typeof Float64Array; - Function: typeof Function; - GLOBAL: Global; - Infinity: typeof Infinity; - Int16Array: typeof Int16Array; - Int32Array: typeof Int32Array; - Int8Array: typeof Int8Array; - Intl: typeof Intl; - JSON: typeof JSON; - Map: MapConstructor; - Math: typeof Math; - NaN: typeof NaN; - Number: typeof Number; - Object: typeof Object; - Promise: Function; - RangeError: typeof RangeError; - ReferenceError: typeof ReferenceError; - RegExp: typeof RegExp; - Set: SetConstructor; - String: typeof String; - Symbol: Function; - SyntaxError: typeof SyntaxError; - TypeError: typeof TypeError; - URIError: typeof URIError; - Uint16Array: typeof Uint16Array; - Uint32Array: typeof Uint32Array; - Uint8Array: typeof Uint8Array; - Uint8ClampedArray: Function; - WeakMap: WeakMapConstructor; - WeakSet: WeakSetConstructor; - clearImmediate: (immediateId: any) => void; - clearInterval: (intervalId: NodeJS.Timer) => void; - clearTimeout: (timeoutId: NodeJS.Timer) => void; - console: typeof console; - decodeURI: typeof decodeURI; - decodeURIComponent: typeof decodeURIComponent; - encodeURI: typeof encodeURI; - encodeURIComponent: typeof encodeURIComponent; - escape: (str: string) => string; - eval: typeof eval; - global: Global; - isFinite: typeof isFinite; - isNaN: typeof isNaN; - parseFloat: typeof parseFloat; - parseInt: typeof parseInt; - process: Process; - root: Global; - setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any; - setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; - setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; - undefined: typeof undefined; - unescape: (str: string) => string; - gc: () => void; - v8debug?: any; - } - - export interface Timer { - ref(): void; - unref(): void; - } -} - -interface IterableIterator { } - -/** - * @deprecated - */ -interface NodeBuffer extends Uint8Array { - write(string: string, offset?: number, length?: number, encoding?: string): number; - toString(encoding?: string, start?: number, end?: number): string; - toJSON(): { type: 'Buffer', data: any[] }; - equals(otherBuffer: Buffer): boolean; - compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number; - copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; - slice(start?: number, end?: number): Buffer; - writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number; - readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number; - readIntLE(offset: number, byteLength: number, noAssert?: boolean): number; - readIntBE(offset: number, byteLength: number, noAssert?: boolean): number; - readUInt8(offset: number, noAssert?: boolean): number; - readUInt16LE(offset: number, noAssert?: boolean): number; - readUInt16BE(offset: number, noAssert?: boolean): number; - readUInt32LE(offset: number, noAssert?: boolean): number; - readUInt32BE(offset: number, noAssert?: boolean): number; - readInt8(offset: number, noAssert?: boolean): number; - readInt16LE(offset: number, noAssert?: boolean): number; - readInt16BE(offset: number, noAssert?: boolean): number; - readInt32LE(offset: number, noAssert?: boolean): number; - readInt32BE(offset: number, noAssert?: boolean): number; - readFloatLE(offset: number, noAssert?: boolean): number; - readFloatBE(offset: number, noAssert?: boolean): number; - readDoubleLE(offset: number, noAssert?: boolean): number; - readDoubleBE(offset: number, noAssert?: boolean): number; - swap16(): Buffer; - swap32(): Buffer; - swap64(): Buffer; - writeUInt8(value: number, offset: number, noAssert?: boolean): number; - writeUInt16LE(value: number, offset: number, noAssert?: boolean): number; - writeUInt16BE(value: number, offset: number, noAssert?: boolean): number; - writeUInt32LE(value: number, offset: number, noAssert?: boolean): number; - writeUInt32BE(value: number, offset: number, noAssert?: boolean): number; - writeInt8(value: number, offset: number, noAssert?: boolean): number; - writeInt16LE(value: number, offset: number, noAssert?: boolean): number; - writeInt16BE(value: number, offset: number, noAssert?: boolean): number; - writeInt32LE(value: number, offset: number, noAssert?: boolean): number; - writeInt32BE(value: number, offset: number, noAssert?: boolean): number; - writeFloatLE(value: number, offset: number, noAssert?: boolean): number; - writeFloatBE(value: number, offset: number, noAssert?: boolean): number; - writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; - writeDoubleBE(value: number, offset: number, noAssert?: boolean): number; - fill(value: any, offset?: number, end?: number): this; - indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; - lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; - entries(): IterableIterator<[number, number]>; - includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean; - keys(): IterableIterator; - values(): IterableIterator; -} - -/************************************************ -* * -* MODULES * -* * -************************************************/ -declare module "buffer" { - export var INSPECT_MAX_BYTES: number; - var BuffType: typeof Buffer; - var SlowBuffType: typeof SlowBuffer; - export { BuffType as Buffer, SlowBuffType as SlowBuffer }; -} - -declare module "querystring" { - export interface StringifyOptions { - encodeURIComponent?: Function; - } - - export interface ParseOptions { - maxKeys?: number; - decodeURIComponent?: Function; - } - - export function stringify(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string; - export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): any; - export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): T; - export function escape(str: string): string; - export function unescape(str: string): string; -} - -declare module "events" { - class internal extends NodeJS.EventEmitter { } - - namespace internal { - export class EventEmitter extends internal { - static listenerCount(emitter: EventEmitter, event: string | symbol): number; // deprecated - static defaultMaxListeners: number; - - addListener(event: string | symbol, listener: Function): this; - on(event: string | symbol, listener: Function): this; - once(event: string | symbol, listener: Function): this; - prependListener(event: string | symbol, listener: Function): this; - prependOnceListener(event: string | symbol, listener: Function): this; - removeListener(event: string | symbol, listener: Function): this; - removeAllListeners(event?: string | symbol): this; - setMaxListeners(n: number): this; - getMaxListeners(): number; - listeners(event: string | symbol): Function[]; - emit(event: string | symbol, ...args: any[]): boolean; - eventNames(): (string | symbol)[]; - listenerCount(type: string | symbol): number; - } - } - - export = internal; -} - -declare module "http" { - import * as events from "events"; - import * as net from "net"; - import * as stream from "stream"; - - export interface RequestOptions { - protocol?: string; - host?: string; - hostname?: string; - family?: number; - port?: number; - localAddress?: string; - socketPath?: string; - method?: string; - path?: string; - headers?: { [key: string]: any }; - auth?: string; - agent?: Agent | boolean; - timeout?: number; - } - - export interface Server extends net.Server { - setTimeout(msecs: number, callback: Function): void; - maxHeadersCount: number; - timeout: number; - listening: boolean; - } - /** - * @deprecated Use IncomingMessage - */ - export interface ServerRequest extends IncomingMessage { - connection: net.Socket; - } - export interface ServerResponse extends stream.Writable { - // Extended base methods - write(buffer: Buffer): boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - write(str: string, encoding?: string, fd?: string): boolean; - - writeContinue(): void; - writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void; - writeHead(statusCode: number, headers?: any): void; - statusCode: number; - statusMessage: string; - headersSent: boolean; - setHeader(name: string, value: string | string[]): void; - setTimeout(msecs: number, callback: Function): ServerResponse; - sendDate: boolean; - getHeader(name: string): string; - removeHeader(name: string): void; - write(chunk: any, encoding?: string): any; - addTrailers(headers: any): void; - finished: boolean; - - // Extended base methods - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - end(data?: any, encoding?: string): void; - } - export interface ClientRequest extends stream.Writable { - // Extended base methods - write(buffer: Buffer): boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - write(str: string, encoding?: string, fd?: string): boolean; - - write(chunk: any, encoding?: string): void; - abort(): void; - setTimeout(timeout: number, callback?: Function): void; - setNoDelay(noDelay?: boolean): void; - setSocketKeepAlive(enable?: boolean, initialDelay?: number): void; - - setHeader(name: string, value: string | string[]): void; - getHeader(name: string): string; - removeHeader(name: string): void; - addTrailers(headers: any): void; - - // Extended base methods - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - end(data?: any, encoding?: string): void; - } - export interface IncomingMessage extends stream.Readable { - httpVersion: string; - httpVersionMajor: number; - httpVersionMinor: number; - connection: net.Socket; - headers: any; - rawHeaders: string[]; - trailers: any; - rawTrailers: any; - setTimeout(msecs: number, callback: Function): NodeJS.Timer; - /** - * Only valid for request obtained from http.Server. - */ - method?: string; - /** - * Only valid for request obtained from http.Server. - */ - url?: string; - /** - * Only valid for response obtained from http.ClientRequest. - */ - statusCode?: number; - /** - * Only valid for response obtained from http.ClientRequest. - */ - statusMessage?: string; - socket: net.Socket; - destroy(error?: Error): void; - } - /** - * @deprecated Use IncomingMessage - */ - export interface ClientResponse extends IncomingMessage { } - - export interface AgentOptions { - /** - * Keep sockets around in a pool to be used by other requests in the future. Default = false - */ - keepAlive?: boolean; - /** - * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. - * Only relevant if keepAlive is set to true. - */ - keepAliveMsecs?: number; - /** - * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity - */ - maxSockets?: number; - /** - * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256. - */ - maxFreeSockets?: number; - } - - export class Agent { - maxSockets: number; - sockets: any; - requests: any; - - constructor(opts?: AgentOptions); - - /** - * Destroy any sockets that are currently in use by the agent. - * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled, - * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise, - * sockets may hang open for quite a long time before the server terminates them. - */ - destroy(): void; - } - - export var METHODS: string[]; - - export var STATUS_CODES: { - [errorCode: number]: string; - [errorCode: string]: string; - }; - export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) => void): Server; - export function createClient(port?: number, host?: string): any; - export function request(options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; - export function get(options: any, callback?: (res: IncomingMessage) => void): ClientRequest; - export var globalAgent: Agent; -} - -declare module "cluster" { - import * as child from "child_process"; - import * as events from "events"; - import * as net from "net"; - - // interfaces - export interface ClusterSettings { - execArgv?: string[]; // default: process.execArgv - exec?: string; - args?: string[]; - silent?: boolean; - stdio?: any[]; - uid?: number; - gid?: number; - } - - export interface ClusterSetupMasterSettings { - exec?: string; // default: process.argv[1] - args?: string[]; // default: process.argv.slice(2) - silent?: boolean; // default: false - stdio?: any[]; - } - - export interface Address { - address: string; - port: number; - addressType: number | "udp4" | "udp6"; // 4, 6, -1, "udp4", "udp6" - } - - export class Worker extends events.EventEmitter { - id: string; - process: child.ChildProcess; - suicide: boolean; - send(message: any, sendHandle?: any): boolean; - kill(signal?: string): void; - destroy(signal?: string): void; - disconnect(): void; - isConnected(): boolean; - isDead(): boolean; - exitedAfterDisconnect: boolean; - - /** - * events.EventEmitter - * 1. disconnect - * 2. error - * 3. exit - * 4. listening - * 5. message - * 6. online - */ - addListener(event: string, listener: Function): this; - addListener(event: "disconnect", listener: () => void): this; - addListener(event: "error", listener: (code: number, signal: string) => void): this; - addListener(event: "exit", listener: (code: number, signal: string) => void): this; - addListener(event: "listening", listener: (address: Address) => void): this; - addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - addListener(event: "online", listener: () => void): this; - - emit(event: string, listener: Function): boolean - emit(event: "disconnect", listener: () => void): boolean - emit(event: "error", listener: (code: number, signal: string) => void): boolean - emit(event: "exit", listener: (code: number, signal: string) => void): boolean - emit(event: "listening", listener: (address: Address) => void): boolean - emit(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): boolean - emit(event: "online", listener: () => void): boolean - - on(event: string, listener: Function): this; - on(event: "disconnect", listener: () => void): this; - on(event: "error", listener: (code: number, signal: string) => void): this; - on(event: "exit", listener: (code: number, signal: string) => void): this; - on(event: "listening", listener: (address: Address) => void): this; - on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - on(event: "online", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "disconnect", listener: () => void): this; - once(event: "error", listener: (code: number, signal: string) => void): this; - once(event: "exit", listener: (code: number, signal: string) => void): this; - once(event: "listening", listener: (address: Address) => void): this; - once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - once(event: "online", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "disconnect", listener: () => void): this; - prependListener(event: "error", listener: (code: number, signal: string) => void): this; - prependListener(event: "exit", listener: (code: number, signal: string) => void): this; - prependListener(event: "listening", listener: (address: Address) => void): this; - prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - prependListener(event: "online", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "disconnect", listener: () => void): this; - prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this; - prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this; - prependOnceListener(event: "listening", listener: (address: Address) => void): this; - prependOnceListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - prependOnceListener(event: "online", listener: () => void): this; - } - - export interface Cluster extends events.EventEmitter { - Worker: Worker; - disconnect(callback?: Function): void; - fork(env?: any): Worker; - isMaster: boolean; - isWorker: boolean; - // TODO: cluster.schedulingPolicy - settings: ClusterSettings; - setupMaster(settings?: ClusterSetupMasterSettings): void; - worker: Worker; - workers: { - [index: string]: Worker - }; - - /** - * events.EventEmitter - * 1. disconnect - * 2. exit - * 3. fork - * 4. listening - * 5. message - * 6. online - * 7. setup - */ - addListener(event: string, listener: Function): this; - addListener(event: "disconnect", listener: (worker: Worker) => void): this; - addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - addListener(event: "fork", listener: (worker: Worker) => void): this; - addListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; - addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - addListener(event: "online", listener: (worker: Worker) => void): this; - addListener(event: "setup", listener: (settings: any) => void): this; - - emit(event: string, listener: Function): boolean; - emit(event: "disconnect", listener: (worker: Worker) => void): boolean; - emit(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): boolean; - emit(event: "fork", listener: (worker: Worker) => void): boolean; - emit(event: "listening", listener: (worker: Worker, address: Address) => void): boolean; - emit(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): boolean; - emit(event: "online", listener: (worker: Worker) => void): boolean; - emit(event: "setup", listener: (settings: any) => void): boolean; - - on(event: string, listener: Function): this; - on(event: "disconnect", listener: (worker: Worker) => void): this; - on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - on(event: "fork", listener: (worker: Worker) => void): this; - on(event: "listening", listener: (worker: Worker, address: Address) => void): this; - on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - on(event: "online", listener: (worker: Worker) => void): this; - on(event: "setup", listener: (settings: any) => void): this; - - once(event: string, listener: Function): this; - once(event: "disconnect", listener: (worker: Worker) => void): this; - once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - once(event: "fork", listener: (worker: Worker) => void): this; - once(event: "listening", listener: (worker: Worker, address: Address) => void): this; - once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - once(event: "online", listener: (worker: Worker) => void): this; - once(event: "setup", listener: (settings: any) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "disconnect", listener: (worker: Worker) => void): this; - prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - prependListener(event: "fork", listener: (worker: Worker) => void): this; - prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; - prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - prependListener(event: "online", listener: (worker: Worker) => void): this; - prependListener(event: "setup", listener: (settings: any) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this; - prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - prependOnceListener(event: "fork", listener: (worker: Worker) => void): this; - prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; - prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - prependOnceListener(event: "online", listener: (worker: Worker) => void): this; - prependOnceListener(event: "setup", listener: (settings: any) => void): this; - - } - - export function disconnect(callback?: Function): void; - export function fork(env?: any): Worker; - export var isMaster: boolean; - export var isWorker: boolean; - // TODO: cluster.schedulingPolicy - export var settings: ClusterSettings; - export function setupMaster(settings?: ClusterSetupMasterSettings): void; - export var worker: Worker; - export var workers: { - [index: string]: Worker - }; - - /** - * events.EventEmitter - * 1. disconnect - * 2. exit - * 3. fork - * 4. listening - * 5. message - * 6. online - * 7. setup - */ - export function addListener(event: string, listener: Function): Cluster; - export function addListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function addListener(event: "fork", listener: (worker: Worker) => void): Cluster; - export function addListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function addListener(event: "online", listener: (worker: Worker) => void): Cluster; - export function addListener(event: "setup", listener: (settings: any) => void): Cluster; - - export function emit(event: string, listener: Function): boolean; - export function emit(event: "disconnect", listener: (worker: Worker) => void): boolean; - export function emit(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): boolean; - export function emit(event: "fork", listener: (worker: Worker) => void): boolean; - export function emit(event: "listening", listener: (worker: Worker, address: Address) => void): boolean; - export function emit(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): boolean; - export function emit(event: "online", listener: (worker: Worker) => void): boolean; - export function emit(event: "setup", listener: (settings: any) => void): boolean; - - export function on(event: string, listener: Function): Cluster; - export function on(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function on(event: "fork", listener: (worker: Worker) => void): Cluster; - export function on(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function on(event: "online", listener: (worker: Worker) => void): Cluster; - export function on(event: "setup", listener: (settings: any) => void): Cluster; - - export function once(event: string, listener: Function): Cluster; - export function once(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function once(event: "fork", listener: (worker: Worker) => void): Cluster; - export function once(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function once(event: "online", listener: (worker: Worker) => void): Cluster; - export function once(event: "setup", listener: (settings: any) => void): Cluster; - - export function removeListener(event: string, listener: Function): Cluster; - export function removeAllListeners(event?: string): Cluster; - export function setMaxListeners(n: number): Cluster; - export function getMaxListeners(): number; - export function listeners(event: string): Function[]; - export function listenerCount(type: string): number; - - export function prependListener(event: string, listener: Function): Cluster; - export function prependListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function prependListener(event: "fork", listener: (worker: Worker) => void): Cluster; - export function prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function prependListener(event: "online", listener: (worker: Worker) => void): Cluster; - export function prependListener(event: "setup", listener: (settings: any) => void): Cluster; - - export function prependOnceListener(event: string, listener: Function): Cluster; - export function prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function prependOnceListener(event: "fork", listener: (worker: Worker) => void): Cluster; - export function prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function prependOnceListener(event: "online", listener: (worker: Worker) => void): Cluster; - export function prependOnceListener(event: "setup", listener: (settings: any) => void): Cluster; - - export function eventNames(): string[]; -} - -declare module "zlib" { - import * as stream from "stream"; - - export interface ZlibOptions { - flush?: number; // default: zlib.constants.Z_NO_FLUSH - finishFlush?: number; // default: zlib.constants.Z_FINISH - chunkSize?: number; // default: 16*1024 - windowBits?: number; - level?: number; // compression only - memLevel?: number; // compression only - strategy?: number; // compression only - dictionary?: any; // deflate/inflate only, empty dictionary by default - } - - export interface Gzip extends stream.Transform { } - export interface Gunzip extends stream.Transform { } - export interface Deflate extends stream.Transform { } - export interface Inflate extends stream.Transform { } - export interface DeflateRaw extends stream.Transform { } - export interface InflateRaw extends stream.Transform { } - export interface Unzip extends stream.Transform { } - - export function createGzip(options?: ZlibOptions): Gzip; - export function createGunzip(options?: ZlibOptions): Gunzip; - export function createDeflate(options?: ZlibOptions): Deflate; - export function createInflate(options?: ZlibOptions): Inflate; - export function createDeflateRaw(options?: ZlibOptions): DeflateRaw; - export function createInflateRaw(options?: ZlibOptions): InflateRaw; - export function createUnzip(options?: ZlibOptions): Unzip; - - export function deflate(buf: Buffer | string, callback: (error: Error, result: Buffer) => void): void; - export function deflateSync(buf: Buffer | string, options?: ZlibOptions): Buffer; - export function deflateRaw(buf: Buffer | string, callback: (error: Error, result: Buffer) => void): void; - export function deflateRawSync(buf: Buffer | string, options?: ZlibOptions): Buffer; - export function gzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; - export function gzipSync(buf: Buffer, options?: ZlibOptions): Buffer; - export function gunzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; - export function gunzipSync(buf: Buffer, options?: ZlibOptions): Buffer; - export function inflate(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; - export function inflateSync(buf: Buffer, options?: ZlibOptions): Buffer; - export function inflateRaw(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; - export function inflateRawSync(buf: Buffer, options?: ZlibOptions): Buffer; - export function unzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; - export function unzipSync(buf: Buffer, options?: ZlibOptions): Buffer; - - export namespace constants { - // Allowed flush values. - - export const Z_NO_FLUSH: number; - export const Z_PARTIAL_FLUSH: number; - export const Z_SYNC_FLUSH: number; - export const Z_FULL_FLUSH: number; - export const Z_FINISH: number; - export const Z_BLOCK: number; - export const Z_TREES: number; - - // Return codes for the compression/decompression functions. Negative values are errors, positive values are used for special but normal events. - - export const Z_OK: number; - export const Z_STREAM_END: number; - export const Z_NEED_DICT: number; - export const Z_ERRNO: number; - export const Z_STREAM_ERROR: number; - export const Z_DATA_ERROR: number; - export const Z_MEM_ERROR: number; - export const Z_BUF_ERROR: number; - export const Z_VERSION_ERROR: number; - - // Compression levels. - - export const Z_NO_COMPRESSION: number; - export const Z_BEST_SPEED: number; - export const Z_BEST_COMPRESSION: number; - export const Z_DEFAULT_COMPRESSION: number; - - // Compression strategy. - - export const Z_FILTERED: number; - export const Z_HUFFMAN_ONLY: number; - export const Z_RLE: number; - export const Z_FIXED: number; - export const Z_DEFAULT_STRATEGY: number; - } - - // Constants - export var Z_NO_FLUSH: number; - export var Z_PARTIAL_FLUSH: number; - export var Z_SYNC_FLUSH: number; - export var Z_FULL_FLUSH: number; - export var Z_FINISH: number; - export var Z_BLOCK: number; - export var Z_TREES: number; - export var Z_OK: number; - export var Z_STREAM_END: number; - export var Z_NEED_DICT: number; - export var Z_ERRNO: number; - export var Z_STREAM_ERROR: number; - export var Z_DATA_ERROR: number; - export var Z_MEM_ERROR: number; - export var Z_BUF_ERROR: number; - export var Z_VERSION_ERROR: number; - export var Z_NO_COMPRESSION: number; - export var Z_BEST_SPEED: number; - export var Z_BEST_COMPRESSION: number; - export var Z_DEFAULT_COMPRESSION: number; - export var Z_FILTERED: number; - export var Z_HUFFMAN_ONLY: number; - export var Z_RLE: number; - export var Z_FIXED: number; - export var Z_DEFAULT_STRATEGY: number; - export var Z_BINARY: number; - export var Z_TEXT: number; - export var Z_ASCII: number; - export var Z_UNKNOWN: number; - export var Z_DEFLATED: number; -} - -declare module "os" { - export interface CpuInfo { - model: string; - speed: number; - times: { - user: number; - nice: number; - sys: number; - idle: number; - irq: number; - }; - } - - export interface NetworkInterfaceInfo { - address: string; - netmask: string; - family: string; - mac: string; - internal: boolean; - } - - export function hostname(): string; - export function loadavg(): number[]; - export function uptime(): number; - export function freemem(): number; - export function totalmem(): number; - export function cpus(): CpuInfo[]; - export function type(): string; - export function release(): string; - export function networkInterfaces(): { [index: string]: NetworkInterfaceInfo[] }; - export function homedir(): string; - export function userInfo(options?: { encoding: string }): { username: string, uid: number, gid: number, shell: any, homedir: string } - export var constants: { - UV_UDP_REUSEADDR: number, - errno: { - SIGHUP: number; - SIGINT: number; - SIGQUIT: number; - SIGILL: number; - SIGTRAP: number; - SIGABRT: number; - SIGIOT: number; - SIGBUS: number; - SIGFPE: number; - SIGKILL: number; - SIGUSR1: number; - SIGSEGV: number; - SIGUSR2: number; - SIGPIPE: number; - SIGALRM: number; - SIGTERM: number; - SIGCHLD: number; - SIGSTKFLT: number; - SIGCONT: number; - SIGSTOP: number; - SIGTSTP: number; - SIGTTIN: number; - SIGTTOU: number; - SIGURG: number; - SIGXCPU: number; - SIGXFSZ: number; - SIGVTALRM: number; - SIGPROF: number; - SIGWINCH: number; - SIGIO: number; - SIGPOLL: number; - SIGPWR: number; - SIGSYS: number; - SIGUNUSED: number; - }, - signals: { - E2BIG: number; - EACCES: number; - EADDRINUSE: number; - EADDRNOTAVAIL: number; - EAFNOSUPPORT: number; - EAGAIN: number; - EALREADY: number; - EBADF: number; - EBADMSG: number; - EBUSY: number; - ECANCELED: number; - ECHILD: number; - ECONNABORTED: number; - ECONNREFUSED: number; - ECONNRESET: number; - EDEADLK: number; - EDESTADDRREQ: number; - EDOM: number; - EDQUOT: number; - EEXIST: number; - EFAULT: number; - EFBIG: number; - EHOSTUNREACH: number; - EIDRM: number; - EILSEQ: number; - EINPROGRESS: number; - EINTR: number; - EINVAL: number; - EIO: number; - EISCONN: number; - EISDIR: number; - ELOOP: number; - EMFILE: number; - EMLINK: number; - EMSGSIZE: number; - EMULTIHOP: number; - ENAMETOOLONG: number; - ENETDOWN: number; - ENETRESET: number; - ENETUNREACH: number; - ENFILE: number; - ENOBUFS: number; - ENODATA: number; - ENODEV: number; - ENOENT: number; - ENOEXEC: number; - ENOLCK: number; - ENOLINK: number; - ENOMEM: number; - ENOMSG: number; - ENOPROTOOPT: number; - ENOSPC: number; - ENOSR: number; - ENOSTR: number; - ENOSYS: number; - ENOTCONN: number; - ENOTDIR: number; - ENOTEMPTY: number; - ENOTSOCK: number; - ENOTSUP: number; - ENOTTY: number; - ENXIO: number; - EOPNOTSUPP: number; - EOVERFLOW: number; - EPERM: number; - EPIPE: number; - EPROTO: number; - EPROTONOSUPPORT: number; - EPROTOTYPE: number; - ERANGE: number; - EROFS: number; - ESPIPE: number; - ESRCH: number; - ESTALE: number; - ETIME: number; - ETIMEDOUT: number; - ETXTBSY: number; - EWOULDBLOCK: number; - EXDEV: number; - }, - }; - export function arch(): string; - export function platform(): NodeJS.Platform; - export function tmpdir(): string; - export var EOL: string; - export function endianness(): "BE" | "LE"; -} - -declare module "https" { - import * as tls from "tls"; - import * as events from "events"; - import * as http from "http"; - - export interface ServerOptions { - pfx?: any; - key?: any; - passphrase?: string; - cert?: any; - ca?: any; - crl?: any; - ciphers?: string; - honorCipherOrder?: boolean; - requestCert?: boolean; - rejectUnauthorized?: boolean; - NPNProtocols?: any; - SNICallback?: (servername: string, cb: (err: Error, ctx: tls.SecureContext) => any) => any; - } - - export interface RequestOptions extends http.RequestOptions { - pfx?: any; - key?: any; - passphrase?: string; - cert?: any; - ca?: any; - ciphers?: string; - rejectUnauthorized?: boolean; - secureProtocol?: string; - } - - export interface Agent extends http.Agent { } - - export interface AgentOptions extends http.AgentOptions { - pfx?: any; - key?: any; - passphrase?: string; - cert?: any; - ca?: any; - ciphers?: string; - rejectUnauthorized?: boolean; - secureProtocol?: string; - maxCachedSessions?: number; - } - - export var Agent: { - new (options?: AgentOptions): Agent; - }; - export interface Server extends tls.Server { } - export function createServer(options: ServerOptions, requestListener?: Function): Server; - export function request(options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; - export function get(options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; - export var globalAgent: Agent; -} - -declare module "punycode" { - export function decode(string: string): string; - export function encode(string: string): string; - export function toUnicode(domain: string): string; - export function toASCII(domain: string): string; - export var ucs2: ucs2; - interface ucs2 { - decode(string: string): number[]; - encode(codePoints: number[]): string; - } - export var version: any; -} - -declare module "repl" { - import * as stream from "stream"; - import * as readline from "readline"; - - export interface ReplOptions { - prompt?: string; - input?: NodeJS.ReadableStream; - output?: NodeJS.WritableStream; - terminal?: boolean; - eval?: Function; - useColors?: boolean; - useGlobal?: boolean; - ignoreUndefined?: boolean; - writer?: Function; - completer?: Function; - replMode?: any; - breakEvalOnSigint?: any; - } - - export interface REPLServer extends readline.ReadLine { - defineCommand(keyword: string, cmd: Function | { help: string, action: Function }): void; - displayPrompt(preserveCursor?: boolean): void; - - /** - * events.EventEmitter - * 1. exit - * 2. reset - **/ - - addListener(event: string, listener: Function): this; - addListener(event: "exit", listener: () => void): this; - addListener(event: "reset", listener: Function): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "exit"): boolean; - emit(event: "reset", context: any): boolean; - - on(event: string, listener: Function): this; - on(event: "exit", listener: () => void): this; - on(event: "reset", listener: Function): this; - - once(event: string, listener: Function): this; - once(event: "exit", listener: () => void): this; - once(event: "reset", listener: Function): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "exit", listener: () => void): this; - prependListener(event: "reset", listener: Function): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "exit", listener: () => void): this; - prependOnceListener(event: "reset", listener: Function): this; - } - - export function start(options: ReplOptions): REPLServer; -} - -declare module "readline" { - import * as events from "events"; - import * as stream from "stream"; - - export interface Key { - sequence?: string; - name?: string; - ctrl?: boolean; - meta?: boolean; - shift?: boolean; - } - - export interface ReadLine extends events.EventEmitter { - setPrompt(prompt: string): void; - prompt(preserveCursor?: boolean): void; - question(query: string, callback: (answer: string) => void): void; - pause(): ReadLine; - resume(): ReadLine; - close(): void; - write(data: string | Buffer, key?: Key): void; - - /** - * events.EventEmitter - * 1. close - * 2. line - * 3. pause - * 4. resume - * 5. SIGCONT - * 6. SIGINT - * 7. SIGTSTP - **/ - - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "line", listener: (input: any) => void): this; - addListener(event: "pause", listener: () => void): this; - addListener(event: "resume", listener: () => void): this; - addListener(event: "SIGCONT", listener: () => void): this; - addListener(event: "SIGINT", listener: () => void): this; - addListener(event: "SIGTSTP", listener: () => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "line", input: any): boolean; - emit(event: "pause"): boolean; - emit(event: "resume"): boolean; - emit(event: "SIGCONT"): boolean; - emit(event: "SIGINT"): boolean; - emit(event: "SIGTSTP"): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "line", listener: (input: any) => void): this; - on(event: "pause", listener: () => void): this; - on(event: "resume", listener: () => void): this; - on(event: "SIGCONT", listener: () => void): this; - on(event: "SIGINT", listener: () => void): this; - on(event: "SIGTSTP", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "line", listener: (input: any) => void): this; - once(event: "pause", listener: () => void): this; - once(event: "resume", listener: () => void): this; - once(event: "SIGCONT", listener: () => void): this; - once(event: "SIGINT", listener: () => void): this; - once(event: "SIGTSTP", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "line", listener: (input: any) => void): this; - prependListener(event: "pause", listener: () => void): this; - prependListener(event: "resume", listener: () => void): this; - prependListener(event: "SIGCONT", listener: () => void): this; - prependListener(event: "SIGINT", listener: () => void): this; - prependListener(event: "SIGTSTP", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "line", listener: (input: any) => void): this; - prependOnceListener(event: "pause", listener: () => void): this; - prependOnceListener(event: "resume", listener: () => void): this; - prependOnceListener(event: "SIGCONT", listener: () => void): this; - prependOnceListener(event: "SIGINT", listener: () => void): this; - prependOnceListener(event: "SIGTSTP", listener: () => void): this; - } - - type Completer = (line: string) => CompleterResult; - type AsyncCompleter = (line: string, callback: (err: any, result: CompleterResult) => void) => any; - - export type CompleterResult = [string[], string]; - - export interface ReadLineOptions { - input: NodeJS.ReadableStream; - output?: NodeJS.WritableStream; - completer?: Completer | AsyncCompleter; - terminal?: boolean; - historySize?: number; - } - - export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): ReadLine; - export function createInterface(options: ReadLineOptions): ReadLine; - - export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void; - export function moveCursor(stream: NodeJS.WritableStream, dx: number | string, dy: number | string): void; - export function clearLine(stream: NodeJS.WritableStream, dir: number): void; - export function clearScreenDown(stream: NodeJS.WritableStream): void; -} - -declare module "vm" { - export interface Context { } - export interface ScriptOptions { - filename?: string; - lineOffset?: number; - columnOffset?: number; - displayErrors?: boolean; - timeout?: number; - cachedData?: Buffer; - produceCachedData?: boolean; - } - export interface RunningScriptOptions { - filename?: string; - lineOffset?: number; - columnOffset?: number; - displayErrors?: boolean; - timeout?: number; - } - export class Script { - constructor(code: string, options?: ScriptOptions); - runInContext(contextifiedSandbox: Context, options?: RunningScriptOptions): any; - runInNewContext(sandbox?: Context, options?: RunningScriptOptions): any; - runInThisContext(options?: RunningScriptOptions): any; - } - export function createContext(sandbox?: Context): Context; - export function isContext(sandbox: Context): boolean; - export function runInContext(code: string, contextifiedSandbox: Context, options?: RunningScriptOptions): any; - export function runInDebugContext(code: string): any; - export function runInNewContext(code: string, sandbox?: Context, options?: RunningScriptOptions): any; - export function runInThisContext(code: string, options?: RunningScriptOptions): any; -} - -declare module "child_process" { - import * as events from "events"; - import * as stream from "stream"; - import * as net from "net"; - - export interface ChildProcess extends events.EventEmitter { - stdin: stream.Writable; - stdout: stream.Readable; - stderr: stream.Readable; - stdio: [stream.Writable, stream.Readable, stream.Readable]; - pid: number; - kill(signal?: string): void; - send(message: any, sendHandle?: any): boolean; - connected: boolean; - disconnect(): void; - unref(): void; - ref(): void; - - /** - * events.EventEmitter - * 1. close - * 2. disconnet - * 3. error - * 4. exit - * 5. message - **/ - - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: (code: number, signal: string) => void): this; - addListener(event: "disconnet", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "exit", listener: (code: number, signal: string) => void): this; - addListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close", code: number, signal: string): boolean; - emit(event: "disconnet"): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "exit", code: number, signal: string): boolean; - emit(event: "message", message: any, sendHandle: net.Socket | net.Server): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: (code: number, signal: string) => void): this; - on(event: "disconnet", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "exit", listener: (code: number, signal: string) => void): this; - on(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: (code: number, signal: string) => void): this; - once(event: "disconnet", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "exit", listener: (code: number, signal: string) => void): this; - once(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: (code: number, signal: string) => void): this; - prependListener(event: "disconnet", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "exit", listener: (code: number, signal: string) => void): this; - prependListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: (code: number, signal: string) => void): this; - prependOnceListener(event: "disconnet", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this; - prependOnceListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - } - - export interface SpawnOptions { - cwd?: string; - env?: any; - stdio?: any; - detached?: boolean; - uid?: number; - gid?: number; - shell?: boolean | string; - } - export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess; - - export interface ExecOptions { - cwd?: string; - env?: any; - shell?: string; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - uid?: number; - gid?: number; - } - export interface ExecOptionsWithStringEncoding extends ExecOptions { - encoding: BufferEncoding; - } - export interface ExecOptionsWithBufferEncoding extends ExecOptions { - encoding: string; // specify `null`. - } - export function exec(command: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - export function exec(command: string, options: ExecOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - // usage. child_process.exec("tsc", {encoding: null as string}, (err, stdout, stderr) => {}); - export function exec(command: string, options: ExecOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; - export function exec(command: string, options: ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - - export interface ExecFileOptions { - cwd?: string; - env?: any; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - uid?: number; - gid?: number; - } - export interface ExecFileOptionsWithStringEncoding extends ExecFileOptions { - encoding: BufferEncoding; - } - export interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions { - encoding: string; // specify `null`. - } - export function execFile(file: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - export function execFile(file: string, options?: ExecFileOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - // usage. child_process.execFile("file.sh", {encoding: null as string}, (err, stdout, stderr) => {}); - export function execFile(file: string, options?: ExecFileOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; - export function execFile(file: string, options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - export function execFile(file: string, args?: string[], callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - export function execFile(file: string, args?: string[], options?: ExecFileOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - // usage. child_process.execFile("file.sh", ["foo"], {encoding: null as string}, (err, stdout, stderr) => {}); - export function execFile(file: string, args?: string[], options?: ExecFileOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; - export function execFile(file: string, args?: string[], options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - - export interface ForkOptions { - cwd?: string; - env?: any; - execPath?: string; - execArgv?: string[]; - silent?: boolean; - uid?: number; - gid?: number; - } - export function fork(modulePath: string, args?: string[], options?: ForkOptions): ChildProcess; - - export interface SpawnSyncOptions { - cwd?: string; - input?: string | Buffer; - stdio?: any; - env?: any; - uid?: number; - gid?: number; - timeout?: number; - killSignal?: string; - maxBuffer?: number; - encoding?: string; - shell?: boolean | string; - } - export interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions { - encoding: BufferEncoding; - } - export interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions { - encoding: string; // specify `null`. - } - export interface SpawnSyncReturns { - pid: number; - output: string[]; - stdout: T; - stderr: T; - status: number; - signal: string; - error: Error; - } - export function spawnSync(command: string): SpawnSyncReturns; - export function spawnSync(command: string, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns; - export function spawnSync(command: string, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns; - export function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns; - export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns; - export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns; - export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptions): SpawnSyncReturns; - - export interface ExecSyncOptions { - cwd?: string; - input?: string | Buffer; - stdio?: any; - env?: any; - shell?: string; - uid?: number; - gid?: number; - timeout?: number; - killSignal?: string; - maxBuffer?: number; - encoding?: string; - } - export interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions { - encoding: BufferEncoding; - } - export interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions { - encoding: string; // specify `null`. - } - export function execSync(command: string): Buffer; - export function execSync(command: string, options?: ExecSyncOptionsWithStringEncoding): string; - export function execSync(command: string, options?: ExecSyncOptionsWithBufferEncoding): Buffer; - export function execSync(command: string, options?: ExecSyncOptions): Buffer; - - export interface ExecFileSyncOptions { - cwd?: string; - input?: string | Buffer; - stdio?: any; - env?: any; - uid?: number; - gid?: number; - timeout?: number; - killSignal?: string; - maxBuffer?: number; - encoding?: string; - } - export interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions { - encoding: BufferEncoding; - } - export interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions { - encoding: string; // specify `null`. - } - export function execFileSync(command: string): Buffer; - export function execFileSync(command: string, options?: ExecFileSyncOptionsWithStringEncoding): string; - export function execFileSync(command: string, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer; - export function execFileSync(command: string, options?: ExecFileSyncOptions): Buffer; - export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptionsWithStringEncoding): string; - export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptionsWithBufferEncoding): Buffer; - export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptions): Buffer; -} - -declare module "url" { - export interface Url { - href?: string; - protocol?: string; - auth?: string; - hostname?: string; - port?: string; - host?: string; - pathname?: string; - search?: string; - query?: string | any; - slashes?: boolean; - hash?: string; - path?: string; - } - - export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): Url; - export function format(url: Url): string; - export function resolve(from: string, to: string): string; - - export class URLSearchParams implements Iterable { - constructor(init?: URLSearchParams | string); - append(name: string, value: string): void; - delete(name: string): void; - entries(): Iterator; - forEach(callback: (value: string, name: string) => void): void; - get(name: string): string | null; - getAll(name: string): string[]; - has(name: string): boolean; - keys(): Iterator; - set(name: string, value: string): void; - sort(): void; - toString(): string; - values(): Iterator; - [Symbol.iterator](): Iterator; - } - - export class URL { - constructor(input: string, base?: string | URL); - hash: string; - host: string; - hostname: string; - href: string; - readonly origin: string; - password: string; - pathname: string; - port: string; - protocol: string; - search: string; - readonly searchParams: URLSearchParams; - username: string; - toString(): string; - toJSON(): string; - } -} - -declare module "dns" { - export interface MxRecord { - exchange: string, - priority: number - } - - export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) => void): string; - export function lookup(domain: string, callback: (err: Error, address: string, family: number) => void): string; - export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve4(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve6(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveMx(domain: string, callback: (err: Error, addresses: MxRecord[]) => void): string[]; - export function resolveTxt(domain: string, callback: (err: Error, addresses: string[][]) => void): string[][]; - export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function reverse(ip: string, callback: (err: Error, domains: string[]) => void): string[]; - export function setServers(servers: string[]): void; - - //Error codes - export var NODATA: string; - export var FORMERR: string; - export var SERVFAIL: string; - export var NOTFOUND: string; - export var NOTIMP: string; - export var REFUSED: string; - export var BADQUERY: string; - export var BADNAME: string; - export var BADFAMILY: string; - export var BADRESP: string; - export var CONNREFUSED: string; - export var TIMEOUT: string; - export var EOF: string; - export var FILE: string; - export var NOMEM: string; - export var DESTRUCTION: string; - export var BADSTR: string; - export var BADFLAGS: string; - export var NONAME: string; - export var BADHINTS: string; - export var NOTINITIALIZED: string; - export var LOADIPHLPAPI: string; - export var ADDRGETNETWORKPARAMS: string; - export var CANCELLED: string; -} - -declare module "net" { - import * as stream from "stream"; - import * as events from "events"; - - export interface Socket extends stream.Duplex { - // Extended base methods - write(buffer: Buffer): boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - write(str: string, encoding?: string, fd?: string): boolean; - - connect(port: number, host?: string, connectionListener?: Function): void; - connect(path: string, connectionListener?: Function): void; - bufferSize: number; - setEncoding(encoding?: string): this; - write(data: any, encoding?: string, callback?: Function): void; - destroy(err?: any): void; - pause(): this; - resume(): this; - setTimeout(timeout: number, callback?: Function): void; - setNoDelay(noDelay?: boolean): void; - setKeepAlive(enable?: boolean, initialDelay?: number): void; - address(): { port: number; family: string; address: string; }; - unref(): void; - ref(): void; - - remoteAddress: string; - remoteFamily: string; - remotePort: number; - localAddress: string; - localPort: number; - bytesRead: number; - bytesWritten: number; - destroyed: boolean; - - // Extended base methods - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - end(data?: any, encoding?: string): void; - - /** - * events.EventEmitter - * 1. close - * 2. connect - * 3. data - * 4. drain - * 5. end - * 6. error - * 7. lookup - * 8. timeout - */ - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: (had_error: boolean) => void): this; - addListener(event: "connect", listener: () => void): this; - addListener(event: "data", listener: (data: Buffer) => void): this; - addListener(event: "drain", listener: () => void): this; - addListener(event: "end", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - addListener(event: "timeout", listener: () => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close", had_error: boolean): boolean; - emit(event: "connect"): boolean; - emit(event: "data", data: Buffer): boolean; - emit(event: "drain"): boolean; - emit(event: "end"): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean; - emit(event: "timeout"): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: (had_error: boolean) => void): this; - on(event: "connect", listener: () => void): this; - on(event: "data", listener: (data: Buffer) => void): this; - on(event: "drain", listener: () => void): this; - on(event: "end", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - on(event: "timeout", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: (had_error: boolean) => void): this; - once(event: "connect", listener: () => void): this; - once(event: "data", listener: (data: Buffer) => void): this; - once(event: "drain", listener: () => void): this; - once(event: "end", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - once(event: "timeout", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: (had_error: boolean) => void): this; - prependListener(event: "connect", listener: () => void): this; - prependListener(event: "data", listener: (data: Buffer) => void): this; - prependListener(event: "drain", listener: () => void): this; - prependListener(event: "end", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - prependListener(event: "timeout", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: (had_error: boolean) => void): this; - prependOnceListener(event: "connect", listener: () => void): this; - prependOnceListener(event: "data", listener: (data: Buffer) => void): this; - prependOnceListener(event: "drain", listener: () => void): this; - prependOnceListener(event: "end", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - prependOnceListener(event: "timeout", listener: () => void): this; - } - - export var Socket: { - new (options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }): Socket; - }; - - export interface ListenOptions { - port?: number; - host?: string; - backlog?: number; - path?: string; - exclusive?: boolean; - } - - export interface Server extends events.EventEmitter { - listen(port: number, hostname?: string, backlog?: number, listeningListener?: Function): Server; - listen(port: number, hostname?: string, listeningListener?: Function): Server; - listen(port: number, backlog?: number, listeningListener?: Function): Server; - listen(port: number, listeningListener?: Function): Server; - listen(path: string, backlog?: number, listeningListener?: Function): Server; - listen(path: string, listeningListener?: Function): Server; - listen(options: ListenOptions, listeningListener?: Function): Server; - listen(handle: any, backlog?: number, listeningListener?: Function): Server; - listen(handle: any, listeningListener?: Function): Server; - close(callback?: Function): Server; - address(): { port: number; family: string; address: string; }; - getConnections(cb: (error: Error, count: number) => void): void; - ref(): Server; - unref(): Server; - maxConnections: number; - connections: number; - listening: boolean; - - /** - * events.EventEmitter - * 1. close - * 2. connection - * 3. error - * 4. listening - */ - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "connection", listener: (socket: Socket) => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "listening", listener: () => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "connection", socket: Socket): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "listening"): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "connection", listener: (socket: Socket) => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "listening", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "connection", listener: (socket: Socket) => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "listening", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "connection", listener: (socket: Socket) => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "listening", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "connection", listener: (socket: Socket) => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "listening", listener: () => void): this; - } - export function createServer(connectionListener?: (socket: Socket) => void): Server; - export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) => void): Server; - export function connect(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; - export function connect(port: number, host?: string, connectionListener?: Function): Socket; - export function connect(path: string, connectionListener?: Function): Socket; - export function createConnection(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; - export function createConnection(port: number, host?: string, connectionListener?: Function): Socket; - export function createConnection(path: string, connectionListener?: Function): Socket; - export function isIP(input: string): number; - export function isIPv4(input: string): boolean; - export function isIPv6(input: string): boolean; -} - -declare module "dgram" { - import * as events from "events"; - - interface RemoteInfo { - address: string; - family: string; - port: number; - } - - interface AddressInfo { - address: string; - family: string; - port: number; - } - - interface BindOptions { - port: number; - address?: string; - exclusive?: boolean; - } - - interface SocketOptions { - type: "udp4" | "udp6"; - reuseAddr?: boolean; - } - - export function createSocket(type: string, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; - export function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; - - export interface Socket extends events.EventEmitter { - send(msg: Buffer | String | any[], port: number, address: string, callback?: (error: Error, bytes: number) => void): void; - send(msg: Buffer | String | any[], offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void; - bind(port?: number, address?: string, callback?: () => void): void; - bind(options: BindOptions, callback?: Function): void; - close(callback?: () => void): void; - address(): AddressInfo; - setBroadcast(flag: boolean): void; - setTTL(ttl: number): void; - setMulticastTTL(ttl: number): void; - setMulticastLoopback(flag: boolean): void; - addMembership(multicastAddress: string, multicastInterface?: string): void; - dropMembership(multicastAddress: string, multicastInterface?: string): void; - ref(): this; - unref(): this; - - /** - * events.EventEmitter - * 1. close - * 2. error - * 3. listening - * 4. message - **/ - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "listening", listener: () => void): this; - addListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "listening"): boolean; - emit(event: "message", msg: Buffer, rinfo: AddressInfo): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "listening", listener: () => void): this; - on(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "listening", listener: () => void): this; - once(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "listening", listener: () => void): this; - prependListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "listening", listener: () => void): this; - prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - } -} - -declare module "fs" { - import * as stream from "stream"; - import * as events from "events"; - - interface Stats { - isFile(): boolean; - isDirectory(): boolean; - isBlockDevice(): boolean; - isCharacterDevice(): boolean; - isSymbolicLink(): boolean; - isFIFO(): boolean; - isSocket(): boolean; - dev: number; - ino: number; - mode: number; - nlink: number; - uid: number; - gid: number; - rdev: number; - size: number; - blksize: number; - blocks: number; - atime: Date; - mtime: Date; - ctime: Date; - birthtime: Date; - } - - interface FSWatcher extends events.EventEmitter { - close(): void; - - /** - * events.EventEmitter - * 1. change - * 2. error - */ - addListener(event: string, listener: Function): this; - addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - addListener(event: "error", listener: (code: number, signal: string) => void): this; - - on(event: string, listener: Function): this; - on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - on(event: "error", listener: (code: number, signal: string) => void): this; - - once(event: string, listener: Function): this; - once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - once(event: "error", listener: (code: number, signal: string) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - prependListener(event: "error", listener: (code: number, signal: string) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this; - } - - export interface ReadStream extends stream.Readable { - close(): void; - destroy(): void; - bytesRead: number; - path: string | Buffer; - - /** - * events.EventEmitter - * 1. open - * 2. close - */ - addListener(event: string, listener: Function): this; - addListener(event: "open", listener: (fd: number) => void): this; - addListener(event: "close", listener: () => void): this; - - on(event: string, listener: Function): this; - on(event: "open", listener: (fd: number) => void): this; - on(event: "close", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "open", listener: (fd: number) => void): this; - once(event: "close", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "open", listener: (fd: number) => void): this; - prependListener(event: "close", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "open", listener: (fd: number) => void): this; - prependOnceListener(event: "close", listener: () => void): this; - } - - export interface WriteStream extends stream.Writable { - close(): void; - bytesWritten: number; - path: string | Buffer; - - /** - * events.EventEmitter - * 1. open - * 2. close - */ - addListener(event: string, listener: Function): this; - addListener(event: "open", listener: (fd: number) => void): this; - addListener(event: "close", listener: () => void): this; - - on(event: string, listener: Function): this; - on(event: "open", listener: (fd: number) => void): this; - on(event: "close", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "open", listener: (fd: number) => void): this; - once(event: "close", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "open", listener: (fd: number) => void): this; - prependListener(event: "close", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "open", listener: (fd: number) => void): this; - prependOnceListener(event: "close", listener: () => void): this; - } - - /** - * Asynchronous rename. - * @param oldPath - * @param newPath - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /** - * Synchronous rename - * @param oldPath - * @param newPath - */ - export function renameSync(oldPath: string, newPath: string): void; - export function truncate(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function truncate(path: string | Buffer, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function truncateSync(path: string | Buffer, len?: number): void; - export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function ftruncateSync(fd: number, len?: number): void; - export function chown(path: string | Buffer, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chownSync(path: string | Buffer, uid: number, gid: number): void; - export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fchownSync(fd: number, uid: number, gid: number): void; - export function lchown(path: string | Buffer, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchownSync(path: string | Buffer, uid: number, gid: number): void; - export function chmod(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chmod(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chmodSync(path: string | Buffer, mode: number): void; - export function chmodSync(path: string | Buffer, mode: string): void; - export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fchmodSync(fd: number, mode: number): void; - export function fchmodSync(fd: number, mode: string): void; - export function lchmod(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchmod(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchmodSync(path: string | Buffer, mode: number): void; - export function lchmodSync(path: string | Buffer, mode: string): void; - export function stat(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function lstat(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function statSync(path: string | Buffer): Stats; - export function lstatSync(path: string | Buffer): Stats; - export function fstatSync(fd: number): Stats; - export function link(srcpath: string | Buffer, dstpath: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function linkSync(srcpath: string | Buffer, dstpath: string | Buffer): void; - export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function symlinkSync(srcpath: string | Buffer, dstpath: string | Buffer, type?: string): void; - export function readlink(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void; - export function readlinkSync(path: string | Buffer): string; - export function realpath(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; - export function realpath(path: string | Buffer, cache: { [path: string]: string }, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; - export function realpathSync(path: string | Buffer, cache?: { [path: string]: string }): string; - /** - * Asynchronous unlink - deletes the file specified in {path} - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function unlink(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - /** - * Synchronous unlink - deletes the file specified in {path} - * - * @param path - */ - export function unlinkSync(path: string | Buffer): void; - /** - * Asynchronous rmdir - removes the directory specified in {path} - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function rmdir(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - /** - * Synchronous rmdir - removes the directory specified in {path} - * - * @param path - */ - export function rmdirSync(path: string | Buffer): void; - /** - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdir(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - /** - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdir(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - /** - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdir(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /** - * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdirSync(path: string | Buffer, mode?: number): void; - /** - * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdirSync(path: string | Buffer, mode?: string): void; - /** - * Asynchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory. - * - * @param prefix - * @param callback The created folder path is passed as a string to the callback's second parameter. - */ - export function mkdtemp(prefix: string, callback?: (err: NodeJS.ErrnoException, folder: string) => void): void; - /** - * Synchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory. - * - * @param prefix - * @returns Returns the created folder path. - */ - export function mkdtempSync(prefix: string): string; - export function readdir(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void; - export function readdirSync(path: string | Buffer): string[]; - export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function closeSync(fd: number): void; - export function open(path: string | Buffer, flags: string | number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void; - export function open(path: string | Buffer, flags: string | number, mode: number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void; - export function openSync(path: string | Buffer, flags: string | number, mode?: number): number; - export function utimes(path: string | Buffer, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function utimes(path: string | Buffer, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function utimesSync(path: string | Buffer, atime: number, mtime: number): void; - export function utimesSync(path: string | Buffer, atime: Date, mtime: Date): void; - export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function futimes(fd: number, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function futimesSync(fd: number, atime: number, mtime: number): void; - export function futimesSync(fd: number, atime: Date, mtime: Date): void; - export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fsyncSync(fd: number): void; - export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; - export function write(fd: number, buffer: Buffer, offset: number, length: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; - export function write(fd: number, data: any, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; - export function write(fd: number, data: any, offset: number, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; - export function write(fd: number, data: any, offset: number, encoding: string, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; - export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position?: number): number; - export function writeSync(fd: number, data: any, position?: number, enconding?: string): number; - export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void; - export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; - /** - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param encoding - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void; - /** - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void; - /** - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; - /** - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; - /** - * Synchronous readFile - Synchronously reads the entire contents of a file. - * - * @param fileName - * @param encoding - */ - export function readFileSync(filename: string, encoding: string): string; - /** - * Synchronous readFile - Synchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. - */ - export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string; - /** - * Synchronous readFile - Synchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. - */ - export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; - export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; - export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; - export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; - export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; - export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; - export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void; - export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void; - export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher; - export function watch(filename: string, encoding: string, listener?: (event: string, filename: string | Buffer) => any): FSWatcher; - export function watch(filename: string, options: { persistent?: boolean; recursive?: boolean; encoding?: string }, listener?: (event: string, filename: string | Buffer) => any): FSWatcher; - export function exists(path: string | Buffer, callback?: (exists: boolean) => void): void; - export function existsSync(path: string | Buffer): boolean; - - export namespace constants { - // File Access Constants - - /** Constant for fs.access(). File is visible to the calling process. */ - export const F_OK: number; - - /** Constant for fs.access(). File can be read by the calling process. */ - export const R_OK: number; - - /** Constant for fs.access(). File can be written by the calling process. */ - export const W_OK: number; - - /** Constant for fs.access(). File can be executed by the calling process. */ - export const X_OK: number; - - // File Open Constants - - /** Constant for fs.open(). Flag indicating to open a file for read-only access. */ - export const O_RDONLY: number; - - /** Constant for fs.open(). Flag indicating to open a file for write-only access. */ - export const O_WRONLY: number; - - /** Constant for fs.open(). Flag indicating to open a file for read-write access. */ - export const O_RDWR: number; - - /** Constant for fs.open(). Flag indicating to create the file if it does not already exist. */ - export const O_CREAT: number; - - /** Constant for fs.open(). Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists. */ - export const O_EXCL: number; - - /** Constant for fs.open(). Flag indicating that if path identifies a terminal device, opening the path shall not cause that terminal to become the controlling terminal for the process (if the process does not already have one). */ - export const O_NOCTTY: number; - - /** Constant for fs.open(). Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero. */ - export const O_TRUNC: number; - - /** Constant for fs.open(). Flag indicating that data will be appended to the end of the file. */ - export const O_APPEND: number; - - /** Constant for fs.open(). Flag indicating that the open should fail if the path is not a directory. */ - export const O_DIRECTORY: number; - - /** Constant for fs.open(). Flag indicating reading accesses to the file system will no longer result in an update to the atime information associated with the file. This flag is available on Linux operating systems only. */ - export const O_NOATIME: number; - - /** Constant for fs.open(). Flag indicating that the open should fail if the path is a symbolic link. */ - export const O_NOFOLLOW: number; - - /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O. */ - export const O_SYNC: number; - - /** Constant for fs.open(). Flag indicating to open the symbolic link itself rather than the resource it is pointing to. */ - export const O_SYMLINK: number; - - /** Constant for fs.open(). When set, an attempt will be made to minimize caching effects of file I/O. */ - export const O_DIRECT: number; - - /** Constant for fs.open(). Flag indicating to open the file in nonblocking mode when possible. */ - export const O_NONBLOCK: number; - - // File Type Constants - - /** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */ - export const S_IFMT: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */ - export const S_IFREG: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */ - export const S_IFDIR: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a character-oriented device file. */ - export const S_IFCHR: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a block-oriented device file. */ - export const S_IFBLK: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a FIFO/pipe. */ - export const S_IFIFO: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a symbolic link. */ - export const S_IFLNK: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a socket. */ - export const S_IFSOCK: number; - - // File Mode Constants - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by owner. */ - export const S_IRWXU: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by owner. */ - export const S_IRUSR: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by owner. */ - export const S_IWUSR: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by owner. */ - export const S_IXUSR: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by group. */ - export const S_IRWXG: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by group. */ - export const S_IRGRP: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by group. */ - export const S_IWGRP: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by group. */ - export const S_IXGRP: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by others. */ - export const S_IRWXO: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by others. */ - export const S_IROTH: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by others. */ - export const S_IWOTH: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */ - export const S_IXOTH: number; - } - - /** Tests a user's permissions for the file specified by path. */ - export function access(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void; - export function access(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException) => void): void; - /** Synchronous version of fs.access. This throws if any accessibility checks fail, and does nothing otherwise. */ - export function accessSync(path: string | Buffer, mode?: number): void; - export function createReadStream(path: string | Buffer, options?: { - flags?: string; - encoding?: string; - fd?: number; - mode?: number; - autoClose?: boolean; - start?: number; - end?: number; - }): ReadStream; - export function createWriteStream(path: string | Buffer, options?: { - flags?: string; - encoding?: string; - fd?: number; - mode?: number; - autoClose?: boolean; - start?: number; - }): WriteStream; - export function fdatasync(fd: number, callback: Function): void; - export function fdatasyncSync(fd: number): void; -} - -declare module "path" { - - /** - * A parsed path object generated by path.parse() or consumed by path.format(). - */ - export interface ParsedPath { - /** - * The root of the path such as '/' or 'c:\' - */ - root: string; - /** - * The full directory path such as '/home/user/dir' or 'c:\path\dir' - */ - dir: string; - /** - * The file name including extension (if any) such as 'index.html' - */ - base: string; - /** - * The file extension (if any) such as '.html' - */ - ext: string; - /** - * The file name without extension (if any) such as 'index' - */ - name: string; - } - - /** - * Normalize a string path, reducing '..' and '.' parts. - * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used. - * - * @param p string path to normalize. - */ - export function normalize(p: string): string; - /** - * Join all arguments together and normalize the resulting path. - * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. - * - * @param paths paths to join. - */ - export function join(...paths: string[]): string; - /** - * The right-most parameter is considered {to}. Other parameters are considered an array of {from}. - * - * Starting from leftmost {from} paramter, resolves {to} to an absolute path. - * - * If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory. - * - * @param pathSegments string paths to join. Non-string arguments are ignored. - */ - export function resolve(...pathSegments: any[]): string; - /** - * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. - * - * @param path path to test. - */ - export function isAbsolute(path: string): boolean; - /** - * Solve the relative path from {from} to {to}. - * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve. - * - * @param from - * @param to - */ - export function relative(from: string, to: string): string; - /** - * Return the directory name of a path. Similar to the Unix dirname command. - * - * @param p the path to evaluate. - */ - export function dirname(p: string): string; - /** - * Return the last portion of a path. Similar to the Unix basename command. - * Often used to extract the file name from a fully qualified path. - * - * @param p the path to evaluate. - * @param ext optionally, an extension to remove from the result. - */ - export function basename(p: string, ext?: string): string; - /** - * Return the extension of the path, from the last '.' to end of string in the last portion of the path. - * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string - * - * @param p the path to evaluate. - */ - export function extname(p: string): string; - /** - * The platform-specific file separator. '\\' or '/'. - */ - export var sep: string; - /** - * The platform-specific file delimiter. ';' or ':'. - */ - export var delimiter: string; - /** - * Returns an object from a path string - the opposite of format(). - * - * @param pathString path to evaluate. - */ - export function parse(pathString: string): ParsedPath; - /** - * Returns a path string from an object - the opposite of parse(). - * - * @param pathString path to evaluate. - */ - export function format(pathObject: ParsedPath): string; - - export module posix { - export function normalize(p: string): string; - export function join(...paths: any[]): string; - export function resolve(...pathSegments: any[]): string; - export function isAbsolute(p: string): boolean; - export function relative(from: string, to: string): string; - export function dirname(p: string): string; - export function basename(p: string, ext?: string): string; - export function extname(p: string): string; - export var sep: string; - export var delimiter: string; - export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; - } - - export module win32 { - export function normalize(p: string): string; - export function join(...paths: any[]): string; - export function resolve(...pathSegments: any[]): string; - export function isAbsolute(p: string): boolean; - export function relative(from: string, to: string): string; - export function dirname(p: string): string; - export function basename(p: string, ext?: string): string; - export function extname(p: string): string; - export var sep: string; - export var delimiter: string; - export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; - } -} - -declare module "string_decoder" { - export interface NodeStringDecoder { - write(buffer: Buffer): string; - end(buffer?: Buffer): string; - } - export var StringDecoder: { - new (encoding?: string): NodeStringDecoder; - }; -} - -declare module "tls" { - import * as crypto from "crypto"; - import * as net from "net"; - import * as stream from "stream"; - - var CLIENT_RENEG_LIMIT: number; - var CLIENT_RENEG_WINDOW: number; - - export interface Certificate { - /** - * Country code. - */ - C: string; - /** - * Street. - */ - ST: string; - /** - * Locality. - */ - L: string; - /** - * Organization. - */ - O: string; - /** - * Organizational unit. - */ - OU: string; - /** - * Common name. - */ - CN: string; - } - - export interface CipherNameAndProtocol { - /** - * The cipher name. - */ - name: string; - /** - * SSL/TLS protocol version. - */ - version: string; - } - - export class TLSSocket extends net.Socket { - /** - * Construct a new tls.TLSSocket object from an existing TCP socket. - */ - constructor(socket:net.Socket, options?: { - /** - * An optional TLS context object from tls.createSecureContext() - */ - secureContext?: SecureContext, - /** - * If true the TLS socket will be instantiated in server-mode. - * Defaults to false. - */ - isServer?: boolean, - /** - * An optional net.Server instance. - */ - server?: net.Server, - /** - * If true the server will request a certificate from clients that - * connect and attempt to verify that certificate. Defaults to - * false. - */ - requestCert?: boolean, - /** - * If true the server will reject any connection which is not - * authorized with the list of supplied CAs. This option only has an - * effect if requestCert is true. Defaults to false. - */ - rejectUnauthorized?: boolean, - /** - * An array of strings or a Buffer naming possible NPN protocols. - * (Protocols should be ordered by their priority.) - */ - NPNProtocols?: string[] | Buffer, - /** - * An array of strings or a Buffer naming possible ALPN protocols. - * (Protocols should be ordered by their priority.) When the server - * receives both NPN and ALPN extensions from the client, ALPN takes - * precedence over NPN and the server does not send an NPN extension - * to the client. - */ - ALPNProtocols?: string[] | Buffer, - /** - * SNICallback(servername, cb) A function that will be - * called if the client supports SNI TLS extension. Two arguments - * will be passed when called: servername and cb. SNICallback should - * invoke cb(null, ctx), where ctx is a SecureContext instance. - * (tls.createSecureContext(...) can be used to get a proper - * SecureContext.) If SNICallback wasn't provided the default callback - * with high-level API will be used (see below). - */ - SNICallback?: Function, - /** - * An optional Buffer instance containing a TLS session. - */ - session?: Buffer, - /** - * If true, specifies that the OCSP status request extension will be - * added to the client hello and an 'OCSPResponse' event will be - * emitted on the socket before establishing a secure communication - */ - requestOCSP?: boolean - }); - /** - * Returns the bound address, the address family name and port of the underlying socket as reported by - * the operating system. - * @returns {any} - An object with three properties, e.g. { port: 12346, family: 'IPv4', address: '127.0.0.1' }. - */ - address(): { port: number; family: string; address: string }; - /** - * A boolean that is true if the peer certificate was signed by one of the specified CAs, otherwise false. - */ - authorized: boolean; - /** - * The reason why the peer's certificate has not been verified. - * This property becomes available only when tlsSocket.authorized === false. - */ - authorizationError: Error; - /** - * Static boolean value, always true. - * May be used to distinguish TLS sockets from regular ones. - */ - encrypted: boolean; - /** - * Returns an object representing the cipher name and the SSL/TLS protocol version of the current connection. - * @returns {CipherNameAndProtocol} - Returns an object representing the cipher name - * and the SSL/TLS protocol version of the current connection. - */ - getCipher(): CipherNameAndProtocol; - /** - * Returns an object representing the peer's certificate. - * The returned object has some properties corresponding to the field of the certificate. - * If detailed argument is true the full chain with issuer property will be returned, - * if false only the top certificate without issuer property. - * If the peer does not provide a certificate, it returns null or an empty object. - * @param {boolean} detailed - If true; the full chain with issuer property will be returned. - * @returns {any} - An object representing the peer's certificate. - */ - getPeerCertificate(detailed?: boolean): { - subject: Certificate; - issuerInfo: Certificate; - issuer: Certificate; - raw: any; - valid_from: string; - valid_to: string; - fingerprint: string; - serialNumber: string; - }; - /** - * Could be used to speed up handshake establishment when reconnecting to the server. - * @returns {any} - ASN.1 encoded TLS session or undefined if none was negotiated. - */ - getSession(): any; - /** - * NOTE: Works only with client TLS sockets. - * Useful only for debugging, for session reuse provide session option to tls.connect(). - * @returns {any} - TLS session ticket or undefined if none was negotiated. - */ - getTLSTicket(): any; - /** - * The string representation of the local IP address. - */ - localAddress: string; - /** - * The numeric representation of the local port. - */ - localPort: number; - /** - * The string representation of the remote IP address. - * For example, '74.125.127.100' or '2001:4860:a005::68'. - */ - remoteAddress: string; - /** - * The string representation of the remote IP family. 'IPv4' or 'IPv6'. - */ - remoteFamily: string; - /** - * The numeric representation of the remote port. For example, 443. - */ - remotePort: number; - /** - * Initiate TLS renegotiation process. - * - * NOTE: Can be used to request peer's certificate after the secure connection has been established. - * ANOTHER NOTE: When running as the server, socket will be destroyed with an error after handshakeTimeout timeout. - * @param {TlsOptions} options - The options may contain the following fields: rejectUnauthorized, - * requestCert (See tls.createServer() for details). - * @param {Function} callback - callback(err) will be executed with null as err, once the renegotiation - * is successfully completed. - */ - renegotiate(options: TlsOptions, callback: (err: Error) => any): any; - /** - * Set maximum TLS fragment size (default and maximum value is: 16384, minimum is: 512). - * Smaller fragment size decreases buffering latency on the client: large fragments are buffered by - * the TLS layer until the entire fragment is received and its integrity is verified; - * large fragments can span multiple roundtrips, and their processing can be delayed due to packet - * loss or reordering. However, smaller fragments add extra TLS framing bytes and CPU overhead, - * which may decrease overall server throughput. - * @param {number} size - TLS fragment size (default and maximum value is: 16384, minimum is: 512). - * @returns {boolean} - Returns true on success, false otherwise. - */ - setMaxSendFragment(size: number): boolean; - - /** - * events.EventEmitter - * 1. OCSPResponse - * 2. secureConnect - **/ - addListener(event: string, listener: Function): this; - addListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; - addListener(event: "secureConnect", listener: () => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "OCSPResponse", response: Buffer): boolean; - emit(event: "secureConnect"): boolean; - - on(event: string, listener: Function): this; - on(event: "OCSPResponse", listener: (response: Buffer) => void): this; - on(event: "secureConnect", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "OCSPResponse", listener: (response: Buffer) => void): this; - once(event: "secureConnect", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; - prependListener(event: "secureConnect", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; - prependOnceListener(event: "secureConnect", listener: () => void): this; - } - - export interface TlsOptions { - host?: string; - port?: number; - pfx?: string | Buffer[]; - key?: string | string[] | Buffer | any[]; - passphrase?: string; - cert?: string | string[] | Buffer | Buffer[]; - ca?: string | string[] | Buffer | Buffer[]; - crl?: string | string[]; - ciphers?: string; - honorCipherOrder?: boolean; - requestCert?: boolean; - rejectUnauthorized?: boolean; - NPNProtocols?: string[] | Buffer; - SNICallback?: (servername: string, cb: (err: Error, ctx: SecureContext) => any) => any; - ecdhCurve?: string; - dhparam?: string | Buffer; - handshakeTimeout?: number; - ALPNProtocols?: string[] | Buffer; - sessionTimeout?: number; - ticketKeys?: any; - sessionIdContext?: string; - secureProtocol?: string; - } - - export interface ConnectionOptions { - host?: string; - port?: number; - socket?: net.Socket; - pfx?: string | Buffer - key?: string | string[] | Buffer | Buffer[]; - passphrase?: string; - cert?: string | string[] | Buffer | Buffer[]; - ca?: string | Buffer | (string | Buffer)[]; - rejectUnauthorized?: boolean; - NPNProtocols?: (string | Buffer)[]; - servername?: string; - path?: string; - ALPNProtocols?: (string | Buffer)[]; - checkServerIdentity?: (servername: string, cert: string | Buffer | (string | Buffer)[]) => any; - secureProtocol?: string; - secureContext?: Object; - session?: Buffer; - minDHSize?: number; - } - - export interface Server extends net.Server { - close(callback?: Function): Server; - address(): { port: number; family: string; address: string; }; - addContext(hostName: string, credentials: { - key: string; - cert: string; - ca: string; - }): void; - maxConnections: number; - connections: number; - - /** - * events.EventEmitter - * 1. tlsClientError - * 2. newSession - * 3. OCSPRequest - * 4. resumeSession - * 5. secureConnection - **/ - addListener(event: string, listener: Function): this; - addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - addListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - addListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - addListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - addListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "tlsClientError", err: Error, tlsSocket: TLSSocket): boolean; - emit(event: "newSession", sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void): boolean; - emit(event: "OCSPRequest", certificate: Buffer, issuer: Buffer, callback: Function): boolean; - emit(event: "resumeSession", sessionId: any, callback: (err: Error, sessionData: any) => void): boolean; - emit(event: "secureConnection", tlsSocket: TLSSocket): boolean; - - on(event: string, listener: Function): this; - on(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - on(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - on(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - on(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - on(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - - once(event: string, listener: Function): this; - once(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - once(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - once(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - once(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - once(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - prependListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - prependListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - prependListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - prependListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - prependOnceListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - prependOnceListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - prependOnceListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - prependOnceListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - } - - export interface ClearTextStream extends stream.Duplex { - authorized: boolean; - authorizationError: Error; - getPeerCertificate(): any; - getCipher: { - name: string; - version: string; - }; - address: { - port: number; - family: string; - address: string; - }; - remoteAddress: string; - remotePort: number; - } - - export interface SecurePair { - encrypted: any; - cleartext: any; - } - - export interface SecureContextOptions { - pfx?: string | Buffer; - key?: string | Buffer; - passphrase?: string; - cert?: string | Buffer; - ca?: string | Buffer; - crl?: string | string[] - ciphers?: string; - honorCipherOrder?: boolean; - } - - export interface SecureContext { - context: any; - } - - export function createServer(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void): Server; - export function connect(options: ConnectionOptions, secureConnectionListener?: () => void): TLSSocket; - export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket; - export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket; - export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair; - export function createSecureContext(details: SecureContextOptions): SecureContext; -} - -declare module "crypto" { - export interface Certificate { - exportChallenge(spkac: string | Buffer): Buffer; - exportPublicKey(spkac: string | Buffer): Buffer; - verifySpkac(spkac: Buffer): boolean; - } - export var Certificate: { - new (): Certificate; - (): Certificate; - } - - export var fips: boolean; - - export interface CredentialDetails { - pfx: string; - key: string; - passphrase: string; - cert: string; - ca: string | string[]; - crl: string | string[]; - ciphers: string; - } - export interface Credentials { context?: any; } - export function createCredentials(details: CredentialDetails): Credentials; - export function createHash(algorithm: string): Hash; - export function createHmac(algorithm: string, key: string | Buffer): Hmac; - - type Utf8AsciiLatin1Encoding = "utf8" | "ascii" | "latin1"; - type HexBase64Latin1Encoding = "latin1" | "hex" | "base64"; - type Utf8AsciiBinaryEncoding = "utf8" | "ascii" | "binary"; - type HexBase64BinaryEncoding = "binary" | "base64" | "hex"; - type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid"; - - export interface Hash extends NodeJS.ReadWriteStream { - update(data: string | Buffer): Hash; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Hash; - digest(): Buffer; - digest(encoding: HexBase64Latin1Encoding): string; - } - export interface Hmac extends NodeJS.ReadWriteStream { - update(data: string | Buffer): Hmac; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Hmac; - digest(): Buffer; - digest(encoding: HexBase64Latin1Encoding): string; - } - export function createCipher(algorithm: string, password: any): Cipher; - export function createCipheriv(algorithm: string, key: any, iv: any): Cipher; - export interface Cipher extends NodeJS.ReadWriteStream { - update(data: Buffer): Buffer; - update(data: string, input_encoding: Utf8AsciiBinaryEncoding): Buffer; - update(data: Buffer, input_encoding: any, output_encoding: HexBase64BinaryEncoding): string; - update(data: string, input_encoding: Utf8AsciiBinaryEncoding, output_encoding: HexBase64BinaryEncoding): string; - final(): Buffer; - final(output_encoding: string): string; - setAutoPadding(auto_padding?: boolean): void; - getAuthTag(): Buffer; - setAAD(buffer: Buffer): void; - } - export function createDecipher(algorithm: string, password: any): Decipher; - export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher; - export interface Decipher extends NodeJS.ReadWriteStream { - update(data: Buffer): Buffer; - update(data: string, input_encoding: HexBase64BinaryEncoding): Buffer; - update(data: Buffer, input_encoding: any, output_encoding: Utf8AsciiBinaryEncoding): string; - update(data: string, input_encoding: HexBase64BinaryEncoding, output_encoding: Utf8AsciiBinaryEncoding): string; - final(): Buffer; - final(output_encoding: string): string; - setAutoPadding(auto_padding?: boolean): void; - setAuthTag(tag: Buffer): void; - setAAD(buffer: Buffer): void; - } - export function createSign(algorithm: string): Signer; - export interface Signer extends NodeJS.WritableStream { - update(data: string | Buffer): Signer; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Signer; - sign(private_key: string | { key: string; passphrase: string }): Buffer; - sign(private_key: string | { key: string; passphrase: string }, output_format: HexBase64Latin1Encoding): string; - } - export function createVerify(algorith: string): Verify; - export interface Verify extends NodeJS.WritableStream { - update(data: string | Buffer): Verify; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Verify; - verify(object: string, signature: Buffer): boolean; - verify(object: string, signature: string, signature_format: HexBase64Latin1Encoding): boolean; - } - export function createDiffieHellman(prime_length: number, generator?: number): DiffieHellman; - export function createDiffieHellman(prime: Buffer): DiffieHellman; - export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding): DiffieHellman; - export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: number | Buffer): DiffieHellman; - export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: string, generator_encoding: HexBase64Latin1Encoding): DiffieHellman; - export interface DiffieHellman { - generateKeys(): Buffer; - generateKeys(encoding: HexBase64Latin1Encoding): string; - computeSecret(other_public_key: Buffer): Buffer; - computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer; - computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string; - getPrime(): Buffer; - getPrime(encoding: HexBase64Latin1Encoding): string; - getGenerator(): Buffer; - getGenerator(encoding: HexBase64Latin1Encoding): string; - getPublicKey(): Buffer; - getPublicKey(encoding: HexBase64Latin1Encoding): string; - getPrivateKey(): Buffer; - getPrivateKey(encoding: HexBase64Latin1Encoding): string; - setPublicKey(public_key: Buffer): void; - setPublicKey(public_key: string, encoding: string): void; - setPrivateKey(private_key: Buffer): void; - setPrivateKey(private_key: string, encoding: string): void; - verifyError: number; - } - export function getDiffieHellman(group_name: string): DiffieHellman; - export function pbkdf2(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2Sync(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string): Buffer; - export function randomBytes(size: number): Buffer; - export function randomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void; - export function pseudoRandomBytes(size: number): Buffer; - export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void; - export interface RsaPublicKey { - key: string; - padding?: number; - } - export interface RsaPrivateKey { - key: string; - passphrase?: string, - padding?: number; - } - export function publicEncrypt(public_key: string | RsaPublicKey, buffer: Buffer): Buffer - export function privateDecrypt(private_key: string | RsaPrivateKey, buffer: Buffer): Buffer - export function privateEncrypt(private_key: string | RsaPrivateKey, buffer: Buffer): Buffer - export function publicDecrypt(public_key: string | RsaPublicKey, buffer: Buffer): Buffer - export function getCiphers(): string[]; - export function getCurves(): string[]; - export function getHashes(): string[]; - export interface ECDH { - generateKeys(): Buffer; - generateKeys(encoding: HexBase64Latin1Encoding): string; - generateKeys(encoding: HexBase64Latin1Encoding, format: ECDHKeyFormat): string; - computeSecret(other_public_key: Buffer): Buffer; - computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer; - computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string; - getPrivateKey(): Buffer; - getPrivateKey(encoding: HexBase64Latin1Encoding): string; - getPublicKey(): Buffer; - getPublicKey(encoding: HexBase64Latin1Encoding): string; - getPublicKey(encoding: HexBase64Latin1Encoding, format: ECDHKeyFormat): string; - setPrivateKey(private_key: Buffer): void; - setPrivateKey(private_key: string, encoding: HexBase64Latin1Encoding): void; - } - export function createECDH(curve_name: string): ECDH; - export function timingSafeEqual(a: Buffer, b: Buffer): boolean; - export var DEFAULT_ENCODING: string; -} - -declare module "stream" { - import * as events from "events"; - - class internal extends events.EventEmitter { - pipe(destination: T, options?: { end?: boolean; }): T; - } - namespace internal { - - export class Stream extends internal { } - - export interface ReadableOptions { - highWaterMark?: number; - encoding?: string; - objectMode?: boolean; - read?: (size?: number) => any; - } - - export class Readable extends events.EventEmitter implements NodeJS.ReadableStream { - readable: boolean; - constructor(opts?: ReadableOptions); - protected _read(size: number): void; - read(size?: number): any; - setEncoding(encoding: string): this; - pause(): this; - resume(): this; - isPaused(): boolean; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): this; - unshift(chunk: any): void; - wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; - push(chunk: any, encoding?: string): boolean; - - /** - * Event emitter - * The defined events on documents including: - * 1. close - * 2. data - * 3. end - * 4. readable - * 5. error - **/ - addListener(event: string, listener: Function): this; - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "data", listener: (chunk: Buffer | string) => void): this; - addListener(event: "end", listener: () => void): this; - addListener(event: "readable", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "data", chunk: Buffer | string): boolean; - emit(event: "end"): boolean; - emit(event: "readable"): boolean; - emit(event: "error", err: Error): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "data", listener: (chunk: Buffer | string) => void): this; - on(event: "end", listener: () => void): this; - on(event: "readable", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "data", listener: (chunk: Buffer | string) => void): this; - once(event: "end", listener: () => void): this; - once(event: "readable", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "data", listener: (chunk: Buffer | string) => void): this; - prependListener(event: "end", listener: () => void): this; - prependListener(event: "readable", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this; - prependOnceListener(event: "end", listener: () => void): this; - prependOnceListener(event: "readable", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - - removeListener(event: string, listener: Function): this; - removeListener(event: "close", listener: () => void): this; - removeListener(event: "data", listener: (chunk: Buffer | string) => void): this; - removeListener(event: "end", listener: () => void): this; - removeListener(event: "readable", listener: () => void): this; - removeListener(event: "error", listener: (err: Error) => void): this; - } - - export interface WritableOptions { - highWaterMark?: number; - decodeStrings?: boolean; - objectMode?: boolean; - write?: (chunk: string | Buffer, encoding: string, callback: Function) => any; - writev?: (chunks: { chunk: string | Buffer, encoding: string }[], callback: Function) => any; - } - - export class Writable extends events.EventEmitter implements NodeJS.WritableStream { - writable: boolean; - constructor(opts?: WritableOptions); - protected _write(chunk: any, encoding: string, callback: Function): void; - write(chunk: any, cb?: Function): boolean; - write(chunk: any, encoding?: string, cb?: Function): boolean; - end(): void; - end(chunk: any, cb?: Function): void; - end(chunk: any, encoding?: string, cb?: Function): void; - - /** - * Event emitter - * The defined events on documents including: - * 1. close - * 2. drain - * 3. error - * 4. finish - * 5. pipe - * 6. unpipe - **/ - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "drain", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "finish", listener: () => void): this; - addListener(event: "pipe", listener: (src: Readable) => void): this; - addListener(event: "unpipe", listener: (src: Readable) => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "drain", chunk: Buffer | string): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "finish"): boolean; - emit(event: "pipe", src: Readable): boolean; - emit(event: "unpipe", src: Readable): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "drain", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "finish", listener: () => void): this; - on(event: "pipe", listener: (src: Readable) => void): this; - on(event: "unpipe", listener: (src: Readable) => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "drain", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "finish", listener: () => void): this; - once(event: "pipe", listener: (src: Readable) => void): this; - once(event: "unpipe", listener: (src: Readable) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "drain", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "finish", listener: () => void): this; - prependListener(event: "pipe", listener: (src: Readable) => void): this; - prependListener(event: "unpipe", listener: (src: Readable) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "drain", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "finish", listener: () => void): this; - prependOnceListener(event: "pipe", listener: (src: Readable) => void): this; - prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this; - - removeListener(event: string, listener: Function): this; - removeListener(event: "close", listener: () => void): this; - removeListener(event: "drain", listener: () => void): this; - removeListener(event: "error", listener: (err: Error) => void): this; - removeListener(event: "finish", listener: () => void): this; - removeListener(event: "pipe", listener: (src: Readable) => void): this; - removeListener(event: "unpipe", listener: (src: Readable) => void): this; - } - - export interface DuplexOptions extends ReadableOptions, WritableOptions { - allowHalfOpen?: boolean; - readableObjectMode?: boolean; - writableObjectMode?: boolean; - } - - // Note: Duplex extends both Readable and Writable. - export class Duplex extends Readable implements NodeJS.ReadWriteStream { - // Readable - pause(): this; - resume(): this; - // Writeable - writable: boolean; - constructor(opts?: DuplexOptions); - protected _write(chunk: any, encoding: string, callback: Function): void; - write(chunk: any, cb?: Function): boolean; - write(chunk: any, encoding?: string, cb?: Function): boolean; - end(): void; - end(chunk: any, cb?: Function): void; - end(chunk: any, encoding?: string, cb?: Function): void; - } - - export interface TransformOptions extends DuplexOptions { - transform?: (chunk: string | Buffer, encoding: string, callback: Function) => any; - flush?: (callback: Function) => any; - } - - // Note: Transform lacks the _read and _write methods of Readable/Writable. - export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream { - readable: boolean; - writable: boolean; - constructor(opts?: TransformOptions); - protected _transform(chunk: any, encoding: string, callback: Function): void; - protected _flush(callback: Function): void; - read(size?: number): any; - setEncoding(encoding: string): this; - pause(): this; - resume(): this; - isPaused(): boolean; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): this; - unshift(chunk: any): void; - wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; - push(chunk: any, encoding?: string): boolean; - write(chunk: any, cb?: Function): boolean; - write(chunk: any, encoding?: string, cb?: Function): boolean; - end(): void; - end(chunk: any, cb?: Function): void; - end(chunk: any, encoding?: string, cb?: Function): void; - } - - export class PassThrough extends Transform { } - } - - export = internal; -} - -declare module "util" { - export interface InspectOptions { - showHidden?: boolean; - depth?: number; - colors?: boolean; - customInspect?: boolean; - } - - export function format(format: any, ...param: any[]): string; - export function debug(string: string): void; - export function error(...param: any[]): void; - export function puts(...param: any[]): void; - export function print(...param: any[]): void; - export function log(string: string): void; - export function inspect(object: any, showHidden?: boolean, depth?: number, color?: boolean): string; - export function inspect(object: any, options: InspectOptions): string; - export function isArray(object: any): boolean; - export function isRegExp(object: any): boolean; - export function isDate(object: any): boolean; - export function isError(object: any): boolean; - export function inherits(constructor: any, superConstructor: any): void; - export function debuglog(key: string): (msg: string, ...param: any[]) => void; - export function isBoolean(object: any): boolean; - export function isBuffer(object: any): boolean; - export function isFunction(object: any): boolean; - export function isNull(object: any): boolean; - export function isNullOrUndefined(object: any): boolean; - export function isNumber(object: any): boolean; - export function isObject(object: any): boolean; - export function isPrimitive(object: any): boolean; - export function isString(object: any): boolean; - export function isSymbol(object: any): boolean; - export function isUndefined(object: any): boolean; - export function deprecate(fn: Function, message: string): Function; -} - -declare module "assert" { - function internal(value: any, message?: string): void; - namespace internal { - export class AssertionError implements Error { - name: string; - message: string; - actual: any; - expected: any; - operator: string; - generatedMessage: boolean; - - constructor(options?: { - message?: string; actual?: any; expected?: any; - operator?: string; stackStartFunction?: Function - }); - } - - export function fail(actual: any, expected: any, message: string, operator: string): void; - export function ok(value: any, message?: string): void; - export function equal(actual: any, expected: any, message?: string): void; - export function notEqual(actual: any, expected: any, message?: string): void; - export function deepEqual(actual: any, expected: any, message?: string): void; - export function notDeepEqual(acutal: any, expected: any, message?: string): void; - export function strictEqual(actual: any, expected: any, message?: string): void; - export function notStrictEqual(actual: any, expected: any, message?: string): void; - export function deepStrictEqual(actual: any, expected: any, message?: string): void; - export function notDeepStrictEqual(actual: any, expected: any, message?: string): void; - export var throws: { - (block: Function, message?: string): void; - (block: Function, error: Function, message?: string): void; - (block: Function, error: RegExp, message?: string): void; - (block: Function, error: (err: any) => boolean, message?: string): void; - }; - - export var doesNotThrow: { - (block: Function, message?: string): void; - (block: Function, error: Function, message?: string): void; - (block: Function, error: RegExp, message?: string): void; - (block: Function, error: (err: any) => boolean, message?: string): void; - }; - - export function ifError(value: any): void; - } - - export = internal; -} - -declare module "tty" { - import * as net from "net"; - - export function isatty(fd: number): boolean; - export interface ReadStream extends net.Socket { - isRaw: boolean; - setRawMode(mode: boolean): void; - isTTY: boolean; - } - export interface WriteStream extends net.Socket { - columns: number; - rows: number; - isTTY: boolean; - } -} - -declare module "domain" { - import * as events from "events"; - - export class Domain extends events.EventEmitter implements NodeJS.Domain { - run(fn: Function): void; - add(emitter: events.EventEmitter): void; - remove(emitter: events.EventEmitter): void; - bind(cb: (err: Error, data: any) => any): any; - intercept(cb: (data: any) => any): any; - dispose(): void; - members: any[]; - enter(): void; - exit(): void; - } - - export function create(): Domain; -} - -declare module "constants" { - export var E2BIG: number; - export var EACCES: number; - export var EADDRINUSE: number; - export var EADDRNOTAVAIL: number; - export var EAFNOSUPPORT: number; - export var EAGAIN: number; - export var EALREADY: number; - export var EBADF: number; - export var EBADMSG: number; - export var EBUSY: number; - export var ECANCELED: number; - export var ECHILD: number; - export var ECONNABORTED: number; - export var ECONNREFUSED: number; - export var ECONNRESET: number; - export var EDEADLK: number; - export var EDESTADDRREQ: number; - export var EDOM: number; - export var EEXIST: number; - export var EFAULT: number; - export var EFBIG: number; - export var EHOSTUNREACH: number; - export var EIDRM: number; - export var EILSEQ: number; - export var EINPROGRESS: number; - export var EINTR: number; - export var EINVAL: number; - export var EIO: number; - export var EISCONN: number; - export var EISDIR: number; - export var ELOOP: number; - export var EMFILE: number; - export var EMLINK: number; - export var EMSGSIZE: number; - export var ENAMETOOLONG: number; - export var ENETDOWN: number; - export var ENETRESET: number; - export var ENETUNREACH: number; - export var ENFILE: number; - export var ENOBUFS: number; - export var ENODATA: number; - export var ENODEV: number; - export var ENOENT: number; - export var ENOEXEC: number; - export var ENOLCK: number; - export var ENOLINK: number; - export var ENOMEM: number; - export var ENOMSG: number; - export var ENOPROTOOPT: number; - export var ENOSPC: number; - export var ENOSR: number; - export var ENOSTR: number; - export var ENOSYS: number; - export var ENOTCONN: number; - export var ENOTDIR: number; - export var ENOTEMPTY: number; - export var ENOTSOCK: number; - export var ENOTSUP: number; - export var ENOTTY: number; - export var ENXIO: number; - export var EOPNOTSUPP: number; - export var EOVERFLOW: number; - export var EPERM: number; - export var EPIPE: number; - export var EPROTO: number; - export var EPROTONOSUPPORT: number; - export var EPROTOTYPE: number; - export var ERANGE: number; - export var EROFS: number; - export var ESPIPE: number; - export var ESRCH: number; - export var ETIME: number; - export var ETIMEDOUT: number; - export var ETXTBSY: number; - export var EWOULDBLOCK: number; - export var EXDEV: number; - export var WSAEINTR: number; - export var WSAEBADF: number; - export var WSAEACCES: number; - export var WSAEFAULT: number; - export var WSAEINVAL: number; - export var WSAEMFILE: number; - export var WSAEWOULDBLOCK: number; - export var WSAEINPROGRESS: number; - export var WSAEALREADY: number; - export var WSAENOTSOCK: number; - export var WSAEDESTADDRREQ: number; - export var WSAEMSGSIZE: number; - export var WSAEPROTOTYPE: number; - export var WSAENOPROTOOPT: number; - export var WSAEPROTONOSUPPORT: number; - export var WSAESOCKTNOSUPPORT: number; - export var WSAEOPNOTSUPP: number; - export var WSAEPFNOSUPPORT: number; - export var WSAEAFNOSUPPORT: number; - export var WSAEADDRINUSE: number; - export var WSAEADDRNOTAVAIL: number; - export var WSAENETDOWN: number; - export var WSAENETUNREACH: number; - export var WSAENETRESET: number; - export var WSAECONNABORTED: number; - export var WSAECONNRESET: number; - export var WSAENOBUFS: number; - export var WSAEISCONN: number; - export var WSAENOTCONN: number; - export var WSAESHUTDOWN: number; - export var WSAETOOMANYREFS: number; - export var WSAETIMEDOUT: number; - export var WSAECONNREFUSED: number; - export var WSAELOOP: number; - export var WSAENAMETOOLONG: number; - export var WSAEHOSTDOWN: number; - export var WSAEHOSTUNREACH: number; - export var WSAENOTEMPTY: number; - export var WSAEPROCLIM: number; - export var WSAEUSERS: number; - export var WSAEDQUOT: number; - export var WSAESTALE: number; - export var WSAEREMOTE: number; - export var WSASYSNOTREADY: number; - export var WSAVERNOTSUPPORTED: number; - export var WSANOTINITIALISED: number; - export var WSAEDISCON: number; - export var WSAENOMORE: number; - export var WSAECANCELLED: number; - export var WSAEINVALIDPROCTABLE: number; - export var WSAEINVALIDPROVIDER: number; - export var WSAEPROVIDERFAILEDINIT: number; - export var WSASYSCALLFAILURE: number; - export var WSASERVICE_NOT_FOUND: number; - export var WSATYPE_NOT_FOUND: number; - export var WSA_E_NO_MORE: number; - export var WSA_E_CANCELLED: number; - export var WSAEREFUSED: number; - export var SIGHUP: number; - export var SIGINT: number; - export var SIGILL: number; - export var SIGABRT: number; - export var SIGFPE: number; - export var SIGKILL: number; - export var SIGSEGV: number; - export var SIGTERM: number; - export var SIGBREAK: number; - export var SIGWINCH: number; - export var SSL_OP_ALL: number; - export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number; - export var SSL_OP_CIPHER_SERVER_PREFERENCE: number; - export var SSL_OP_CISCO_ANYCONNECT: number; - export var SSL_OP_COOKIE_EXCHANGE: number; - export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number; - export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number; - export var SSL_OP_EPHEMERAL_RSA: number; - export var SSL_OP_LEGACY_SERVER_CONNECT: number; - export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number; - export var SSL_OP_MICROSOFT_SESS_ID_BUG: number; - export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number; - export var SSL_OP_NETSCAPE_CA_DN_BUG: number; - export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number; - export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number; - export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number; - export var SSL_OP_NO_COMPRESSION: number; - export var SSL_OP_NO_QUERY_MTU: number; - export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number; - export var SSL_OP_NO_SSLv2: number; - export var SSL_OP_NO_SSLv3: number; - export var SSL_OP_NO_TICKET: number; - export var SSL_OP_NO_TLSv1: number; - export var SSL_OP_NO_TLSv1_1: number; - export var SSL_OP_NO_TLSv1_2: number; - export var SSL_OP_PKCS1_CHECK_1: number; - export var SSL_OP_PKCS1_CHECK_2: number; - export var SSL_OP_SINGLE_DH_USE: number; - export var SSL_OP_SINGLE_ECDH_USE: number; - export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number; - export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number; - export var SSL_OP_TLS_BLOCK_PADDING_BUG: number; - export var SSL_OP_TLS_D5_BUG: number; - export var SSL_OP_TLS_ROLLBACK_BUG: number; - export var ENGINE_METHOD_DSA: number; - export var ENGINE_METHOD_DH: number; - export var ENGINE_METHOD_RAND: number; - export var ENGINE_METHOD_ECDH: number; - export var ENGINE_METHOD_ECDSA: number; - export var ENGINE_METHOD_CIPHERS: number; - export var ENGINE_METHOD_DIGESTS: number; - export var ENGINE_METHOD_STORE: number; - export var ENGINE_METHOD_PKEY_METHS: number; - export var ENGINE_METHOD_PKEY_ASN1_METHS: number; - export var ENGINE_METHOD_ALL: number; - export var ENGINE_METHOD_NONE: number; - export var DH_CHECK_P_NOT_SAFE_PRIME: number; - export var DH_CHECK_P_NOT_PRIME: number; - export var DH_UNABLE_TO_CHECK_GENERATOR: number; - export var DH_NOT_SUITABLE_GENERATOR: number; - export var NPN_ENABLED: number; - export var RSA_PKCS1_PADDING: number; - export var RSA_SSLV23_PADDING: number; - export var RSA_NO_PADDING: number; - export var RSA_PKCS1_OAEP_PADDING: number; - export var RSA_X931_PADDING: number; - export var RSA_PKCS1_PSS_PADDING: number; - export var POINT_CONVERSION_COMPRESSED: number; - export var POINT_CONVERSION_UNCOMPRESSED: number; - export var POINT_CONVERSION_HYBRID: number; - export var O_RDONLY: number; - export var O_WRONLY: number; - export var O_RDWR: number; - export var S_IFMT: number; - export var S_IFREG: number; - export var S_IFDIR: number; - export var S_IFCHR: number; - export var S_IFBLK: number; - export var S_IFIFO: number; - export var S_IFSOCK: number; - export var S_IRWXU: number; - export var S_IRUSR: number; - export var S_IWUSR: number; - export var S_IXUSR: number; - export var S_IRWXG: number; - export var S_IRGRP: number; - export var S_IWGRP: number; - export var S_IXGRP: number; - export var S_IRWXO: number; - export var S_IROTH: number; - export var S_IWOTH: number; - export var S_IXOTH: number; - export var S_IFLNK: number; - export var O_CREAT: number; - export var O_EXCL: number; - export var O_NOCTTY: number; - export var O_DIRECTORY: number; - export var O_NOATIME: number; - export var O_NOFOLLOW: number; - export var O_SYNC: number; - export var O_SYMLINK: number; - export var O_DIRECT: number; - export var O_NONBLOCK: number; - export var O_TRUNC: number; - export var O_APPEND: number; - export var F_OK: number; - export var R_OK: number; - export var W_OK: number; - export var X_OK: number; - export var UV_UDP_REUSEADDR: number; - export var SIGQUIT: number; - export var SIGTRAP: number; - export var SIGIOT: number; - export var SIGBUS: number; - export var SIGUSR1: number; - export var SIGUSR2: number; - export var SIGPIPE: number; - export var SIGALRM: number; - export var SIGCHLD: number; - export var SIGSTKFLT: number; - export var SIGCONT: number; - export var SIGSTOP: number; - export var SIGTSTP: number; - export var SIGTTIN: number; - export var SIGTTOU: number; - export var SIGURG: number; - export var SIGXCPU: number; - export var SIGXFSZ: number; - export var SIGVTALRM: number; - export var SIGPROF: number; - export var SIGIO: number; - export var SIGPOLL: number; - export var SIGPWR: number; - export var SIGSYS: number; - export var SIGUNUSED: number; - export var defaultCoreCipherList: string; - export var defaultCipherList: string; - export var ENGINE_METHOD_RSA: number; - export var ALPN_ENABLED: number; -} - -declare module "process" { - export = process; -} - -declare module "v8" { - interface HeapSpaceInfo { - space_name: string; - space_size: number; - space_used_size: number; - space_available_size: number; - physical_space_size: number; - } - - //** Signifies if the --zap_code_space option is enabled or not. 1 == enabled, 0 == disabled. */ - type DoesZapCodeSpaceFlag = 0 | 1; - - interface HeapInfo { - total_heap_size: number; - total_heap_size_executable: number; - total_physical_size: number; - total_available_size: number; - used_heap_size: number; - heap_size_limit: number; - malloced_memory: number; - peak_malloced_memory: number; - does_zap_garbage: DoesZapCodeSpaceFlag; - } - - export function getHeapStatistics(): HeapInfo; - export function getHeapSpaceStatistics(): HeapSpaceInfo[]; - export function setFlagsFromString(flags: string): void; -} - -declare module "timers" { - export function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; - export function clearTimeout(timeoutId: NodeJS.Timer): void; - export function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; - export function clearInterval(intervalId: NodeJS.Timer): void; - export function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; - export function clearImmediate(immediateId: any): void; -} - -declare module "console" { - export = console; -} - -/** - * _debugger module is not documented. - * Source code is at https://github.com/nodejs/node/blob/master/lib/_debugger.js - */ -declare module "_debugger" { - export interface Packet { - raw: string; - headers: string[]; - body: Message; - } - - export interface Message { - seq: number; - type: string; - } - - export interface RequestInfo { - command: string; - arguments: any; - } - - export interface Request extends Message, RequestInfo { - } - - export interface Event extends Message { - event: string; - body?: any; - } - - export interface Response extends Message { - request_seq: number; - success: boolean; - /** Contains error message if success === false. */ - message?: string; - /** Contains message body if success === true. */ - body?: any; - } - - export interface BreakpointMessageBody { - type: string; - target: number; - line: number; - } - - export class Protocol { - res: Packet; - state: string; - execute(data: string): void; - serialize(rq: Request): string; - onResponse: (pkt: Packet) => void; - } - - export var NO_FRAME: number; - export var port: number; - - export interface ScriptDesc { - name: string; - id: number; - isNative?: boolean; - handle?: number; - type: string; - lineOffset?: number; - columnOffset?: number; - lineCount?: number; - } - - export interface Breakpoint { - id: number; - scriptId: number; - script: ScriptDesc; - line: number; - condition?: string; - scriptReq?: string; - } - - export interface RequestHandler { - (err: boolean, body: Message, res: Packet): void; - request_seq?: number; - } - - export interface ResponseBodyHandler { - (err: boolean, body?: any): void; - request_seq?: number; - } - - export interface ExceptionInfo { - text: string; - } - - export interface BreakResponse { - script?: ScriptDesc; - exception?: ExceptionInfo; - sourceLine: number; - sourceLineText: string; - sourceColumn: number; - } - - export function SourceInfo(body: BreakResponse): string; - - export interface ClientInstance extends NodeJS.EventEmitter { - protocol: Protocol; - scripts: ScriptDesc[]; - handles: ScriptDesc[]; - breakpoints: Breakpoint[]; - currentSourceLine: number; - currentSourceColumn: number; - currentSourceLineText: string; - currentFrame: number; - currentScript: string; - - connect(port: number, host: string): void; - req(req: any, cb: RequestHandler): void; - reqFrameEval(code: string, frame: number, cb: RequestHandler): void; - mirrorObject(obj: any, depth: number, cb: ResponseBodyHandler): void; - setBreakpoint(rq: BreakpointMessageBody, cb: RequestHandler): void; - clearBreakpoint(rq: Request, cb: RequestHandler): void; - listbreakpoints(cb: RequestHandler): void; - reqSource(from: number, to: number, cb: RequestHandler): void; - reqScripts(cb: any): void; - reqContinue(cb: RequestHandler): void; - } - - export var Client : { - new (): ClientInstance - } -} diff --git a/helloworld/scripts/tsconfig.json b/helloworld/scripts/tsconfig.json deleted file mode 100644 index 1868374..0000000 --- a/helloworld/scripts/tsconfig.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "compilerOptions": { - /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ - "lib": [ - "es5", - "es2015.promise" - ], /* Specify library files to be included in the compilation: */ - "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - // "outDir": "./", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - /* Strict Type-Checking Options */ - "strict": true, /* Enable all strict type-checking options. */ - "noImplicitAny": false /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - } -} \ No newline at end of file diff --git a/helloworld/scripts/wxgame/wxgame.ts b/helloworld/scripts/wxgame/wxgame.ts deleted file mode 100644 index acdf1e8..0000000 --- a/helloworld/scripts/wxgame/wxgame.ts +++ /dev/null @@ -1,78 +0,0 @@ -import * as fs from 'fs'; -import * as path from 'path'; -export class WxgamePlugin implements plugins.Command { - - constructor() { - } - async onFile(file: plugins.File) { - if (file.extname == '.js') { - const filename = file.origin; - if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { - return null; - } - if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { - let content = file.contents.toString(); - content += `;window.egret = egret;`; - content = content.replace(/definition = __global/, "definition = window"); - file.contents = new Buffer(content); - } - else { - let content = file.contents.toString(); - if ( - filename == "libs/modules/res/res.js" || - filename == 'libs/modules/res/res.min.js' || - filename == 'libs/modules/assetsmanager/assetsmanager.min.js' || - filename == 'libs/modules/assetsmanager/assetsmanager.js' - ) { - content += ";window.RES = RES;" - } - if (filename == "libs/modules/eui/eui.js" || filename == 'libs/modules/eui/eui.min.js') { - content += ";window.eui = eui;" - } - if (filename == 'libs/modules/dragonBones/dragonBones.js' || filename == 'libs/modules/dragonBones/dragonBones.min.js') { - content += ';window.dragonBones = dragonBones'; - } - content = "var egret = window.egret;" + content; - if (filename == 'main.js') { - content += ";window.Main = Main;" - } - file.contents = new Buffer(content); - } - } - return file; - } - async onFinish(pluginContext: plugins.CommandContext) { - //同步 index.html 配置到 game.js - const gameJSPath = path.join(pluginContext.outputDir, "game.js"); - let gameJSContent = fs.readFileSync(gameJSPath, { encoding: "utf8" }); - const projectConfig = pluginContext.buildConfig.projectConfig; - const optionStr = - `entryClassName: ${projectConfig.entryClassName},\n\t\t` + - `orientation: ${projectConfig.orientation},\n\t\t` + - `frameRate: ${projectConfig.frameRate},\n\t\t` + - `scaleMode: ${projectConfig.scaleMode},\n\t\t` + - `contentWidth: ${projectConfig.contentWidth},\n\t\t` + - `contentHeight: ${projectConfig.contentHeight},\n\t\t` + - `showFPS: ${projectConfig.showFPS},\n\t\t` + - `fpsStyles: ${projectConfig.fpsStyles},\n\t\t` + - `showLog: ${projectConfig.showLog},\n\t\t` + - `maxTouches: ${projectConfig.maxTouches},`; - const reg = /\/\/----auto option start----[\s\S]*\/\/----auto option end----/; - const replaceStr = '\/\/----auto option start----\n\t\t' + optionStr + '\n\t\t\/\/----auto option end----'; - gameJSContent = gameJSContent.replace(reg, replaceStr); - fs.writeFileSync(gameJSPath, gameJSContent); - - //修改横竖屏 - let orientation; - if (projectConfig.orientation == '"landscape"') { - orientation = "landscape"; - } - else { - orientation = "portrait"; - } - const gameJSONPath = path.join(pluginContext.outputDir, "game.json"); - let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); - gameJSONContent.deviceOrientation = orientation; - fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); - } -} \ No newline at end of file diff --git a/helloworld/src/LoadingUI.ts b/helloworld/src/LoadingUI.ts deleted file mode 100644 index e611046..0000000 --- a/helloworld/src/LoadingUI.ts +++ /dev/null @@ -1,51 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// - -class LoadingUI extends egret.Sprite implements RES.PromiseTaskReporter { - - public constructor() { - super(); - this.createView(); - } - - private textField: egret.TextField; - - private createView(): void { - this.textField = new egret.TextField(); - this.addChild(this.textField); - this.textField.y = 300; - this.textField.width = 480; - this.textField.height = 100; - this.textField.textAlign = "center"; - } - - public onProgress(current: number, total: number): void { - this.textField.text = `Loading...${current}/${total}`; - } -} diff --git a/helloworld/src/Main.ts b/helloworld/src/Main.ts deleted file mode 100644 index 790ede1..0000000 --- a/helloworld/src/Main.ts +++ /dev/null @@ -1,317 +0,0 @@ - -class Main extends egret.DisplayObjectContainer { - - - /** - * 加载进度界面 - */ - private loadingView: LoadingUI; - - public constructor() { - super(); - this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this); - } - - private onAddToStage(event: egret.Event) { - // 设置加载进度界面 - this.loadingView = new LoadingUI(); - this.stage.addChild(this.loadingView); - - // 初始化Res资源加载库 - RES.addEventListener(RES.ResourceEvent.CONFIG_COMPLETE, this.onConfigComplete, this); - RES.loadConfig("resource/default.res.json", "resource/"); - } - - /** - * 配置文件加载完成,开始预加载preload资源组 - */ - private onConfigComplete(event: RES.ResourceEvent): void { - RES.removeEventListener(RES.ResourceEvent.CONFIG_COMPLETE, this.onConfigComplete, this); - RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onResourceLoadComplete, this); - RES.addEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onResourceProgress, this); - RES.loadGroup("preload"); - } - - /** - * preload 资源组加载完成 - */ - private onResourceLoadComplete(event: RES.ResourceEvent): void { - if (event.groupName == "preload") { - this.stage.removeChild(this.loadingView); - RES.removeEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onResourceLoadComplete, this); - RES.removeEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onResourceProgress, this); - this.createGameScene(); - } - - } - - /** - * preload资源组加载进度 - */ - private onResourceProgress(event: RES.ResourceEvent): void { - if (event.groupName == "preload") { - // this.loadingView.setProgress(event.itemsLoaded, event.itemsTotal); - } - } - - //debug模式,使用图形绘制 - private isDebug: boolean = false; - - private worldBox: egret.Sprite = new egret.Sprite(); - - // 滚动背景图 - private bgscrollView: egret.ScrollView = new egret.ScrollView(); - - // 当前物体的总高度 - private totalHeight: number = 0; - - /** - * 添加背景滚动视图 - */ - - private addBgScrollView() { - var content: egret.Bitmap = this.createBitmapByName("bg_jpg"); - - //创建ScrollView - let myscrollView = this.bgscrollView; - myscrollView.setContent(content); - myscrollView.width = this.stage.stageWidth; - myscrollView.height = this.stage.stageHeight; - myscrollView.x = 0; - myscrollView.y = 0; - this.addChild(myscrollView); - - content.width = myscrollView.width; - content.height = myscrollView.height * 2; - myscrollView.scrollTop = this.stage.stageHeight; - myscrollView.verticalScrollPolicy = "off"; - } - - // 漂浮的物体 - // private flowBody:p2.Body; - private flowDisplay: egret.DisplayObject; - - // 漂浮动画 - private flowAnimation(display: egret.DisplayObject) { - var rect = display; - rect.y = 100; - this.addChild(rect); - let duration = 3000; - egret.Tween.get(rect, { loop: true }).to({ x: this.stage.stageWidth + 100 }, duration).to({ x: -100 }, duration); - } - - /** - * 创建刚体 - */ - private createBody(boxWidth: number, boxHeight: number, factor: number,m:number = 1): [p2.Body,egret.DisplayObject] { - var display: egret.DisplayObject; - //添加方形刚体 - var boxShape: p2.Shape = new p2.Box({ width: boxWidth, height: boxHeight }); - var boxBody: p2.Body = new p2.Body({ - mass: m, - angularVelocity: 0, - gravityScale: 2, - damping: 0.7 - }); - boxBody.addShape(boxShape); - - if (this.isDebug) { - display = this.createBox((boxShape).width * factor, (boxShape).height * factor); - } else { - display = this.createBitmapByName("rect_png"); - } - display.width = (boxShape).width * factor; - display.height = (boxShape).height * factor; - - display.anchorOffsetX = display.width / 2; - display.anchorOffsetY = display.height / 2; - boxBody.displays = [display]; - this.addChild(display); - return [boxBody,display]; - } - - /** - * 定时添加刚体 - */ - private addBoxByTimer(factor: number, boxWidth: number, boxHeight: number, world: p2.World) { - if (this.flowDisplay || this.isFail) { - return; - } - var array = this.createBody(boxWidth,boxHeight,factor); - var boxBody = array[0]; - var display = array[1]; - this.flowDisplay = display; - this.flowAnimation(display); - - this.stage.addEventListener(egret.TouchEvent.TOUCH_TAP, addOneBox, this); - let self = this; - - function addOneBox(e: egret.TouchEvent): void { - if (boxBody.displays[0] == self.flowDisplay) { - self.flowDisplay = null; - var positionX: number = display.x / factor; - var positionY: number = Math.floor((egret.MainContext.instance.stage.stageHeight - display.y) / factor); - boxBody.position = [positionX, positionY]; - // 添加到世界 - world.addBody(boxBody); - // 停止动画 - egret.Tween.pauseTweens(display); - - // 延迟三秒后添加新的刚体 - egret.setTimeout(function () { - self.addBoxByTimer(factor, boxWidth, boxHeight, world) - }, 1, 3000); - } - } - } - - - - /** - * 碰撞 - */ - private hit() { - - var sound: egret.Sound = RES.getRes("hit_mp3"); - sound.play(0, 1); - var self = this; - var count = this.world.bodies.length; - egret.setTimeout(function () { - let boxHieght = 3; - for (var i = 0; i < count; i++) { - var body = self.world.bodies[i]; - var positionY = body.position[1]; - positionY -= boxHieght; - body.position = [body.position[0], positionY] - } - self.bgscrollView.scrollTop -= boxHieght * 50; - }, 0, 2000); - - } - - private fail() { - var sound: egret.Sound = RES.getRes("break_mp3"); - sound.play(0, 1); - } - - // 掉下去了 - private isFail: boolean = false; - // 上次碰撞的刚体ID - private hitID = 0; - // 地面 - private planeBody: p2.Body; - // 世界 - private world: p2.World; - // 地面距离舞台的初始高度 - private sh = 7; - - /** - * 创建游戏场景 - * Create a game scene - */ - private createGameScene() { - - // 添加背景 - this.addBgScrollView(); - - //egret.Profiler.getInstance().run(); - var factor: number = 50; - - //创建world - var world: p2.World = new p2.World(); - world.sleepMode = p2.World.BODY_SLEEPING; - world.defaultContactMaterial.restitution = 0; - this.world = world; - - //创建一个地基 - var array = this.createBody(8,this.sh,50,0); - var baseBody = array[0]; - baseBody.position = [this.stage.stageWidth / 100,this.sh * 0.5]; - world.addBody(baseBody); - - // 刚体在物理世界的宽和高 - let boxWidth = 6; - let boxHeight = 3; - - egret.Ticker.getInstance().register(function (dt) { - if (dt < 10) { - return; - } - if (dt > 1000) { - return; - } - world.step(dt / 1000); - - var stageHeight: number = egret.MainContext.instance.stage.stageHeight; - var l = world.bodies.length; - for (var i: number = 0; i < l; i++) { - var lastBody: p2.Body = world.bodies[l - 1]; - var lastBox: egret.DisplayObject = lastBody.displays[0]; - if (lastBox && l != 1) { - lastBox.y = Math.floor(stageHeight - lastBody.position[1] * factor); - // let limitHeight = stageHeight - (l - 2) * boxHeight * factor; - let limitHeight = Math.floor(stageHeight - lastBox.anchorOffsetY); - if (lastBox.y > limitHeight + 20) { - console.log("掉下去了!!!!!!!!!!!---->", l - 1, lastBox.y); - if (this.isFail == false) { - this.isFail = true; - this.fail(); - } - } else if (lastBox.y >= limitHeight - this.sh * factor - 20) { - console.log("碰撞上了---->", l - 1); - if (lastBody.id != this.hitID) { - this.hitID = lastBody.id; - this.hit(); - } - } - } - var boxBody: p2.Body = world.bodies[i]; - var box: egret.DisplayObject = boxBody.displays[0]; - if (box) { - box.x = boxBody.position[0] * factor; - box.y = stageHeight - boxBody.position[1] * factor; - box.rotation = 360 - (boxBody.angle + boxBody.shapes[0].angle) * 180 / Math.PI; - if (boxBody.sleepState == p2.Body.SLEEPING) { - box.alpha = 0.5; - } - else { - box.alpha = 1; - } - } - } - }, this); - - this.addBoxByTimer(factor, boxWidth, boxHeight, world); - } - - /** - * 判断是否叠放成功 - */ - private testPlaceSafe(world: p2.World) { - - } - - - /** - * 根据name关键字创建一个Bitmap对象。name属性请参考resources/resource.json配置文件的内容。 - * Create a Bitmap object according to name keyword.As for the property of name please refer to the configuration file of resources/resource.json. - */ - private createBitmapByName(name: string) { - let result = new egret.Bitmap(); - let texture: egret.Texture = RES.getRes(name); - result.texture = texture; - return result; - } - - /** - * 创建一个方形 - */ - private createBox(width: number, height: number): egret.Shape { - var shape = new egret.Shape(); - shape.graphics.beginFill(0xfff000); - shape.graphics.drawRect(0, 0, width, height); - shape.graphics.endFill(); - return shape; - } - -} \ No newline at end of file diff --git a/helloworld/src/Platform.ts b/helloworld/src/Platform.ts deleted file mode 100644 index 4942b99..0000000 --- a/helloworld/src/Platform.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * 平台数据接口。 - * 由于每款游戏通常需要发布到多个平台上,所以提取出一个统一的接口用于开发者获取平台数据信息 - * 推荐开发者通过这种方式封装平台逻辑,以保证整体结构的稳定 - * 由于不同平台的接口形式各有不同,白鹭推荐开发者将所有接口封装为基于 Promise 的异步形式 - */ -declare interface Platform { - - getUserInfo(): Promise; - - login(): Promise - -} - -class DebugPlatform implements Platform { - async getUserInfo() { - return { nickName: "username" } - } - async login() { - - } -} - - -if (!window.platform) { - window.platform = new DebugPlatform(); -} - - - -declare let platform: Platform; - -declare interface Window { - - platform: Platform -} - - - - - diff --git a/helloworld/template/runtime/native_loader.js b/helloworld/template/runtime/native_loader.js deleted file mode 100644 index ad94285..0000000 --- a/helloworld/template/runtime/native_loader.js +++ /dev/null @@ -1,8 +0,0 @@ -require("launcher/native_require.js"); - -egret_native.egtMain = function () { - egret_native.nativeType = "native"; - - egret_native.egretInit(); - egret_native.egretStart(); -}; diff --git a/helloworld/template/runtime/native_require.js b/helloworld/template/runtime/native_require.js deleted file mode 100644 index 3b7e504..0000000 --- a/helloworld/template/runtime/native_require.js +++ /dev/null @@ -1,53 +0,0 @@ -var manifest = JSON.parse(egret_native.readFileSync("manifest.json")); -var game_file_list = manifest.initial.concat(manifest.game); - -var window = this; - -egret_native.setSearchPaths([""]); - -egret_native.requireFiles = function () { - for (var key in game_file_list) { - var src = game_file_list[key]; - require(src); - } -}; - -egret_native.egretInit = function () { - if(egret_native.featureEnable) { - //控制一些优化方案是否开启 - //Control whether some optimization options are open - var result = egret_native.featureEnable({ - - }); - } - egret_native.requireFiles(); - egret.dom = {}; - egret.dom.drawAsCanvas = function () { - }; -}; - -egret_native.egretStart = function () { - var option = { - //以下为自动修改,请勿修改 - //The following is automatically modified, please do not modify - //----auto option start---- - entryClassName: "Main", - frameRate: 30, - scaleMode: "showAll", - contentWidth: 640, - contentHeight: 1136, - showPaintRect: false, - showFPS: false, - fpsStyles: "x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9", - showLog: false, - logFilter: "", - maxTouches: 2, - textureScaleFactor: 1 - //----auto option end---- - }; - - egret.native.NativePlayer.option = option; - egret.runEgret(); - egret_native.Label.createLabel("/system/fonts/DroidSansFallback.ttf", 20, "", 0); - egret_native.EGTView.preSetOffScreenBufferEnable(true); -}; \ No newline at end of file diff --git a/helloworld/template/runtime/runtime_loader.js b/helloworld/template/runtime/runtime_loader.js deleted file mode 100644 index 5b5f76b..0000000 --- a/helloworld/template/runtime/runtime_loader.js +++ /dev/null @@ -1,8 +0,0 @@ -require("launcher/native_require.js"); - -egret_native.egtMain = function () { - egret_native.nativeType = "runtime"; - - egret_native.egretInit(); - egret_native.egretStart(); -}; \ No newline at end of file diff --git a/helloworld/template/web/index.html b/helloworld/template/web/index.html deleted file mode 100644 index 73f7bb1..0000000 --- a/helloworld/template/web/index.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - Egret - - - - - - - - - - -
      -
      - - - - \ No newline at end of file diff --git a/helloworld/tsconfig.json b/helloworld/tsconfig.json deleted file mode 100644 index 905433a..0000000 --- a/helloworld/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "outDir": "bin-debug", - "experimentalDecorators": true, - "lib": [ - "es5", - "dom", - "es2015.promise" - ], - "types": [] - }, - "include": [ - "src", - "libs" - ] -} \ No newline at end of file diff --git a/helloworld/wingProperties.json b/helloworld/wingProperties.json deleted file mode 100644 index 31cf46d..0000000 --- a/helloworld/wingProperties.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "resourcePlugin":{ - "configs":[{ - "configPath":"resource/default.res.json", - "relativePath":"resource/" - }] - }, - "theme":"resource/default.thm.json" -} \ No newline at end of file