diff --git a/.wing/launch.json b/.wing/launch.json new file mode 100644 index 0000000..ccc9929 --- /dev/null +++ b/.wing/launch.json @@ -0,0 +1,29 @@ +{ + "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":5630 + }, + { + "name": "Launch Chrome", + "type": "chrome", + "request": "launch", + "file": "index.html", + "useBuildInServer": true, + "sourceMaps": true, + "webRoot": "${workspaceRoot}", + "preLaunchTask":"build", + "userDataDir":"${tmpdir}", + "port":5630 + } + ] +} \ No newline at end of file diff --git a/.wing/settings.json b/.wing/settings.json new file mode 100644 index 0000000..372e43c --- /dev/null +++ b/.wing/settings.json @@ -0,0 +1,6 @@ +{ + "search.exclude": { + "**/bin-debug": true, + "**/bin-release": true + } +} \ No newline at end of file diff --git a/.wing/tasks.json b/.wing/tasks.json new file mode 100644 index 0000000..521f0c8 --- /dev/null +++ b/.wing/tasks.json @@ -0,0 +1,34 @@ +{ + "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/bin-debug/Ball.js b/bin-debug/Ball.js new file mode 100644 index 0000000..483bff3 --- /dev/null +++ b/bin-debug/Ball.js @@ -0,0 +1,36 @@ +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 Ball = (function (_super) { + __extends(Ball, _super); + function Ball() { + var _this = _super.call(this) || this; + _this.createScene(); + return _this; + } + Ball.prototype.createScene = function () { + this.ball = this.createBitmapByName('ball_png'); + this.ball.width = 10; + this.ball.height = 10; + this.addChild(this.ball); + }; + /** + * 根据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. + */ + Ball.prototype.createBitmapByName = function (name) { + var result = new egret.Bitmap(); + var texture = RES.getRes(name); + result.texture = texture; + return result; + }; + return Ball; +}(egret.Sprite)); +__reflect(Ball.prototype, "Ball"); diff --git a/bin-debug/CXK.js b/bin-debug/CXK.js new file mode 100644 index 0000000..340b7ff --- /dev/null +++ b/bin-debug/CXK.js @@ -0,0 +1,100 @@ +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 CXK = (function (_super) { + __extends(CXK, _super); + function CXK() { + var _this = _super.call(this) || this; + _this.speedBall = 0; + _this.status = 1; + _this.step = 0; + _this.shotStatus = 0; + _this.createScene(); + _this.addEventListener(egret.Event.ENTER_FRAME, _this.changeIkun, _this); + return _this; + } + CXK.prototype.reset = function () { + this.step = 0; + }; + CXK.prototype.prepare = function () { + this.step = 1; + }; + CXK.prototype.shot = function () { + this.step = 2; + }; + CXK.prototype.createScene = function () { + this.cxk = new egret.Bitmap(); + this.cxk.width = 40; + this.cxk.height = 60; + this.ball = this.createBitmapByName('ball_png'); + this.ball.width = 10; + this.ball.height = 10; + this.ball.x = 15; + this.addChild(this.ball); + this.addChild(this.cxk); + }; + CXK.prototype.changeIkun = function () { + if (this.step === 0) { + this.cxk.height = 60; + this.shotStatus = 0; + this.cxk.y = 0; + if (this.status > 3) { + this.status = 1; + this.speedBall = 0; + } + if (this.status > 2) { + this.cxk.texture = RES.getRes('paddle_2_png'); + } + else { + this.cxk.texture = RES.getRes('paddle_1_png'); + } + this.status = this.status + 0.1; + this.changeBall(); + } + else if (this.step === 1) { + this.cxk.texture = RES.getRes('paddle_2_png'); + this.ball.y = 30; + if (this.cxk.height > 40) { + this.cxk.height -= .6; + this.cxk.y += .6; + } + } + else if (this.step === 2) { + this.cxk.texture = RES.getRes('paddle_3_png'); + this.cxk.height = 62; + this.cxk.y = 0; + this.shotStatus += 0.4; + if (this.shotStatus > 1) { + this.cxk.texture = RES.getRes('paddle_4_png'); + } + } + }; + CXK.prototype.changeBall = function () { + if (this.status > 2) { + this.ball.y = 15 + 10 * (this.speedBall); + } + else { + this.ball.y = 40 - 10 * (this.speedBall); + } + this.speedBall += 0.15; + }; + /** + * 根据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. + */ + CXK.prototype.createBitmapByName = function (name) { + var result = new egret.Bitmap(); + var texture = RES.getRes(name); + result.texture = texture; + return result; + }; + return CXK; +}(egret.DisplayObjectContainer)); +__reflect(CXK.prototype, "CXK"); diff --git a/bin-debug/LoadingUI.js b/bin-debug/LoadingUI.js new file mode 100644 index 0000000..3510761 --- /dev/null +++ b/bin-debug/LoadingUI.js @@ -0,0 +1,58 @@ +////////////////////////////////////////////////////////////////////////////////////// +// +// 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.textColor = 0x55c04b; + this.textField.width = 480; + this.textField.height = 100; + }; + LoadingUI.prototype.onProgress = function (current, total) { + this.textField.text = "\u6B63\u5728\u52A0\u8F7D..." + current + "/" + total; + }; + return LoadingUI; +}(egret.Sprite)); +__reflect(LoadingUI.prototype, "LoadingUI", ["RES.PromiseTaskReporter"]); diff --git a/bin-debug/Main.js b/bin-debug/Main.js new file mode 100644 index 0000000..a19d78c --- /dev/null +++ b/bin-debug/Main.js @@ -0,0 +1,345 @@ +////////////////////////////////////////////////////////////////////////////////////// +// +// 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 __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return 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 getTimer = egret.getTimer; +var Main = (function (_super) { + __extends(Main, _super); + function Main() { + var _this = _super.call(this) || this; + _this.ballT = 0; + _this.gameStatus = 0; //游戏状态 0 未开始 1 按压 2 正在投篮 3命中 4积分 + _this.powerEarn = 0; //力量 0-1 + _this.ballCount = 10; + _this.totalPoint = 0; + _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.onAddToStage, _this); + _this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, _this.onTouchBeginState, _this); + _this.addEventListener(egret.TouchEvent.TOUCH_END, _this.onTouchEndState, _this); + _this.addEventListener(egret.Event.ENTER_FRAME, _this.onEnterFrame, _this); + return _this; + } + Main.prototype.onAddToStage = function (event) { + egret.lifecycle.addLifecycleListener(function (context) { + // custom lifecycle plugin + context.onUpdate = function () { + }; + }); + egret.lifecycle.onPause = function () { + egret.ticker.pause(); + }; + egret.lifecycle.onResume = function () { + egret.ticker.resume(); + }; + this.runGame().catch(function (e) { + console.log(e); + }); + }; + Main.prototype.runGame = function () { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.loadResource()]; + case 1: + _a.sent(); + this.createGameScene(); + return [2 /*return*/]; + } + }); + }); + }; + Main.prototype.loadResource = function () { + return __awaiter(this, void 0, void 0, function () { + var loadingView, e_1; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + _a.trys.push([0, 3, , 4]); + loadingView = new LoadingUI(); + this.stage.addChild(loadingView); + return [4 /*yield*/, RES.loadConfig("resource/default.res.json", "resource/")]; + case 1: + _a.sent(); + return [4 /*yield*/, RES.loadGroup("preload", 0, loadingView)]; + case 2: + _a.sent(); + this.scale_intro = RES.getRes('scale_intro_mp3'); + this.scale_circle = RES.getRes('scale_loop_mp3'); + this.shotSound = RES.getRes('launch_mp3'); + this.bingoSound = RES.getRes('point_mp3'); + this.dieSound = RES.getRes('die_mp3'); + this.stage.removeChild(loadingView); + return [3 /*break*/, 4]; + case 3: + e_1 = _a.sent(); + console.error(e_1); + return [3 /*break*/, 4]; + case 4: return [2 /*return*/]; + } + }); + }); + }; + Main.prototype.drawBallCountAndScore = function () { + this.ballCountText.text = 'x' + this.ballCount.toString(); + this.pointText.text = '得分:' + this.totalPoint.toString(); + }; + /** + * 创建游戏场景 + * Create a game scene + */ + Main.prototype.createGameScene = function () { + var stageW = this.stage.stageWidth; + var stageH = this.stage.stageHeight; + // 白色背景 + var shp = new egret.Shape(); + shp.graphics.beginFill(0xffffff, 1); + shp.graphics.drawRect(0, 0, stageW, stageH); + shp.graphics.endFill(); + this.addChild(shp); + //篮球场背景 + var sky = this.createBitmapByName("bg_png"); + this.addChild(sky); + sky.width = stageW; + sky.height = stageW / (1102 / 1172); + sky.y = (stageH - sky.height) / 2; + this.cxk = new CXK(); + this.addChild(this.cxk); + this.cxk.x = 349; + this.cxk.y = sky.y + 231; + var ball2 = new Ball(); + this.addChild(ball2); + ball2.x = 156; + ball2.y = 325; + ball2.alpha = 0; + this.ball2 = ball2; + this.touchEnabled = true; + this.scoreboardImg = new ScoreBoard(); + this.scoreboardImg.touchEnabled = true; + this.scoreboardImg.addEventListener(egret.TouchEvent.TOUCH_TAP, this.restart, this); + var tipText = new egret.TextField(); + this.addChild(tipText); + tipText.textColor = 0x1aad19; + tipText.x = 200; + tipText.y = 900; + tipText.text = '长按蓄力,松开投球'; + this.pointText = new egret.TextField(); + this.addChild(this.pointText); + this.pointText.x = 400; + this.pointText.y = 5; + this.pointText.textColor = 0x333333; + this.pointText.size = 28; + this.ballCountText = new egret.TextField(); + this.addChild(this.ballCountText); + this.ballCountText.x = 60; + this.ballCountText.y = 5; + this.ballCountText.size = 28; + this.ballCountText.textColor = 0x333333; + this.ball3 = this.createBitmapByName('ball_png'); + this.addChild(this.ball3); + this.ball3.y = 5; + this.ball3.x = 25; + this.ball3.width = 25; + this.ball3.height = 25; + this.drawBallCountAndScore(); + }; + Main.prototype.restart = function () { + console.log('restart'); + if (this.gameStatus === 4) { + this.removeChild(this.scoreboardImg); + this.gameStatus = 0; + this.totalPoint = 0; + this.ballCount = 10; + this.drawBallCountAndScore(); + } + }; + Main.prototype.onEnterFrame = function () { + if (this.gameStatus === 2 || this.gameStatus === 3) { + this.ballSport(); + } + if (this.gameStatus === 1) { + //蓄力过程 + this.powerEarn = this.powerEarn + (1 / 66); + } + }; + Main.prototype.onTouchBeginState = function () { + var _this = this; + console.log('touch begin'); + if (this.gameStatus === 0) { + this.gameStatus = 1; + this.powerEarn = 0; + this.ballT = 0; + this.scaleChannel = this.scale_intro.play(0, 1); + setTimeout(function () { + if (_this.gameStatus === 1) { + _this.scaleChannel.stop(); + _this.scaleChannel = _this.scale_circle.play(0, 0); + } + }, 2200); + this.cxk.prepare(); + } + }; + Main.prototype.onTouchEndState = function () { + console.log('touch end'); + if (this.gameStatus === 1) { + this.ballT = 0; + this.gameStatus = 2; + this.scaleChannel.stop(); + this.shotSound.play(0, 1); + this.cxk.shot(); + this.ballCount--; + this.drawBallCountAndScore(); + this.ball = new Ball(); + this.addChild(this.ball); + this.ball.alpha = 0; + } + }; + Main.prototype.ballSport = function () { + var _this = this; + //篮球弧线 + var speed = 0.015; + var t = this.ballT; + var p0 = { x: 350, y: 445 }; + // let p1 = {x: 250, y: 200}; + var p1 = { x: 250, y: 200 + (0.5 - this.powerEarn) * 320 }; + var p2 = __assign({}, p1); + var p3 = { x: 100 + (0.5 - this.powerEarn) * 160, y: 400 }; + var cx = 3 * (p1.x - p0.x); + var bx = 3 * (p2.x - p1.x) - cx; + var ax = p3.x - p0.x - cx - bx; + var cy = 3 * (p1.y - p0.y); + var by = 3 * (p2.y - p1.y) - cy; + var ay = p3.y - p0.y - cy - by; + var xt = ax * (t * t * t) + bx * (t * t) + cx * t + p0.x; + var yt = ay * (t * t * t) + by * (t * t) + cy * t + p0.y; + this.ballT += speed; + if (this.ballT > 1) { + this.ballT = 1; + } + this.ball.alpha = 1; + //结束这一步 + var stepOver = function () { + _this.gameStatus = 0; + _this.cxk.reset(); + _this.removeChild(_this.ball); + if (_this.ballCount <= 0) { + _this.gameStatus = 4; + _this.addChildAt(_this.scoreboardImg, 10); + _this.scoreboardImg.x = (_this.stage.stageWidth - _this.scoreboardImg.scoreBoard.width) / 2; + _this.scoreboardImg.y = (_this.stage.stageHeight - _this.scoreboardImg.scoreBoard.height) / 2; + console.log(_this.scoreboardImg.x, _this.scoreboardImg.y); + _this.scoreboardImg.setCurrentPoint(_this.totalPoint); + } + _this.drawBallCountAndScore(); + }; + if (this.gameStatus === 3) { + this.ball.y = yt; + if (yt >= p3.y - 1) { + this.totalPoint++; + stepOver(); + } + } + else if (this.gameStatus === 2) { + var isHit = this.ball2.hitTestPoint(this.ball.x + 5, this.ball.y + 5); + if (isHit) { + this.bingoSound.play(0, 1); + this.gameStatus = 3; + } + this.ball.x = xt; + this.ball.y = yt; + } + if (this.ball.y >= p3.y - 1 && this.ball.x <= p3.x + 1) { + if (this.gameStatus === 2) { + this.dieSound.play(0, 1); + stepOver(); + } + } + }; + /** + * 根据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; + }; + return Main; +}(egret.DisplayObjectContainer)); +__reflect(Main.prototype, "Main"); diff --git a/bin-debug/ScoreBoard.js b/bin-debug/ScoreBoard.js new file mode 100644 index 0000000..be6e3a9 --- /dev/null +++ b/bin-debug/ScoreBoard.js @@ -0,0 +1,61 @@ +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 ScoreBoard = (function (_super) { + __extends(ScoreBoard, _super); + function ScoreBoard() { + var _this = _super.call(this) || this; + //任务移动的方向 + _this.currentPoint = 0; + _this.maxPoint = 0; + // this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this); + _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.init, _this); + return _this; + } + /** + * 根据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. + */ + ScoreBoard.prototype.createBitmapByName = function (name) { + var result = new egret.Bitmap(); + result.texture = RES.getRes(name); + return result; + }; + ScoreBoard.prototype.setCurrentPoint = function (point) { + this.currentPoint = point; + if (point > this.maxPoint) { + this.maxPoint = point; + } + this.currentPointText.text = this.currentPoint + ""; + this.maxPointText.text = this.maxPoint + ""; + }; + ScoreBoard.prototype.init = function () { + var shp = new egret.DisplayObjectContainer(); + this.scoreBoard = this.createBitmapByName('scoreboard_png'); + shp.width = this.scoreBoard.width; + shp.height = this.scoreBoard.height; + this.width = shp.width; + this.height = shp.height; + shp.addChild(this.scoreBoard); + this.currentPointText = new egret.TextField(); + this.maxPointText = new egret.TextField(); + shp.addChild(this.currentPointText); + shp.addChild(this.maxPointText); + this.currentPointText.y = this.scoreBoard.height / 2.5; + this.currentPointText.textColor = 0xcc0000; + this.maxPointText.textColor = 0xcc0000; + this.maxPointText.y = this.scoreBoard.height / 1.65; + this.currentPointText.x = this.scoreBoard.width / 2; + this.maxPointText.x = this.scoreBoard.width / 2; + this.addChild(shp); + }; + return ScoreBoard; +}(egret.DisplayObjectContainer)); +__reflect(ScoreBoard.prototype, "ScoreBoard"); diff --git a/bin-release/web/191201225322/index.html b/bin-release/web/191201225322/index.html new file mode 100644 index 0000000..3d8ce27 --- /dev/null +++ b/bin-release/web/191201225322/index.html @@ -0,0 +1,102 @@ + + + + + + Egret + + + + + + + + + + +
正在加载...0/14
+
+
+ + + + \ No newline at end of file diff --git a/bin-release/web/191201225322/js/assetsmanager.min_2ef412b7.js b/bin-release/web/191201225322/js/assetsmanager.min_2ef412b7.js new file mode 100644 index 0000000..bd155e9 --- /dev/null +++ b/bin-release/web/191201225322/js/assetsmanager.min_2ef412b7.js @@ -0,0 +1 @@ +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},__decorate=this&&this.__decorate||function(e,r,t,o){var n,i=arguments.length,a=3>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){}(RES||(RES={}));var RES;!function(e){var r=function(){function r(){this.groupTotalDic={},this.numLoadedDic={},this.groupErrorDic={},this.retryTimesDic={},this.maxRetryTimes=3,this.reporterDic={},this.dispatcherDic={},this.failedList=new Array,this.loadItemErrorDic={},this.errorDic={},this.itemListPriorityDic={},this.itemLoadDic={},this.promiseHash={},this.lazyLoadList=new Array,this.loadingCount=0,this.thread=4}return r.prototype.pushResItem=function(e){if(this.promiseHash[e.root+e.name])return this.promiseHash[e.root+e.name];this.lazyLoadList.push(e),this.itemListPriorityDic[Number.NEGATIVE_INFINITY]=this.lazyLoadList,this.updatelistPriority(this.lazyLoadList,Number.NEGATIVE_INFINITY);var r=new egret.EventDispatcher;this.dispatcherDic[e.root+e.name]=r;var t=new Promise(function(e,t){r.addEventListener("complete",function(r){e(r.data)},null),r.addEventListener("error",function(e){t(e.data)},null)});return this.promiseHash[e.root+e.name]=t,this.loadNextResource(),t},r.prototype.pushResGroup=function(e,r,t,o){if(this.promiseHash[r])return this.promiseHash[r];for(var n=e.length,i=0;n>i;i++){var a=e[i];a.groupNames||(a.groupNames=[]),a.groupNames.push(r)}this.groupTotalDic[r]=e.length,this.numLoadedDic[r]=0,this.updatelistPriority(e,t),this.reporterDic[r]=o;var s=new egret.EventDispatcher;this.dispatcherDic[r]=s;var u=new Promise(function(e,r){s.addEventListener("complete",e,null),s.addEventListener("error",function(e){r(e.data)},null)});return this.promiseHash[r]=u,this.loadNextResource(),u},r.prototype.updatelistPriority=function(e,r){void 0==this.itemListPriorityDic[r]&&(this.itemListPriorityDic[r]=[]);for(var t=0,o=e;ti){this.itemListPriorityDic[r].push(n);var a=this.itemListPriorityDic[i].indexOf(n);this.itemListPriorityDic[i].splice(a,1)}}}},r.prototype.findPriorityInDic=function(e){for(var r in this.itemListPriorityDic)if(this.itemListPriorityDic[r].indexOf(e)>-1)return parseInt(r)},r.prototype.loadNextResource=function(){for(;this.loadingCountr.maxRetryTimes))return r.retryTimesDic[t.name]=n+1,r.failedList.push(t),void r.loadNextResource();if(delete r.retryTimesDic[t.name],r.promiseHash[t.root+t.name]){var i=r.deleteDispatcher(t.root+t.name);i.dispatchEventWith("error",!1,{r:t,error:o})}var a=t.groupNames;if(a){delete t.groupNames;for(var s=0,u=a;s0)return this.failedList.shift();var e=Number.NEGATIVE_INFINITY;for(var r in this.itemListPriorityDic)e=Math.max(e,r);var t=this.itemListPriorityDic[e];if(t)return 0==t.length?(delete this.itemListPriorityDic[e],this.getOneResourceInfoInGroup()):t.shift()},r.prototype.setGroupProgress=function(e,r){var t=this.reporterDic[e];this.numLoadedDic[e]++;var o=this.numLoadedDic[e],n=this.groupTotalDic[e];return t&&t.onProgress&&t.onProgress(o,n,r),o==n},r.prototype.loadGroupEnd=function(e,r){delete this.groupTotalDic[e],delete this.numLoadedDic[e],delete this.reporterDic[e];var t=this.deleteDispatcher(e);if(r){delete this.groupErrorDic[e];var o=this.loadItemErrorDic[e];delete this.loadItemErrorDic[e],t.dispatchEventWith("error",!1,{itemList:o,lastError:r})}else{var n=this.groupErrorDic[e];if(delete this.groupErrorDic[e],n){var o=this.loadItemErrorDic[e];delete this.loadItemErrorDic[e];var i=this.errorDic[e];delete this.errorDic[e],t.dispatchEventWith("error",!1,{itemList:o,error:i})}else t.dispatchEventWith("complete")}},r.prototype.deleteDispatcher=function(e){delete this.promiseHash[e];var r=this.dispatcherDic[e];return delete this.dispatcherDic[e],r},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),!1;var o=e.processor.isSupport(r);return o?(o.onRemoveStart(e.host,r),e.host.remove(r),1==r.extra&&e.config.removeResourceData(r),!0):!0},r}();e.ResourceLoader=r,__reflect(r.prototype,"RES.ResourceLoader")}(RES||(RES={}));var RES;!function(e){e.checkNull=function(e,r,t){var o=t.value;t.value=function(){for(var e=[],t=0;t=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(){return this.config||(this.config={alias:{},groups:{},resourceRoot:o.root,mergeSelector:null,fileSystem:null,loadGroup:[]}),e.queue.pushResItem(o)["catch"](function(r){return e.isCompatible||r.__resource_manager_error__||(r.error?console.error(r.error.stack):console.error(r.stack),r=new e.ResourceManagerError(1002)),e.host.remove(o),Promise.reject(r)})},t.prototype.getGroupByName=function(r){var t=this.config.groups[r],o=[];if(!t)return o;for(var n=0,i=t;n=0&&(t=e.substr(r+1),e=e.substr(0,r));var o=this.getResource(e);return o?{r:o,key:e,subkey:t}:null},t.prototype.getKeyByAlias=function(e){return this.config.alias[e]?this.config.alias[e]:e},t.prototype.getResource=function(e){var t=this.config.alias[e];t||(t=e);var o=r(t);return o?o:null},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;n=0){var o=t.split("://");t=o[0]+"://"+e.path.normalize(o[1]+"/"),r=r.replace(t,"")}else t=e.path.normalize(t+"/"),r=r.replace(t,"");return e.setConfigURL(r,t),P||(P=new D),a(P.loadConfig())}function a(r){return e.isCompatible?void r["catch"](function(e){}).then():r}function s(e,r,t){return void 0===r&&(r=0),a(P.loadGroup(e,r,t))}function u(e){return P.isGroupLoaded(e)}function c(r){return P.getGroupByName(r).map(function(r){return e.ResourceItem.convertToResItem(r)})}function l(e,r,t){return void 0===t&&(t=!1),P.createGroup(e,r,t)}function f(e){return P.hasRes(e)}function p(e){return P.getRes(e)}function g(e,r,t){return a(P.getResAsync.apply(P,arguments))}function d(e,r,t,o){if(void 0===o&&(o=""),!P){var n=egret.sys.tr(3200);return egret.warn(n),Promise.reject(n)}return a(P.getResByUrl(e,r,t,o))}function v(e,r){return P.destroyRes(e,r)}function h(e){P||(P=new D),P.setMaxLoadingThread(e)}function m(e){P.setMaxRetryTimes(e)}function R(e,r,t,o,n){void 0===o&&(o=!1),void 0===n&&(n=0),P||(P=new D),P.addEventListener(e,r,t,o,n)}function E(e,r,t,o){void 0===o&&(o=!1),P.removeEventListener(e,r,t,o)}function y(e){P.addResourceData(e)}function _(){return P||(P=new D),P.vcs}function S(e){P||(P=new D),P.registerVersionController(e)}function L(e){return P.vcs?P.vcs.getVirtualUrl(e):e}e.nameSelector=r,e.typeSelector=t,e.registerAnalyzer=o,e.setIsCompatible=n,e.isCompatible=!1,e.loadConfig=i,e.loadGroup=s,e.isGroupLoaded=u,e.getGroupByName=c,e.createGroup=l,e.hasRes=f,e.getRes=p,e.getResAsync=g,e.getResByUrl=d,e.destroyRes=v,e.setMaxLoadingThread=h,e.setMaxRetryTimes=m,e.addEventListener=R,e.removeEventListener=E,e.$addResourceData=y,e.getVersionController=_,e.registerVersionController=S,e.getVirtualUrl=L;var D=function(r){function t(){var t=r.call(this)||this;return t.isVcsInit=!1,t.normalLoadConfig=function(){return e.config.init().then(function(r){e.ResourceEvent.dispatchResourceEvent(t,e.ResourceEvent.CONFIG_COMPLETE)},function(r){return e.ResourceEvent.dispatchResourceEvent(t,e.ResourceEvent.CONFIG_LOAD_ERROR),Promise.reject(r)})},e.VersionController&&(t.vcs=new e.VersionController),t}return __extends(t,r),t.prototype.registerVersionController=function(e){this.vcs=e,this.isVcsInit=!1},t.prototype.loadConfig=function(){var e=this;return!this.isVcsInit&&this.vcs?(this.isVcsInit=!0,this.vcs.init().then(function(){return e.normalLoadConfig()})):this.normalLoadConfig()},t.prototype.isGroupLoaded=function(r){var t=e.config.getGroupByName(r);return t.every(function(r){return null!=e.host.get(r)})},t.prototype.getGroupByName=function(r){return e.config.getGroupByName(r)},t.prototype.loadGroup=function(r,t,o){var n=this;void 0===t&&(t=0);var i={onProgress:function(t,i,a){o&&o.onProgress&&o.onProgress(t,i,a),e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.GROUP_PROGRESS,r,a,t,i)}};return this._loadGroup(r,t,i).then(function(t){-1==e.config.config.loadGroup.indexOf(r)&&e.config.config.loadGroup.push(r),e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.GROUP_COMPLETE,r)},function(t){if(-1==e.config.config.loadGroup.indexOf(r)&&e.config.config.loadGroup.push(r),t.itemList)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.isCompatible&&console.warn(t.error.message),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);return 0==n.length?new Promise(function(t,o){o({error:new e.ResourceManagerError(2005,r)})}):e.queue.pushResGroup(n,r,t,o)},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);if(null==a)return t&&t.call(o,null,i),Promise.reject(new e.ResourceManagerError(2006,r));var s=this.getRes(r);if(s)return t&&egret.callLater(function(){t.call(o,s,i)},this),Promise.resolve(s);var u=a.r,c=a.subkey;return e.queue.pushResItem(u).then(function(n){e.host.save(u,n);var a=e.processor.isSupport(u);return a&&a.getData&&c&&(n=a.getData(e.host,u,r,c)),t&&t.call(o,n,i),n},function(r){return e.host.remove(u),e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.ITEM_LOAD_ERROR,"",u),t?(t.call(o,null,i),Promise.reject(null)):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:"",extra:1},e.config.addResourceData(a),a=e.config.getResource(r),!a))throw"never";return e.queue.pushResItem(a).then(function(r){return e.host.save(a,r),t&&a&&t.call(o,r,a.url),r},function(n){return e.host.remove(a),e.ResourceEvent.dispatchResourceEvent(i,e.ResourceEvent.ITEM_LOAD_ERROR,"",a),t?(t.call(o,null,r),Promise.reject(null)):Promise.reject(n)})},t.prototype.destroyRes=function(r,t){void 0===t&&(t=!0);var o=e.config.getGroupByName(r);if(o&&o.length>0){var n=e.config.config.loadGroup.indexOf(r);if(-1==n)return!1;if(t||1==e.config.config.loadGroup.length&&e.config.config.loadGroup[0]==r){for(var i=0,a=o;ir&&(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){r.root="",e.config.addResourceData(r)},__decorate([e.checkNull],t.prototype,"hasRes",null),__decorate([e.checkNull],t.prototype,"getRes",null),__decorate([e.checkNull],t.prototype,"getResAsync",null),__decorate([e.checkNull],t.prototype,"getResByUrl",null),t}(egret.EventDispatcher);e.Resource=D,__reflect(D.prototype,"RES.Resource");var P}(RES||(RES={}));var RES;!function(e){var r;!function(e){function r(e){var r=e.split("/");return r.filter(function(e,t){return!!e||t==r.length-1}).join("/")}function t(e){return e.substr(e.lastIndexOf("/")+1)}function o(e){return e.substr(0,e.lastIndexOf("/"))}e.normalize=r,e.basename=t,e.dirname=o}(r=e.path||(e.path={}))}(RES||(RES={}));var RES;!function(e){function r(){e.config.config.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.profile=r,e.host={state:{},get resourceConfig(){return e.config},load:function(r,t){var o="string"==typeof t?e.processor._map[t]:t;return e.queue.loadResource(r,o)},unload:function(r){return e.queue.unloadResource(r)},save:function(r,o){e.host.state[r.root+r.name]=2,delete r.promise,t[r.root+r.name]=o},get:function(e){return t[e.root+e.name]},remove:function(r){delete e.host.state[r.root+r.name],delete t[r.root+r.name]}},e.config=new e.ResourceConfig,e.queue=new e.ResourceLoader;var o=function(e){function r(t,o,n){var i=e.call(this)||this;return i.__resource_manager_error__=!0,i.name=t.toString(),i.message=r.errorMessage[t].replace("{0}",o).replace("{1}",n),i}return __extends(r,e),r.errorMessage={1001:"文件加载失败:{0}",1002:"ResourceManager 初始化失败:配置文件加载失败",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:'RES加载了不存在或空的资源组:"{0}"',2006:"资源配置文件中无法找到特定的资源:{0}"},r}(Error);e.ResourceManagerError=o,__reflect(o.prototype,"RES.ResourceManagerError")}(RES||(RES={}));var RES;!function(e){var r;!function(r){function t(e){return r._map[e.type]}function o(e,t){r._map[e]=t}function n(r,t){var o=this;return new Promise(function(n,i){var a=function(){var e=r.data?r.data:r.response;n(e)},s=function(){var r=new e.ResourceManagerError(1001,t.url);i(r)};r.addEventListener(egret.Event.COMPLETE,a,o),r.addEventListener(egret.IOErrorEvent.IO_ERROR,s,o)})}function i(e,r){if(-1!=r.indexOf("://"))return r;e=e.split("\\").join("/");var t=e.match(/#.*|\?.*/),o="";t&&(o=t[0]);var n=e.lastIndexOf("/");return e=-1!=n?e.substring(0,n+1)+r:r,e+o}function a(e){return{name:e.name+"_alpha",url:e.etc1_alpha_url,type:"ktx",root:e.root}}r.isSupport=t,r.map=o,r.getRelativePath=i,r.ImageProcessor={onLoadStart:function(r,t){var o=new egret.ImageLoader;return o.load(e.getVirtualUrl(t.root+t.url)),n(o,t).then(function(e){var o=new egret.Texture;o._setBitmapData(e);var n=r.resourceConfig.getResource(t.name);if(n&&n.scale9grid){var i=n.scale9grid.split(",");o.scale9Grid=new egret.Rectangle(parseInt(i[0]),parseInt(i[1]),parseInt(i[2]),parseInt(i[3]))}return o})},onRemoveStart:function(e,r){var t=e.get(r);t.dispose()}},r.KTXTextureProcessor={onLoadStart:function(e,r){return e.load(r,"bin").then(function(t){if(!t)return console.error("ktx:"+r.root+r.url+" is null"),null;var o=new egret.KTXContainer(t,1);if(o.isInvalid)return console.error("ktx:"+r.root+r.url+" is invalid"),null;var n=new egret.BitmapData(t);n.debugCompressedTextureURL=r.root+r.url,n.format="ktx",o.uploadLevels(n,!1);var i=new egret.Texture;i._setBitmapData(n);var a=e.resourceConfig.getResource(r.name);if(a&&a.scale9grid){var s=a.scale9grid.split(",");i.scale9Grid=new egret.Rectangle(parseInt(s[0]),parseInt(s[1]),parseInt(s[2]),parseInt(s[3]))}return e.save(r,i),i},function(t){throw e.remove(r),t})},onRemoveStart:function(e,r){var t=e.get(r);t&&t.dispose()}},r.makeEtc1SeperatedAlphaResourceInfo=a,r.ETC1KTXProcessor={onLoadStart:function(e,r){return e.load(r,"ktx").then(function(t){if(!t)return null;if(r.etc1_alpha_url){var o=a(r);return e.load(o,"ktx").then(function(r){return t&&t.$bitmapData&&r.$bitmapData?(t.$bitmapData.etcAlphaMask=r.$bitmapData,e.save(o,r)):e.remove(o),t},function(r){throw e.remove(o),r})}return t},function(t){throw e.remove(r),t})},onRemoveStart:function(e,r){var t=e.get(r);if(t&&t.dispose(),r.etc1_alpha_url){var o=a(r),n=e.get(o);n&&n.dispose(),e.unload(o)}}},r.BinaryProcessor={onLoadStart:function(r,t){var o=new egret.HttpRequest;return o.responseType=egret.HttpResponseType.ARRAY_BUFFER,o.open(e.getVirtualUrl(t.root+t.url),"get"),o.send(),n(o,t)},onRemoveStart:function(e,r){}},r.TextProcessor={onLoadStart:function(r,t){var o=new egret.HttpRequest;return o.responseType=egret.HttpResponseType.TEXT,o.open(e.getVirtualUrl(t.root+t.url),"get"),o.send(),n(o,t)},onRemoveStart:function(e,r){return!0}},r.JsonProcessor={onLoadStart:function(e,r){return e.load(r,"text").then(function(e){var r=JSON.parse(e);return r})},onRemoveStart:function(e,r){}},r.XMLProcessor={onLoadStart:function(e,r){return e.load(r,"text").then(function(e){var r=egret.XML.parse(e);return r})},onRemoveStart:function(e,r){return!0}},r.CommonJSProcessor={onLoadStart:function(r,t){return r.load(t,"text").then(function(r){var o=new Function("require","exports",r),n=function(){},i={};try{o(n,i)}catch(a){throw new e.ResourceManagerError(2003,t.name,a.message)}return i})},onRemoveStart:function(e,r){}},r.SheetProcessor={onLoadStart:function(r,t){return r.load(t,"json").then(function(o){var n=r.resourceConfig.getResource(e.nameSelector(o.file));if(!n){var a=i(t.url,o.file);n={name:a,url:a,type:"image",root:t.root}}return r.load(n).then(function(e){if(!e)return null;var t=o.frames,i=new egret.SpriteSheet(e);i.$resourceInfo=n;for(var a in t){var s=t[a],u=i.createTexture(a,s.x,s.y,s.w,s.h,s.offX,s.offY,s.sourceW,s.sourceH);if(s.scale9grid){var c=s.scale9grid,l=c.split(",");u.scale9Grid=new egret.Rectangle(parseInt(l[0]),parseInt(l[1]),parseInt(l[2]),parseInt(l[3]))}}return r.save(n,e),i},function(e){throw r.remove(n),e})})},getData:function(e,r,t,o){var n=e.get(r);return n?n.getTexture(o):null},onRemoveStart:function(e,r){var t=e.get(r),o=t.$resourceInfo;t.dispose(),e.unload(o)}};var s=function(e,r){var t="",o=r.split("\n"),n=o[2],i=n.indexOf('file="');-1!=i&&(n=n.substring(i+6),i=n.indexOf('"'),t=n.substring(0,i)),e=e.split("\\").join("/");var i=e.lastIndexOf("/");return e=-1!=i?e.substring(0,i+1)+t:t};r.FontProcessor={onLoadStart:function(r,t){return r.load(t,"text").then(function(o){var n;try{n=JSON.parse(o)}catch(a){n=o}var u;u="string"==typeof n?s(t.url,n):i(t.url,n.file);var c=r.resourceConfig.getResource(e.nameSelector(u));return c||(c={name:u,url:u,type:"image",root:t.root}),r.load(c).then(function(e){var t=new egret.BitmapFont(e,n);return t.$resourceInfo=c,r.save(c,e),t},function(e){throw r.remove(c),e})})},onRemoveStart:function(e,r){var t=e.get(r),o=t.$resourceInfo;e.unload(o)}},r.SoundProcessor={onLoadStart:function(r,t){var o=new egret.Sound;return o.load(e.getVirtualUrl(t.root+t.url)),n(o,t).then(function(){return o})},onRemoveStart:function(e,r){var t=e.get(r);t.close()}},r.MovieClipProcessor={onLoadStart:function(r,t){var o,n;return r.load(t,"json").then(function(i){o=i;var a=t.name,s=a.substring(0,a.lastIndexOf("."))+".png";if(n=r.resourceConfig.getResource(s),!n)throw new e.ResourceManagerError(1001,s);return r.load(n)}).then(function(e){r.save(n,e);var t=e,i=new egret.MovieClipDataFactory(o,t);return i})},onRemoveStart:function(e,r){var t=e.get(r);t.clearCache(),t.$spriteSheet.dispose();var o=r.name,n=o.substring(0,o.lastIndexOf("."))+".png",i=e.resourceConfig.getResource(n);i&&e.unload(i)}},r.MergeJSONProcessor={onLoadStart:function(r,t){return r.load(t,"json").then(function(r){for(var o in r)e.config.addSubkey(o,t.name);return r})},getData:function(e,r,t,o){var n=e.get(r);return n?n[o]:(console.error("missing resource :"+r.name),null)},onRemoveStart:function(e,r){}},r.LegacyResourceConfigProcessor={onLoadStart:function(r,t){return r.load(t,"json").then(function(o){var n=e.config.config,i=t.root,a=n.fileSystem;a||(a={fsData:{},getFile:function(e){return p[e]},addFile:function(e){e.type||(e.type=""),void 0==i&&(e.root=""),p[e.name]=e},profile:function(){console.log(p)},removeFile:function(e){delete p[e]}},n.fileSystem=a);for(var s=n.groups,u=0,c=o.groups;uc;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,e._tint=0,e.$tintRGB=0,e.$sortDirty=!1,e._zIndex=0,e.$lastSortedIndex=0,e.sortableChildren=!1,t.nativeRender&&e.createNativeDisplayObject(),e.tint=16777215,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)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)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+r.$rotation)/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){t=isNaN(t)?0/0:t,this.$explicitWidth!=t&&(this.$explicitWidth=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){t=isNaN(t)?0/0:t,this.$explicitHeight!=t&&(this.$explicitHeight=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;if(i.$anchorOffsetX!=e)if(i.$anchorOffsetX=e,t.nativeRender)i.$nativeDisplayObject.setAnchorOffsetX(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,"anchorOffsetY",{get:function(){return this.$anchorOffsetY},set:function(t){this.$setAnchorOffsetY(t)},enumerable:!0,configurable:!0}),r.prototype.$setAnchorOffsetY=function(e){var i=this;if(i.$anchorOffsetY!=e)if(i.$anchorOffsetY=e,t.nativeRender)i.$nativeDisplayObject.setAnchorOffsetY(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,"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)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)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;if(!e&&!i.$scrollRect)return void i.$updateRenderMode();if(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)),!t.nativeRender){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,"blendMode",{get:function(){return t.sys.numberToBlendMode(this.$blendMode)},set:function(e){var i=this,r=t.sys.blendModeToNumber(e);if(i.$blendMode!=r)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(e,i){var r=this;if(!t.nativeRender&&!r.$renderNode||!r.$visible||0==r.$scaleX||0==r.$scaleY)return null;var n=r.$getInvertedConcatenatedMatrix();if(0==n.a&&0==n.b&&0==n.c&&0==n.d)return null;var a=r.$getContentBounds(),o=n.a*e+n.c*i+n.tx,s=n.b*e+n.d*i+n.ty;if(a.contains(o,s)){if(!r.$children){var h=r.$scrollRect?r.$scrollRect:r.$maskRect;if(h&&!h.contains(o,s))return null;if(r.$mask&&!r.$mask.$hitTest(e,i))return null}return r}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},Object.defineProperty(r.prototype,"tint",{get:function(){return this._tint},set:function(t){this._tint=t,this.$tintRGB=(t>>16)+(65280&t)+((255&t)<<16)},enumerable:!0,configurable:!0}),r.prototype.sortChildren=function(){this.$sortDirty=!1},Object.defineProperty(r.prototype,"zIndex",{get:function(){return this._zIndex},set:function(t){this._zIndex=t,this.parent&&(this.parent.$sortDirty=!0)},enumerable:!0,configurable:!0}),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.$ktxData=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.$ktxData=null,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)},Object.defineProperty(i.prototype,"ktxData",{get:function(){return this.$ktxData},set:function(t){this._setKtxData(t)},enumerable:!0,configurable:!0}),i.prototype._setKtxData=function(e){if(!e)return void t.error("ktx data is null");if(e!=this.$ktxData){var i=new t.KTXContainer(e,1);if(i.isInvalid)return void t.error("ktx data is invalid");this.$ktxData=e;var r=new t.BitmapData(e);r.format="ktx",i.uploadLevels(r,!1),this._setBitmapData(r)}},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)},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,a=t.hasOwnProperty("eventPool");if(a&&(n=t.eventPool),n||(n=t.eventPool=[]),n.length){var o=n.pop();return o.$type=e,o.$bubbles=!!i,o.$cancelable=!!r,o.$isDefaultPrevented=!1,o.$isPropagationStopped=!1,o.$isPropagationImmediateStopped=!1,o.$eventPhase=2,o}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.setChildrenSortMode=function(e){t.nativeRender&&this.$nativeDisplayObject.setChildrenSortMode&&this.$nativeDisplayObject.setChildrenSortMode(e) +},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),t.nativeRender&&a.$nativeDisplayObject.addChildAt(e.$nativeDisplayObject.id,r);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&&(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.prototype._sortChildrenFunc=function(t,e){return t.zIndex===e.zIndex?t.$lastSortedIndex-e.$lastSortedIndex:t.zIndex-e.zIndex},i.prototype.sortChildren=function(){e.prototype.sortChildren.call(this),this.$sortDirty=!1;for(var t=!1,i=this.$children,r=null,n=0,a=i.length;a>n;++n)r=i[n],r.$lastSortedIndex=n,t||0===r.zIndex||(t=!0);t&&i.length>1&&i.sort(this._sortChildrenFunc)},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.setTexture(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){var i=this;if(e==i.$fillMode)return!1;if(i.$fillMode=e,t.nativeRender)i.$nativeDisplayObject.setBitmapFillMode(i.$fillMode);else{i.$renderDirty=!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())}return!0},Object.defineProperty(i.prototype,"smoothing",{get:function(){return this.$smoothing},set:function(e){var i=this;if(e!=this.$smoothing&&(this.$smoothing=e,this.$renderNode.smoothing=e,!t.nativeRender)){var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},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 m=l+d*$*i,b=u-p*$*r;if(this.cubicCurveTo(y,v,m,b,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(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 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.ChildrenSortMode={DEFAULT:"default",INCREASE_Y:"increaseY",DECREASE_Y:"decreaseY"}}(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(e){if(e&&!e[t.engine_default_empty_texture]){var i=e[t.glContext];i&&i.deleteTexture(e)}},e.premultiplyTint=function(t,e){if(1===e)return(255*e<<24)+t;if(0===e)return 0;var i=t>>16&255,r=t>>8&255,n=255&t;return i=i*e+.5|0,r=r*e+.5|0,n=n*e+.5|0,(255*e<<24)+(i<<16)+(r<<8)+n},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(){function t(){}return t}();t.CompressedTextureData=e,__reflect(e.prototype,"egret.CompressedTextureData"),t.etc_alpha_mask="etc_alpha_mask",t.engine_default_empty_texture="engine_default_empty_texture",t.is_compressed_texture="is_compressed_texture",t.glContext="glContext",t.UNPACK_PREMULTIPLY_ALPHA_WEBGL="UNPACK_PREMULTIPLY_ALPHA_WEBGL";var i=function(e){function i(i){var r=e.call(this)||this;if(r.format="image",r.$deleteSource=!0,r.compressedTextureData=[],r.debugCompressedTextureURL="",r.etcAlphaMask=null,t.nativeRender){var n=new egret_native.NativeBitmapData;n.$init(),r.$nativeBitmapData=n}return r.source=i,r.source=i,r.source&&(r.width=+i.width,r.height=+i.height),r}return __extends(i,e),Object.defineProperty(i.prototype,"source",{get:function(){return this.$source},set:function(e){this.$source=e,t.nativeRender&&egret_native.NativeDisplayObject.setSourceToNativeBitmapData(this.$nativeBitmapData,e)},enumerable:!0,configurable:!0}),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&&this.source.src&&(this.source.src=""),this.source=null,this.clearCompressedTextureData(),this.debugCompressedTextureURL="",this.etcAlphaMask=null,t.nativeRender&&egret_native.NativeDisplayObject.disposeNativeBitmapData(this.$nativeBitmapData),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,m=0;u>d&&(m=u,u=d,d=m),g>y&&(m=g,g=y,y=m),t.x=Math.floor(g>u?u:g),t.width=Math.ceil((d>y?d:y)-t.x),p>f&&(m=p,p=f,f=m),$>v&&(m=$,$=v,v=m),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[1051]="runtime only support webgl render mode",e[1052]="network request timeout{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[3200]="getResByUrl must be called after loadConfig",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!",e[4500]="The platform does not support {0} adapter mode and has been automatically replaced with {1} mode, please modify your code adapter logic"}(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[1051]="runtime 只支持 webgl 渲染模式",e[1052]="网络请求超时:{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[3200]="getResByUrl 必须在 loadConfig 之后调用",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!",e[4500]="该平台不支持 {0} 适配模式,已经自动替换为 {1} 模式,请修改您的代码适配逻辑" +}(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=5;if(r>e){t.nativeRender=!1;var n="需要升级微端版本到 0.1.14 才可以开启原生渲染加速";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(){function e(t,i,r,n){this.arrayBuffer=t,this.isInvalid=!1;var a=new Uint8Array(this.arrayBuffer,0,12);if(171!==a[0]||75!==a[1]||84!==a[2]||88!==a[3]||32!==a[4]||49!==a[5]||49!==a[6]||187!==a[7]||13!==a[8]||10!==a[9]||26!==a[10]||10!==a[11])return this.isInvalid=!0,void console.error("texture missing KTX identifier");var o=Uint32Array.BYTES_PER_ELEMENT,s=new DataView(this.arrayBuffer,12,13*o),h=s.getUint32(0,!0),c=67305985===h;return this.glType=s.getUint32(1*o,c),this.glTypeSize=s.getUint32(2*o,c),this.glFormat=s.getUint32(3*o,c),this.glInternalFormat=s.getUint32(4*o,c),this.glBaseInternalFormat=s.getUint32(5*o,c),this.pixelWidth=s.getUint32(6*o,c),this.pixelHeight=s.getUint32(7*o,c),this.pixelDepth=s.getUint32(8*o,c),this.numberOfArrayElements=s.getUint32(9*o,c),this.numberOfFaces=s.getUint32(10*o,c),this.numberOfMipmapLevels=s.getUint32(11*o,c),this.bytesOfKeyValueData=s.getUint32(12*o,c),0!==this.glType?void console.error("only compressed formats currently supported"):(this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels),0===this.pixelHeight||0!==this.pixelDepth?void console.error("only 2D textures currently supported"):0!==this.numberOfArrayElements?void console.error("texture arrays not currently supported"):this.numberOfFaces!==i?void console.error("number of faces expected"+i+", but found "+this.numberOfFaces):void(this.loadType=e.COMPRESSED_2D))}return e.prototype.uploadLevels=function(t,i){this.loadType===e.COMPRESSED_2D&&this._upload2DCompressedLevels(t,i)},e.prototype._upload2DCompressedLevels=function(i,r){i.clearCompressedTextureData();for(var n=i.compressedTextureData,a=e.HEADER_LEN+this.bytesOfKeyValueData,o=this.pixelWidth,s=this.pixelHeight,h=r?this.numberOfMipmapLevels:1,c=0;h>c;c++){var l=new Int32Array(this.arrayBuffer,a,1)[0];a+=4;for(var u=[],p=0;pu?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 t.Capabilities.runtimeType!=t.RuntimeType.WXGAME&&(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){function e(t,e){return console.error("empty sys.mainCanvas = "+t+", "+e),null}function i(t,e){return console.error("empty sys.createCanvas = "+t+", "+e),null}function r(t,e,i,r){console.error("empty sys.resizeContext = "+t+", "+e+", "+i+", "+r)}function n(t){return console.error("empty sys.getContextWebGL = "+t),null}function a(t){return console.error("empty sys.getContext2d = "+t),null}function o(t,e){return console.error("empty sys.createTexture = "+e),null}function s(t,e,i,r){return console.error("empty sys._createTexture = "+e+", "+i+", "+r),null}function h(t,e,i){return console.error("empty sys.drawTextureElements = "+t+", "+e+", "+i),0}function c(t,e){return console.error("empty sys.measureTextWith = "+t+", "+e),0}function l(t,e,i,r){return console.error("empty sys.createCanvasRenderBufferSurface = "+e+", "+i),null}function u(t,e,i,r){console.error("empty sys.resizeContext = "+t+", "+e+", "+i+", "+r)}t.mainCanvas=e,t.createCanvas=i,t.resizeContext=r,t.getContextWebGL=n,t.getContext2d=a,t.createTexture=o,t._createTexture=s,t.drawTextureElements=h,t.measureTextWith=c,t.createCanvasRenderBufferSurface=l,t.resizeCanvasRenderBuffer=u}(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(i){for(var r=t.getTimer(),n=this.callBackList,a=this.thisObjectList,o=n.length,s=e.$requestRenderingFlag,h=t.getTimer(),c=t.lifecycle.contexts,l=0,u=c;ld;d++)n[d].call(a[d],h)&&(s=!0);var f=t.getTimer(),g=h-this.lastTimeStamp;if(this.lastTimeStamp=h,g>=this.frameDeltaTime||i)this.lastCount=this.frameInterval;else{if(this.lastCount-=1e3,this.lastCount>0)return void(s&&this.render(!1,this.costEnterFrame+f-r));this.lastCount+=this.frameInterval}this.render(!0,this.costEnterFrame+f-r);var $=t.getTimer();this.broadcastEnterFrame();var y=t.getTimer();this.costEnterFrame=y-$},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 m=p/l*v,b=d/u*v;e.drawImage(n,a,o,s,m*h,b*c,m*o,b*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 m=r.x-h,b=r.y-c,x=m/t.$TextureScaleFactor,T=b/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,C=S+T,F=C+D,P=v-T-D,M=R*t.$TextureScaleFactor,j=P*t.$TextureScaleFactor;if((x+R)*t.$TextureScaleFactor>p||(T+P)*t.$TextureScaleFactor>d)return void e.drawImage(n,a,o,s,h,c,p,d);var A=h,B=A+m,N=A+(p-M),k=p-m-M,L=c,I=L+b,U=L+d-j,H=d-b-j;T>0&&(x>0&&e.drawImage(O,S,x,T,A,L,m,b),_>0&&e.drawImage(w,S,_,T,B,L,k,b),R>0&&e.drawImage(E,S,R,T,N,L,M,b)),D>0&&(x>0&&e.drawImage(O,C,x,D,A,I,m,H),_>0&&e.drawImage(w,C,_,D,B,I,k,H),R>0&&e.drawImage(E,C,R,D,N,I,M,H)),P>0&&(x>0&&e.drawImage(O,F,x,P,A,U,m,j),_>0&&e.drawImage(w,F,_,P,B,U,k,j),R>0&&e.drawImage(E,F,R,P,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){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.height>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],m=r[15],b=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]=m*w+b*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,m=0,b=$-4*r,x=$+4*(r+1);y>$;$+=4,m+=4,x+=4,b+=4)0===d?(a[m+0]=0,a[m+1]=0,a[m+2]=0,a[m+3]=0):(a[m+0]=l/d,a[m+1]=u/d,a[m+2]=p/d,a[m+3]=d/s),f=t[x+3],g=t[b+3],f||0==f?g||0==g?(l+=t[x+0]*f-t[b+0]*g,u+=t[x+1]*f-t[b+1]*g,p+=t[x+2]*f-t[b+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[b+0]*g,u+=-t[b+1]*g,p+=-t[b+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,m=h-r*a,b=h+(r+1)*a;$>g;g+=a,v+=4,b+=a,m+=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[b+3],f=t[m+3],d||0==d?f||0==f?(c+=t[b+0]*d-t[m+0]*f,l+=t[b+1]*d-t[m+1]*f,u+=t[b+2]*d-t[m+2]*f,p+=d-f):(c+=t[b+0]*d,l+=t[b+1]*d,u+=t[b+2]*d,p+=d):(f||0==f)&&(c+=-t[m+0]*f,l+=-t[m+1]*f,u+=-t[m+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,m=0,b=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 C=0,F=S*e*4+4*R,P=0,M=0,j=t[F+0]/255,A=t[F+1]/255,B=t[F+2]/255,N=t[F+3]/255,k=0;2*O>=k;k+=2*O/D){g=Math.cos(k+C),$=Math.sin(k+C);for(var L=0;T>L;L++){v=L*w*g,m=L*E*$;var I=Math.round(R+v-b),U=Math.round(S+m-x),H=0;if(I>=e||0>I||0>U||U>=i)H=0;else{var X=U*e*4+4*I;H=t[X+3]/255}P+=(T-L)*H,M+=T-L}}N=Math.max(N,1e-4);var Y=P/M*c*y*(1-l)*Math.max(Math.min(p,u),1-N),W=(M-P)/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),K=Y/(W+N+Y),J=f(z,r[0],K),Q=f(V,r[1],K),Z=f(q,r[2],K),te=Math.min(N+Y+W,1); +d[F+0]=255*J,d[F+1]=255*Q,d[F+2]=255*Z,d[F+3]=255*te}_?t.set(d):n(t,d)}var $=["source-over","lighter","destination-out"],y="source-over",v="#000000",m={none:"butt",square:"square",round:"round"},b=[],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){b.length>6&&(b.length=6);for(var h=b.length,c=0;h>c;c++)b[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,m=p.height;if(0>=v||0>=m)return s;var b=this.createRenderBuffer(v-d,m-f,!0),T=b.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,b.surface.width,b.surface.height),D=0;l>D;D++){var O=h[D];if("colorTransform"==O.type)a(_.data,b.surface.width,b.surface.height,O.$matrix);else if("blur"==O.type)o(_.data,b.surface.width,b.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,b.surface.width,b.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,b.surface.width,b.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(b.surface,i+d,r+f),u&&(e.globalCompositeOperation=y)}return x.push(b),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;if(c){var u=c.$getRenderNode();if((!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),p.prepend(1,0,0,1,r,n),i.transform(p.a,p.b,p.c,p.d,p.tx,p.ty);var d=this.drawDisplayObject(c,i,0,0);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,m=f.width,x=f.height;if(0>=m||0>=x)return o;var T=this.createRenderBuffer(m,x),_=T.context;if(!_)return o+=this.drawDisplayObject(e,i,r,n);if(o+=this.drawDisplayObject(e,_,-g,-v),c){var u=c.$getRenderNode(),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(m,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),b.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)),b.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],m=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,m,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),b.push(E)}else for(;s>h;)if(f++,t.rotated){var v=o[h++],m=o[h++],T=o[h++],x=o[h++],C=o[h++],F=o[h++],w=o[h++],O=o[h++];e.save(),e.transform(0,-1,1,0,0,O),e.drawImage(i.source,v,m,x,T,C+e.$offsetX,F+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=m[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():b.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.MYGAME="mygame",t.WXGAME="wxgame",t.BAIDUGAME="baidugame",t.QGAME="qgame",t.OPPOGAME="oppogame",t.QQGAME="qqgame",t.VIVOGAME="vivogame"}(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.31",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;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){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(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){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(e){var i=this;if(e!=i.$smoothing&&(i.$smoothing=e,!t.nativeRender)){var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},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)return void(t.nativeRender&&e.$font&&(e.$nativeDisplayObject.setDataToBitmapNode(e.$nativeDisplayObject.id,e.$font.$texture,[]),e.$nativeDisplayObject.setWidth(0),e.$nativeDisplayObject.setHeight(0)));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 m=y[v];if(u&&v>0&&$+m>f)break;var b=r[v],x=b.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=b.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)}$+=m+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 m&&n.length>0&&f>m?!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,m=r.$textFieldHeight,b=r.$font,x=b._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 C=0;S>C;C++){s||(l+=p);var F=R.charAt(C),P=void 0,M=void 0,j=0,A=0,B=b.getTexture(F);if(B)P=B.$getTextureWidth(),M=B.$getTextureHeight(),j=B.$offsetX,A=B.$offsetY;else{if(" "!=F){t.$warn(1046,F),s&&(s=!1);continue}P=T,M=x}if(s&&(s=!1),w&&(w=!1),y&&C>0&&l+P>v){if(!e(R.substring(0,C)))break;R=R.substring(C),S=R.length,C=0,l=C==S-1?P:b.getConfig(F,"xadvance")||P,c=M}else l+=C==S-1?P:b.getConfig(F,"xadvance")||P,c=Math.max(M,c)}if(m&&E>0&&f>m)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))),m>f&&(N=r.$verticalAlign,N==t.VerticalAlign.BOTTOM?this.$textStartY=m-f:N==t.VerticalAlign.MIDDLE&&(this.$textStartY=Math.floor((m-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&&(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){e=Math.max(e,1),e!=this.$TextField[28]&&(this.$TextField[28]=e,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?!1:(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&&(this.$TextField[31]=e,this.$invalidateTextField(),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&&(this.$TextField[32]=e,this.$invalidateTextField(),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&&(this.$TextField[33]=e,this.$invalidateTextField(),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&&(this.$TextField[34]=e,this.$invalidateTextField(),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 m=!0;if(""==$[y])y==v-1&&(m=!1);else{var b=e($[y],r,f.style);if(isNaN(a))h+=b,c+=$[y].length,o.elements.push({width:b,text:$[y],style:f.style}),y==v-1&&(m=!1);else if(a>=h+b)o.elements.push({width:b,text:$[y],style:f.style}),h+=b,c+=$[y].length,y==v-1&&(m=!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),C=D[x+1].charCodeAt(0);if(S>=55296&&56319>=S&&56320==(64512&C)){var F=D[x]+D[x+1];E=2,R=!0,b=e(F,r,f.style)}else b=e(D[x],r,f.style)}else b=e(D[x],r,f.style);if(0!=h&&h+b>a&&h+x!=0)break;if(T+b>a)for(var P=D[x].match(/./g),M=0,j=P.length;j>M;M++){var E=P[M].length,A=!1;if(1==E&&j-1>M){var S=P[M].charCodeAt(0),C=P[M+1].charCodeAt(0);if(S>=55296&&56319>=S&&56320==(64512&C)){var F=P[M]+P[M+1];E=2,A=!0,b=e(F,r,f.style)}else b=e(P[M],r,f.style)}else b=e(P[M],r,f.style);if(M>0&&h+b>a)break;w+=E,T+=b,h+=b,c+=w,A&&M++}else w+=E,T+=b,h+=b,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--,m=!1)}}m&&(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,m=$.elements.length;m>v;v++){var b=$.elements[v],x=b.style.size||i[0];e.drawText(p,s+(y-x)/2,b.text,b.style),b.style.underline&&d.push(p,s+y/2,b.width,b.style.textColor),p+=b.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;i=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){function e(t,e,i){var r=t.prototype;Object.defineProperty(r,"__class__",{value:e,enumerable:!1,writable:!0});var n=[e];i&&(n=n.concat(i));var a=r.__types__;if(r.__types__)for(var o=a.length,s=0;o>s;s++){var h=a[s];-1==n.indexOf(h)&&n.push(h)}Object.defineProperty(r,"__types__",{value:n,enumerable:!1,writable:!0})}t.registerClass=e}(egret||(egret={}));var egret;!function(t){t.BitmapFillMode={REPEAT:"repeat",SCALE:"scale",CLIP:"clip"}}(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.convertStringToHashCode=function(t){if(0===t.length)return 0;for(var e=0,i=0,r=t.length;r>i;++i){var n=t.charCodeAt(i);e=(e<<5)-e+n,e|=0}return e},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(0==this.repeatCount||this._currentCount<=this.repeatCount)&&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={})); \ No newline at end of file diff --git a/bin-release/web/191201225322/js/egret.web.min_d1451e99.js b/bin-release/web/191201225322/js/egret.web.min_d1451e99.js new file mode 100644 index 0000000..f6c2006 --- /dev/null +++ b/bin-release/web/191201225322/js/egret.web.min_d1451e99.js @@ -0,0 +1,5 @@ +var __reflect=this&&this.__reflect||function(e,t,r){e.__class__=t,r?r.push(t):r=[t],e.__types__=e.__types__?r.concat(e.__types__):r},__extends=this&&this.__extends||function(e,t){function r(){this.constructor=e}for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);r.prototype=t.prototype,e.prototype=new r},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"])}(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"])}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){function r(e){if(window.location){var t=location.search;if(""==t)return"";t=t.slice(1);for(var r=t.split("&"),i=r.length,n=0;i>n;n++){var a=r[n],o=a.split("=");if(o[0]==e)return o[1]}}return""}t.getOption=r,e.getOption=r}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(r){function i(t){var i=r.call(this)||this;return i.$startTime=0,i.audio=null,i.isStopped=!1,i.canPlay=function(){i.audio.removeEventListener("canplay",i.canPlay);try{i.audio.currentTime=i.$startTime}catch(e){}finally{i.audio.play()}},i.onPlayEnd=function(){return 1==i.$loops?(i.stop(),void i.dispatchEventWith(e.Event.SOUND_COMPLETE)):(i.$loops>0&&i.$loops--,void i.$play())},i._volume=1,t.addEventListener("ended",i.onPlayEnd),i.audio=t,i}return __extends(i,r),i.prototype.$play=function(){if(this.isStopped)return void e.$error(1036);try{this.audio.volume=this._volume,this.audio.currentTime=this.$startTime}catch(t){return void this.audio.addEventListener("canplay",this.canPlay)}this.audio.play()},i.prototype.stop=function(){if(this.audio){this.isStopped||e.sys.$popSoundChannel(this),this.isStopped=!0;var r=this.audio;r.removeEventListener("ended",this.onPlayEnd),r.removeEventListener("canplay",this.canPlay),r.volume=0,this._volume=0,this.audio=null;var i=this.$url;window.setTimeout(function(){r.pause(),t.HtmlSound.$recycle(i,r)},200)}},Object.defineProperty(i.prototype,"volume",{get:function(){return this._volume},set:function(t){return this.isStopped?void e.$error(1036):(this._volume=t,void(this.audio&&(this.audio.volume=t)))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"position",{get:function(){return this.audio?this.audio.currentTime:0},enumerable:!0,configurable:!0}),i}(e.EventDispatcher);t.HtmlSoundChannel=r,__reflect(r.prototype,"egret.web.HtmlSoundChannel",["egret.SoundChannel","egret.IEventDispatcher"])}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(){function t(){}return t.decodeAudios=function(){if(!(t.decodeArr.length<=0||t.isDecoding)){t.isDecoding=!0;var r=t.decodeArr.shift();t.ctx.decodeAudioData(r.buffer,function(e){r.self.audioBuffer=e,r.success&&r.success(),t.isDecoding=!1,t.decodeAudios()},function(){e.log("sound decode error"),r.fail&&r.fail(),t.isDecoding=!1,t.decodeAudios()})}},t.decodeArr=[],t.isDecoding=!1,t}();t.WebAudioDecode=r,__reflect(r.prototype,"egret.web.WebAudioDecode");var i=function(i){function n(){var e=i.call(this)||this;return e.loaded=!1,e}return __extends(n,i),Object.defineProperty(n.prototype,"length",{get:function(){if(this.audioBuffer)return this.audioBuffer.duration;throw new Error("sound not loaded!")},enumerable:!0,configurable:!0}),n.prototype.load=function(t){function i(){a.loaded=!0,a.dispatchEventWith(e.Event.COMPLETE)}function n(){a.dispatchEventWith(e.IOErrorEvent.IO_ERROR)}var a=this;this.url=t;var o=new XMLHttpRequest;o.open("GET",t,!0),o.responseType="arraybuffer",o.addEventListener("load",function(){var t=o.status>=400;t?a.dispatchEventWith(e.IOErrorEvent.IO_ERROR):(r.decodeArr.push({buffer:o.response,success:i,fail:n,self:a,url:a.url}),r.decodeAudios())}),o.addEventListener("error",function(){a.dispatchEventWith(e.IOErrorEvent.IO_ERROR)}),o.send()},n.prototype.play=function(r,i){r=+r||0,i=+i||0;var n=new t.WebAudioSoundChannel;return n.$url=this.url,n.$loops=i,n.$audioBuffer=this.audioBuffer,n.$startTime=r,n.$play(),e.sys.$pushSoundChannel(n),n},n.prototype.close=function(){},n.MUSIC="music",n.EFFECT="effect",n}(e.EventDispatcher);t.WebAudioSound=i,__reflect(i.prototype,"egret.web.WebAudioSound",["egret.Sound"])}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(r){function i(){var i=r.call(this)||this;return i.$startTime=0,i.bufferSource=null,i.context=t.WebAudioDecode.ctx,i.isStopped=!1,i._currentTime=0,i._volume=1,i.onPlayEnd=function(){return 1==i.$loops?(i.stop(),void i.dispatchEventWith(e.Event.SOUND_COMPLETE)):(i.$loops>0&&i.$loops--,void i.$play())},i._startTime=0,i.context.createGain?i.gain=i.context.createGain():i.gain=i.context.createGainNode(),i}return __extends(i,r),i.prototype.$play=function(){if(this.isStopped)return void e.$error(1036);this.bufferSource&&(this.bufferSource.onended=null,this.bufferSource=null);var t=this.context,r=this.gain,i=t.createBufferSource();this.bufferSource=i,i.buffer=this.$audioBuffer,i.connect(r),r.connect(t.destination),i.onended=this.onPlayEnd,this._startTime=Date.now(),this.gain.gain.value=this._volume,i.start(0,this.$startTime),this._currentTime=0},i.prototype.stop=function(){if(this.bufferSource){var t=this.bufferSource;t.stop?t.stop(0):t.noteOff(0),t.onended=null,t.disconnect(),this.bufferSource=null,this.$audioBuffer=null}this.isStopped||e.sys.$popSoundChannel(this),this.isStopped=!0},Object.defineProperty(i.prototype,"volume",{get:function(){return this._volume},set:function(t){return this.isStopped?void e.$error(1036):(this._volume=t,void(this.gain.gain.value=t))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"position",{get:function(){return this.bufferSource?(Date.now()-this._startTime)/1e3+this.$startTime:0},enumerable:!0,configurable:!0}),i}(e.EventDispatcher);t.WebAudioSoundChannel=r,__reflect(r.prototype,"egret.web.WebAudioSoundChannel",["egret.SoundChannel","egret.IEventDispatcher"])}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(t){function r(r,i){void 0===i&&(i=!0);var n=t.call(this)||this;return n.loaded=!1,n.closed=!1,n.heightSet=0/0,n.widthSet=0/0,n.waiting=!1,n.userPause=!1,n.userPlay=!1,n.isPlayed=!1,n.screenChanged=function(t){var r=document.fullscreenEnabled||document.webkitIsFullScreen;r||(n.checkFullScreen(!1),e.Capabilities.isMobile||(n._fullscreen=r))},n._fullscreen=!0,n.onVideoLoaded=function(){n.video.removeEventListener("canplay",n.onVideoLoaded);var t=n.video;n.loaded=!0,n.posterData&&(n.posterData.width=n.getPlayWidth(),n.posterData.height=n.getPlayHeight()),t.width=t.videoWidth,t.height=t.videoHeight,window.setTimeout(function(){n.dispatchEventWith(e.Event.COMPLETE)},200)},n.$renderNode=new e.sys.BitmapNode,n.src=r,n.once(e.Event.ADDED_TO_STAGE,n.loadPoster,n),r&&n.load(),n}return __extends(r,t),r.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(1)},r.prototype.load=function(t,r){var i=this;if(void 0===r&&(r=!0),t=t||this.src,this.src=t,!this.video||this.video.src!=t){var n;!this.video||e.Capabilities.isMobile?(n=document.createElement("video"),this.video=n,n.controls=null):n=this.video,n.src=t,n.setAttribute("autoplay","autoplay"),n.setAttribute("webkit-playsinline","true"),n.addEventListener("canplay",this.onVideoLoaded),n.addEventListener("error",function(){return i.onVideoError()}),n.addEventListener("ended",function(){return i.onVideoEnded()});var a=!1;n.addEventListener("canplay",function(){i.waiting=!1,a?i.userPause?i.pause():i.userPlay&&i.play():(a=!0,n.pause())}),n.addEventListener("waiting",function(){i.waiting=!0}),n.load(),this.videoPlay(),n.style.position="absolute",n.style.top="0px",n.style.zIndex="-88888",n.style.left="0px",n.height=1,n.width=1}},r.prototype.play=function(t,r){var i=this;if(void 0===r&&(r=!1),0==this.loaded)return this.load(this.src),void this.once(e.Event.COMPLETE,function(e){return i.play(t,r)},this);this.isPlayed=!0;var n=this.video;void 0!=t&&(n.currentTime=+t||0),n.loop=!!r,e.Capabilities.isMobile?n.style.zIndex="-88888":n.style.zIndex="9999",n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.height=n.videoHeight,n.width=n.videoWidth,"Windows PC"!=e.Capabilities.os&&"Mac OS"!=e.Capabilities.os&&window.setTimeout(function(){n.width=0},1e3),this.checkFullScreen(this._fullscreen)},r.prototype.videoPlay=function(){return this.userPause=!1,this.waiting?void(this.userPlay=!0):(this.userPlay=!1,void this.video.play())},r.prototype.checkFullScreen=function(t){var r=this.video;if(t)null==r.parentElement&&(r.removeAttribute("webkit-playsinline"),document.body.appendChild(r)),e.stopTick(this.markDirty,this),this.goFullscreen();else if(null!=r.parentElement&&r.parentElement.removeChild(r),r.setAttribute("webkit-playsinline","true"),this.setFullScreenMonitor(!1),e.startTick(this.markDirty,this),e.Capabilities.isMobile)return this.video.currentTime=0,void this.onVideoEnded();this.videoPlay()},r.prototype.goFullscreen=function(){var t,r=this.video;return t=e.web.getPrefixStyleName("requestFullscreen",r),r[t]||(t=e.web.getPrefixStyleName("requestFullScreen",r),r[t])?(r.removeAttribute("webkit-playsinline"),r[t](),this.setFullScreenMonitor(!0),!0):!0},r.prototype.setFullScreenMonitor=function(e){var t=this.video;e?(t.addEventListener("mozfullscreenchange",this.screenChanged),t.addEventListener("webkitfullscreenchange",this.screenChanged),t.addEventListener("mozfullscreenerror",this.screenError),t.addEventListener("webkitfullscreenerror",this.screenError)):(t.removeEventListener("mozfullscreenchange",this.screenChanged),t.removeEventListener("webkitfullscreenchange",this.screenChanged),t.removeEventListener("mozfullscreenerror",this.screenError),t.removeEventListener("webkitfullscreenerror",this.screenError))},r.prototype.screenError=function(){e.$error(3014)},r.prototype.exitFullscreen=function(){document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.oCancelFullScreen?document.oCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()},r.prototype.onVideoEnded=function(){this.pause(),this.isPlayed=!1,this.dispatchEventWith(e.Event.ENDED)},r.prototype.onVideoError=function(){this.dispatchEventWith(e.IOErrorEvent.IO_ERROR)},r.prototype.close=function(){var e=this;this.closed=!0,this.video.removeEventListener("canplay",this.onVideoLoaded),this.video.removeEventListener("error",function(){return e.onVideoError()}),this.video.removeEventListener("ended",function(){return e.onVideoEnded()}),this.pause(),0==this.loaded&&this.video&&(this.video.src=""),this.video&&this.video.parentElement&&(this.video.parentElement.removeChild(this.video),this.video=null),this.loaded=!1},r.prototype.pause=function(){return this.userPlay=!1,this.waiting?void(this.userPause=!0):(this.userPause=!1,this.video.pause(),void e.stopTick(this.markDirty,this))},Object.defineProperty(r.prototype,"volume",{get:function(){return this.video?this.video.volume:1},set:function(e){this.video&&(this.video.volume=e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"position",{get:function(){return this.video?this.video.currentTime:0},set:function(e){this.video&&(this.video.currentTime=e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"fullscreen",{get:function(){return this._fullscreen},set:function(t){e.Capabilities.isMobile||(this._fullscreen=!!t,this.video&&0==this.video.paused&&this.checkFullScreen(this._fullscreen))},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"bitmapData",{get:function(){return this.video&&this.loaded?(this._bitmapData||(this.video.width=this.video.videoWidth,this.video.height=this.video.videoHeight,this._bitmapData=new e.BitmapData(this.video),this._bitmapData.$deleteSource=!1),this._bitmapData):null},enumerable:!0,configurable:!0}),r.prototype.loadPoster=function(){var t=this,r=this.poster;if(r){var i=new e.ImageLoader;i.once(e.Event.COMPLETE,function(r){i.data;if(t.posterData=i.data,t.$renderDirty=!0,t.posterData.width=t.getPlayWidth(),t.posterData.height=t.getPlayHeight(),e.nativeRender){var n=new e.Texture;n._setBitmapData(t.posterData),t.$nativeDisplayObject.setTexture(n)}},this),i.load(r)}},r.prototype.$measureContentBounds=function(e){var t=this.bitmapData,r=this.posterData;t?e.setTo(0,0,this.getPlayWidth(),this.getPlayHeight()):r?e.setTo(0,0,this.getPlayWidth(),this.getPlayHeight()):e.setEmpty()},r.prototype.getPlayWidth=function(){return isNaN(this.widthSet)?this.bitmapData?this.bitmapData.width:this.posterData?this.posterData.width:0/0:this.widthSet},r.prototype.getPlayHeight=function(){return isNaN(this.heightSet)?this.bitmapData?this.bitmapData.height:this.posterData?this.posterData.height:0/0:this.heightSet},r.prototype.$updateRenderNode=function(){var t=this.$renderNode,r=this.bitmapData,i=this.posterData,n=this.getPlayWidth(),a=this.getPlayHeight();this.isPlayed&&!e.Capabilities.isMobile||!i?this.isPlayed&&r&&(t.image=r,t.imageWidth=r.width,t.imageHeight=r.height,e.WebGLUtils.deleteWebGLTexture(r.webGLTexture),r.webGLTexture=null,t.drawImage(0,0,r.width,r.height,0,0,n,a)):(t.image=i,t.imageWidth=n,t.imageHeight=a,t.drawImage(0,0,i.width,i.height,0,0,n,a))},r.prototype.markDirty=function(){return this.$renderDirty=!0,!0},r.prototype.$setHeight=function(e){if(this.heightSet=e,this.paused){var r=this;this.$renderDirty=!0,window.setTimeout(function(){r.$renderDirty=!1},200)}t.prototype.$setHeight.call(this,e)},r.prototype.$setWidth=function(e){if(this.widthSet=e,this.paused){var r=this;this.$renderDirty=!0,window.setTimeout(function(){r.$renderDirty=!1},200)}t.prototype.$setWidth.call(this,e)},Object.defineProperty(r.prototype,"paused",{get:function(){return this.video?this.video.paused:!0},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"length",{get:function(){if(this.video)return this.video.duration;throw new Error("Video not loaded!")},enumerable:!0,configurable:!0}),r}(e.DisplayObject);t.WebVideo=r,__reflect(r.prototype,"egret.web.WebVideo",["egret.Video","egret.DisplayObject"]),e.Video=r}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(t){function r(){var e=t.call(this)||this;return e.timeout=0,e._url="",e._method="",e}return __extends(r,t),Object.defineProperty(r.prototype,"response",{get:function(){if(!this._xhr)return null;if(void 0!=this._xhr.response)return this._xhr.response;if("text"==this._responseType)return this._xhr.responseText;if("arraybuffer"==this._responseType&&/msie 9.0/i.test(navigator.userAgent)){var e=window;return e.convertResponseBodyToText(this._xhr.responseBody)}return"document"==this._responseType?this._xhr.responseXML:null},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"responseType",{get:function(){return this._responseType},set:function(e){this._responseType=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"withCredentials",{get:function(){return this._withCredentials},set:function(e){this._withCredentials=e},enumerable:!0,configurable:!0}),r.prototype.getXHR=function(){return window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP")},r.prototype.open=function(e,t){void 0===t&&(t="GET"),this._url=e,this._method=t,this._xhr&&(this._xhr.abort(),this._xhr=null);var r=this.getXHR();window.XMLHttpRequest?(r.addEventListener("load",this.onload.bind(this)),r.addEventListener("error",this.onerror.bind(this))):r.onreadystatechange=this.onReadyStateChange.bind(this),r.onprogress=this.updateProgress.bind(this),r.ontimeout=this.onTimeout.bind(this),r.open(this._method,this._url,!0),this._xhr=r},r.prototype.send=function(e){if(null!=this._responseType&&(this._xhr.responseType=this._responseType),null!=this._withCredentials&&(this._xhr.withCredentials=this._withCredentials),this.headerObj)for(var t in this.headerObj)this._xhr.setRequestHeader(t,this.headerObj[t]);this._xhr.timeout=this.timeout,this._xhr.send(e)},r.prototype.abort=function(){this._xhr&&this._xhr.abort()},r.prototype.getAllResponseHeaders=function(){if(!this._xhr)return null;var e=this._xhr.getAllResponseHeaders();return e?e:""},r.prototype.setRequestHeader=function(e,t){this.headerObj||(this.headerObj={}),this.headerObj[e]=t},r.prototype.getResponseHeader=function(e){if(!this._xhr)return null;var t=this._xhr.getResponseHeader(e);return t?t:""},r.prototype.onTimeout=function(){this.dispatchEventWith(e.IOErrorEvent.IO_ERROR)},r.prototype.onReadyStateChange=function(){var t=this._xhr;if(4==t.readyState){var r=t.status>=400||0==t.status,i=(this._url,this);window.setTimeout(function(){r?i.dispatchEventWith(e.IOErrorEvent.IO_ERROR):i.dispatchEventWith(e.Event.COMPLETE)},0)}},r.prototype.updateProgress=function(t){t.lengthComputable&&e.ProgressEvent.dispatchProgressEvent(this,e.ProgressEvent.PROGRESS,t.loaded,t.total)},r.prototype.onload=function(){var t=this,r=this._xhr,i=(this._url,r.status>=400);window.setTimeout(function(){i?t.dispatchEventWith(e.IOErrorEvent.IO_ERROR):t.dispatchEventWith(e.Event.COMPLETE)},0)},r.prototype.onerror=function(){var t=(this._url,this);window.setTimeout(function(){t.dispatchEventWith(e.IOErrorEvent.IO_ERROR)},0)},r}(e.EventDispatcher);t.WebHttpRequest=r,__reflect(r.prototype,"egret.web.WebHttpRequest",["egret.HttpRequest"]),e.HttpRequest=r}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=window.URL||window.webkitURL,i=function(i){function n(){var e=null!==i&&i.apply(this,arguments)||this;return e.data=null,e._crossOrigin=null,e._hasCrossOriginSet=!1,e.currentImage=null,e.request=null,e}return __extends(n,i),Object.defineProperty(n.prototype,"crossOrigin",{get:function(){return this._crossOrigin},set:function(e){this._hasCrossOriginSet=!0,this._crossOrigin=e},enumerable:!0,configurable:!0}),n.prototype.load=function(r){if(t.Html5Capatibility._canUseBlob&&0!=r.indexOf("wxLocalResource:")&&0!=r.indexOf("data:")&&0!=r.indexOf("http:")&&0!=r.indexOf("https:")){var i=this.request;i||(i=this.request=new e.web.WebHttpRequest,i.addEventListener(e.Event.COMPLETE,this.onBlobLoaded,this),i.addEventListener(e.IOErrorEvent.IO_ERROR,this.onBlobError,this),i.responseType="blob"),i.open(r),i.send()}else this.loadImage(r)},n.prototype.onBlobLoaded=function(e){var t=this.request.response;this.request=void 0,this.loadImage(r.createObjectURL(t))},n.prototype.onBlobError=function(e){this.dispatchIOError(this.currentURL),this.request=void 0},n.prototype.loadImage=function(e){var t=new Image;this.data=null,this.currentImage=t,this._hasCrossOriginSet?this._crossOrigin&&(t.crossOrigin=this._crossOrigin):n.crossOrigin&&(t.crossOrigin=n.crossOrigin),t.onload=this.onImageComplete.bind(this),t.onerror=this.onLoadError.bind(this),t.src=e},n.prototype.onImageComplete=function(t){var r=this.getImage(t);if(r){this.data=new e.BitmapData(r);var i=this;window.setTimeout(function(){i.dispatchEventWith(e.Event.COMPLETE)},0)}},n.prototype.onLoadError=function(e){var t=this.getImage(e);t&&this.dispatchIOError(t.src)},n.prototype.dispatchIOError=function(t){var r=this;window.setTimeout(function(){r.dispatchEventWith(e.IOErrorEvent.IO_ERROR)},0)},n.prototype.getImage=function(t){var i=t.target,n=i.src;if(0==n.indexOf("blob:"))try{r.revokeObjectURL(i.src)}catch(a){e.$warn(1037)}return i.onerror=null,i.onload=null,this.currentImage!==i?null:(this.currentImage=null,i)},n.crossOrigin=null,n}(e.EventDispatcher);t.WebImageLoader=i,__reflect(i.prototype,"egret.web.WebImageLoader",["egret.ImageLoader"]),e.ImageLoader=i}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(t){function r(){var e=t.call(this)||this;return e._isNeedShow=!1,e.inputElement=null,e.inputDiv=null,e._gscaleX=0,e._gscaleY=0,e.textValue="",e.colorValue=16777215,e._styleInfoes={},e}return __extends(r,t),r.prototype.$setTextField=function(e){return this.$textfield=e,!0},r.prototype.$addToStage=function(){this.htmlInput=e.web.$getTextAdapter(this.$textfield)},r.prototype._initElement=function(){var t=this.$textfield.localToGlobal(0,0),r=t.x,i=t.y,n=this.htmlInput.$scaleX,a=this.htmlInput.$scaleY;this.inputDiv.style.left=r*n+"px",this.inputDiv.style.top=i*a+"px",this.$textfield.multiline&&this.$textfield.height>this.$textfield.size?(this.inputDiv.style.top=i*a+"px",this.inputElement.style.top=-this.$textfield.lineSpacing/2*a+"px"):(this.inputDiv.style.top=i*a+"px",this.inputElement.style.top="0px");for(var o=this.$textfield,s=1,l=1,c=0;o.parent;)s*=o.scaleX,l*=o.scaleY,c+=o.rotation,o=o.parent;var h=e.web.getPrefixStyleName("transform");this.inputDiv.style[h]="rotate("+c+"deg)",this._gscaleX=n*s,this._gscaleY=a*l},r.prototype.$show=function(){this.htmlInput.isCurrentStageText(this)?this.inputElement.onblur=null:(this.inputElement=this.htmlInput.getInputElement(this),this.$textfield.multiline?this.inputElement.type="text":this.inputElement.type=this.$textfield.inputType,this.inputDiv=this.htmlInput._inputDIV),this.htmlInput._needShow=!0,this._isNeedShow=!0,this._initElement()},r.prototype.onBlurHandler=function(){this.htmlInput.clearInputElement(),window.scrollTo(0,0)},r.prototype.onFocusHandler=function(){var e=this;window.setTimeout(function(){e.inputElement&&e.inputElement.scrollIntoView()},200)},r.prototype.executeShow=function(){this.inputElement.value=this.$getText(),null==this.inputElement.onblur&&(this.inputElement.onblur=this.onBlurHandler.bind(this)),null==this.inputElement.onfocus&&(this.inputElement.onfocus=this.onFocusHandler.bind(this)),this.$resetStageText(),this.$textfield.maxChars>0?this.inputElement.setAttribute("maxlength",this.$textfield.maxChars):this.inputElement.removeAttribute("maxlength"),this.inputElement.selectionStart=this.inputElement.value.length,this.inputElement.selectionEnd=this.inputElement.value.length,this.inputElement.focus()},r.prototype.$hide=function(){this.htmlInput&&this.htmlInput.disconnectStageText(this)},r.prototype.$getText=function(){return this.textValue||(this.textValue=""),this.textValue},r.prototype.$setText=function(e){return this.textValue=e,this.resetText(),!0},r.prototype.resetText=function(){this.inputElement&&(this.inputElement.value=this.textValue)},r.prototype.$setColor=function(e){return this.colorValue=e,this.resetColor(),!0},r.prototype.resetColor=function(){this.inputElement&&this.setElementStyle("color",e.toColorString(this.colorValue))},r.prototype.$onBlur=function(){},r.prototype._onInput=function(){var t=this;window.setTimeout(function(){t.inputElement&&t.inputElement.selectionStart==t.inputElement.selectionEnd&&(t.textValue=t.inputElement.value,e.Event.dispatchEvent(t,"updateText",!1))},0)},r.prototype.setAreaHeight=function(){var t=this.$textfield;if(t.multiline){var r=e.TextFieldUtils.$getTextHeight(t);if(t.height<=t.size)this.setElementStyle("height",t.size*this._gscaleY+"px"),this.setElementStyle("padding","0px"),this.setElementStyle("lineHeight",t.size*this._gscaleY+"px");else if(t.height=0&&(a=o[s],void 0===n[a]);s--);try{Object.defineProperty(n,"imageSmoothingEnabled",{get:function(){return this[a]},set:function(e){this[a]=e}})}catch(l){n.imageSmoothingEnabled=n[a]}}return i}var i=function(){function t(t,i,n){this.surface=e.sys.createCanvasRenderBufferSurface(r,t,i,n),this.context=this.surface.getContext("2d"),this.context&&(this.context.$offsetX=0,this.context.$offsetY=0),this.resize(t,i) +}return Object.defineProperty(t.prototype,"width",{get:function(){return this.surface.width},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this.surface.height},enumerable:!0,configurable:!0}),t.prototype.resize=function(t,r,i){e.sys.resizeCanvasRenderBuffer(this,t,r,i)},t.prototype.getPixels=function(e,t,r,i){return void 0===r&&(r=1),void 0===i&&(i=1),this.context.getImageData(e,t,r,i).data},t.prototype.toDataURL=function(e,t){return this.surface.toDataURL(e,t)},t.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.surface.width,this.surface.height)},t.prototype.destroy=function(){this.surface.width=this.surface.height=0},t}();t.CanvasRenderBuffer=i,__reflect(i.prototype,"egret.web.CanvasRenderBuffer",["egret.sys.RenderBuffer"])}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(t){function r(r,i){var n=t.call(this)||this;return n.onTouchBegin=function(e){var t=n.getLocation(e);n.touch.onTouchBegin(t.x,t.y,e.identifier)},n.onMouseMove=function(e){0==e.buttons?n.onTouchEnd(e):n.onTouchMove(e)},n.onTouchMove=function(e){var t=n.getLocation(e);n.touch.onTouchMove(t.x,t.y,e.identifier)},n.onTouchEnd=function(e){var t=n.getLocation(e);n.touch.onTouchEnd(t.x,t.y,e.identifier)},n.scaleX=1,n.scaleY=1,n.rotation=0,n.canvas=i,n.touch=new e.sys.TouchHandler(r),n.addListeners(),n}return __extends(r,t),r.prototype.addListeners=function(){var t=this;window.navigator.msPointerEnabled?(this.canvas.addEventListener("MSPointerDown",function(e){e.identifier=e.pointerId,t.onTouchBegin(e),t.prevent(e)},!1),this.canvas.addEventListener("MSPointerMove",function(e){e.identifier=e.pointerId,t.onTouchMove(e),t.prevent(e)},!1),this.canvas.addEventListener("MSPointerUp",function(e){e.identifier=e.pointerId,t.onTouchEnd(e),t.prevent(e)},!1)):(e.Capabilities.isMobile||this.addMouseListener(),this.addTouchListener())},r.prototype.addMouseListener=function(){this.canvas.addEventListener("mousedown",this.onTouchBegin),this.canvas.addEventListener("mousemove",this.onMouseMove),this.canvas.addEventListener("mouseup",this.onTouchEnd)},r.prototype.addTouchListener=function(){var e=this;this.canvas.addEventListener("touchstart",function(t){for(var r=t.changedTouches.length,i=0;r>i;i++)e.onTouchBegin(t.changedTouches[i]);e.prevent(t)},!1),this.canvas.addEventListener("touchmove",function(t){for(var r=t.changedTouches.length,i=0;r>i;i++)e.onTouchMove(t.changedTouches[i]);e.prevent(t)},!1),this.canvas.addEventListener("touchend",function(t){for(var r=t.changedTouches.length,i=0;r>i;i++)e.onTouchEnd(t.changedTouches[i]);e.prevent(t)},!1),this.canvas.addEventListener("touchcancel",function(t){for(var r=t.changedTouches.length,i=0;r>i;i++)e.onTouchEnd(t.changedTouches[i]);e.prevent(t)},!1)},r.prototype.prevent=function(e){e.stopPropagation(),1==e.isScroll||this.canvas.userTyping||e.preventDefault()},r.prototype.getLocation=function(t){t.identifier=+t.identifier||0;var r=document.documentElement,i=this.canvas.getBoundingClientRect(),n=i.left+window.pageXOffset-r.clientLeft,a=i.top+window.pageYOffset-r.clientTop,o=t.pageX-n,s=o,l=t.pageY-a,c=l;return 90==this.rotation?(s=l,c=i.width-o):-90==this.rotation&&(s=i.height-l,c=o),s/=this.scaleX,c/=this.scaleY,e.$TempPoint.setTo(Math.round(s),Math.round(c))},r.prototype.updateScaleMode=function(e,t,r){this.scaleX=e,this.scaleY=t,this.rotation=r},r.prototype.$updateMaxTouches=function(){this.touch.$initMaxTouches()},r}(e.HashObject);t.WebTouchHandler=r,__reflect(r.prototype,"egret.web.WebTouchHandler")}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(e){e.WebLifeCycleHandler=function(e){var t=function(){document[r]?e.pause():e.resume()};window.addEventListener("focus",e.resume,!1),window.addEventListener("blur",e.pause,!1);var r,i;"undefined"!=typeof document.hidden?(r="hidden",i="visibilitychange"):"undefined"!=typeof document.mozHidden?(r="mozHidden",i="mozvisibilitychange"):"undefined"!=typeof document.msHidden?(r="msHidden",i="msvisibilitychange"):"undefined"!=typeof document.webkitHidden?(r="webkitHidden",i="webkitvisibilitychange"):"undefined"!=typeof document.oHidden&&(r="oHidden",i="ovisibilitychange"),"onpageshow"in window&&"onpagehide"in window&&(window.addEventListener("pageshow",e.resume,!1),window.addEventListener("pagehide",e.pause,!1)),r&&i&&document.addEventListener(i,t,!1);var n=navigator.userAgent,a=/micromessenger/gi.test(n),o=/mqq/gi.test(n),s=/mobile.*qq/gi.test(n);if((s||a)&&(o=!1),o){var l=window.browser||{};l.execWebFn=l.execWebFn||{},l.execWebFn.postX5GamePlayerMessage=function(t){var r=t.type;"app_enter_background"==r?e.pause():"app_enter_foreground"==r&&e.resume()},window.browser=l}}}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){function r(e,t){var r="";if(null!=t)r=i(e,t);else{if(null==o){var n=document.createElement("div").style;o=i("transform",n)}r=o}return""==r?e:r+e.charAt(0).toUpperCase()+e.substring(1,e.length)}function i(e,t){if(e in t)return"";e=e.charAt(0).toUpperCase()+e.substring(1,e.length);for(var r=["webkit","ms","Moz","O"],i=0;i=0||r.indexOf("ipad")>=0||r.indexOf("ipod")>=0;if(a)try{t.WebAudioDecode.ctx=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext)}catch(s){a=!1}var l,c=i._audioType;c==n.WEB_AUDIO&&a||c==n.HTML5_AUDIO?(l=!1,i.setAudioType(c)):!o&&r.indexOf("safari")>=0&&-1===r.indexOf("chrome")?(l=!1,i.setAudioType(n.WEB_AUDIO)):(l=!0,i.setAudioType(n.HTML5_AUDIO)),r.indexOf("android")>=0?l&&a&&i.setAudioType(n.WEB_AUDIO):o&&i.getIOSVersion()>=7&&(i._canUseBlob=!0,l&&a&&i.setAudioType(n.WEB_AUDIO));var h=window.URL||window.webkitURL;h||(i._canUseBlob=!1),r.indexOf("egretnative")>=0&&(i.setAudioType(n.HTML5_AUDIO),i._canUseBlob=!0),e.Sound=i._AudioClass},i.setAudioType=function(t){switch(i._audioType=t,t){case n.WEB_AUDIO:i._AudioClass=e.web.WebAudioSound;break;case n.HTML5_AUDIO:i._AudioClass=e.web.HtmlSound}},i.getIOSVersion=function(){var e=i.ua.toLowerCase().match(/cpu [^\d]*\d.*like mac os x/);if(!e||0==e.length)return 0;var t=e[0];return parseInt(t.match(/\d+(_\d)*/)[0])||0},i._canUseBlob=!1,i._audioType=0,i.ua="",i}(e.HashObject);t.Html5Capatibility=a,__reflect(a.prototype,"egret.web.Html5Capatibility");var o=null;t.getPrefixStyleName=r,t.getPrefix=i}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){function r(e,t){return i(e,t)}function i(e,t){var r=document.createElement("canvas");return isNaN(e)||isNaN(t)||(r.width=e,r.height=t),r}function n(e,t,r,i){if(e){var n=e,a=n.surface;i?(a.widthr;r++){var i=e[r],n=i["egret-player"];n.updateScreenSize()}}function i(r){if(!s){s=!0,r||(r={});var i=navigator.userAgent.toLowerCase();if(i.indexOf("egretnative")>=0&&-1==i.indexOf("egretwebview")&&(e.Capabilities.runtimeType=e.RuntimeType.RUNTIME2),i.indexOf("egretnative")>=0&&e.nativeRender)egret_native.addModuleCallback(function(){if(t.Html5Capatibility.$init(),"webgl"==r.renderMode){var i=r.antialias;t.WebGLRenderContext.antialias=!!i}e.sys.CanvasRenderBuffer=t.CanvasRenderBuffer,n(r.renderMode),egret_native.nrSetRenderMode(2);var s;s=r.canvasScaleFactor?r.canvasScaleFactor:r.calculateCanvasScaleFactor?r.calculateCanvasScaleFactor(e.sys.canvasHitTestBuffer.context):window.devicePixelRatio,e.sys.DisplayList.$canvasScaleFactor=s;var c=e.ticker;a(c),r.screenAdapter?e.sys.screenAdapter=r.screenAdapter:e.sys.screenAdapter||(e.sys.screenAdapter=new e.sys.DefaultScreenAdapter);for(var h=document.querySelectorAll(".egret-player"),u=h.length,d=0;u>d;d++){var f=h[d],p=new t.WebPlayer(f,r);f["egret-player"]=p}window.addEventListener("resize",function(){isNaN(l)&&(l=window.setTimeout(o,300))})},null),egret_native.initNativeRender();else{t.Html5Capatibility._audioType=r.audioType,t.Html5Capatibility.$init();var c=r.renderMode;if("webgl"==c){var h=r.antialias;t.WebGLRenderContext.antialias=!!h}e.sys.CanvasRenderBuffer=t.CanvasRenderBuffer,i.indexOf("egretnative")>=0&&"webgl"!=c&&(e.$warn(1051),c="webgl"),n(c);var u=void 0;if(r.canvasScaleFactor)u=r.canvasScaleFactor;else if(r.calculateCanvasScaleFactor)u=r.calculateCanvasScaleFactor(e.sys.canvasHitTestBuffer.context);else{var d=e.sys.canvasHitTestBuffer.context,f=d.backingStorePixelRatio||d.webkitBackingStorePixelRatio||d.mozBackingStorePixelRatio||d.msBackingStorePixelRatio||d.oBackingStorePixelRatio||d.backingStorePixelRatio||1;u=(window.devicePixelRatio||1)/f}e.sys.DisplayList.$canvasScaleFactor=u;var p=e.ticker;a(p),r.screenAdapter?e.sys.screenAdapter=r.screenAdapter:e.sys.screenAdapter||(e.sys.screenAdapter=new e.sys.DefaultScreenAdapter);for(var v=document.querySelectorAll(".egret-player"),g=v.length,x=0;g>x;x++){var y=v[x],m=new t.WebPlayer(y,r);y["egret-player"]=m}window.addEventListener("resize",function(){isNaN(l)&&(l=window.setTimeout(o,300))})}}}function n(r){"webgl"==r&&e.WebGLUtils.checkCanUseWebGL()?(e.sys.RenderBuffer=t.WebGLRenderBuffer,e.sys.systemRenderer=new t.WebGLRenderer,e.sys.canvasRenderer=new e.CanvasRenderer,e.sys.customHitTestBuffer=new t.WebGLRenderBuffer(3,3),e.sys.canvasHitTestBuffer=new t.CanvasRenderBuffer(3,3),e.Capabilities.renderMode="webgl"):(e.sys.RenderBuffer=t.CanvasRenderBuffer,e.sys.systemRenderer=new e.CanvasRenderer,e.sys.canvasRenderer=e.sys.systemRenderer,e.sys.customHitTestBuffer=new t.CanvasRenderBuffer(3,3),e.sys.canvasHitTestBuffer=e.sys.customHitTestBuffer,e.Capabilities.renderMode="canvas")}function a(e){function t(){r(t),e.update()}var r=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;r||(r=function(e){return window.setTimeout(e,1e3/60)}),r(t)}function o(){l=0/0,e.updateAllScreens()}var s=!1;window.isNaN=function(e){return e=+e,e!==e},e.runEgret=i,e.updateAllScreens=r;var l=0/0}(t=e.web||(e.web={}))}(egret||(egret={}));var language,egret;!function(e){var t;!function(t){var r=function(){function t(){}return t.detect=function(){var r=e.Capabilities,i=navigator.userAgent.toLowerCase();r.isMobile=-1!=i.indexOf("mobile")||-1!=i.indexOf("android"),r.isMobile?i.indexOf("windows")<0&&(-1!=i.indexOf("iphone")||-1!=i.indexOf("ipad")||-1!=i.indexOf("ipod"))?r.os="iOS":-1!=i.indexOf("android")&&-1!=i.indexOf("linux")?r.os="Android":-1!=i.indexOf("windows")&&(r.os="Windows Phone"):-1!=i.indexOf("windows nt")?r.os="Windows PC":"MacIntel"==navigator.platform&&navigator.maxTouchPoints>1?(r.os="iOS",r.isMobile=!0):-1!=i.indexOf("mac os")&&(r.os="Mac OS");var n=(navigator.language||navigator.browserLanguage).toLowerCase(),a=n.split("-");a.length>1&&(a[1]=a[1].toUpperCase()),r.language=a.join("-"),t.injectUIntFixOnIE9()},t.injectUIntFixOnIE9=function(){if(/msie 9.0/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)){var e="\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",o.id="egret-fps-panel",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 l=document.createElement("div");this.divCost=l,l.innerHTML='0 0',o.appendChild(l),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],l=this.arrFps[0],c=0;o>c;c++){var h=this.arrFps[c];a+=h,s>h?s=h:h>l&&(l=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 x=Math.floor(n/2);1>x?x=1:x>20&&(x=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-x,1,x);var y=Math.floor(a/o),m=r+" FPS "+this.renderMode;this.showPanle&&(m+="
min"+s+" max"+l+" avg"+y,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){console.log("Egret Engine Version:",e.Capabilities.engineVersion);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 l=new t.WebTouchHandler(a,s),c=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||c.displayFPS(n.showFPS,n.showLog,n.logFilter,n.fpsStyles)),this.playerOption=n,this.container=r,this.canvas=s,this.stage=a,this.player=c,this.webTouchHandler=l,this.webInput=h,e.web.$cacheTextAdapter(h,a,r,s),this.updateScreenSize(),this.updateMaxTouches(),c.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||l==e.OrientationMode.PORTRAIT&&a>o);var c=s?o:a,h=s?a:o;e.Capabilities.boundingClientWidth=c,e.Capabilities.boundingClientHeight=h;var u=e.sys.screenAdapter.calculateStageSize(this.stage.$scaleMode,c,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?l==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 x=p/d,y=v/f,m=x*e.sys.DisplayList.$canvasScaleFactor,b=y*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(x/m,y/b),w.rotate(g*Math.PI/180);var T="matrix("+w.a+","+w.b+","+w.c+","+w.d+","+w.tx+","+w.ty+")";e.Matrix.release(w),t.style[e.web.getPrefixStyleName("transform")]=T,e.sys.DisplayList.$setCanvasScale(m,b),this.webTouchHandler.updateScaleMode(x,y,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=e.sys.createCanvas(),l=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,c=s;if(c.style.width=a+"px",c.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,l=n.length,c=0;l>c;c++){var h=n[c],u=h.name;0!=u.indexOf("xmlns:")&&(s[u]=h.value,r["$"+u]=h.value)}var d=e.childNodes;l=d.length;for(var f=r.children,c=0;l>c;c++){var p=d[c],v=p.nodeType,g=null;if(1==v)g=i(p,r);else if(3==v){var x=p.textContent.trim();x&&(g=new o(x,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(){function e(){}return e.call=function(e,t){},e.addCallback=function(e,t){},e}();t.WebExternalInterface=r,__reflect(r.prototype,"egret.web.WebExternalInterface",["egret.ExternalInterface"]);var i=navigator.userAgent.toLowerCase();i.indexOf("egretnative")<0&&(e.ExternalInterface=r)}(t=e.web||(e.web={}))}(egret||(egret={})),function(e){var t;!function(t){function r(t){var r=JSON.parse(t),n=r.functionName,a=i[n];if(a){var o=r.value;a.call(null,o)}else e.$warn(1050,n)}var i={},n=function(){function e(){}return e.call=function(e,t){var r={};r.functionName=e,r.value=t,egret_native.sendInfoToPlugin(JSON.stringify(r))},e.addCallback=function(e,t){i[e]=t},e}();t.NativeExternalInterface=n,__reflect(n.prototype,"egret.web.NativeExternalInterface",["egret.ExternalInterface"]);var a=navigator.userAgent.toLowerCase();a.indexOf("egretnative")>=0&&(e.ExternalInterface=n,egret_native.receivedPluginInfo=r)}(t=e.web||(e.web={}))}(egret||(egret={})),function(e){var t;!function(t){var r={},i=function(){function t(){}return t.call=function(e,t){__global.ExternalInterface.call(e,t)},t.addCallback=function(e,t){r[e]=t},t.invokeCallback=function(t,i){var n=r[t];n?n.call(null,i):e.$warn(1050,t)},t}();t.WebViewExternalInterface=i,__reflect(i.prototype,"egret.web.WebViewExternalInterface",["egret.ExternalInterface"]);var n=navigator.userAgent.toLowerCase();n.indexOf("egretwebview")>=0&&(e.ExternalInterface=i)}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(r){function i(){var e=r.call(this)||this;return e.loaded=!1,e}return __extends(i,r),Object.defineProperty(i.prototype,"length",{get:function(){if(this.originAudio)return this.originAudio.duration;throw new Error("sound not loaded!")},enumerable:!0,configurable:!0}),i.prototype.load=function(t){function r(){i.$recycle(o.url,s),a(),l.indexOf("firefox")>=0&&(s.pause(),s.muted=!1),c&&document.body.appendChild(s),o.loaded=!0,o.dispatchEventWith(e.Event.COMPLETE)}function n(){a(),o.dispatchEventWith(e.IOErrorEvent.IO_ERROR)}function a(){s.removeEventListener("canplaythrough",r),s.removeEventListener("error",n),c&&document.body.removeChild(s)}var o=this;this.url=t;var s=new Audio(t);s.addEventListener("canplaythrough",r),s.addEventListener("error",n);var l=navigator.userAgent.toLowerCase();l.indexOf("firefox")>=0&&(s.autoplay=!0,s.muted=!0);var c=l.indexOf("edge")>=0||l.indexOf("trident")>=0;c&&document.body.appendChild(s),s.load(),this.originAudio=s,i.clearAudios[this.url]&&delete i.clearAudios[this.url]},i.prototype.play=function(r,n){r=+r||0,n=+n||0;var a=i.$pop(this.url);null==a&&(a=this.originAudio.cloneNode()),a.autoplay=!0;var o=new t.HtmlSoundChannel(a);return o.$url=this.url,o.$loops=n,o.$startTime=r,o.$play(),e.sys.$pushSoundChannel(o),o},i.prototype.close=function(){this.loaded&&this.originAudio&&(this.originAudio.src=""),this.originAudio&&(this.originAudio=null),i.$clear(this.url),this.loaded=!1},i.$clear=function(e){i.clearAudios[e]=!0;var t=i.audios[e];t&&(t.length=0)},i.$pop=function(e){var t=i.audios[e];return t&&t.length>0?t.pop():null},i.$recycle=function(e,t){if(!i.clearAudios[e]){var r=i.audios[e];null==i.audios[e]&&(r=i.audios[e]=[]),r.push(t)}},i.MUSIC="music",i.EFFECT="effect",i.audios={},i.clearAudios={},i}(e.EventDispatcher);t.HtmlSound=r,__reflect(r.prototype,"egret.web.HtmlSound",["egret.Sound"])}(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 t.prototype.reachMaxSize=function(e,t){return void 0===e&&(e=4),void 0===t&&(t=6),this.vertexIndex>this.maxVertexCount-e||this.indexIndex>this.maxIndicesCount-t},t.prototype.getVertices=function(){var e=this.vertices.subarray(0,this.vertexIndex*this.vertSize);return e},t.prototype.getIndices=function(){return this.indices},t.prototype.getMeshIndices=function(){return this.indicesForMesh},t.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}},t.prototype.isMesh=function(){return this.hasMesh},t.prototype.cacheArrays=function(t,r,i,n,a,o,s,l,c,h,u,d,f,p,v){var g=t.globalAlpha;g=Math.min(g,1);var x=t.globalTintColor||16777215,y=t.currentTexture;g=1>g&&y&&y[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL]?e.WebGLUtils.premultiplyTint(x,g):x+(255*g<<24);var m=t.globalMatrix,b=m.a,w=m.b,T=m.c,E=m.d,_=m.tx,C=m.ty,S=t.$offsetX,R=t.$offsetY;if((0!=S||0!=R)&&(_=S*b+R*T+_,C=S*w+R*E+C),!f){(0!=o||0!=s)&&(_=o*b+s*T+_,C=o*w+s*E+C);var L=l/n;1!=L&&(b=L*b,w=L*w);var D=c/a;1!=D&&(T=D*T,E=D*E)}if(f){var A=this.vertices,I=this._verticesUint32View,$=this.vertexIndex*this.vertSize,M=0,B=0,O=0,P=0,W=0,k=0,G=0;for(M=0,O=d.length;O>M;M+=2)B=$+5*M/2,k=f[M],G=f[M+1],P=d[M],W=d[M+1],A[B+0]=b*k+T*G+_,A[B+1]=w*k+E*G+C,v?(A[B+2]=(r+(1-W)*a)/h,A[B+3]=(i+P*n)/u):(A[B+2]=(r+P*n)/h,A[B+3]=(i+W*a)/u),I[B+4]=g;if(this.hasMesh)for(var H=0,F=p.length;F>H;++H)this.indicesForMesh[this.indexIndex+H]=p[H]+this.vertexIndex;this.vertexIndex+=d.length/2,this.indexIndex+=p.length}else{var U=h,N=u,X=n,z=a;r/=U,i/=N;var A=this.vertices,I=this._verticesUint32View,$=this.vertexIndex*this.vertSize;if(v){var Y=n;n=a/U,a=Y/N,A[$++]=_,A[$++]=C,A[$++]=n+r,A[$++]=i,I[$++]=g,A[$++]=b*X+_,A[$++]=w*X+C,A[$++]=n+r,A[$++]=a+i,I[$++]=g,A[$++]=b*X+T*z+_,A[$++]=E*z+w*X+C,A[$++]=r,A[$++]=a+i,I[$++]=g,A[$++]=T*z+_,A[$++]=E*z+C,A[$++]=r,A[$++]=i,I[$++]=g}else n/=U,a/=N,A[$++]=_,A[$++]=C,A[$++]=r,A[$++]=i,I[$++]=g,A[$++]=b*X+_,A[$++]=w*X+C,A[$++]=n+r,A[$++]=i,I[$++]=g,A[$++]=b*X+T*z+_,A[$++]=E*z+w*X+C,A[$++]=n+r,A[$++]=a+i,I[$++]=g,A[$++]=T*z+_,A[$++]=E*z+C,A[$++]=r,A[$++]=a+i,I[$++]=g;if(this.hasMesh){var V=this.indicesForMesh;V[this.indexIndex+0]=0+this.vertexIndex,V[this.indexIndex+1]=1+this.vertexIndex,V[this.indexIndex+2]=2+this.vertexIndex,V[this.indexIndex+3]=0+this.vertexIndex,V[this.indexIndex+4]=2+this.vertexIndex,V[this.indexIndex+5]=3+this.vertexIndex}this.vertexIndex+=4,this.indexIndex+=6}},t.prototype.clear=function(){this.hasMesh=!1,this.vertexIndex=0,this.indexIndex=0},t}();t.WebGLVertexArrayObject=r,__reflect(r.prototype,"egret.web.WebGLVertexArrayObject")}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(r){function i(e,t,i){var n=r.call(this)||this;return n.clearColor=[0,0,0,0],n.useFrameBuffer=!0,n.gl=e,n._resize(t,i),n}return __extends(i,r),i.prototype._resize=function(e,t){e=e||1,t=t||1,1>e&&(e=1),1>t&&(t=1),this.width=e,this.height=t},i.prototype.resize=function(e,t){this._resize(e,t);var r=this.gl;this.frameBuffer&&(r.bindTexture(r.TEXTURE_2D,this.texture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,this.width,this.height,0,r.RGBA,r.UNSIGNED_BYTE,null)),this.stencilBuffer&&(r.deleteRenderbuffer(this.stencilBuffer),this.stencilBuffer=null)},i.prototype.activate=function(){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,this.getFrameBuffer())},i.prototype.getFrameBuffer=function(){return this.useFrameBuffer?this.frameBuffer:null},i.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)}},i.prototype.createTexture=function(){var r=t.WebGLRenderContext.getInstance(0,0);return e.sys._createTexture(r,this.width,this.height,null)},i.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)},i.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)}},i.prototype.dispose=function(){e.WebGLUtils.deleteWebGLTexture(this.texture)},i}(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){var r={},i=function(){function i(r,i){if(this._defaultEmptyTexture=null,this.glID=null,this.projectionX=0/0,this.projectionY=0/0,this.contextLost=!1,this._supportedCompressedTextureInfo=[],this.$scissorState=!1,this.vertSize=5,this.surface=e.sys.mainCanvas(r,i),!e.nativeRender){this.initWebGL(),this.$bufferStack=[];var n=this.context;this.vertexBuffer=n.createBuffer(),this.indexBuffer=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,this.vertexBuffer),n.bindBuffer(n.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(t,r,i){e.sys.resizeContext(this,t,r,i)},i.prototype._buildSupportedCompressedTextureInfo=function(e){for(var t=[],r=0,i=e;rr;++r)for(var n=e[r],a=n.supportedFormats,o=0,s=a.length;s>o;++o)if(a[o][1]===t)return!0;return!1},i.prototype.$debugLogCompressedTextureNotSupported=function(t,i){if(!r[i]){r[i]=!0,e.log("internalFormat = "+i+":0x"+i.toString(16)+", the current hardware does not support the corresponding compression format.");for(var n=0,a=t.length;a>n;++n){var o=t[n];if(o.supportedFormats.length>0){e.log("support = "+o.extensionName);for(var s=0,l=o.supportedFormats.length;l>s;++s){var c=o.supportedFormats[s];e.log(c[0]+" : "+c[1]+" : 0x"+c[1].toString(16))}}}}},i.prototype.createCompressedTexture=function(t,r,i,n,a){var o=this.checkCompressedTextureInternalFormat(this._supportedCompressedTextureInfo,a);if(!o)return this.$debugLogCompressedTextureNotSupported(this._supportedCompressedTextureInfo,a),this.defaultEmptyTexture;var s=this.context,l=s.createTexture();return l?(l[e.glContext]=s,l[e.is_compressed_texture]=!0,s.bindTexture(s.TEXTURE_2D,l),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),l[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL]=!0,s.compressedTexImage2D(s.TEXTURE_2D,n,a,r,i,0,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.bindTexture(s.TEXTURE_2D,null),l):void(this.contextLost=!0)},i.prototype.updateTexture=function(e,t){var r=this.context;r.bindTexture(r.TEXTURE_2D,e),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t)},Object.defineProperty(i.prototype,"defaultEmptyTexture",{get:function(){if(!this._defaultEmptyTexture){var t=16,r=e.sys.createCanvas(t,t),i=e.sys.getContext2d(r);i.fillStyle="white",i.fillRect(0,0,t,t),this._defaultEmptyTexture=this.createTexture(r),this._defaultEmptyTexture[e.engine_default_empty_texture]=!0}return this._defaultEmptyTexture},enumerable:!0,configurable:!0}),i.prototype.getWebGLTexture=function(t){if(!t.webGLTexture){if("image"!=t.format||t.hasCompressed2d()){if(t.hasCompressed2d()){var r=t.getCompressed2dTextureData();t.webGLTexture=this.createCompressedTexture(r.byteArray,r.width,r.height,r.level,r.glInternalFormat);var i=t.etcAlphaMask;if(i){var n=this.getWebGLTexture(i);n&&(t.webGLTexture[e.etc_alpha_mask]=n)}}}else t.webGLTexture=this.createTexture(t.source);t.$deleteSource&&t.webGLTexture&&(t.source&&(t.source.src="",t.source=null),t.clearCompressedTextureData()),t.webGLTexture&&(t.webGLTexture.smoothing=!0)}return t.webGLTexture},i.prototype.clearRect=function(e,t,r,i){if(0!=e||0!=t||r!=this.surface.width||i!=this.surface.height){var n=this.currentBuffer;if(n.$hasScissor)this.setGlobalCompositeOperation("destination-out"),this.drawRect(e,t,r,i),this.setGlobalCompositeOperation("source-over");else{var a=n.globalMatrix;0==a.b&&0==a.c?(e=e*a.a+a.tx,t=t*a.d+a.ty,r*=a.a,i*=a.d,this.enableScissor(e,-t-i+n.height,r,i),this.clear(),this.disableScissor()):(this.setGlobalCompositeOperation("destination-out"),this.drawRect(e,t,r,i),this.setGlobalCompositeOperation("source-over"))}}else this.clear()},i.prototype.setGlobalCompositeOperation=function(e){this.drawCmdManager.pushSetBlend(e)},i.prototype.drawImage=function(e,t,r,i,n,a,o,s,l,c,h,u,d){var f=this.currentBuffer;if(!this.contextLost&&e&&f){var p,v,g;if(e.texture||e.source&&e.source.texture)p=e.texture||e.source.texture,f.saveTransform(),v=f.$offsetX,g=f.$offsetY,f.useOffset(),f.transform(1,0,0,-1,0,l+2*o);else{if(!e.source&&!e.webGLTexture)return;p=this.getWebGLTexture(e)}p&&(this.drawTexture(p,t,r,i,n,a,o,s,l,c,h,void 0,void 0,void 0,void 0,u,d),e.source&&e.source.texture&&(f.$offsetX=v,f.$offsetY=g,f.restoreTransform()))}},i.prototype.drawMesh=function(e,t,r,i,n,a,o,s,l,c,h,u,d,f,p,v,g){var x=this.currentBuffer;if(!this.contextLost&&e&&x){var y,m,b;if(e.texture||e.source&&e.source.texture)y=e.texture||e.source.texture,x.saveTransform(),m=x.$offsetX,b=x.$offsetY,x.useOffset(),x.transform(1,0,0,-1,0,l+2*o);else{if(!e.source&&!e.webGLTexture)return;y=this.getWebGLTexture(e)}y&&(this.drawTexture(y,t,r,i,n,a,o,s,l,c,h,u,d,f,p,v,g),(e.texture||e.source&&e.source.texture)&&(x.$offsetX=m,x.$offsetY=b,x.restoreTransform()))}},i.prototype.drawTexture=function(e,t,r,i,n,a,o,s,l,c,h,u,d,f,p,v,g){var x=this.currentBuffer;if(!this.contextLost&&e&&x){d&&f?this.vao.reachMaxSize(d.length/2,f.length)&&this.$drawWebGL():this.vao.reachMaxSize()&&this.$drawWebGL(),void 0!=g&&e.smoothing!=g&&this.drawCmdManager.pushChangeSmoothing(e,g),u&&this.vao.changeToMeshIndices();var y=f?f.length/3:2;this.drawCmdManager.pushDrawTexture(e,y,this.$filter,c,h),x.currentTexture=e,this.vao.cacheArrays(x,t,r,i,n,a,o,s,l,c,h,u,d,f,v)}},i.prototype.drawRect=function(e,t,r,i){var n=this.currentBuffer;!this.contextLost&&n&&(this.vao.reachMaxSize()&&this.$drawWebGL(),this.drawCmdManager.pushDrawRect(),n.currentTexture=null,this.vao.cacheArrays(n,0,0,r,i,e,t,r,i,r,i))},i.prototype.pushMask=function(e,t,r,i){var n=this.currentBuffer;!this.contextLost&&n&&(n.$stencilList.push({x:e,y:t,width:r,height:i}),this.vao.reachMaxSize()&&this.$drawWebGL(),this.drawCmdManager.pushPushMask(),n.currentTexture=null,this.vao.cacheArrays(n,0,0,r,i,e,t,r,i,r,i))},i.prototype.popMask=function(){var e=this.currentBuffer;if(!this.contextLost&&e){var t=e.$stencilList.pop();this.vao.reachMaxSize()&&this.$drawWebGL(),this.drawCmdManager.pushPopMask(),e.currentTexture=null,this.vao.cacheArrays(e,0,0,t.width,t.height,t.x,t.y,t.width,t.height,t.width,t.height)}},i.prototype.clear=function(){this.drawCmdManager.pushClearColor()},i.prototype.enableScissor=function(e,t,r,i){var n=this.currentBuffer;this.drawCmdManager.pushEnableScissor(e,t,r,i),n.$hasScissor=!0},i.prototype.disableScissor=function(){var e=this.currentBuffer;this.drawCmdManager.pushDisableScissor(),e.$hasScissor=!1},i.prototype.$drawWebGL=function(){if(0!=this.drawCmdManager.drawDataLen&&!this.contextLost){this.uploadVerticesArray(this.vao.getVertices()),this.vao.isMesh()&&this.uploadIndicesArray(this.vao.getMeshIndices());for(var e=this.drawCmdManager.drawDataLen,t=0,r=0;e>r;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(r,i){if(r){var n,a=this.context,o=r.filter;switch(r.type){case 0:o?"custom"===o.type?n=t.EgretWebGLProgram.getProgram(a,o.$vertexSrc,o.$fragmentSrc,o.$shaderKey):"colorTransform"===o.type?r.texture[e.etc_alpha_mask]?(a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,r.texture[e.etc_alpha_mask]),n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.colorTransform_frag_etc_alphamask_frag,"colorTransform_frag_etc_alphamask_frag")):n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.colorTransform_frag,"colorTransform"):"blurX"===o.type?n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.blur_frag,"blur"):"blurY"===o.type?n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.blur_frag,"blur"):"glow"===o.type&&(n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.glow_frag,"glow")):r.texture[e.etc_alpha_mask]?(n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.texture_etc_alphamask_frag,e.etc_alpha_mask),a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,r.texture[e.etc_alpha_mask])):n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.texture_frag,"texture"),this.activeProgram(a,n),this.syncUniforms(n,o,r.textureWidth,r.textureHeight),i+=this.drawTextureElements(r,i);break;case 1:n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.primitive_frag,"primitive"),this.activeProgram(a,n),this.syncUniforms(n,o,r.textureWidth,r.textureHeight),i+=this.drawRectElements(r,i);break;case 2:n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.primitive_frag,"primitive"),this.activeProgram(a,n),this.syncUniforms(n,o,r.textureWidth,r.textureHeight),i+=this.drawPushMaskElements(r,i);break;case 3:n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.primitive_frag,"primitive"),this.activeProgram(a,n),this.syncUniforms(n,o,r.textureWidth,r.textureHeight),i+=this.drawPopMaskElements(r,i);break;case 4:this.setBlendMode(r.value);break;case 5:r.buffer.rootRenderTarget.resize(r.width,r.height),this.onResize(r.width,r.height);break;case 6:if(this.activatedBuffer){var s=this.activatedBuffer.rootRenderTarget;(0!=s.width||0!=s.height)&&s.clear(!0)}break;case 7:this.activateBuffer(r.buffer,r.width,r.height);break;case 8:var l=this.activatedBuffer;l&&(l.rootRenderTarget&&l.rootRenderTarget.enabledStencil(),l.enableScissor(r.x,r.y,r.width,r.height));break;case 9:l=this.activatedBuffer,l&&l.disableScissor();break;case 10:a.bindTexture(a.TEXTURE_2D,r.texture),r.smoothing?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR)):(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST))}return i}},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,4,e.UNSIGNED_BYTE,!0,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)n[a].setValue(0);else if("uSamplerAlphaMask"===a)n[a].setValue(1);else{var o=t.$uniforms[a];void 0!==o&&n[a].setValue(o)}},i.prototype.drawTextureElements=function(t,r){return e.sys.drawTextureElements(this,t,r)},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],l=r.rootRenderTarget.width,c=r.rootRenderTarget.height;i=t.WebGLRenderBuffer.create(l,c),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 l=e.blurXFilter,c=e.blurYFilter;0!=l.blurX&&0!=c.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=c):e=0===l.blurX?c:l}i.saveTransform(),i.transform(1,0,0,-1,0,s),i.currentTexture=r.rootRenderTarget.texture,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",["egret.sys.RenderContext"]),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.currentTexture=null,o.globalAlpha=1,o.globalTintColor=16777215,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):(this.context.pushBuffer(this),(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.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),l=0;n>l;l++)for(var c=0;i>c;c++){var h=4*(i*(n-l-1)+c),u=4*(i*l+c),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,l){void 0===l&&(l=!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"),l&&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,l){void 0===l&&(l=!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"),l&&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,l=o.b,c=o.c,h=o.d;(1!=e||0!=t||0!=r||1!=i)&&(o.a=e*s+t*c,o.b=e*l+t*h,o.c=r*s+i*c,o.d=r*l+i*h),o.tx=n*s+a*c+o.tx,o.ty=n*l+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.wxiOS10=!1,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 l=o.$drawCalls;o.onRenderFinish(),s.popBuffer();var c=e.Matrix.create();if(i.$invertInto(c),o.transform(c.a,c.b,c.c,c.d,0,0),e.Matrix.release(c),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 l},a.prototype.drawDisplayObject=function(t,r,i,n,a){var o,s=0,l=t.$displayList;if(l&&!a?((t.$cacheDirty||t.$renderDirty||l.$canvasScaleX!=e.sys.DisplayList.$canvasScaleX||l.$canvasScaleY!=e.sys.DisplayList.$canvasScaleY)&&(s+=l.drawToSurface()),o=l.$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(l&&!a)return s;var c=t.$children;if(c){t.sortableChildren&&t.$sortDirty&&t.sortChildren();for(var h=c.length,u=0;h>u;u++){var d=c[u],f=void 0,p=void 0,v=void 0,g=void 0;1!=d.$alpha&&(v=r.globalAlpha,r.globalAlpha*=d.$alpha),16777215!==d.tint&&(g=r.globalTintColor,r.globalTintColor=d.$tintRGB);var x=void 0;if(d.$useTranslate){var y=d.$getMatrix();f=i+d.$x,p=n+d.$y;var m=r.globalMatrix;x=e.Matrix.create(),x.a=m.a,x.b=m.b,x.c=m.c,x.d=m.d,x.tx=m.tx,x.ty=m.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&&(r.globalTintColor=g),x){var y=r.globalMatrix;y.a=x.a,y.b=x.b,y.c=x.c,y.d=x.d,y.tx=x.tx,y.ty=x.ty,e.Matrix.release(x)}}}return s},a.prototype.drawWithFilter=function(t,a,o,s){var l=0;if(t.$children&&0==t.$children.length&&(!t.$renderNode||0==t.$renderNode.$getRenderCount()))return l;var c,h=t.$filters,u=0!==t.$blendMode;u&&(c=r[t.$blendMode],c||(c=i));var d=t.$getOriginalBounds(),f=d.x,p=d.y,v=d.width,g=d.height;if(0>=v||0>=g)return l;if(!t.mask&&1==h.length&&("colorTransform"==h[0].type||"custom"===h[0].type&&0===h[0].padding)){var x=this.getRenderCount(t);if(!t.$children||1==x)return u&&a.context.setGlobalCompositeOperation(c),a.context.$filter=h[0],l+=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),l}var y=this.createRenderBuffer(v,g);if(y.context.pushBuffer(y),l+=t.$mask?this.drawWithClip(t,y,-f,-p):t.$scrollRect||t.$maskRect?this.drawWithScrollRect(t,y,-f,-p):this.drawDisplayObject(t,y,-f,-p),y.context.popBuffer(),l>0){u&&a.context.setGlobalCompositeOperation(c),l++,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,y),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(y),l},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 l,c=0,h=0!==t.$blendMode;h&&(l=r[t.$blendMode],l||(l=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 c}if(d||t.$children&&0!=t.$children.length){var p=t.$getOriginalBounds(),v=p.x,g=p.y,x=p.width,y=p.height;if(0>=x||0>=y)return c;var m=this.createRenderBuffer(x,y);if(m.context.pushBuffer(m),c+=this.drawDisplayObject(t,m,-v,-g),d){var b=this.createRenderBuffer(x,y);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),c+=this.drawDisplayObject(d,b,0,0),b.context.popBuffer(),m.context.setGlobalCompositeOperation("destination-in"),m.setTransform(1,0,0,-1,0,b.height);var T=b.rootRenderTarget.width,E=b.rootRenderTarget.height;m.context.drawTexture(b.rootRenderTarget.texture,0,0,T,E,0,0,T,E,T,E),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(),c>0){c++,h&&a.context.setGlobalCompositeOperation(l),u&&a.context.pushMask(u.x+o,u.y+s,u.width,u.height);var _=e.Matrix.create(),C=a.globalMatrix;_.a=C.a,_.b=C.b,_.c=C.c,_.d=C.d,_.tx=C.tx,_.ty=C.ty,C.append(1,0,0,-1,o+v,s+g+m.height);var S=m.rootRenderTarget.width,R=m.rootRenderTarget.height;a.context.drawTexture(m.rootRenderTarget.texture,0,0,S,R,0,0,S,R,S,R),u&&m.context.popMask(),h&&a.context.setGlobalCompositeOperation(i);var L=a.globalMatrix;L.a=_.a,L.b=_.b,L.c=_.c,L.d=_.d,L.tx=_.tx,L.ty=_.ty,e.Matrix.release(_)}return n.push(m),c}return u&&a.context.pushMask(u.x+o,u.y+s,u.width,u.height),h&&a.context.setGlobalCompositeOperation(l),c+=this.drawDisplayObject(t,a,o,s),h&&a.context.setGlobalCompositeOperation(i),u&&a.context.popMask(),c},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,l=!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 c=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,x=void 0,y=void 0,m=void 0,b=void 0;if(1==c&&1==h)x=f+u,y=p+d,m=v+u,b=g+d;else{var w=c*f+u,T=h*p+d,E=c*v+u,_=h*p+d,C=c*v+u,S=h*g+d,R=c*f+u,L=h*g+d,D=0;w>E&&(D=w,w=E,E=D),C>R&&(D=C,C=R,R=D),x=C>w?w:C,m=E>R?E:R,T>_&&(D=T,T=_,_=D),S>L&&(D=S,S=L,L=D),y=S>T?T:S,b=_>L?_:L}s.enableScissor(x,-b+t.height,m-x,b-y),l=!0}return n+=this.drawDisplayObject(e,t,r,i),l?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 l=a[s];switch(l.$renderMode){case 1:break;case 2:n+=this.drawWithFilter(l,t,0,0);break;case 3:n+=this.drawWithClip(l,t,0,0);break;case 4:n+=this.drawWithScrollRect(l,t,0,0);break;default:n+=this.drawDisplayObject(l,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,l,c=t.drawData,h=c.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,l=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,c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],t.imageWidth,t.imageHeight,t.rotated,t.smoothing);n.context.$filter=null}else for(;h>u;)n.context.drawImage(a,c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],t.imageWidth,t.imageHeight,t.rotated,t.smoothing);if(f&&n.context.setGlobalCompositeOperation(i),p==p&&(n.globalAlpha=g),d){var x=n.globalMatrix;x.a=o.a,x.b=o.b,x.c=o.c,x.d=o.d,x.tx=o.tx,x.ty=o.ty,n.$offsetX=s,n.$offsetY=l,e.Matrix.release(o)}}},a.prototype.renderMesh=function(t,n){var a,o,s,l=t.image,c=t.drawData,h=c.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(l,c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[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(l,c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[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 x=n.globalMatrix;x.a=a.a,x.b=a.b,x.c=a.c,x.d=a.d,x.tx=a.tx,x.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,l=i.context.$maxTextureSize;n*o>l&&(o*=l/(n*o)),a*s>l&&(s*=l/(a*s)),n*=o,a*=s;var c=r.x*o,h=r.y*s;(r.$canvasScaleX!==o||r.$canvasScaleY!==s)&&(r.$canvasScaleX=o,r.$canvasScaleY=s,r.dirtyRender=!0),(c||h)&&i.transform(1,0,0,1,c/o,h/s),r.dirtyRender&&t.TextAtlasRender.analysisTextNodeAndFlushDrawLabel(r);var u=r[t.property_drawLabel];if(u&&u.length>0){for(var d=i.$offsetX,f=i.$offsetY,p=null,v=0,g=0,x=null,y=null,m=null,b=0,w=u.length;w>b;++b){p=u[b],v=p.anchorX,g=p.anchorY,x=p.textBlocks,i.$offsetX=d+v;for(var T=0,E=x.length;E>T;++T)y=x[T],T>0&&(i.$offsetX-=y.canvasWidthOffset),i.$offsetY=f+g-(y.measureHeight+(y.stroke2?y.canvasHeightOffset:0))/2,m=y.line.page,i.context.drawTexture(m.webGLTexture,y.u,y.v,y.contentWidth,y.contentHeight,0,0,y.contentWidth,y.contentHeight,m.pageWidth,m.pageHeight),i.$offsetX+=y.contentWidth-y.canvasWidthOffset}i.$offsetX=d,i.$offsetY=f}(c||h)&&i.transform(1,0,0,1,-c/o,-h/s),r.dirtyRender=!1}},a.prototype.renderText=function(r,i){if(t.textAtlasRenderEnable)return void this.___renderText____(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,l=i.context.$maxTextureSize;n*o>l&&(o*=l/(n*o)),a*s>l&&(s*=l/(a*s)),n*=o,a*=s;var c=r.x*o,h=r.y*s;if((r.$canvasScaleX!=o||r.$canvasScaleY!=s)&&(r.$canvasScaleX=o,r.$canvasScaleY=s,r.dirtyRender=!0),this.wxiOS10?(this.canvasRenderer||(this.canvasRenderer=new e.CanvasRenderer),r.dirtyRender&&(this.canvasRenderBuffer=new t.CanvasRenderBuffer(n,a))):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),c||h?(r.dirtyRender&&this.canvasRenderBuffer.context.setTransform(o,0,0,s,-c,-h),i.transform(1,0,0,1,c/o,h/s)):(1!=o||1!=s)&&this.canvasRenderBuffer.context.setTransform(o,0,0,s,0,0),r.dirtyRender){var u=this.canvasRenderBuffer.surface;if(this.canvasRenderer.renderText(r,this.canvasRenderBuffer.context),this.wxiOS10)u.isCanvas=!0,r.$texture=u;else{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),(c||h)&&(r.dirtyRender&&this.canvasRenderBuffer.context.setTransform(o,0,0,s,0,0),i.transform(1,0,0,1,-c/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,l=e.sys.DisplayList.$canvasScaleY;(1>a*s||1>o*l)&&(s=l=1),(r.$canvasScaleX!=s||r.$canvasScaleY!=l)&&(r.$canvasScaleX=s,r.$canvasScaleY=l,r.dirtyRender=!0),a*=s,o*=l;var c=Math.ceil(a),h=Math.ceil(o);if(s*=c/a,l*=h/o,a=c,o=h,this.wxiOS10?(this.canvasRenderer||(this.canvasRenderer=new e.CanvasRenderer),r.dirtyRender&&(this.canvasRenderBuffer=new t.CanvasRenderBuffer(a,o))):this.canvasRenderBuffer&&this.canvasRenderBuffer.context?r.dirtyRender&&this.canvasRenderBuffer.resize(a,o):(this.canvasRenderer=new e.CanvasRenderer,this.canvasRenderBuffer=new t.CanvasRenderBuffer(a,o)),this.canvasRenderBuffer.context){(1!=s||1!=l)&&this.canvasRenderBuffer.context.setTransform(s,0,0,l,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);var d=void 0;this.wxiOS10?(u.isCanvas=!0,d=u):(e.WebGLUtils.deleteWebGLTexture(u),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){if(this.canvasRenderer.renderGraphics(r,this.canvasRenderBuffer.context),this.wxiOS10)u.isCanvas=!0,r.$texture=u;else{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/l,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 l=t.drawData,c=l.length,h=0;c>h;h++){var u=l[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(t){var r=function(e){function t(t,r,i,n,a,o,s,l){var c=e.call(this)||this;return c._width=0,c._height=0,c._border=0,c.line=null,c.x=0,c.y=0,c.u=0,c.v=0,c.tag="",c.measureWidth=0,c.measureHeight=0,c.canvasWidthOffset=0,c.canvasHeightOffset=0,c.stroke2=0,c._width=t,c._height=r,c._border=l,c.measureWidth=i,c.measureHeight=n,c.canvasWidthOffset=a,c.canvasHeightOffset=o,c.stroke2=s,c}return __extends(t,e),Object.defineProperty(t.prototype,"border",{get:function(){return this._border},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._width+2*this.border},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height+2*this.border},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"contentWidth",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"contentHeight",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"page",{get:function(){return this.line?this.line.page:null},enumerable:!0,configurable:!0}),t.prototype.updateUV=function(){var e=this.line;return e?(this.u=e.x+this.x+1*this.border,this.v=e.y+this.y+1*this.border,!0):!1},Object.defineProperty(t.prototype,"subImageOffsetX",{get:function(){var e=this.line;return e?e.x+this.x+this.border:0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subImageOffsetY",{get:function(){var e=this.line;return e?e.y+this.y+this.border:0},enumerable:!0,configurable:!0}),t}(e.HashObject);t.TextBlock=r,__reflect(r.prototype,"egret.web.TextBlock");var i=function(e){function t(t){var r=e.call(this)||this;return r.page=null,r.textBlocks=[],r.dynamicMaxHeight=0,r.maxWidth=0,r.x=0,r.y=0,r.maxWidth=t,r}return __extends(t,e),t.prototype.isCapacityOf=function(e){if(!e)return!1;var t=0,r=0,i=this.lastTextBlock();return i&&(t=i.x+i.width,r=i.y),t+e.width>this.maxWidth?!1:this.dynamicMaxHeight>0&&(e.height>this.dynamicMaxHeight||e.height/this.dynamicMaxHeight<.5)?!1:!0},t.prototype.lastTextBlock=function(){var e=this.textBlocks;return e.length>0?e[e.length-1]:null},t.prototype.addTextBlock=function(e,t){if(!e)return!1;if(t&&!this.isCapacityOf(e))return!1;var r=0,i=0,n=this.lastTextBlock();return n&&(r=n.x+n.width,i=n.y),e.x=r,e.y=i,e.line=this,this.textBlocks.push(e),this.dynamicMaxHeight=Math.max(this.dynamicMaxHeight,e.height),!0},t}(e.HashObject);t.Line=i,__reflect(i.prototype,"egret.web.Line");var n=function(e){function t(t,r){var i=e.call(this)||this;return i.lines=[],i.pageWidth=0,i.pageHeight=0,i.webGLTexture=null,i.pageWidth=t,i.pageHeight=r,i}return __extends(t,e),t.prototype.addLine=function(e){if(!e)return!1;var t=0,r=0,i=this.lines;if(i.length>0){var n=i[i.length-1];t=n.x,r=n.y+n.dynamicMaxHeight}return e.maxWidth>this.pageWidth?(console.error("line.maxWidth = "+e.maxWidth+", this.pageWidth = "+this.pageWidth),!1):r+e.dynamicMaxHeight>this.pageHeight?!1:(e.x=t,e.y=r,e.page=this,this.lines.push(e),!0)},t}(e.HashObject);t.Page=n,__reflect(n.prototype,"egret.web.Page");var a=function(e){function t(t,r){var i=e.call(this)||this;return i._pages=[],i._sortLines=[],i._maxSize=1024,i._border=1,i._maxSize=t,i._border=r,i}return __extends(t,e),t.prototype.addTextBlock=function(e){var t=this._addTextBlock(e);if(!t)return!1;e.updateUV();for(var r=!1,i=t,n=this._sortLines,a=0,o=n;athis._maxSize||e.height>this._maxSize)return null;for(var t=this._sortLines,r=0,n=t.length;n>r;++r){var a=t[r];if(a.isCapacityOf(e)&&a.addTextBlock(e,!1))return[a.page,a]}var o=new i(this._maxSize);if(!o.addTextBlock(e,!0))return console.error("_addTextBlock !newLine.addTextBlock(textBlock, true)"),null;for(var s=this._pages,r=0,l=s.length;l>r;++r){var c=s[r];if(c.addLine(o))return[c,o]}var h=this.createPage(this._maxSize,this._maxSize);return h.addLine(o)?[h,o]:(console.error("_addText newPage.addLine failed"),null)},t.prototype.createPage=function(e,t){var r=new n(e,t);return this._pages.push(r),r},t.prototype.sort=function(){if(!(this._sortLines.length<=1)){var e=function(e,t){return e.dynamicMaxHeight=0)return void console.error("DrawLabel.back repeat");e.clear(),i.push(e)}},t.pool=[],t}(e.HashObject);t.DrawLabel=i,__reflect(i.prototype,"egret.web.DrawLabel");var n=function(t){function i(i,n){var a=t.call(this)||this;a.format=null;var o=0;r&&(o=i.textColor,i.textColor=16711680),a.textColor=i.textColor,a.strokeColor=i.strokeColor,a.size=i.size,a.stroke=i.stroke,a.bold=i.bold,a.italic=i.italic,a.fontFamily=i.fontFamily,a.format=n,a.font=e.getFontString(i,a.format);var s=n.textColor?n.textColor:i.textColor,l=n.strokeColor?n.strokeColor:i.strokeColor,c=n.stroke?n.stroke:i.stroke,h=n.size?n.size:i.size;return a.description=""+a.font+"-"+h,a.description+="-"+e.toColorString(s),a.description+="-"+e.toColorString(l),c&&(a.description+="-"+2*c),r&&(i.textColor=o),a}return __extends(i,t),i}(e.HashObject);__reflect(n.prototype,"StyleInfo");var a=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e["char"]="",e.styleInfo=null,e.hashCodeString="",e.charWithStyleHashCode=0,e.measureWidth=0,e.measureHeight=0,e.canvasWidthOffset=0,e.canvasHeightOffset=0,e.stroke2=0,e}return __extends(r,t),r.prototype.reset=function(t,r){return this["char"]=t,this.styleInfo=r,this.hashCodeString=t+":"+r.description,this.charWithStyleHashCode=e.NumberUtils.convertStringToHashCode(this.hashCodeString),this.canvasWidthOffset=0,this.canvasHeightOffset=0,this.stroke2=0,this},r.prototype.measureAndDraw=function(t){var r=t;if(r){var i=this["char"],n=this.styleInfo.format,a=n.textColor?n.textColor:this.styleInfo.textColor,o=n.strokeColor?n.strokeColor:this.styleInfo.strokeColor,s=n.stroke?n.stroke:this.styleInfo.stroke,l=n.size?n.size:this.styleInfo.size;this.measureWidth=this.measure(i,this.styleInfo,l),this.measureHeight=l;var c=this.measureWidth,h=this.measureHeight,u=2*s;u>0&&(c+=2*u,h+=2*u),this.stroke2=u,r.width=c=Math.ceil(c)+4,r.height=h=Math.ceil(h)+4,this.canvasWidthOffset=(r.width-this.measureWidth)/2,this.canvasHeightOffset=(r.height-this.measureHeight)/2;var d=3,f=Math.pow(10,d);this.canvasWidthOffset=Math.floor(this.canvasWidthOffset*f)/f,this.canvasHeightOffset=Math.floor(this.canvasHeightOffset*f)/f;var p=e.sys.getContext2d(r);p.save(),p.textAlign="center",p.textBaseline="middle",p.lineJoin="round",p.font=this.styleInfo.font,p.fillStyle=e.toColorString(a),p.strokeStyle=e.toColorString(o),p.clearRect(0,0,r.width,r.height),s&&(p.lineWidth=2*s,p.strokeText(i,r.width/2,r.height/2)),p.fillText(i,r.width/2,r.height/2),p.restore()}},r.prototype.measure=function(t,i,n){var a=r.chineseCharactersRegExp.test(t);if(a&&r.chineseCharacterMeasureFastMap[i.font])return r.chineseCharacterMeasureFastMap[i.font];var o=e.sys.measureText(t,i.fontFamily,n||i.size,i.bold,i.italic);return a&&(r.chineseCharacterMeasureFastMap[i.font]=o),o},r.chineseCharactersRegExp=new RegExp("^[一-龥]$"),r.chineseCharacterMeasureFastMap={},r}(e.HashObject);__reflect(a.prototype,"CharImageRender");var o=function(o){function s(e,r,i){var n=o.call(this)||this;return n.book=null,n.charImageRender=new a,n.textBlockMap={},n._canvas=null,n.textAtlasTextureCache=[],n.webglRenderContext=null,n.webglRenderContext=e,n.book=new t.Book(r,i),n}return __extends(s,o),s.analysisTextNodeAndFlushDrawLabel=function(a){if(a){if(!t.__textAtlasRender__){var o=e.web.WebGLRenderContext.getInstance(0,0);t.__textAtlasRender__=new s(o,512,r?12:1)}a[t.property_drawLabel]=a[t.property_drawLabel]||[];for(var l=a[t.property_drawLabel],c=0,h=l;cm;m+=d){p=f[m+0],v=f[m+1],g=f[m+2],x=f[m+3]||{},y.length=0,t.__textAtlasRender__.convertLabelStringToTextAtlas(g,new n(a,x),y);var u=i.create();u.anchorX=p,u.anchorY=v,u.textBlocks=[].concat(y),l.push(u)}}},s.prototype.convertLabelStringToTextAtlas=function(t,i,n){for(var a=this.canvas,o=this.charImageRender,s=this.textBlockMap,l=0,c=t;la;a++){var o=t.getActiveAttrib(r,a),s=o.name,l=new e.EgretWebGLAttribute(t,r,o);i[s]=l}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,l=new e.EgretWebGLUniform(t,r,o);i[s]=l}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(){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 5126:case 35678:case 35680:case 35670:case 5124:this.value=0;break;case 35664:case 35671:case 35667:this.value=[0,0];break;case 35665:case 35672:case 35668:this.value=[0,0,0];break;case 35666:case 35673:case 35669:this.value=[0,0,0,0];break;case 35674:this.value=new Float32Array([1,0,0,1]);break;case 35675:this.value=new Float32Array([1,0,0,0,1,0,0,0,1]);break;case 35676: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 5126:case 35678:case 35680:case 35670:case 5124:this.setValue=function(e){var t=this.value!==e;this.value=e,t&&this.upload()};break;case 35664:case 35671:case 35667: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 35665:case 35672:case 35668:this.setValue=function(e){this.value[0]=e.x,this.value[1]=e.y,this.value[2]=e.z,this.upload()};break;case 35666:case 35673:case 35669: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 35674:case 35675:case 35676:this.setValue=function(e){this.value.set(e),this.upload()}}},e.prototype.generateUpload=function(){var e=this.gl,t=this.type,r=this.location;switch(t){case 5126:this.upload=function(){var t=this.value;e.uniform1f(r,t)};break;case 35664:this.upload=function(){var t=this.value;e.uniform2f(r,t[0],t[1])};break;case 35665:this.upload=function(){var t=this.value;e.uniform3f(r,t[0],t[1],t[2])};break;case 35666:this.upload=function(){var t=this.value;e.uniform4f(r,t[0],t[1],t[2],t[3])};break;case 35678:case 35680:case 35670:case 5124:this.upload=function(){var t=this.value;e.uniform1i(r,t)};break;case 35671:case 35667:this.upload=function(){var t=this.value;e.uniform2i(r,t[0],t[1])};break;case 35672:case 35668:this.upload=function(){var t=this.value;e.uniform3i(r,t[0],t[1],t[2])};break;case 35673:case 35669:this.upload=function(){var t=this.value;e.uniform4i(r,t[0],t[1],t[2],t[3])};break;case 35674:this.upload=function(){var t=this.value;e.uniformMatrix2fv(r,!1,t)};break;case 35675:this.upload=function(){var t=this.value;e.uniformMatrix3fv(r,!1,t)};break;case 35676:this.upload=function(){var t=this.value;e.uniformMatrix4fv(r,!1,t)}}},e}();e.EgretWebGLUniform=t,__reflect(t.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;\r\nuniform vec2 blur;\r\nuniform sampler2D uSampler;\r\nvarying vec2 vTextureCoord;\r\nuniform vec2 uTextureSize;\r\nvoid main()\r\n{\r\n const int sampleRadius = 5;\r\n const int samples = sampleRadius * 2 + 1;\r\n vec2 blurUv = blur / uTextureSize;\r\n vec4 color = vec4(0, 0, 0, 0);\r\n vec2 uv = vec2(0.0, 0.0);\r\n blurUv /= float(sampleRadius);\r\n\r\n for (int i = -sampleRadius; i <= sampleRadius; i++) {\r\n uv.x = vTextureCoord.x + float(i) * blurUv.x;\r\n uv.y = vTextureCoord.y + float(i) * blurUv.y;\r\n color += texture2D(uSampler, uv);\r\n }\r\n\r\n color /= float(samples);\r\n gl_FragColor = color;\r\n}",e.colorTransform_frag="precision mediump float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\nuniform mat4 matrix;\r\nuniform vec4 colorAdd;\r\nuniform sampler2D uSampler;\r\n\r\nvoid main(void) {\r\n vec4 texColor = texture2D(uSampler, vTextureCoord);\r\n if(texColor.a > 0.) {\r\n // 抵消预乘的alpha通道\r\n texColor = vec4(texColor.rgb / texColor.a, texColor.a);\r\n }\r\n vec4 locColor = clamp(texColor * matrix + colorAdd, 0., 1.);\r\n gl_FragColor = vColor * vec4(locColor.rgb * locColor.a, locColor.a);\r\n}",e.default_vert="attribute vec2 aVertexPosition;\r\nattribute vec2 aTextureCoord;\r\nattribute vec4 aColor;\r\n\r\nuniform vec2 projectionVector;\r\n// uniform vec2 offsetVector;\r\n\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\n\r\nconst vec2 center = vec2(-1.0, 1.0);\r\n\r\nvoid main(void) {\r\n gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\r\n vTextureCoord = aTextureCoord;\r\n vColor = aColor;\r\n}",e.glow_frag="precision highp float;\r\nvarying vec2 vTextureCoord;\r\n\r\nuniform sampler2D uSampler;\r\n\r\nuniform float dist;\r\nuniform float angle;\r\nuniform vec4 color;\r\nuniform float alpha;\r\nuniform float blurX;\r\nuniform float blurY;\r\n// uniform vec4 quality;\r\nuniform float strength;\r\nuniform float inner;\r\nuniform float knockout;\r\nuniform float hideObject;\r\n\r\nuniform vec2 uTextureSize;\r\n\r\nfloat random(vec2 scale)\r\n{\r\n return fract(sin(dot(gl_FragCoord.xy, scale)) * 43758.5453);\r\n}\r\n\r\nvoid main(void) {\r\n vec2 px = vec2(1.0 / uTextureSize.x, 1.0 / uTextureSize.y);\r\n // TODO 自动调节采样次数?\r\n const float linearSamplingTimes = 7.0;\r\n const float circleSamplingTimes = 12.0;\r\n vec4 ownColor = texture2D(uSampler, vTextureCoord);\r\n vec4 curColor;\r\n float totalAlpha = 0.0;\r\n float maxTotalAlpha = 0.0;\r\n float curDistanceX = 0.0;\r\n float curDistanceY = 0.0;\r\n float offsetX = dist * cos(angle) * px.x;\r\n float offsetY = dist * sin(angle) * px.y;\r\n\r\n const float PI = 3.14159265358979323846264;\r\n float cosAngle;\r\n float sinAngle;\r\n float offset = PI * 2.0 / circleSamplingTimes * random(vec2(12.9898, 78.233));\r\n float stepX = blurX * px.x / linearSamplingTimes;\r\n float stepY = blurY * px.y / linearSamplingTimes;\r\n for (float a = 0.0; a <= PI * 2.0; a += PI * 2.0 / circleSamplingTimes) {\r\n cosAngle = cos(a + offset);\r\n sinAngle = sin(a + offset);\r\n for (float i = 1.0; i <= linearSamplingTimes; i++) {\r\n curDistanceX = i * stepX * cosAngle;\r\n curDistanceY = i * stepY * sinAngle;\r\n if (vTextureCoord.x + curDistanceX - offsetX >= 0.0 && vTextureCoord.y + curDistanceY + offsetY <= 1.0){\r\n curColor = texture2D(uSampler, vec2(vTextureCoord.x + curDistanceX - offsetX, vTextureCoord.y + curDistanceY + offsetY));\r\n totalAlpha += (linearSamplingTimes - i) * curColor.a;\r\n }\r\n maxTotalAlpha += (linearSamplingTimes - i);\r\n }\r\n }\r\n\r\n ownColor.a = max(ownColor.a, 0.0001);\r\n ownColor.rgb = ownColor.rgb / ownColor.a;\r\n\r\n float outerGlowAlpha = (totalAlpha / maxTotalAlpha) * strength * alpha * (1. - inner) * max(min(hideObject, knockout), 1. - ownColor.a);\r\n float innerGlowAlpha = ((maxTotalAlpha - totalAlpha) / maxTotalAlpha) * strength * alpha * inner * ownColor.a;\r\n\r\n ownColor.a = max(ownColor.a * knockout * (1. - hideObject), 0.0001);\r\n vec3 mix1 = mix(ownColor.rgb, color.rgb, innerGlowAlpha / (innerGlowAlpha + ownColor.a));\r\n vec3 mix2 = mix(mix1, color.rgb, outerGlowAlpha / (innerGlowAlpha + ownColor.a + outerGlowAlpha));\r\n float resultAlpha = min(ownColor.a + outerGlowAlpha + innerGlowAlpha, 1.);\r\n gl_FragColor = vec4(mix2 * resultAlpha, resultAlpha);\r\n}",e.primitive_frag="precision lowp float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\n\r\nvoid main(void) {\r\n gl_FragColor = vColor;\r\n}",e.texture_frag="precision lowp float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\nuniform sampler2D uSampler;\r\n\r\nvoid main(void) {\r\n gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;\r\n}",e.texture_etc_alphamask_frag="precision lowp float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\nuniform sampler2D uSampler;\r\nuniform sampler2D uSamplerAlphaMask;\r\nvoid main(void) {\r\nfloat alpha = texture2D(uSamplerAlphaMask, vTextureCoord).r;\r\nif (alpha < 0.0039) { discard; }\r\nvec4 v4Color = texture2D(uSampler, vTextureCoord);\r\nv4Color.rgb = v4Color.rgb * alpha;\r\nv4Color.a = alpha;\r\ngl_FragColor = v4Color * vColor;\r\n}",e.colorTransform_frag_etc_alphamask_frag="precision mediump float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\nuniform mat4 matrix;\r\nuniform vec4 colorAdd;\r\nuniform sampler2D uSampler;\r\nuniform sampler2D uSamplerAlphaMask;\r\n\r\nvoid main(void){\r\nfloat alpha = texture2D(uSamplerAlphaMask, vTextureCoord).r;\r\nif (alpha < 0.0039) { discard; }\r\nvec4 texColor = texture2D(uSampler, vTextureCoord);\r\nif(texColor.a > 0.0) {\r\n // 抵消预乘的alpha通道\r\ntexColor = vec4(texColor.rgb / texColor.a, texColor.a);\r\n}\r\nvec4 v4Color = clamp(texColor * matrix + colorAdd, 0.0, 1.0);\r\nv4Color.rgb = v4Color.rgb * alpha;\r\nv4Color.a = alpha;\r\ngl_FragColor = v4Color * vColor;\r\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/bin-release/web/191201225322/js/game.min_16249d0f.js b/bin-release/web/191201225322/js/game.min_16249d0f.js new file mode 100644 index 0000000..85fb4ee --- /dev/null +++ b/bin-release/web/191201225322/js/game.min_16249d0f.js @@ -0,0 +1,2 @@ +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&&i.source.setAttribute("bitmapSrc",a);var o=new t.Texture;o._setBitmapData(i),e.data=o,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.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;hi;i++){e=arguments[i];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},__awaiter=this&&this.__awaiter||function(t,e,i,s){return new(i||(i=Promise))(function(a,n){function r(t){try{h(s.next(t))}catch(e){n(e)}}function o(t){try{h(s["throw"](t))}catch(e){n(e)}}function h(t){t.done?a(t.value):new i(function(e){e(t.value)}).then(r,o)}h((s=s.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){function i(t){return function(e){return s([t,e])}}function s(i){if(a)throw new TypeError("Generator is already executing.");for(;h;)try{if(a=1,n&&(r=n[2&i[0]?"return":i[0]?"throw":"next"])&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[0,r.value]),i[0]){case 0:case 1:r=i;break;case 4:return h.label++,{value:i[1],done:!1};case 5:h.label++,n=i[1],i=[0];continue;case 7:i=h.ops.pop(),h.trys.pop();continue;default:if(r=h.trys,!(r=r.length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){h=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]3&&(this.status=1,this.speedBall=0),this.status>2?this.cxk.texture=RES.getRes("paddle_2_png"):this.cxk.texture=RES.getRes("paddle_1_png"),this.status=this.status+.1,this.changeBall()):1===this.step?(this.cxk.texture=RES.getRes("paddle_2_png"),this.ball.y=30,this.cxk.height>40&&(this.cxk.height-=.6,this.cxk.y+=.6)):2===this.step&&(this.cxk.texture=RES.getRes("paddle_3_png"),this.cxk.height=62,this.cxk.y=0,this.shotStatus+=.4,this.shotStatus>1&&(this.cxk.texture=RES.getRes("paddle_4_png")))},e.prototype.changeBall=function(){this.status>2?this.ball.y=15+10*this.speedBall:this.ball.y=40-10*this.speedBall,this.speedBall+=.15},e.prototype.createBitmapByName=function(t){var e=new egret.Bitmap,i=RES.getRes(t);return e.texture=i,e},e}(egret.DisplayObjectContainer);__reflect(CXK.prototype,"CXK");var LoadingUI=function(t){function e(){var e=t.call(this)||this;return e.createView(),e}return __extends(e,t),e.prototype.createView=function(){this.textField=new egret.TextField,this.addChild(this.textField),this.textField.textColor=5619787,this.textField.width=480,this.textField.height=100},e.prototype.onProgress=function(t,e){this.textField.text="正在加载..."+t+"/"+e},e}(egret.Sprite);__reflect(LoadingUI.prototype,"LoadingUI",["RES.PromiseTaskReporter"]);var getTimer=egret.getTimer,Main=function(t){function e(){var e=t.call(this)||this;return e.ballT=0,e.gameStatus=0,e.powerEarn=0,e.ballCount=10,e.totalPoint=0,e.addEventListener(egret.Event.ADDED_TO_STAGE,e.onAddToStage,e),e.addEventListener(egret.TouchEvent.TOUCH_BEGIN,e.onTouchBeginState,e),e.addEventListener(egret.TouchEvent.TOUCH_END,e.onTouchEndState,e),e.addEventListener(egret.Event.ENTER_FRAME,e.onEnterFrame,e),e}return __extends(e,t),e.prototype.onAddToStage=function(t){egret.lifecycle.addLifecycleListener(function(t){t.onUpdate=function(){}}),egret.lifecycle.onPause=function(){egret.ticker.pause()},egret.lifecycle.onResume=function(){egret.ticker.resume()},this.runGame()["catch"](function(t){console.log(t)})},e.prototype.runGame=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,this.loadResource()];case 1:return t.sent(),this.createGameScene(),[2]}})})},e.prototype.loadResource=function(){return __awaiter(this,void 0,void 0,function(){var t,e;return __generator(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),t=new LoadingUI,this.stage.addChild(t),[4,RES.loadConfig("resource/default.res.json","resource/")];case 1:return i.sent(),[4,RES.loadGroup("preload",0,t)];case 2:return i.sent(),this.scale_intro=RES.getRes("scale_intro_mp3"),this.scale_circle=RES.getRes("scale_loop_mp3"),this.shotSound=RES.getRes("launch_mp3"),this.bingoSound=RES.getRes("point_mp3"),this.dieSound=RES.getRes("die_mp3"),this.stage.removeChild(t),[3,4];case 3:return e=i.sent(),console.error(e),[3,4];case 4:return[2]}})})},e.prototype.drawBallCountAndScore=function(){this.ballCountText.text="x"+this.ballCount.toString(),this.pointText.text="得分:"+this.totalPoint.toString()},e.prototype.createGameScene=function(){var t=this.stage.stageWidth,e=this.stage.stageHeight,i=new egret.Shape;i.graphics.beginFill(16777215,1),i.graphics.drawRect(0,0,t,e),i.graphics.endFill(),this.addChild(i);var s=this.createBitmapByName("bg_png");this.addChild(s),s.width=t,s.height=t/(1102/1172),s.y=(e-s.height)/2,this.cxk=new CXK,this.addChild(this.cxk),this.cxk.x=349,this.cxk.y=s.y+231;var a=new Ball;this.addChild(a),a.x=156,a.y=325,a.alpha=0,this.ball2=a,this.touchEnabled=!0,this.scoreboardImg=new ScoreBoard,this.scoreboardImg.touchEnabled=!0,this.scoreboardImg.addEventListener(egret.TouchEvent.TOUCH_TAP,this.restart,this);var n=new egret.TextField;this.addChild(n),n.textColor=1748249,n.x=200,n.y=900,n.text="长按蓄力,松开投球",this.pointText=new egret.TextField,this.addChild(this.pointText),this.pointText.x=400,this.pointText.y=5,this.pointText.textColor=3355443,this.pointText.size=28,this.ballCountText=new egret.TextField,this.addChild(this.ballCountText),this.ballCountText.x=60,this.ballCountText.y=5,this.ballCountText.size=28,this.ballCountText.textColor=3355443,this.ball3=this.createBitmapByName("ball_png"),this.addChild(this.ball3),this.ball3.y=5,this.ball3.x=25,this.ball3.width=25,this.ball3.height=25,this.drawBallCountAndScore()},e.prototype.restart=function(){console.log("restart"),4===this.gameStatus&&(this.removeChild(this.scoreboardImg),this.gameStatus=0,this.totalPoint=0,this.ballCount=10,this.drawBallCountAndScore())},e.prototype.onEnterFrame=function(){(2===this.gameStatus||3===this.gameStatus)&&this.ballSport(),1===this.gameStatus&&(this.powerEarn=this.powerEarn+1/66)},e.prototype.onTouchBeginState=function(){var t=this;console.log("touch begin"),0===this.gameStatus&&(this.gameStatus=1,this.powerEarn=0,this.ballT=0,this.scaleChannel=this.scale_intro.play(0,1),setTimeout(function(){1===t.gameStatus&&(t.scaleChannel.stop(),t.scaleChannel=t.scale_circle.play(0,0))},2200),this.cxk.prepare())},e.prototype.onTouchEndState=function(){console.log("touch end"),1===this.gameStatus&&(this.ballT=0,this.gameStatus=2,this.scaleChannel.stop(),this.shotSound.play(0,1),this.cxk.shot(),this.ballCount--,this.drawBallCountAndScore(),this.ball=new Ball,this.addChild(this.ball),this.ball.alpha=0)},e.prototype.ballSport=function(){var t=this,e=.015,i=this.ballT,s={x:350,y:445},a={x:250,y:200+320*(.5-this.powerEarn)},n=__assign({},a),r={x:100+160*(.5-this.powerEarn),y:400},o=3*(a.x-s.x),h=3*(n.x-a.x)-o,l=r.x-s.x-o-h,c=3*(a.y-s.y),u=3*(n.y-a.y)-c,d=r.y-s.y-c-u,p=l*(i*i*i)+h*(i*i)+o*i+s.x,g=d*(i*i*i)+u*(i*i)+c*i+s.y;this.ballT+=e,this.ballT>1&&(this.ballT=1),this.ball.alpha=1;var x=function(){t.gameStatus=0,t.cxk.reset(),t.removeChild(t.ball),t.ballCount<=0&&(t.gameStatus=4,t.addChildAt(t.scoreboardImg,10),t.scoreboardImg.x=(t.stage.stageWidth-t.scoreboardImg.scoreBoard.width)/2,t.scoreboardImg.y=(t.stage.stageHeight-t.scoreboardImg.scoreBoard.height)/2,console.log(t.scoreboardImg.x,t.scoreboardImg.y),t.scoreboardImg.setCurrentPoint(t.totalPoint)),t.drawBallCountAndScore()};if(3===this.gameStatus)this.ball.y=g,g>=r.y-1&&(this.totalPoint++,x());else if(2===this.gameStatus){var y=this.ball2.hitTestPoint(this.ball.x+5,this.ball.y+5);y&&(this.bingoSound.play(0,1),this.gameStatus=3),this.ball.x=p,this.ball.y=g}this.ball.y>=r.y-1&&this.ball.x<=r.x+1&&2===this.gameStatus&&(this.dieSound.play(0,1),x())},e.prototype.createBitmapByName=function(t){var e=new egret.Bitmap,i=RES.getRes(t);return e.texture=i,e},e}(egret.DisplayObjectContainer);__reflect(Main.prototype,"Main");var ScoreBoard=function(t){function e(){var e=t.call(this)||this;return e.currentPoint=0,e.maxPoint=0,e.addEventListener(egret.Event.ADDED_TO_STAGE,e.init,e),e}return __extends(e,t),e.prototype.createBitmapByName=function(t){var e=new egret.Bitmap;return e.texture=RES.getRes(t),e},e.prototype.setCurrentPoint=function(t){this.currentPoint=t,t>this.maxPoint&&(this.maxPoint=t),this.currentPointText.text=this.currentPoint+"",this.maxPointText.text=this.maxPoint+""},e.prototype.init=function(){var t=new egret.DisplayObjectContainer;this.scoreBoard=this.createBitmapByName("scoreboard_png"),t.width=this.scoreBoard.width,t.height=this.scoreBoard.height,this.width=t.width,this.height=t.height,t.addChild(this.scoreBoard),this.currentPointText=new egret.TextField,this.maxPointText=new egret.TextField,t.addChild(this.currentPointText),t.addChild(this.maxPointText),this.currentPointText.y=this.scoreBoard.height/2.5,this.currentPointText.textColor=13369344,this.maxPointText.textColor=13369344,this.maxPointText.y=this.scoreBoard.height/1.65,this.currentPointText.x=this.scoreBoard.width/2,this.maxPointText.x=this.scoreBoard.width/2,this.addChild(t)},e}(egret.DisplayObjectContainer);__reflect(ScoreBoard.prototype,"ScoreBoard"); \ No newline at end of file diff --git a/bin-release/web/191201225322/js/promise.min_83a6a5d.js b/bin-release/web/191201225322/js/promise.min_83a6a5d.js new file mode 100644 index 0000000..765fa21 --- /dev/null +++ b/bin-release/web/191201225322/js/promise.min_83a6a5d.js @@ -0,0 +1 @@ +!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/bin-release/web/191201225322/js/tween.min_6c5a88f9.js b/bin-release/web/191201225322/js/tween.min_6c5a88f9.js new file mode 100644 index 0000000..abe1c4b --- /dev/null +++ b/bin-release/web/191201225322/js/tween.min_6c5a88f9.js @@ -0,0 +1 @@ +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/bin-release/web/191201225322/resource/default.res.json b/bin-release/web/191201225322/resource/default.res.json new file mode 100644 index 0000000..cf4941e --- /dev/null +++ b/bin-release/web/191201225322/resource/default.res.json @@ -0,0 +1,80 @@ +{ + "groups": [ + { + "keys": "egret_icon_png,description_json,bg_png,ball_png,paddle_4_png,paddle_3_png,paddle_2_png,paddle_1_png,launch_mp3,die_mp3,point_mp3,scale_loop_mp3,scale_intro_mp3,scoreboard_png", + "name": "preload" + } + ], + "resources": [ + { + "url": "assets/egret_icon.png", + "type": "image", + "name": "egret_icon_png" + }, + { + "url": "config/description.json", + "type": "json", + "name": "description_json" + }, + { + "url": "assets/bg.png", + "type": "image", + "name": "bg_png" + }, + { + "url": "assets/ball.png", + "type": "image", + "name": "ball_png" + }, + { + "url": "assets/paddle_2.png", + "type": "image", + "name": "paddle_1_png" + }, + { + "url": "assets/paddle2_2.png", + "type": "image", + "name": "paddle_2_png" + }, + { + "url": "assets/paddle3_2.png", + "type": "image", + "name": "paddle_3_png" + }, + { + "url": "assets/paddle4_1.png", + "type": "image", + "name": "paddle_4_png" + }, + { + "url": "assets/die.mp3", + "type": "sound", + "name": "die_mp3" + }, + { + "url": "assets/launch.mp3", + "type": "sound", + "name": "launch_mp3" + }, + { + "url": "assets/point.mp3", + "type": "sound", + "name": "point_mp3" + }, + { + "url": "assets/scale_intro.mp3", + "type": "sound", + "name": "scale_intro_mp3" + }, + { + "url": "assets/scale_loop.mp3", + "type": "sound", + "name": "scale_loop_mp3" + }, + { + "url": "assets/scoreboard.png", + "type": "image", + "name": "scoreboard_png" + } + ] +} \ No newline at end of file diff --git a/egretProperties.json b/egretProperties.json new file mode 100644 index 0000000..3d4de8a --- /dev/null +++ b/egretProperties.json @@ -0,0 +1,25 @@ +{ + "engineVersion": "5.2.31", + "compilerVersion": "5.2.31", + "template": {}, + "target": { + "current": "web" + }, + "modules": [ + { + "name": "egret" + }, + { + "name": "game" + }, + { + "name": "tween" + }, + { + "name": "assetsmanager" + }, + { + "name": "promise" + } + ] +} \ No newline at end of file diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..e4ec42c Binary files /dev/null and b/favicon.ico differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..7d47df3 --- /dev/null +++ b/index.html @@ -0,0 +1,97 @@ + + + + + + Egret + + + + + + + + + + +
正在加载...0/14
+
+
+ + + + \ No newline at end of file diff --git a/libs/modules/assetsmanager/assetsmanager.d.ts b/libs/modules/assetsmanager/assetsmanager.d.ts new file mode 100644 index 0000000..97a9ee1 --- /dev/null +++ b/libs/modules/assetsmanager/assetsmanager.d.ts @@ -0,0 +1,1522 @@ +declare namespace RES { + /** + * Version control loading interface + * @version Egret 2.4 + * @platform Web,Native + * @includeExample extension/version/VersionControl.ts + * @language en_US + */ + /** + * 版本控制加载的接口 + * @version Egret 2.4 + * @platform Web,Native + * @includeExample extension/version/VersionControl.ts + * @language zh_CN + */ + interface IVersionController { + /** + * Get the version information data.
+ * Before calling this method requires the application of any resource load, we recommend starting at the application entry class (Main) The first call processing. This method is only responsible for acquiring version information, is not responsible for downloaded resources. + * @version Egret 2.4 + * @platform Web,Native + * @language en_US + */ + /** + * 获取版本信息数据。
+ * 这个方法的调用需要在应用程序进行任何资源加载之前,建议在应用程序的入口类(Main)的开始最先进行调用处理。此方法只负责获取版本信息,不负责资源的下载。 + * @version Egret 2.4 + * @platform Web,Native + * @language zh_CN + */ + init(): Promise; + /** + * Get the actual URL of the resource file.
+ * Because this method needs to be called to control the actual version of the URL have the original resource files were changed, so would like to get the specified resource file the actual URL.
+ * In the development and debugging phase, this method will directly return value passed. + * @param url Url used in the game + * @returns Actual loaded url + * @version Egret 2.4 + * @platform Web,Native + * @language en_US + */ + /** + * 获取资源文件实际的URL地址。
+ * 由于版本控制实际已经对原来的资源文件的URL进行了改变,因此想获取指定资源文件实际的URL时需要调用此方法。
+ * 在开发调试阶段,这个方法会直接返回传入的参数值。 + * @param url 游戏中使用的url + * @returns 实际加载的url + * @version Egret 2.4 + * @platform Web,Native + * @language zh_CN + */ + getVirtualUrl(url: string): string; + } + /** + * Manage version control class + * @version Egret 2.4 + * @platform Web,Native + * @event egret.Event.COMPLETE Version control loading is complete when thrown + * @event egret.IOErrorEvent.IO_ERROR Version control failed to load when thrown + * @includeExample extension/version/VersionControl.ts + * @language en_US + */ + /** + * 管理版本控制的类 + * @version Egret 2.4 + * @platform Web,Native + * @event egret.Event.COMPLETE 版本控制加载完成时抛出 + * @event egret.IOErrorEvent.IO_ERROR 版本控制加载失败时抛出 + * @includeExample extension/version/VersionControl.ts + * @language zh_CN + */ + interface VersionController extends IVersionController { + } + /** + * @version Egret 2.4 + * @platform Web,Native + */ + let VersionController: { + /** + * Constructor initialization + * @language en_US + */ + /** + * 初始化构造函数 + * @language zh_CN + */ + new (): VersionController; + }; +} +declare type ResourceRootSelector = () => T; +declare type ResourceNameSelector = (file: string) => string; +declare type ResourceMergerSelector = (file: string) => { + path: string; + alias: string; +}; +declare module RES { + /** + * Get resource information through file path + * @param path file path + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 通过文件路径获取资源信息 + * @param path 文件路径 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function getResourceInfo(path: string): File | null; + /** + * @private + */ + interface ResourceInfo { + url: string; + type: string; + root: string; + crc32?: string; + size?: number; + extra?: 1 | undefined; + name: string; + soundType?: string; + scale9grid?: string; + groupNames?: string[]; + promise?: Promise; + } + /** + * @private + */ + interface Data { + resourceRoot: string; + mergeSelector: ResourceMergerSelector | null; + fileSystem: FileSystem; + groups: { + [groupName: string]: string[]; + }; + alias: { + [aliasName: string]: string; + }; + loadGroup: string[]; + } + /** + * @class RES.ResourceConfig + * @classdesc + * @private + */ + class ResourceConfig { + config: Data; + constructor(); + init(): Promise; + /** + * 根据组名获取组加载项列表 + * @method RES.ResourceConfig#getGroupByName + * @param name {string} 组名 + * @returns {Array} + */ + getGroupByName(name: string): ResourceInfo[]; + __temp__get__type__via__url(url_or_alias: string): string; + getResourceWithSubkey(key: string): { + r: ResourceInfo; + key: string; + subkey: string; + } | null; + getKeyByAlias(aliasName: string): string; + getResource(path_or_alias: string): ResourceInfo | null; + /** + * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 + * 可以监听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; + addResourceData(data: { + name: string; + type: string; + url: string; + root?: string; + extra?: 1 | undefined; + }): void; + removeResourceData(data: { + name: string; + type?: string; + url: string; + root?: string; + extra?: 1 | undefined; + }): void; + } +} +declare module RES { + /** + * @class RES.ResourceLoader + * @classdesc + * @private + */ + class ResourceLoader { + /** + * 当前组加载的项总个数,key为groupName + */ + private groupTotalDic; + /** + * 已经加载的项个数,key为groupName + */ + private numLoadedDic; + /** + * 加载失败的组,key为groupName + */ + private groupErrorDic; + private retryTimesDic; + maxRetryTimes: number; + private reporterDic; + private dispatcherDic; + private failedList; + private loadItemErrorDic; + private errorDic; + /** + * 资源优先级队列,key为资源,value为优先级 + */ + private itemListPriorityDic; + /** + * 资源是否在加载 + */ + private itemLoadDic; + private promiseHash; + /** + * 延迟加载队列,getResByUrl ,getResAsync等方法存储队列 + */ + private lazyLoadList; + pushResItem(resInfo: ResourceInfo): Promise; + /** + * 加载队列,存储组的队列 + */ + pushResGroup(list: ResourceInfo[], groupName: string, priority: number, reporter?: PromiseTaskReporter): Promise; + /** + * 更新组的优先级顺序 + * @param list 存储数据的队列 + * @param priority 优先级 + */ + private updatelistPriority(list, priority); + /** + * 搜索单项资源的优先级 + * @param item 单项资源 + */ + private findPriorityInDic(item); + private loadingCount; + /** + * 最大线程数目 + */ + thread: number; + /** + * 加载下一项资源,线程控制 + */ + private loadNextResource(); + /** + * 加载单向资源 + */ + private loadSingleResource(); + /** + * 获取下一个待加载项 + */ + private getOneResourceInfoInGroup(); + /** + * 设置组的加载进度,同时返回当前组是否加载完成 + * @param groupName 组名 + * @param r 加载完成的资源 + */ + private setGroupProgress(groupName, r); + /** + * 加载组的最后一项,同时派发事件 + * @param groupName 组名 + * @param lastError 最后一项是否成功,此项为错误信息 + */ + private loadGroupEnd(groupName, lastError?); + /** + * 删除事件派发器,Promise的缓存,返回事件派发器 + * @param groupName 组名或是root+name + */ + private deleteDispatcher(groupName); + /** + * 加载资源 + * @param r 资源信息 + * @param p 加载处理器 + */ + private loadResource(r, p?); + /** + * 释放资源 + * @param r 资源信息 + */ + unloadResource(r: ResourceInfo): boolean; + } +} +declare module RES { +} +declare module RES { + type GetResAsyncCallback = (value?: any, key?: string) => any; + /** + * Convert the file name of the resource to the Key value used in the project. + * @param url Resource Name. + * @returns The key value used in the project + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 将资源的文件名称转换为项目中所使用的Key值。 + * 在加载合并图集的时候使用,例如图集加载A_json,需要加载对应A_png,这里就是转换的机制 + * 一般项目中无需更改,只有没有使用默认的key和文件对应的需要修改 + * @param url 资源名称。 + * @returns 项目中所用的key值 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function nameSelector(url: any): string; + /** + * Get the read type of the file. + * When using getResByUrl does not specify the type of the read file, it will find the corresponding type according to this method. + * File types not found are loaded by default in binary format + * @param path file path. + * @returns Processor type used to read the file + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 获取文件的读取类型 + * 在使用getResByUrl没有指定读取文件的类型,会根据这个方法寻找对应的类型 + * 没有查找到的文件类型以二进制格式默认加载 + * @param path 文件路径 + * @returns 读取文件所用的Processor类型 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function typeSelector(path: string): string; + /** + * Conduct mapping injection with class definition as the value, Deprecated. + * @deprecated + * @see RES.processor.map + * @language en_US + */ + /** + * 以类定义为值进行映射注入,已废弃。 + * @deprecated + * @see RES.processor.map + * @language zh_CN + */ + function registerAnalyzer(type: string, analyzerClass: any): void; + /** + * Set whether it is compatible mode + * When the value is true, the assetsManager will output the design of Res. When it is false, all the loaded resources will be returned as promises. + * The default is false, run in strict assetsManager mode + * @version Egret 5.2.9 + * @platform Web,Native + * @language en_US + */ + /** + * 设置是否为兼容模式 + * 当值为true时,assetsManager会以Res的设计输出,当为false时候,所有的加载资源都会以promise的方式返回 + * 默认是false,以严格assetsManager方式运行 + * @version Egret 5.2.9 + * @platform Web,Native + * @language zh_CN + */ + function setIsCompatible(value: boolean): void; + /** + * Load configuration file and parse. + * @param url The url address of the resource config + * @param resourceRoot The root address of the resource config + * @returns Promise + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 加载配置文件并解析。 + * @param url 资源配置的url地址 + * @param resourceRoot 资源配置的根地址 + * @returns Promise + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @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. + * @param reporter Resource group loading progress prompt + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 根据组名加载一组资源。 + * @param name 要加载资源组的组名。 + * @param priority 加载优先级,可以为负数,默认值为 0。 + *
低优先级的组必须等待高优先级组完全加载结束才能开始,同一优先级的组会同时加载。 + * @param reporter 资源组的加载进度提示 + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 检查某个资源组是否已经加载完成。 + * @param name 组名。 + * @returns 是否正在加载。 + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 根据组名获取组加载项列表。 + * @param name 组名。 + * @returns 加载项列表。 + * @see RES.ResourceItem + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 + *
可以监听 ResourceEvent.CONFIG_COMPLETE 事件来确认配置加载完成。 + * @param name 要创建的加载资源组的组名。 + * @param keys 要包含的键名列表,key 对应配置文件里的 name 属性或 sbuKeys 属性的一项或一个资源组名。 + * @param override 是否覆盖已经存在的同名资源组,默认 false。 + * @returns 是否创建成功。 + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @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. + * @returns Whether you have the specified resource + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 检查配置文件里是否含有指定的资源。 + * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 + * @returns 是否拥有指定资源 + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @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 5.2 + * @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 5.2 + * @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. + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 异步方式获取配置里的资源。只要是配置文件里存在的资源,都可以通过异步方式获取。 + * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function getResAsync(key: string): Promise; + /** + * 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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 异步方式获取配置里的资源。只要是配置文件里存在的资源,都可以通过异步方式获取。 + * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 + * @param compFunc 回调函数。示例:compFunc(data,key):void。 + * @param thisObject 回调函数的 this 引用。 + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function getResAsync(key: string, compFunc: GetResAsyncCallback, thisObject: any): Promise | 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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 通过完整URL方式获取外部资源。 + * @param url 要加载文件的外部路径。 + * @param compFunc 回调函数。示例:compFunc(data,url):void。 + * @param thisObject 回调函数的 this 引用。 + * @param type 文件类型(可选)。请使用 ResourceItem 类中定义的静态常量。若不设置将根据文件扩展名生成。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function getResByUrl(url: string, compFunc?: Function, thisObject?: any, type?: string): Promise; + /** + * 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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。 + * @param name 配置文件中加载项的name属性或资源组名。 + * @param force 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值 true。 + * @see #setMaxRetryTimes + * @returns 是否销毁成功。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function destroyRes(name: string, force?: boolean): boolean; + /** + * Sets the maximum number of concurrent load threads, the default value is 4. + * @param thread The number of concurrent loads to be set. + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 设置最大并发加载线程数量,默认值是 4。 + * @param thread 要设置的并发加载数。 + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 设置资源加载失败时的重试次数,默认值是 3。 + * @param retry 要设置的重试次数。 + * @includeExample extension/resource/Resource.ts + * @version Egret 5.2 + * @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 5.2 + * @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 5.2 + * @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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 移除事件侦听器,参考ResourceEvent定义的常量。 + * @param type 事件名。 + * @param listener 侦听函数。 + * @param thisObject 侦听函数绑定的this对象。 + * @param useCapture 是否使用捕获,这个属性只在显示列表中生效。 + * @version Egret 5.2 + * @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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 自定义添加一项资源配置。 + * @param data 要添加的配置。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function $addResourceData(data: { + name: string; + type: string; + url: string; + }): void; + /** + * Returns the VersionController + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 获得版本控制器. + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function getVersionController(): VersionController; + /** + * Register the VersionController + * @param vcs The VersionController to register. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 注册版本控制器,通过RES模块加载资源时会从版本控制器获取真实url + * @param vcs 注入的版本控制器。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function registerVersionController(vcs: VersionController): void; + /** + * Convert the address of the loaded resource (via version controller conversion) + * @param url path to the original resource + * @returns converted address + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 转换加载资源的地址(经过版本控制器的转换) + * @param url 原始资源的路径 + * @returns 转换后的地址 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function getVirtualUrl(url: any): any; + /** + * @private + */ + class Resource extends egret.EventDispatcher { + vcs: VersionController; + isVcsInit: boolean; + constructor(); + registerVersionController(vcs: VersionController): void; + /** + * 开始加载配置 + * @method RES.loadConfig + */ + loadConfig(): Promise; + /** + * @private + * 版本控制器加载后的加载配置 + */ + private normalLoadConfig; + /** + * 检查某个资源组是否已经加载完成 + * @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?); + /** + * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 + * 可以监听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): Promise; + /** + * 通过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; + /** + * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。 + * @method RES.destroyRes + * @param name {string} 配置文件中加载项的name属性或资源组名 + * @param force {boolean} 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值true + * @returns {boolean} + */ + destroyRes(name: string, force?: boolean): boolean; + /** + * 设置最大并发加载线程数量,默认值是4. + * @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; + } +} +declare namespace RES { + /** + * Print the memory occupied by the picture. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 对文件路径的一些操作,针对的是 C:/A/B/C/D/example.ts这种格式 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + namespace path { + /** + * Format the file path,"C:/A/B//C//D//example.ts"=>"C:/A/B/C/D/example.ts" + * @param filename Incoming file path + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 格式化文件路径,"C:/A/B//C//D//example.ts"=>"C:/A/B/C/D/example.ts" + * @param filename 传入的文件路径 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function normalize(filename: string): string; + /** + * Get the file name according to the file path, "C:/A/B/example.ts"=>"example.ts" + * @param filename Incoming file path + * @return File name + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 根据文件路径得到文件名字,"C:/A/B/example.ts"=>"example.ts" + * @param filename 传入的文件路径 + * @return 文件的名字 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function basename(filename: string): string; + /** + * The path to the folder where the file is located,"C:/A/B/example.ts"=>"C:/A/B" + * @param filename Incoming file path + * @return The address of the folder where the file is located + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 文件所在文件夹路径,"C:/A/B/example.ts"=>"C:/A/B" + * @param filename 传入的文件路径 + * @return 文件所在文件夹的地址 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function dirname(path: string): string; + } +} +declare namespace RES { + /** + * @private + */ + class NativeVersionController implements IVersionController { + private versionInfo; + init(): Promise; + getVirtualUrl(url: string): string; + private getLocalData(filePath); + } +} +declare module RES.processor { + interface Processor { + /** + * Start loading a single resource + * @param host Load the processor, you can use the processor to load resources, directly use http to get the resources back + * @param resource Resource information + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 开始加载单项资源 + * @param host 加载处理器,可以不使用这个处理器加载资源,直接用http获取资源返回即可 + * @param resource 资源的信息 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + onLoadStart(host: ProcessHost, resource: ResourceInfo): Promise; + /** + * Remove a single resource, usually call host.unload (resource); + * @param host Load the processor + * @param resource Resource information + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 移除单项资源,一般调用host.unload(resource); + * @param host 加载处理器 + * @param resource 资源的信息 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + onRemoveStart(host: ProcessHost, resource: ResourceInfo): void; + /** + * Get the submap of the merged atlas + * @param host Load the processor + * @param resource Resource information + * @param key The key value of the resource + * @param subkey Collection of subset names + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 获取合并图集的子图 + * @param host 加载处理器 + * @param resource 资源的信息 + * @param key 资源的key值 + * @param subkey 子集名称的集合 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + getData?(host: ProcessHost, resource: ResourceInfo, key: string, subkey: string): any; + } + /** + * Register the processor that loads the resource + * @param type Load resource type + * @param processor Loaded processor, an instance that implements the Processor interface + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 注册加载资源的处理器 + * @param type 加载资源类型 + * @param processor 加载的处理器,一个实现Processor接口的实例 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function map(type: string, processor: Processor): void; + /** + * @private + * @param url + * @param file + */ + function getRelativePath(url: string, file: string): string; + var ImageProcessor: Processor; + const KTXTextureProcessor: RES.processor.Processor; + /** + * + */ + function makeEtc1SeperatedAlphaResourceInfo(resource: ResourceInfo): ResourceInfo; + /** + * + */ + const ETC1KTXProcessor: Processor; + var BinaryProcessor: Processor; + var TextProcessor: Processor; + var JsonProcessor: Processor; + var SoundProcessor: Processor; +} +declare module RES { + /** + * The events of resource loading. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 资源加载事件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + class ResourceEvent extends egret.Event { + /** + * Failure event for a load item. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 一个加载项加载失败事件。 + * @version Egret 5.2 + * @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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 配置文件加载并解析完成事件。注意:若有配置文件加载失败,将不会抛出此事件,若要处理配置加载失败,请同时监听 CONFIG_LOAD_ERROR 事件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + static CONFIG_COMPLETE: string; + /** + * Configuration file failed to load. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 配置文件加载失败事件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + static CONFIG_LOAD_ERROR: string; + /** + * Delay load group resource loading progress event. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 延迟加载组资源加载进度事件。 + * @version Egret 5.2 + * @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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 延迟加载组资源加载完成事件。注意:若组内有资源项加载失败,将不会抛出此事件,若要处理组加载失败,请同时监听 GROUP_LOAD_ERROR 事件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + static GROUP_COMPLETE: string; + /** + * Delayed load group resource failed event. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 延迟加载组资源加载失败事件。 + * @version Egret 5.2 + * @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 5.2 + * @platform Web,Native + * @private + * @language en_US + */ + /** + * 创建一个作为参数传递给事件侦听器的 Event 对象。 + * @param type 事件的类型,可以作为 Event.type 访问。 + * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 + * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 + * @version Egret 5.2 + * @platform Web,Native + * @private + * @language zh_CN + */ + constructor(type: string, bubbles?: boolean, cancelable?: boolean); + /** + * File number that has been loaded. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 已经加载的文件数。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + itemsLoaded: number; + /** + * Total file number to load. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 要加载的总文件数。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + itemsTotal: number; + /** + * Resource group name. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 资源组名。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + groupName: string; + /** + * An item of information that is finished by the end of a load. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 一次加载项加载结束的项信息对象。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + resItem: ResourceItem; + } +} +declare module RES { + /** + * Resource term. One of the resources arrays in resource.json. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 资源项。对应 resource.json 中 resources 数组中的一项。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + namespace ResourceItem { + /** + * XML file. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * XML 文件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + const TYPE_XML: string; + /** + * Picture file. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 图片文件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + const TYPE_IMAGE: string; + /** + * Binary file. + * @version Egret 5.2 + * @platform Web + * @language en_US + */ + /** + * 二进制文件。 + * @version Egret 5.2 + * @platform Web + * @language zh_CN + */ + const TYPE_BIN: string; + /** + * Text file. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 文本文件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + const TYPE_TEXT: string; + /** + * JSON file. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * JSON 文件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + const TYPE_JSON: string; + /** + * SpriteSheet file. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * SpriteSheet 文件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + const TYPE_SHEET: string; + /** + * BitmapTextSpriteSheet file. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * BitmapTextSpriteSheet 文件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + const TYPE_FONT: string; + /** + * Sound file. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 声音文件。 + * @version Egret 5.2 + * @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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 加载项名称。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + name: string; + /** + * URL of resource term. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 要加载的文件地址。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + url: string; + /** + * Type of resource term. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 加载项文件类型。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + type: string; + /** + * The raw data object to be referenced. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 被引用的原始数据对象。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + data: ResourceInfo; + crc32?: string; + size?: number; + soundType?: string; + } +} +declare module RES { + /** + * assetsManager underlying storage resource information + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * assetsManager底层存储资源信息 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + interface File { + url: string; + type: string; + name: string; + root: string; + } + /** + * @private + */ + interface FileSystem { + addFile(data: { + name: string; + type: string; + url: string; + root?: string; + extra?: 1 | undefined; + }): any; + getFile(filename: string): File | null; + profile(): void; + removeFile(filename: string): any; + } +} +declare module RES { + /** + * Print the memory occupied by the picture. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 打印图片所占内存 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function profile(): void; + /** + * @private + */ + interface ProcessHost { + state: { + [index: string]: number; + }; + resourceConfig: ResourceConfig; + load: (resource: ResourceInfo, processor?: string | processor.Processor) => Promise; + unload: (resource: ResourceInfo) => void; + save: (rexource: ResourceInfo, data: any) => void; + get: (resource: ResourceInfo) => any; + remove: (resource: ResourceInfo) => void; + } + /** + * @private + */ + class ResourceManagerError extends Error { + static errorMessage: { + 1001: string; + 1002: 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 { + /** + * Resource group loading progress prompt + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 资源组的加载进度提示 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + interface PromiseTaskReporter { + /** + * Progress callback, asynchronous execution, load number and order have nothing to do + * @param current The number of currently loaded + * @param total Total resources required in the current resource bundle + * @param resItem currently loading resource information + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 进度回调,异步执行,加载数目和顺序无关 + * @param current 当前已经加载数目 + * @param total 当前资源包内需要资源总数 + * @param resItem 当前加载资源信息 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + onProgress?(current: number, total: number, resItem: ResourceInfo | undefined): void; + } +} diff --git a/libs/modules/assetsmanager/assetsmanager.js b/libs/modules/assetsmanager/assetsmanager.js new file mode 100644 index 0000000..8a02b53 --- /dev/null +++ b/libs/modules/assetsmanager/assetsmanager.js @@ -0,0 +1,2992 @@ +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 __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; +}; +////////////////////////////////////////////////////////////////////////////////////// +// +// 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 || (RES = {})); +var RES; +(function (RES) { + /** + * @internal + */ + RES.resourceNameSelector = function (p) { return p; }; + /** + * Get resource information through file path + * @param path file path + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 通过文件路径获取资源信息 + * @param path 文件路径 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function getResourceInfo(path) { + var result = RES.config.config.fileSystem.getFile(path); + if (!result) { + path = RES.resourceNameSelector(path); + result = RES.config.config.fileSystem.getFile(path); + } + return result; + } + RES.getResourceInfo = getResourceInfo; + var configItem; + /** + * 注册config的相关配置 + * @internal + * @param url config的地址 + * @param root 根路径 + */ + 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 () { + if (!this.config) { + this.config = { + alias: {}, groups: {}, resourceRoot: configItem.root, + mergeSelector: null, + fileSystem: null, + loadGroup: [] + }; + } + return RES.queue.pushResItem(configItem).catch(function (e) { + if (!RES.isCompatible) { + if (!e.__resource_manager_error__) { + if (e.error) { + console.error(e.error.stack); + } + else { + console.error(e.stack); + } + e = new RES.ResourceManagerError(1002); + } + } + RES.host.remove(configItem); + return Promise.reject(e); + }); + }; + /** + * 根据组名获取组加载项列表 + * @method RES.ResourceConfig#getGroupByName + * @param name {string} 组名 + * @returns {Array} + */ + ResourceConfig.prototype.getGroupByName = function (name) { + var group = this.config.groups[name]; + var result = []; + if (!group) { + return result; + } + for (var _i = 0, group_1 = group; _i < group_1.length; _i++) { + var paramKey = group_1[_i]; + var tempResult = void 0; + tempResult = RES.config.getResourceWithSubkey(paramKey); + if (tempResult == null) { + continue; + } + var r = tempResult.r, key = tempResult.key; + if (r == null) { + /** 加载组里面的资源,可能不存在 */ + throw new RES.ResourceManagerError(2005, key); + continue; + } + 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.typeSelector) { + var type = RES.typeSelector(url); + if (!type) { + throw new RES.ResourceManagerError(2004, url); + } + return type; + } + else { + console.warn("RES.mapConfig 并未设置 typeSelector"); + return "unknown"; + } + }; + ResourceConfig.prototype.getResourceWithSubkey = function (key) { + 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) { + 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) { + var path = this.config.alias[path_or_alias]; + if (!path) { + path = path_or_alias; + } + var r = getResourceInfo(path); + if (!r) { + return null; + } + else { + return r; + } + }; + /** + * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 + * 可以监听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; + }; + /** + * 添加一个二级键名到配置列表。 + * @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; + }; + 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.config.config.fileSystem.addFile(data); + }; + ResourceConfig.prototype.removeResourceData = function (data) { + if (!RES.hasRes(data.name)) { + return; + } + RES.config.config.fileSystem.removeFile(data.url); + if (this.config.alias[data.name]) { + delete this.config.alias[data.name]; + } + }; + 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.groupErrorDic = {}; + this.retryTimesDic = {}; + this.maxRetryTimes = 3; + this.reporterDic = {}; + this.dispatcherDic = {}; + this.failedList = new Array(); + this.loadItemErrorDic = {}; + this.errorDic = {}; + /** + * 资源优先级队列,key为资源,value为优先级 + */ + this.itemListPriorityDic = {}; + /** + * 资源是否在加载 + */ + this.itemLoadDic = {}; + this.promiseHash = {}; + /** + * 延迟加载队列,getResByUrl ,getResAsync等方法存储队列 + */ + this.lazyLoadList = new Array(); + this.loadingCount = 0; + /** + * 最大线程数目 + */ + this.thread = 4; + } + ResourceLoader.prototype.pushResItem = function (resInfo) { + if (this.promiseHash[resInfo.root + resInfo.name]) { + return this.promiseHash[resInfo.root + resInfo.name]; + } + this.lazyLoadList.push(resInfo); + this.itemListPriorityDic[Number.NEGATIVE_INFINITY] = this.lazyLoadList; + this.updatelistPriority(this.lazyLoadList, Number.NEGATIVE_INFINITY); + var dispatcher = new egret.EventDispatcher(); + this.dispatcherDic[resInfo.root + resInfo.name] = dispatcher; + var promise = new Promise(function (resolve, reject) { + dispatcher.addEventListener("complete", function (e) { + resolve(e.data); + }, null); + dispatcher.addEventListener("error", function (e) { + reject(e.data); + }, null); + }); + this.promiseHash[resInfo.root + resInfo.name] = promise; + this.loadNextResource(); + return promise; + }; + /** + * 加载队列,存储组的队列 + */ + ResourceLoader.prototype.pushResGroup = function (list, groupName, priority, reporter) { + if (this.promiseHash[groupName]) { + return this.promiseHash[groupName]; + } + 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.groupTotalDic[groupName] = list.length; + this.numLoadedDic[groupName] = 0; + this.updatelistPriority(list, priority); + this.reporterDic[groupName] = reporter; + var dispatcher = new egret.EventDispatcher(); + this.dispatcherDic[groupName] = dispatcher; + var promise = new Promise(function (resolve, reject) { + dispatcher.addEventListener("complete", resolve, null); + dispatcher.addEventListener("error", function (e) { + reject(e.data); + }, null); + }); + this.promiseHash[groupName] = promise; + this.loadNextResource(); + return promise; + }; + /** + * 更新组的优先级顺序 + * @param list 存储数据的队列 + * @param priority 优先级 + */ + ResourceLoader.prototype.updatelistPriority = function (list, priority) { + if (this.itemListPriorityDic[priority] == undefined) { + this.itemListPriorityDic[priority] = []; + } + for (var _i = 0, list_1 = list; _i < list_1.length; _i++) { + var item = list_1[_i]; + if (this.itemLoadDic[item.root + item.name] == 1) { + continue; + } + var oldPriority = this.findPriorityInDic(item); + if (oldPriority == undefined) { + this.itemListPriorityDic[priority].push(item); + } + else { + if (oldPriority < priority) { + this.itemListPriorityDic[priority].push(item); + var index = this.itemListPriorityDic[oldPriority].indexOf(item); + this.itemListPriorityDic[oldPriority].splice(index, 1); + } + } + } + }; + /** + * 搜索单项资源的优先级 + * @param item 单项资源 + */ + ResourceLoader.prototype.findPriorityInDic = function (item) { + for (var priority in this.itemListPriorityDic) { + if (this.itemListPriorityDic[priority].indexOf(item) > -1) + return parseInt(priority); + } + return undefined; + }; + /** + * 加载下一项资源,线程控制 + */ + ResourceLoader.prototype.loadNextResource = function () { + while (this.loadingCount < this.thread) { + var isload = this.loadSingleResource(); + if (!isload) { + break; + } + } + }; + /** + * 加载单向资源 + */ + ResourceLoader.prototype.loadSingleResource = function () { + var _this = this; + var r = this.getOneResourceInfoInGroup(); + if (!r) + return false; + this.itemLoadDic[r.root + r.name] = 1; + this.loadingCount++; + this.loadResource(r) + .then(function (response) { + _this.loadingCount--; + delete _this.itemLoadDic[r.root + r.name]; + RES.host.save(r, response); + if (_this.promiseHash[r.root + r.name]) { + var dispatcher = _this.deleteDispatcher(r.root + r.name); + dispatcher.dispatchEventWith("complete", false, response); + } + var groupNames = r.groupNames; + if (groupNames) { + delete r.groupNames; + for (var _i = 0, groupNames_1 = groupNames; _i < groupNames_1.length; _i++) { + var groupName = groupNames_1[_i]; + if (_this.setGroupProgress(groupName, r)) { + _this.loadGroupEnd(groupName); + } + } + } + _this.loadNextResource(); + }).catch(function (error) { + if (!error) { + throw r.name + " load fail"; + } + if (!error.__resource_manager_error__) { + throw error; + } + delete _this.itemLoadDic[r.root + r.name]; + _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]; + if (_this.promiseHash[r.root + r.name]) { + var dispatcher = _this.deleteDispatcher(r.root + r.name); + dispatcher.dispatchEventWith("error", false, { r: r, error: error }); + } + var groupNames = r.groupNames; + if (groupNames) { + delete r.groupNames; + for (var _i = 0, groupNames_2 = groupNames; _i < groupNames_2.length; _i++) { + var groupName = groupNames_2[_i]; + if (!_this.loadItemErrorDic[groupName]) { + _this.loadItemErrorDic[groupName] = []; + } + if (_this.loadItemErrorDic[groupName].indexOf(r) == -1) { + _this.loadItemErrorDic[groupName].push(r); + } + _this.groupErrorDic[groupName] = true; + if (_this.setGroupProgress(groupName, r)) { + _this.loadGroupEnd(groupName, error); + } + else { + _this.errorDic[groupName] = error; + } + } + } + _this.loadNextResource(); + } + else { + _this.retryTimesDic[r.name] = times + 1; + _this.failedList.push(r); + _this.loadNextResource(); + return; + } + }); + return true; + }; + /** + * 获取下一个待加载项 + */ + ResourceLoader.prototype.getOneResourceInfoInGroup = function () { + if (this.failedList.length > 0) + return this.failedList.shift(); + var maxPriority = Number.NEGATIVE_INFINITY; + for (var p in this.itemListPriorityDic) { + maxPriority = Math.max(maxPriority, p); + } + var list = this.itemListPriorityDic[maxPriority]; + if (!list) { + return undefined; + } + if (list.length == 0) { + delete this.itemListPriorityDic[maxPriority]; + return this.getOneResourceInfoInGroup(); + } + return list.shift(); + }; + /** + * 设置组的加载进度,同时返回当前组是否加载完成 + * @param groupName 组名 + * @param r 加载完成的资源 + */ + ResourceLoader.prototype.setGroupProgress = function (groupName, r) { + 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, r); + } + return current == total; + }; + /** + * 加载组的最后一项,同时派发事件 + * @param groupName 组名 + * @param lastError 最后一项是否成功,此项为错误信息 + */ + ResourceLoader.prototype.loadGroupEnd = function (groupName, lastError) { + delete this.groupTotalDic[groupName]; + delete this.numLoadedDic[groupName]; + delete this.reporterDic[groupName]; + var dispatcher = this.deleteDispatcher(groupName); + if (!lastError) { + var groupError = this.groupErrorDic[groupName]; + delete this.groupErrorDic[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"); + } + } + else { + delete this.groupErrorDic[groupName]; + var itemList = this.loadItemErrorDic[groupName]; + delete this.loadItemErrorDic[groupName]; + dispatcher.dispatchEventWith("error", false, { itemList: itemList, lastError: lastError }); + } + }; + /** + * 删除事件派发器,Promise的缓存,返回事件派发器 + * @param groupName 组名或是root+name + */ + ResourceLoader.prototype.deleteDispatcher = function (groupName) { + delete this.promiseHash[groupName]; + var dispatcher = this.dispatcherDic[groupName]; + delete this.dispatcherDic[groupName]; + return dispatcher; + }; + /** + * 加载资源 + * @param r 资源信息 + * @param p 加载处理器 + */ + 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; + }; + /** + * 释放资源 + * @param r 资源信息 + */ + ResourceLoader.prototype.unloadResource = function (r) { + var data = RES.host.get(r); + if (!data) { + console.warn("尝试释放不存在的资源:", r.name); + return false; + } + var p = RES.processor.isSupport(r); + if (p) { + p.onRemoveStart(RES.host, r); + RES.host.remove(r); + if (r.extra == 1) { + RES.config.removeResourceData(r); + } + return true; + } + else { + return true; + } + }; + return ResourceLoader; + }()); + RES.ResourceLoader = ResourceLoader; + __reflect(ResourceLoader.prototype, "RES.ResourceLoader"); +})(RES || (RES = {})); +var RES; +(function (RES) { + /** + * Decorator, determine if the parameter is null + * @internal + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 装饰器,判断参数是否为null + * @internal + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + 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:处理重复加载 + * @internal + */ + RES.FEATURE_FLAG = { + FIX_DUPLICATE_LOAD: 1 + }; + /** + * @internal + */ + var upgrade; + (function (upgrade) { + var _level = "warning"; + function setUpgradeGuideLevel(level) { + _level = level; + } + upgrade.setUpgradeGuideLevel = setUpgradeGuideLevel; + })(upgrade = RES.upgrade || (RES.upgrade = {})); +})(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) { + /** + * Convert the file name of the resource to the Key value used in the project. + * @param url Resource Name. + * @returns The key value used in the project + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 将资源的文件名称转换为项目中所使用的Key值。 + * 在加载合并图集的时候使用,例如图集加载A_json,需要加载对应A_png,这里就是转换的机制 + * 一般项目中无需更改,只有没有使用默认的key和文件对应的需要修改 + * @param url 资源名称。 + * @returns 项目中所用的key值 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function nameSelector(url) { + return RES.path.basename(url).split(".").join("_"); + } + RES.nameSelector = nameSelector; + /** + * Get the read type of the file. + * When using getResByUrl does not specify the type of the read file, it will find the corresponding type according to this method. + * File types not found are loaded by default in binary format + * @param path file path. + * @returns Processor type used to read the file + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 获取文件的读取类型 + * 在使用getResByUrl没有指定读取文件的类型,会根据这个方法寻找对应的类型 + * 没有查找到的文件类型以二进制格式默认加载 + * @param path 文件路径 + * @returns 读取文件所用的Processor类型 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function typeSelector(path) { + var ext = path.substr(path.lastIndexOf(".") + 1); + var type; + switch (ext) { + case RES.ResourceItem.TYPE_XML: + case RES.ResourceItem.TYPE_JSON: + case RES.ResourceItem.TYPE_SHEET: + type = ext; + break; + case "png": + case "jpg": + case "gif": + case "jpeg": + case "bmp": + type = RES.ResourceItem.TYPE_IMAGE; + break; + case "fnt": + type = RES.ResourceItem.TYPE_FONT; + break; + case "txt": + type = RES.ResourceItem.TYPE_TEXT; + break; + case "mp3": + case "ogg": + case "mpeg": + case "wav": + case "m4a": + case "mp4": + case "aiff": + case "wma": + case "mid": + type = RES.ResourceItem.TYPE_SOUND; + break; + case "mergeJson": + case "zip": + case "pvr": + type = ext; + break; + default: + type = RES.ResourceItem.TYPE_BIN; + break; + } + return type; + } + RES.typeSelector = typeSelector; + /** + * Conduct mapping injection with class definition as the value, Deprecated. + * @deprecated + * @see RES.processor.map + * @language en_US + */ + /** + * 以类定义为值进行映射注入,已废弃。 + * @deprecated + * @see RES.processor.map + * @language zh_CN + */ + function registerAnalyzer(type, analyzerClass) { + throw new RES.ResourceManagerError(2002); + } + RES.registerAnalyzer = registerAnalyzer; + /** + * Set whether it is compatible mode + * When the value is true, the assetsManager will output the design of Res. When it is false, all the loaded resources will be returned as promises. + * The default is false, run in strict assetsManager mode + * @version Egret 5.2.9 + * @platform Web,Native + * @language en_US + */ + /** + * 设置是否为兼容模式 + * 当值为true时,assetsManager会以Res的设计输出,当为false时候,所有的加载资源都会以promise的方式返回 + * 默认是false,以严格assetsManager方式运行 + * @version Egret 5.2.9 + * @platform Web,Native + * @language zh_CN + */ + function setIsCompatible(value) { + RES.isCompatible = value; + } + RES.setIsCompatible = setIsCompatible; + /** + * @internal + */ + RES.isCompatible = false; + /** + * Load configuration file and parse. + * @param url The url address of the resource config + * @param resourceRoot The root address of the resource config + * @returns Promise + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 加载配置文件并解析。 + * @param url 资源配置的url地址 + * @param resourceRoot 资源配置的根地址 + * @returns Promise + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @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] + '/'); + url = url.replace(resourceRoot, ''); + } + else { + resourceRoot = RES.path.normalize(resourceRoot + "/"); + url = url.replace(resourceRoot, ''); + } + RES.setConfigURL(url, resourceRoot); + if (!instance) + instance = new Resource(); + return compatiblePromise(instance.loadConfig()); + } + RES.loadConfig = loadConfig; + function compatiblePromise(promise) { + if (RES.isCompatible) { + promise.catch(function (e) { }).then(); + return undefined; + } + else { + return 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. + * @param reporter Resource group loading progress prompt + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 根据组名加载一组资源。 + * @param name 要加载资源组的组名。 + * @param priority 加载优先级,可以为负数,默认值为 0。 + *
低优先级的组必须等待高优先级组完全加载结束才能开始,同一优先级的组会同时加载。 + * @param reporter 资源组的加载进度提示 + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function loadGroup(name, priority, reporter) { + if (priority === void 0) { priority = 0; } + return compatiblePromise(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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 检查某个资源组是否已经加载完成。 + * @param name 组名。 + * @returns 是否正在加载。 + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 根据组名获取组加载项列表。 + * @param name 组名。 + * @returns 加载项列表。 + * @see RES.ResourceItem + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 + *
可以监听 ResourceEvent.CONFIG_COMPLETE 事件来确认配置加载完成。 + * @param name 要创建的加载资源组的组名。 + * @param keys 要包含的键名列表,key 对应配置文件里的 name 属性或 sbuKeys 属性的一项或一个资源组名。 + * @param override 是否覆盖已经存在的同名资源组,默认 false。 + * @returns 是否创建成功。 + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @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. + * @returns Whether you have the specified resource + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 检查配置文件里是否含有指定的资源。 + * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 + * @returns 是否拥有指定资源 + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @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 5.2 + * @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 5.2 + * @platform Web,Native + * @language zh_CN + */ + function getRes(key) { + return instance.getRes(key); + } + RES.getRes = getRes; + /** + * 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 + * @example The following code demonstrates how to load a resource via getResAsync + *
+     *       RES.getResAsync("resource/example.json");//Only pass the key value to get the resource
+     *
+     *       RES.getResAsync("resource/example.json", (data) => {
+     *          console.log(data)
+     *       }, this) //Pass in the key value, compFunc and thisObject get the resource, the latter two must appear at the same time
+     * 
+ * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 异步方式获取配置里的资源。只要是配置文件里存在的资源,都可以通过异步方式获取。 + * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 + * @param compFunc 回调函数。示例:compFunc(data,key):void。 + * @param thisObject 回调函数的 this 引用。 + * @see #setMaxRetryTimes + * @example 以下代码演示了如何通过getResAsync加载资源 + *
+     *       RES.getResAsync("resource/example.json");//只传入key值获取资源
+     *
+     *       RES.getResAsync("resource/example.json", (data) => {
+     *          console.log(data)
+     *       }, this) //传入key值,compFunc和thisObject获取资源,后两个必须同时出现
+     * 
+ * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function getResAsync(key, compFunc, thisObject) { + return compatiblePromise(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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 通过完整URL方式获取外部资源。 + * @param url 要加载文件的外部路径。 + * @param compFunc 回调函数。示例:compFunc(data,url):void。 + * @param thisObject 回调函数的 this 引用。 + * @param type 文件类型(可选)。请使用 ResourceItem 类中定义的静态常量。若不设置将根据文件扩展名生成。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function getResByUrl(url, compFunc, thisObject, type) { + if (type === void 0) { type = ""; } + if (!instance) { + var message = egret.sys.tr(3200); + egret.warn(message); + return Promise.reject(message); + } + return compatiblePromise(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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。 + * @param name 配置文件中加载项的name属性或资源组名。 + * @param force 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值 true。 + * @see #setMaxRetryTimes + * @returns 是否销毁成功。 + * @version Egret 5.2 + * @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 4. + * @param thread The number of concurrent loads to be set. + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 设置最大并发加载线程数量,默认值是 4。 + * @param thread 要设置的并发加载数。 + * @see #setMaxRetryTimes + * @version Egret 5.2 + * @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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 设置资源加载失败时的重试次数,默认值是 3。 + * @param retry 要设置的重试次数。 + * @includeExample extension/resource/Resource.ts + * @version Egret 5.2 + * @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 5.2 + * @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 5.2 + * @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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 移除事件侦听器,参考ResourceEvent定义的常量。 + * @param type 事件名。 + * @param listener 侦听函数。 + * @param thisObject 侦听函数绑定的this对象。 + * @param useCapture 是否使用捕获,这个属性只在显示列表中生效。 + * @version Egret 5.2 + * @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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 自定义添加一项资源配置。 + * @param data 要添加的配置。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function $addResourceData(data) { + //这里可能需要其他配置 + instance.addResourceData(data); + } + RES.$addResourceData = $addResourceData; + /** + * Returns the VersionController + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 获得版本控制器. + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function getVersionController() { + if (!instance) + instance = new Resource(); + return instance.vcs; + } + RES.getVersionController = getVersionController; + /** + * Register the VersionController + * @param vcs The VersionController to register. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 注册版本控制器,通过RES模块加载资源时会从版本控制器获取真实url + * @param vcs 注入的版本控制器。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function registerVersionController(vcs) { + if (!instance) + instance = new Resource(); + instance.registerVersionController(vcs); + } + RES.registerVersionController = registerVersionController; + /** + * Convert the address of the loaded resource (via version controller conversion) + * @param url path to the original resource + * @returns converted address + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 转换加载资源的地址(经过版本控制器的转换) + * @param url 原始资源的路径 + * @returns 转换后的地址 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function getVirtualUrl(url) { + if (instance.vcs) { + return instance.vcs.getVirtualUrl(url); + } + else { + return url; + } + } + RES.getVirtualUrl = getVirtualUrl; + /** + * @private + */ + var Resource = (function (_super) { + __extends(Resource, _super); + function Resource() { + var _this = _super.call(this) || this; + _this.isVcsInit = false; + /** + * @private + * 版本控制器加载后的加载配置 + */ + _this.normalLoadConfig = function () { + 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); + }); + }; + if (RES.VersionController) { + _this.vcs = new RES.VersionController(); + } + return _this; + } + Resource.prototype.registerVersionController = function (vcs) { + this.vcs = vcs; + this.isVcsInit = false; + }; + /** + * 开始加载配置 + * @method RES.loadConfig + */ + Resource.prototype.loadConfig = function () { + var _this = this; + if (!this.isVcsInit && this.vcs) { + this.isVcsInit = true; + return this.vcs.init().then(function () { + return _this.normalLoadConfig(); + }); + } + else { + return this.normalLoadConfig(); + } + }; + /** + * 检查某个资源组是否已经加载完成 + * @method RES.isGroupLoaded + * @param name {string} + */ + Resource.prototype.isGroupLoaded = function (name) { + var resources = RES.config.getGroupByName(name); + 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); + }; + /** + * 根据组名加载一组资源 + * @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, resItem) { + if (reporter && reporter.onProgress) { + reporter.onProgress(current, total, resItem); + } + RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.GROUP_PROGRESS, name, resItem, current, total); + } + }; + return this._loadGroup(name, priority, reporterDelegate).then(function (data) { + if (RES.config.config.loadGroup.indexOf(name) == -1) { + RES.config.config.loadGroup.push(name); + } + RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.GROUP_COMPLETE, name); + }, function (error) { + if (RES.config.config.loadGroup.indexOf(name) == -1) { + RES.config.config.loadGroup.push(name); + } + if (error.itemList) { + var itemList = error.itemList; + var length_1 = itemList.length; + for (var i = 0; i < length_1; i++) { + var item = itemList[i]; + delete item.promise; + RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.ITEM_LOAD_ERROR, name, item); + } + } + if (RES.isCompatible) { + console.warn(error.error.message); + } + 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); + if (resources.length == 0) { + return new Promise(function (resolve, reject) { + reject({ error: new RES.ResourceManagerError(2005, name) }); + }); + } + return RES.queue.pushResGroup(resources, name, priority, 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 tempResult = RES.config.getResourceWithSubkey(key); + if (tempResult == null) { + if (compFunc) { + compFunc.call(thisObject, null, paramKey); + } + return Promise.reject(new RES.ResourceManagerError(2006, key)); + } + var data = this.getRes(key); + if (data) { + if (compFunc) { + egret.callLater(function () { + compFunc.call(thisObject, data, paramKey); + }, this); + } + return Promise.resolve(data); + } + var r = tempResult.r, subkey = tempResult.subkey; + return RES.queue.pushResItem(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.host.remove(r); + RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.ITEM_LOAD_ERROR, "", r); + if (compFunc) { + compFunc.call(thisObject, null, paramKey); + return Promise.reject(null); + } + 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: '', extra: 1 }; + RES.config.addResourceData(r); + r = RES.config.getResource(url); + if (!r) { + throw 'never'; + } + } + return RES.queue.pushResItem(r).then(function (value) { + RES.host.save(r, value); + if (compFunc && r) { + compFunc.call(thisObject, value, r.url); + } + return value; + }, function (error) { + RES.host.remove(r); + RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.ITEM_LOAD_ERROR, "", r); + if (compFunc) { + compFunc.call(thisObject, null, url); + return Promise.reject(null); + } + 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; } + var group = RES.config.getGroupByName(name); + if (group && group.length > 0) { + var index = RES.config.config.loadGroup.indexOf(name); + if (index == -1) { + return false; + } + if (force || (RES.config.config.loadGroup.length == 1 && RES.config.config.loadGroup[0] == name)) { + for (var _i = 0, group_2 = group; _i < group_2.length; _i++) { + var item = group_2[_i]; + RES.queue.unloadResource(item); + } + RES.config.config.loadGroup.splice(index, 1); + } + else { + var removeItemHash = {}; + for (var _a = 0, _b = RES.config.config.loadGroup; _a < _b.length; _a++) { + var groupName = _b[_a]; + for (var key in RES.config.config.groups[groupName]) { + var tmpname = RES.config.config.groups[groupName][key]; + if (removeItemHash[tmpname]) { + removeItemHash[tmpname]++; + } + else { + removeItemHash[tmpname] = 1; + } + } + } + for (var _c = 0, group_3 = group; _c < group_3.length; _c++) { + var item = group_3[_c]; + if (removeItemHash[item.name] && removeItemHash[item.name] == 1) { + RES.queue.unloadResource(item); + } + } + RES.config.config.loadGroup.splice(index, 1); + } + return true; + } + else { + var item = RES.config.getResource(name); + if (item) { + return RES.queue.unloadResource(item); + } + else { + console.warn("\u5728\u5185\u5B58" + name + "\u8D44\u6E90\u4E0D\u5B58\u5728"); + return false; + } + } + }; + /** + * 设置最大并发加载线程数量,默认值是4. + * @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) { + data["root"] = ''; + RES.config.addResourceData(data); + }; + __decorate([ + RES.checkNull + ], Resource.prototype, "hasRes", null); + __decorate([ + RES.checkNull + ], Resource.prototype, "getRes", null); + __decorate([ + RES.checkNull + ], Resource.prototype, "getResAsync", null); + __decorate([ + RES.checkNull + ], Resource.prototype, "getResByUrl", null); + return Resource; + }(egret.EventDispatcher)); + RES.Resource = Resource; + __reflect(Resource.prototype, "RES.Resource"); + /** + * Resource单例 + */ + var instance; +})(RES || (RES = {})); +var RES; +(function (RES) { + /** + * Print the memory occupied by the picture. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 对文件路径的一些操作,针对的是 C:/A/B/C/D/example.ts这种格式 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + var path; + (function (path_1) { + /** + * Format the file path,"C:/A/B//C//D//example.ts"=>"C:/A/B/C/D/example.ts" + * @param filename Incoming file path + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 格式化文件路径,"C:/A/B//C//D//example.ts"=>"C:/A/B/C/D/example.ts" + * @param filename 传入的文件路径 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function normalize(filename) { + var arr = filename.split("/"); + return arr.filter(function (value, index) { return !!value || index == arr.length - 1; }).join("/"); + } + path_1.normalize = normalize; + /** + * Get the file name according to the file path, "C:/A/B/example.ts"=>"example.ts" + * @param filename Incoming file path + * @return File name + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 根据文件路径得到文件名字,"C:/A/B/example.ts"=>"example.ts" + * @param filename 传入的文件路径 + * @return 文件的名字 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function basename(filename) { + return filename.substr(filename.lastIndexOf("/") + 1); + } + path_1.basename = basename; + /** + * The path to the folder where the file is located,"C:/A/B/example.ts"=>"C:/A/B" + * @param filename Incoming file path + * @return The address of the folder where the file is located + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 文件所在文件夹路径,"C:/A/B/example.ts"=>"C:/A/B" + * @param filename 传入的文件路径 + * @return 文件所在文件夹的地址 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function dirname(path) { + return path.substr(0, path.lastIndexOf("/")); + } + path_1.dirname = dirname; + })(path = RES.path || (RES.path = {})); +})(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) { + /** + * @private + */ + var NativeVersionController = (function () { + function NativeVersionController() { + } + NativeVersionController.prototype.init = function () { + this.versionInfo = this.getLocalData("all.manifest"); + return Promise.resolve(); + }; + NativeVersionController.prototype.getVirtualUrl = function (url) { + return url; + }; + NativeVersionController.prototype.getLocalData = function (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; + }; + return NativeVersionController; + }()); + RES.NativeVersionController = NativeVersionController; + __reflect(NativeVersionController.prototype, "RES.NativeVersionController", ["RES.IVersionController"]); + if (egret.Capabilities.runtimeType == egret.RuntimeType.NATIVE) { + RES.VersionController = NativeVersionController; + } +})(RES || (RES = {})); +var RES; +(function (RES) { + var processor; + (function (processor_1) { + /** + * @internal + * @param resource 对应的资源接口,需要type属性 + */ + function isSupport(resource) { + return processor_1._map[resource.type]; + } + processor_1.isSupport = isSupport; + /** + * Register the processor that loads the resource + * @param type Load resource type + * @param processor Loaded processor, an instance that implements the Processor interface + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 注册加载资源的处理器 + * @param type 加载资源类型 + * @param processor 加载的处理器,一个实现Processor接口的实例 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function map(type, processor) { + processor_1._map[type] = processor; + } + processor_1.map = map; + /** + * @internal + */ + function promisify(loader, resource) { + var _this = this; + return new Promise(function (resolve, reject) { + var onSuccess = function () { + var texture = loader['data'] ? loader['data'] : loader['response']; + resolve(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); + }); + } + /** + * @private + * @param url + * @param file + */ + 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; + processor_1.ImageProcessor = { + onLoadStart: function (host, resource) { + var loader = new egret.ImageLoader(); + loader.load(RES.getVirtualUrl(resource.root + resource.url)); + return promisify(loader, resource) + .then(function (bitmapData) { + var texture = new egret.Texture(); + texture._setBitmapData(bitmapData); + var r = host.resourceConfig.getResource(resource.name); + if (r && r.scale9grid) { + var list = r.scale9grid.split(","); + texture["scale9Grid"] = new egret.Rectangle(parseInt(list[0]), parseInt(list[1]), parseInt(list[2]), parseInt(list[3])); + } + return texture; + }); + }, + onRemoveStart: function (host, resource) { + var texture = host.get(resource); + texture.dispose(); + } + }; + processor_1.KTXTextureProcessor = { + onLoadStart: function (host, resource) { + return host.load(resource, 'bin').then(function (data) { + if (!data) { + console.error('ktx:' + resource.root + resource.url + ' is null'); + return null; + } + var ktx = new egret.KTXContainer(data, 1); + if (ktx.isInvalid) { + console.error('ktx:' + resource.root + resource.url + ' is invalid'); + return null; + } + // + var bitmapData = new egret.BitmapData(data); + bitmapData.debugCompressedTextureURL = resource.root + resource.url; + bitmapData.format = 'ktx'; + ktx.uploadLevels(bitmapData, false); + // + var texture = new egret.Texture(); + texture._setBitmapData(bitmapData); + var r = host.resourceConfig.getResource(resource.name); + if (r && r.scale9grid) { + var list = r.scale9grid.split(","); + texture["scale9Grid"] = new egret.Rectangle(parseInt(list[0]), parseInt(list[1]), parseInt(list[2]), parseInt(list[3])); + } + // + host.save(resource, texture); + return texture; + }, function (e) { + host.remove(resource); + throw e; + }); + }, + onRemoveStart: function (host, resource) { + var texture = host.get(resource); + if (texture) { + texture.dispose(); + } + } + }; + /** + * + */ + function makeEtc1SeperatedAlphaResourceInfo(resource) { + return { name: resource.name + '_alpha', url: resource['etc1_alpha_url'], type: 'ktx', root: resource.root }; + } + processor_1.makeEtc1SeperatedAlphaResourceInfo = makeEtc1SeperatedAlphaResourceInfo; + /** + * + */ + processor_1.ETC1KTXProcessor = { + onLoadStart: function (host, resource) { + return host.load(resource, "ktx").then(function (colorTex) { + if (!colorTex) { + return null; + } + if (resource['etc1_alpha_url']) { + var r_1 = makeEtc1SeperatedAlphaResourceInfo(resource); + return host.load(r_1, "ktx") + .then(function (alphaMaskTex) { + if (colorTex && colorTex.$bitmapData && alphaMaskTex.$bitmapData) { + colorTex.$bitmapData.etcAlphaMask = alphaMaskTex.$bitmapData; + host.save(r_1, alphaMaskTex); + } + else { + host.remove(r_1); + } + return colorTex; + }, function (e) { + host.remove(r_1); + throw e; + }); + } + return colorTex; + }, function (e) { + host.remove(resource); + throw e; + }); + }, + onRemoveStart: function (host, resource) { + var colorTex = host.get(resource); + if (colorTex) { + colorTex.dispose(); + } + if (resource['etc1_alpha_url']) { + var r = makeEtc1SeperatedAlphaResourceInfo(resource); + var alphaMaskTex = host.get(r); + if (alphaMaskTex) { + alphaMaskTex.dispose(); + } + host.unload(r); //这里其实还会再删除一次,不过无所谓了。alphaMaskTex已经显示删除了 + } + } + }; + processor_1.BinaryProcessor = { + onLoadStart: function (host, resource) { + var request = new egret.HttpRequest(); + request.responseType = egret.HttpResponseType.ARRAY_BUFFER; + request.open(RES.getVirtualUrl(resource.root + resource.url), "get"); + request.send(); + return promisify(request, resource); + }, + onRemoveStart: function (host, resource) { + } + }; + processor_1.TextProcessor = { + onLoadStart: function (host, resource) { + var request = new egret.HttpRequest(); + request.responseType = egret.HttpResponseType.TEXT; + request.open(RES.getVirtualUrl(resource.root + resource.url), "get"); + request.send(); + return promisify(request, resource); + }, + onRemoveStart: function (host, resource) { + return true; + } + }; + processor_1.JsonProcessor = { + onLoadStart: function (host, resource) { + return host.load(resource, 'text').then(function (text) { + var data = JSON.parse(text); + return data; + }); + }, + onRemoveStart: function (host, request) { + } + }; + /** + * @internal + */ + processor_1.XMLProcessor = { + onLoadStart: function (host, resource) { + return host.load(resource, 'text').then(function (text) { + var data = egret.XML.parse(text); + return data; + }); + }, + onRemoveStart: function (host, resource) { + return true; + } + }; + /** + * @internal + */ + processor_1.CommonJSProcessor = { + onLoadStart: function (host, resource) { + // let text = await host.load(resource, 'text'); + return host.load(resource, 'text').then(function (text) { + var f = new Function('require', 'exports', text); + var require = function () { }; + var exports = {}; + try { + f(require, exports); + } + catch (e) { + throw new RES.ResourceManagerError(2003, resource.name, e.message); + } + return exports; + }); + }, + onRemoveStart: function (host, resource) { + } + }; + /** + * @internal + */ + processor_1.SheetProcessor = { + onLoadStart: function (host, resource) { + return host.load(resource, "json").then(function (data) { + var r = host.resourceConfig.getResource(RES.nameSelector(data.file)); + if (!r) { + var imageName = getRelativePath(resource.url, data.file); + r = { name: imageName, url: imageName, type: 'image', root: resource.root }; + } + return host.load(r) + .then(function (bitmapData) { + if (!bitmapData) { + return null; + } + var frames = data.frames; + var spriteSheet = new egret.SpriteSheet(bitmapData); + spriteSheet["$resourceInfo"] = r; + for (var subkey in frames) { + var config = frames[subkey]; + var texture = spriteSheet.createTexture(subkey, config.x, config.y, config.w, config.h, config.offX, config.offY, config.sourceW, config.sourceH); + if (config["scale9grid"]) { + var str = config["scale9grid"]; + var list = str.split(","); + texture["scale9Grid"] = new egret.Rectangle(parseInt(list[0]), parseInt(list[1]), parseInt(list[2]), parseInt(list[3])); + } + } + host.save(r, bitmapData); + return spriteSheet; + }, function (e) { + host.remove(r); + throw e; + }); + }); + }, + 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); + } + }; + 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; + }; + /** + * @internal + */ + processor_1.FontProcessor = { + onLoadStart: function (host, resource) { + // let data: string = await host.load(resource, 'text'); + return host.load(resource, 'text').then(function (data) { + var config; + try { + config = JSON.parse(data); + } + catch (e) { + config = data; + } + var imageName; + if (typeof config === 'string') { + imageName = fontGetTexturePath(resource.url, config); + } + else { + imageName = getRelativePath(resource.url, config.file); + } + var r = host.resourceConfig.getResource(RES.nameSelector(imageName)); + if (!r) { + r = { name: imageName, url: imageName, type: 'image', root: resource.root }; + } + // var texture: egret.Texture = await host.load(r); + return host.load(r).then(function (texture) { + var font = new egret.BitmapFont(texture, config); + font["$resourceInfo"] = r; + // todo refactor + host.save(r, texture); + return font; + }, function (e) { + host.remove(r); + throw e; + }); + }); + }, + onRemoveStart: function (host, resource) { + var font = host.get(resource); + var r = font["$resourceInfo"]; + host.unload(r); + } + }; + processor_1.SoundProcessor = { + onLoadStart: function (host, resource) { + var sound = new egret.Sound(); + sound.load(RES.getVirtualUrl(resource.root + resource.url)); + return promisify(sound, resource).then(function () { + return sound; + }); + }, + onRemoveStart: function (host, resource) { + var sound = host.get(resource); + sound.close(); + } + }; + /** + * @internal + */ + 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); + 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); + if (imageResource) { + host.unload(imageResource); + } + } + }; + /** + * @internal + */ + processor_1.MergeJSONProcessor = { + onLoadStart: function (host, resource) { + // let data = await host.load(resource, 'json'); + return host.load(resource, 'json').then(function (data) { + for (var key in data) { + RES.config.addSubkey(key, resource.name); + } + 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) { + } + }; + /** + * @internal + */ + 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 (data) { + if (!data.type) + data.type = ""; + if (root == undefined) { + data.root = ""; + } + fsData[data.name] = data; + }, + profile: function () { + console.log(fsData); + }, + removeFile: function (filename) { + delete fsData[filename]; + } + }; + resConfigData.fileSystem = fileSystem; + } + var groups = resConfigData.groups; + for (var _i = 0, _a = data.groups; _i < _a.length; _i++) { + var g = _a[_i]; + if (g.keys == "") { + groups[g.name] = []; + } + else { + groups[g.name] = g.keys.split(","); + } + } + var alias = resConfigData.alias; + var fsData = fileSystem['fsData']; + var _loop_1 = 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_1(resource_1); + } + host.save(resource, data); + return data; + }); + }, + onRemoveStart: function () { + } + }; + /** + * @internal + */ + 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, + "mergeJson": processor_1.MergeJSONProcessor, + "legacyResourceConfig": processor_1.LegacyResourceConfigProcessor, + "ktx": processor_1.KTXTextureProcessor, + "etc1.ktx": processor_1.ETC1KTXProcessor, + "pvrtc.ktx": processor_1.KTXTextureProcessor, + }; + })(processor = RES.processor || (RES.processor = {})); +})(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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 资源加载事件。 + * @version Egret 5.2 + * @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 5.2 + * @platform Web,Native + * @private + * @language en_US + */ + /** + * 创建一个作为参数传递给事件侦听器的 Event 对象。 + * @param type 事件的类型,可以作为 Event.type 访问。 + * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 + * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 + * @version Egret 5.2 + * @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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 已经加载的文件数。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + _this.itemsLoaded = 0; + /** + * Total file number to load. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 要加载的总文件数。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + _this.itemsTotal = 0; + /** + * Resource group name. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 资源组名。 + * @version Egret 5.2 + * @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 + * @version Egret 5.2 + * @platform Web,Native + * @language en_CN + */ + 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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 一个加载项加载失败事件。 + * @version Egret 5.2 + * @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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 配置文件加载并解析完成事件。注意:若有配置文件加载失败,将不会抛出此事件,若要处理配置加载失败,请同时监听 CONFIG_LOAD_ERROR 事件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + ResourceEvent.CONFIG_COMPLETE = "configComplete"; + /** + * Configuration file failed to load. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 配置文件加载失败事件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + ResourceEvent.CONFIG_LOAD_ERROR = "configLoadError"; + /** + * Delay load group resource loading progress event. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 延迟加载组资源加载进度事件。 + * @version Egret 5.2 + * @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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 延迟加载组资源加载完成事件。注意:若组内有资源项加载失败,将不会抛出此事件,若要处理组加载失败,请同时监听 GROUP_LOAD_ERROR 事件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + ResourceEvent.GROUP_COMPLETE = "groupComplete"; + /** + * Delayed load group resource failed event. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 延迟加载组资源加载失败事件。 + * @version Egret 5.2 + * @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 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 资源项。对应 resource.json 中 resources 数组中的一项。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + var ResourceItem; + (function (ResourceItem) { + /** + * XML file. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * XML 文件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + ResourceItem.TYPE_XML = "xml"; + /** + * Picture file. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 图片文件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + ResourceItem.TYPE_IMAGE = "image"; + /** + * Binary file. + * @version Egret 5.2 + * @platform Web + * @language en_US + */ + /** + * 二进制文件。 + * @version Egret 5.2 + * @platform Web + * @language zh_CN + */ + ResourceItem.TYPE_BIN = "bin"; + /** + * Text file. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 文本文件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + ResourceItem.TYPE_TEXT = "text"; + /** + * JSON file. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * JSON 文件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + ResourceItem.TYPE_JSON = "json"; + /** + * SpriteSheet file. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * SpriteSheet 文件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + ResourceItem.TYPE_SHEET = "sheet"; + /** + * BitmapTextSpriteSheet file. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * BitmapTextSpriteSheet 文件。 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + ResourceItem.TYPE_FONT = "font"; + /** + * Sound file. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 声音文件。 + * @version Egret 5.2 + * @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) { + /** + * @internal + */ + 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.resolve(folder); + d[basefilename] = { url: filename, type: type }; + }; + NewFileSystem.prototype.getFile = function (filename) { + var result = this.resolve(filename); + if (result) { + result.name = filename; + } + return result; + }; + NewFileSystem.prototype.resolve = 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_2 = list; _i < list_2.length; _i++) { + var f = list_2[_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_3 = list; _i < list_3.length; _i++) { + var f = list_3[_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_4 = list; _i < list_4.length; _i++) { + var f = list_4[_i]; + if (!current[f]) { + return false; + } + current = current[f]; + } + return true; + }; + return NewFileSystem; + }()); + RES.NewFileSystem = NewFileSystem; + __reflect(NewFileSystem.prototype, "RES.NewFileSystem"); +})(RES || (RES = {})); +var RES; +(function (RES) { + var __tempCache = {}; + /** + * Print the memory occupied by the picture. + * @version Egret 5.2 + * @platform Web,Native + * @language en_US + */ + /** + * 打印图片所占内存 + * @version Egret 5.2 + * @platform Web,Native + * @language zh_CN + */ + function profile() { + RES.config.config.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; + /** + * @internal + */ + 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; + delete resource.promise; + __tempCache[resource.root + resource.name] = data; + }, + get: function (resource) { + return __tempCache[resource.root + resource.name]; + }, + remove: function (resource) { + delete RES.host.state[resource.root + resource.name]; + delete __tempCache[resource.root + resource.name]; + } + }; + /** + * @internal + */ + RES.config = new RES.ResourceConfig(); + /** + * @internal + */ + RES.queue = new RES.ResourceLoader(); + /** + * @private + */ + 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 初始化失败:配置文件加载失败", + 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: "RES加载了不存在或空的资源组:\"{0}\"", + 2006: "资源配置文件中无法找到特定的资源:{0}" + }; + return ResourceManagerError; + }(Error)); + RES.ResourceManagerError = ResourceManagerError; + __reflect(ResourceManagerError.prototype, "RES.ResourceManagerError"); +})(RES || (RES = {})); diff --git a/libs/modules/assetsmanager/assetsmanager.min.js b/libs/modules/assetsmanager/assetsmanager.min.js new file mode 100644 index 0000000..bd155e9 --- /dev/null +++ b/libs/modules/assetsmanager/assetsmanager.min.js @@ -0,0 +1 @@ +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},__decorate=this&&this.__decorate||function(e,r,t,o){var n,i=arguments.length,a=3>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){}(RES||(RES={}));var RES;!function(e){var r=function(){function r(){this.groupTotalDic={},this.numLoadedDic={},this.groupErrorDic={},this.retryTimesDic={},this.maxRetryTimes=3,this.reporterDic={},this.dispatcherDic={},this.failedList=new Array,this.loadItemErrorDic={},this.errorDic={},this.itemListPriorityDic={},this.itemLoadDic={},this.promiseHash={},this.lazyLoadList=new Array,this.loadingCount=0,this.thread=4}return r.prototype.pushResItem=function(e){if(this.promiseHash[e.root+e.name])return this.promiseHash[e.root+e.name];this.lazyLoadList.push(e),this.itemListPriorityDic[Number.NEGATIVE_INFINITY]=this.lazyLoadList,this.updatelistPriority(this.lazyLoadList,Number.NEGATIVE_INFINITY);var r=new egret.EventDispatcher;this.dispatcherDic[e.root+e.name]=r;var t=new Promise(function(e,t){r.addEventListener("complete",function(r){e(r.data)},null),r.addEventListener("error",function(e){t(e.data)},null)});return this.promiseHash[e.root+e.name]=t,this.loadNextResource(),t},r.prototype.pushResGroup=function(e,r,t,o){if(this.promiseHash[r])return this.promiseHash[r];for(var n=e.length,i=0;n>i;i++){var a=e[i];a.groupNames||(a.groupNames=[]),a.groupNames.push(r)}this.groupTotalDic[r]=e.length,this.numLoadedDic[r]=0,this.updatelistPriority(e,t),this.reporterDic[r]=o;var s=new egret.EventDispatcher;this.dispatcherDic[r]=s;var u=new Promise(function(e,r){s.addEventListener("complete",e,null),s.addEventListener("error",function(e){r(e.data)},null)});return this.promiseHash[r]=u,this.loadNextResource(),u},r.prototype.updatelistPriority=function(e,r){void 0==this.itemListPriorityDic[r]&&(this.itemListPriorityDic[r]=[]);for(var t=0,o=e;ti){this.itemListPriorityDic[r].push(n);var a=this.itemListPriorityDic[i].indexOf(n);this.itemListPriorityDic[i].splice(a,1)}}}},r.prototype.findPriorityInDic=function(e){for(var r in this.itemListPriorityDic)if(this.itemListPriorityDic[r].indexOf(e)>-1)return parseInt(r)},r.prototype.loadNextResource=function(){for(;this.loadingCountr.maxRetryTimes))return r.retryTimesDic[t.name]=n+1,r.failedList.push(t),void r.loadNextResource();if(delete r.retryTimesDic[t.name],r.promiseHash[t.root+t.name]){var i=r.deleteDispatcher(t.root+t.name);i.dispatchEventWith("error",!1,{r:t,error:o})}var a=t.groupNames;if(a){delete t.groupNames;for(var s=0,u=a;s0)return this.failedList.shift();var e=Number.NEGATIVE_INFINITY;for(var r in this.itemListPriorityDic)e=Math.max(e,r);var t=this.itemListPriorityDic[e];if(t)return 0==t.length?(delete this.itemListPriorityDic[e],this.getOneResourceInfoInGroup()):t.shift()},r.prototype.setGroupProgress=function(e,r){var t=this.reporterDic[e];this.numLoadedDic[e]++;var o=this.numLoadedDic[e],n=this.groupTotalDic[e];return t&&t.onProgress&&t.onProgress(o,n,r),o==n},r.prototype.loadGroupEnd=function(e,r){delete this.groupTotalDic[e],delete this.numLoadedDic[e],delete this.reporterDic[e];var t=this.deleteDispatcher(e);if(r){delete this.groupErrorDic[e];var o=this.loadItemErrorDic[e];delete this.loadItemErrorDic[e],t.dispatchEventWith("error",!1,{itemList:o,lastError:r})}else{var n=this.groupErrorDic[e];if(delete this.groupErrorDic[e],n){var o=this.loadItemErrorDic[e];delete this.loadItemErrorDic[e];var i=this.errorDic[e];delete this.errorDic[e],t.dispatchEventWith("error",!1,{itemList:o,error:i})}else t.dispatchEventWith("complete")}},r.prototype.deleteDispatcher=function(e){delete this.promiseHash[e];var r=this.dispatcherDic[e];return delete this.dispatcherDic[e],r},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),!1;var o=e.processor.isSupport(r);return o?(o.onRemoveStart(e.host,r),e.host.remove(r),1==r.extra&&e.config.removeResourceData(r),!0):!0},r}();e.ResourceLoader=r,__reflect(r.prototype,"RES.ResourceLoader")}(RES||(RES={}));var RES;!function(e){e.checkNull=function(e,r,t){var o=t.value;t.value=function(){for(var e=[],t=0;t=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(){return this.config||(this.config={alias:{},groups:{},resourceRoot:o.root,mergeSelector:null,fileSystem:null,loadGroup:[]}),e.queue.pushResItem(o)["catch"](function(r){return e.isCompatible||r.__resource_manager_error__||(r.error?console.error(r.error.stack):console.error(r.stack),r=new e.ResourceManagerError(1002)),e.host.remove(o),Promise.reject(r)})},t.prototype.getGroupByName=function(r){var t=this.config.groups[r],o=[];if(!t)return o;for(var n=0,i=t;n=0&&(t=e.substr(r+1),e=e.substr(0,r));var o=this.getResource(e);return o?{r:o,key:e,subkey:t}:null},t.prototype.getKeyByAlias=function(e){return this.config.alias[e]?this.config.alias[e]:e},t.prototype.getResource=function(e){var t=this.config.alias[e];t||(t=e);var o=r(t);return o?o:null},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;n=0){var o=t.split("://");t=o[0]+"://"+e.path.normalize(o[1]+"/"),r=r.replace(t,"")}else t=e.path.normalize(t+"/"),r=r.replace(t,"");return e.setConfigURL(r,t),P||(P=new D),a(P.loadConfig())}function a(r){return e.isCompatible?void r["catch"](function(e){}).then():r}function s(e,r,t){return void 0===r&&(r=0),a(P.loadGroup(e,r,t))}function u(e){return P.isGroupLoaded(e)}function c(r){return P.getGroupByName(r).map(function(r){return e.ResourceItem.convertToResItem(r)})}function l(e,r,t){return void 0===t&&(t=!1),P.createGroup(e,r,t)}function f(e){return P.hasRes(e)}function p(e){return P.getRes(e)}function g(e,r,t){return a(P.getResAsync.apply(P,arguments))}function d(e,r,t,o){if(void 0===o&&(o=""),!P){var n=egret.sys.tr(3200);return egret.warn(n),Promise.reject(n)}return a(P.getResByUrl(e,r,t,o))}function v(e,r){return P.destroyRes(e,r)}function h(e){P||(P=new D),P.setMaxLoadingThread(e)}function m(e){P.setMaxRetryTimes(e)}function R(e,r,t,o,n){void 0===o&&(o=!1),void 0===n&&(n=0),P||(P=new D),P.addEventListener(e,r,t,o,n)}function E(e,r,t,o){void 0===o&&(o=!1),P.removeEventListener(e,r,t,o)}function y(e){P.addResourceData(e)}function _(){return P||(P=new D),P.vcs}function S(e){P||(P=new D),P.registerVersionController(e)}function L(e){return P.vcs?P.vcs.getVirtualUrl(e):e}e.nameSelector=r,e.typeSelector=t,e.registerAnalyzer=o,e.setIsCompatible=n,e.isCompatible=!1,e.loadConfig=i,e.loadGroup=s,e.isGroupLoaded=u,e.getGroupByName=c,e.createGroup=l,e.hasRes=f,e.getRes=p,e.getResAsync=g,e.getResByUrl=d,e.destroyRes=v,e.setMaxLoadingThread=h,e.setMaxRetryTimes=m,e.addEventListener=R,e.removeEventListener=E,e.$addResourceData=y,e.getVersionController=_,e.registerVersionController=S,e.getVirtualUrl=L;var D=function(r){function t(){var t=r.call(this)||this;return t.isVcsInit=!1,t.normalLoadConfig=function(){return e.config.init().then(function(r){e.ResourceEvent.dispatchResourceEvent(t,e.ResourceEvent.CONFIG_COMPLETE)},function(r){return e.ResourceEvent.dispatchResourceEvent(t,e.ResourceEvent.CONFIG_LOAD_ERROR),Promise.reject(r)})},e.VersionController&&(t.vcs=new e.VersionController),t}return __extends(t,r),t.prototype.registerVersionController=function(e){this.vcs=e,this.isVcsInit=!1},t.prototype.loadConfig=function(){var e=this;return!this.isVcsInit&&this.vcs?(this.isVcsInit=!0,this.vcs.init().then(function(){return e.normalLoadConfig()})):this.normalLoadConfig()},t.prototype.isGroupLoaded=function(r){var t=e.config.getGroupByName(r);return t.every(function(r){return null!=e.host.get(r)})},t.prototype.getGroupByName=function(r){return e.config.getGroupByName(r)},t.prototype.loadGroup=function(r,t,o){var n=this;void 0===t&&(t=0);var i={onProgress:function(t,i,a){o&&o.onProgress&&o.onProgress(t,i,a),e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.GROUP_PROGRESS,r,a,t,i)}};return this._loadGroup(r,t,i).then(function(t){-1==e.config.config.loadGroup.indexOf(r)&&e.config.config.loadGroup.push(r),e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.GROUP_COMPLETE,r)},function(t){if(-1==e.config.config.loadGroup.indexOf(r)&&e.config.config.loadGroup.push(r),t.itemList)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.isCompatible&&console.warn(t.error.message),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);return 0==n.length?new Promise(function(t,o){o({error:new e.ResourceManagerError(2005,r)})}):e.queue.pushResGroup(n,r,t,o)},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);if(null==a)return t&&t.call(o,null,i),Promise.reject(new e.ResourceManagerError(2006,r));var s=this.getRes(r);if(s)return t&&egret.callLater(function(){t.call(o,s,i)},this),Promise.resolve(s);var u=a.r,c=a.subkey;return e.queue.pushResItem(u).then(function(n){e.host.save(u,n);var a=e.processor.isSupport(u);return a&&a.getData&&c&&(n=a.getData(e.host,u,r,c)),t&&t.call(o,n,i),n},function(r){return e.host.remove(u),e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.ITEM_LOAD_ERROR,"",u),t?(t.call(o,null,i),Promise.reject(null)):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:"",extra:1},e.config.addResourceData(a),a=e.config.getResource(r),!a))throw"never";return e.queue.pushResItem(a).then(function(r){return e.host.save(a,r),t&&a&&t.call(o,r,a.url),r},function(n){return e.host.remove(a),e.ResourceEvent.dispatchResourceEvent(i,e.ResourceEvent.ITEM_LOAD_ERROR,"",a),t?(t.call(o,null,r),Promise.reject(null)):Promise.reject(n)})},t.prototype.destroyRes=function(r,t){void 0===t&&(t=!0);var o=e.config.getGroupByName(r);if(o&&o.length>0){var n=e.config.config.loadGroup.indexOf(r);if(-1==n)return!1;if(t||1==e.config.config.loadGroup.length&&e.config.config.loadGroup[0]==r){for(var i=0,a=o;ir&&(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){r.root="",e.config.addResourceData(r)},__decorate([e.checkNull],t.prototype,"hasRes",null),__decorate([e.checkNull],t.prototype,"getRes",null),__decorate([e.checkNull],t.prototype,"getResAsync",null),__decorate([e.checkNull],t.prototype,"getResByUrl",null),t}(egret.EventDispatcher);e.Resource=D,__reflect(D.prototype,"RES.Resource");var P}(RES||(RES={}));var RES;!function(e){var r;!function(e){function r(e){var r=e.split("/");return r.filter(function(e,t){return!!e||t==r.length-1}).join("/")}function t(e){return e.substr(e.lastIndexOf("/")+1)}function o(e){return e.substr(0,e.lastIndexOf("/"))}e.normalize=r,e.basename=t,e.dirname=o}(r=e.path||(e.path={}))}(RES||(RES={}));var RES;!function(e){function r(){e.config.config.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.profile=r,e.host={state:{},get resourceConfig(){return e.config},load:function(r,t){var o="string"==typeof t?e.processor._map[t]:t;return e.queue.loadResource(r,o)},unload:function(r){return e.queue.unloadResource(r)},save:function(r,o){e.host.state[r.root+r.name]=2,delete r.promise,t[r.root+r.name]=o},get:function(e){return t[e.root+e.name]},remove:function(r){delete e.host.state[r.root+r.name],delete t[r.root+r.name]}},e.config=new e.ResourceConfig,e.queue=new e.ResourceLoader;var o=function(e){function r(t,o,n){var i=e.call(this)||this;return i.__resource_manager_error__=!0,i.name=t.toString(),i.message=r.errorMessage[t].replace("{0}",o).replace("{1}",n),i}return __extends(r,e),r.errorMessage={1001:"文件加载失败:{0}",1002:"ResourceManager 初始化失败:配置文件加载失败",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:'RES加载了不存在或空的资源组:"{0}"',2006:"资源配置文件中无法找到特定的资源:{0}"},r}(Error);e.ResourceManagerError=o,__reflect(o.prototype,"RES.ResourceManagerError")}(RES||(RES={}));var RES;!function(e){var r;!function(r){function t(e){return r._map[e.type]}function o(e,t){r._map[e]=t}function n(r,t){var o=this;return new Promise(function(n,i){var a=function(){var e=r.data?r.data:r.response;n(e)},s=function(){var r=new e.ResourceManagerError(1001,t.url);i(r)};r.addEventListener(egret.Event.COMPLETE,a,o),r.addEventListener(egret.IOErrorEvent.IO_ERROR,s,o)})}function i(e,r){if(-1!=r.indexOf("://"))return r;e=e.split("\\").join("/");var t=e.match(/#.*|\?.*/),o="";t&&(o=t[0]);var n=e.lastIndexOf("/");return e=-1!=n?e.substring(0,n+1)+r:r,e+o}function a(e){return{name:e.name+"_alpha",url:e.etc1_alpha_url,type:"ktx",root:e.root}}r.isSupport=t,r.map=o,r.getRelativePath=i,r.ImageProcessor={onLoadStart:function(r,t){var o=new egret.ImageLoader;return o.load(e.getVirtualUrl(t.root+t.url)),n(o,t).then(function(e){var o=new egret.Texture;o._setBitmapData(e);var n=r.resourceConfig.getResource(t.name);if(n&&n.scale9grid){var i=n.scale9grid.split(",");o.scale9Grid=new egret.Rectangle(parseInt(i[0]),parseInt(i[1]),parseInt(i[2]),parseInt(i[3]))}return o})},onRemoveStart:function(e,r){var t=e.get(r);t.dispose()}},r.KTXTextureProcessor={onLoadStart:function(e,r){return e.load(r,"bin").then(function(t){if(!t)return console.error("ktx:"+r.root+r.url+" is null"),null;var o=new egret.KTXContainer(t,1);if(o.isInvalid)return console.error("ktx:"+r.root+r.url+" is invalid"),null;var n=new egret.BitmapData(t);n.debugCompressedTextureURL=r.root+r.url,n.format="ktx",o.uploadLevels(n,!1);var i=new egret.Texture;i._setBitmapData(n);var a=e.resourceConfig.getResource(r.name);if(a&&a.scale9grid){var s=a.scale9grid.split(",");i.scale9Grid=new egret.Rectangle(parseInt(s[0]),parseInt(s[1]),parseInt(s[2]),parseInt(s[3]))}return e.save(r,i),i},function(t){throw e.remove(r),t})},onRemoveStart:function(e,r){var t=e.get(r);t&&t.dispose()}},r.makeEtc1SeperatedAlphaResourceInfo=a,r.ETC1KTXProcessor={onLoadStart:function(e,r){return e.load(r,"ktx").then(function(t){if(!t)return null;if(r.etc1_alpha_url){var o=a(r);return e.load(o,"ktx").then(function(r){return t&&t.$bitmapData&&r.$bitmapData?(t.$bitmapData.etcAlphaMask=r.$bitmapData,e.save(o,r)):e.remove(o),t},function(r){throw e.remove(o),r})}return t},function(t){throw e.remove(r),t})},onRemoveStart:function(e,r){var t=e.get(r);if(t&&t.dispose(),r.etc1_alpha_url){var o=a(r),n=e.get(o);n&&n.dispose(),e.unload(o)}}},r.BinaryProcessor={onLoadStart:function(r,t){var o=new egret.HttpRequest;return o.responseType=egret.HttpResponseType.ARRAY_BUFFER,o.open(e.getVirtualUrl(t.root+t.url),"get"),o.send(),n(o,t)},onRemoveStart:function(e,r){}},r.TextProcessor={onLoadStart:function(r,t){var o=new egret.HttpRequest;return o.responseType=egret.HttpResponseType.TEXT,o.open(e.getVirtualUrl(t.root+t.url),"get"),o.send(),n(o,t)},onRemoveStart:function(e,r){return!0}},r.JsonProcessor={onLoadStart:function(e,r){return e.load(r,"text").then(function(e){var r=JSON.parse(e);return r})},onRemoveStart:function(e,r){}},r.XMLProcessor={onLoadStart:function(e,r){return e.load(r,"text").then(function(e){var r=egret.XML.parse(e);return r})},onRemoveStart:function(e,r){return!0}},r.CommonJSProcessor={onLoadStart:function(r,t){return r.load(t,"text").then(function(r){var o=new Function("require","exports",r),n=function(){},i={};try{o(n,i)}catch(a){throw new e.ResourceManagerError(2003,t.name,a.message)}return i})},onRemoveStart:function(e,r){}},r.SheetProcessor={onLoadStart:function(r,t){return r.load(t,"json").then(function(o){var n=r.resourceConfig.getResource(e.nameSelector(o.file));if(!n){var a=i(t.url,o.file);n={name:a,url:a,type:"image",root:t.root}}return r.load(n).then(function(e){if(!e)return null;var t=o.frames,i=new egret.SpriteSheet(e);i.$resourceInfo=n;for(var a in t){var s=t[a],u=i.createTexture(a,s.x,s.y,s.w,s.h,s.offX,s.offY,s.sourceW,s.sourceH);if(s.scale9grid){var c=s.scale9grid,l=c.split(",");u.scale9Grid=new egret.Rectangle(parseInt(l[0]),parseInt(l[1]),parseInt(l[2]),parseInt(l[3]))}}return r.save(n,e),i},function(e){throw r.remove(n),e})})},getData:function(e,r,t,o){var n=e.get(r);return n?n.getTexture(o):null},onRemoveStart:function(e,r){var t=e.get(r),o=t.$resourceInfo;t.dispose(),e.unload(o)}};var s=function(e,r){var t="",o=r.split("\n"),n=o[2],i=n.indexOf('file="');-1!=i&&(n=n.substring(i+6),i=n.indexOf('"'),t=n.substring(0,i)),e=e.split("\\").join("/");var i=e.lastIndexOf("/");return e=-1!=i?e.substring(0,i+1)+t:t};r.FontProcessor={onLoadStart:function(r,t){return r.load(t,"text").then(function(o){var n;try{n=JSON.parse(o)}catch(a){n=o}var u;u="string"==typeof n?s(t.url,n):i(t.url,n.file);var c=r.resourceConfig.getResource(e.nameSelector(u));return c||(c={name:u,url:u,type:"image",root:t.root}),r.load(c).then(function(e){var t=new egret.BitmapFont(e,n);return t.$resourceInfo=c,r.save(c,e),t},function(e){throw r.remove(c),e})})},onRemoveStart:function(e,r){var t=e.get(r),o=t.$resourceInfo;e.unload(o)}},r.SoundProcessor={onLoadStart:function(r,t){var o=new egret.Sound;return o.load(e.getVirtualUrl(t.root+t.url)),n(o,t).then(function(){return o})},onRemoveStart:function(e,r){var t=e.get(r);t.close()}},r.MovieClipProcessor={onLoadStart:function(r,t){var o,n;return r.load(t,"json").then(function(i){o=i;var a=t.name,s=a.substring(0,a.lastIndexOf("."))+".png";if(n=r.resourceConfig.getResource(s),!n)throw new e.ResourceManagerError(1001,s);return r.load(n)}).then(function(e){r.save(n,e);var t=e,i=new egret.MovieClipDataFactory(o,t);return i})},onRemoveStart:function(e,r){var t=e.get(r);t.clearCache(),t.$spriteSheet.dispose();var o=r.name,n=o.substring(0,o.lastIndexOf("."))+".png",i=e.resourceConfig.getResource(n);i&&e.unload(i)}},r.MergeJSONProcessor={onLoadStart:function(r,t){return r.load(t,"json").then(function(r){for(var o in r)e.config.addSubkey(o,t.name);return r})},getData:function(e,r,t,o){var n=e.get(r);return n?n[o]:(console.error("missing resource :"+r.name),null)},onRemoveStart:function(e,r){}},r.LegacyResourceConfigProcessor={onLoadStart:function(r,t){return r.load(t,"json").then(function(o){var n=e.config.config,i=t.root,a=n.fileSystem;a||(a={fsData:{},getFile:function(e){return p[e]},addFile:function(e){e.type||(e.type=""),void 0==i&&(e.root=""),p[e.name]=e},profile:function(){console.log(p)},removeFile:function(e){delete p[e]}},n.fileSystem=a);for(var s=n.groups,u=0,c=o.groups;u = T | null; + /** + * 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 + */ + interface IHashObject { + /** + * a unique identification number assigned to this instance. + * @version Egret 2.4 + * @platform Web,Native + * @readOnly + * @language en_US + */ + /** + * 返回此对象唯一的哈希值,用于唯一确定一个对象。hashCode为大于等于1的整数。 + * @version Egret 2.4 + * @platform Web,Native + * @readOnly + * @language zh_CN + */ + hashCode: number; + } + /** + * @private + * 哈希计数 + */ + let $hashCount: number; + /** + * 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 + */ + class HashObject implements IHashObject { + /** + * Initializes a HashObject + * @version Egret 2.4 + * @platform Web,Native + * @language en_US + */ + /** + * 创建一个 HashObject 对象 + * @version Egret 2.4 + * @platform Web,Native + * @language zh_CN + */ + constructor(); + /** + * @private + */ + $hashCode: number; + /** + * 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 + */ + readonly hashCode: number; + } +} +declare namespace egret { + /** + * 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 + */ + 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; + /** + * inspired by pixi.js + */ + private _tint; + /** + * @private + */ + $tintRGB: number; + /** + * Set a tint color for the current object + * @version Egret 5.2.24 + * @platform Web,Native + * @language en_US + */ + /** + * 给当前对象设置填充色 + * @version Egret 5.2.24 + * @platform Web,Native + * @language zh_CN + */ + tint: number; + /** + * @private + * inspired by pixi.js + */ + $sortDirty: boolean; + sortChildren(): void; + /** + * @private + */ + private _zIndex; + /** + * the z-order (front-to-back order) of the object + * @version Egret 5.2.24 + * @platform Web,Native + * @language en_US + */ + /** + * 设置对象的 Z 轴顺序(前后顺序) + * @version Egret 5.2.24 + * @platform Web,Native + * @language zh_CN + */ + zIndex: number; + /** + * @private + */ + $lastSortedIndex: number; + /** + * Allow objects to use zIndex sorting + * @version Egret 5.2.24 + * @platform Web,Native + * @language en_US + */ + /** + * 允许对象使用 zIndex 排序 + * @version Egret 5.2.24 + * @platform Web,Native + * @language zh_CN + */ + sortableChildren: 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(); + /** + * 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 + */ + $ktxData: ArrayBuffer; + /** + * @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; + /** + * The KTX object being referenced. + * @version Egret 5.2.21 + * @platform Web,Native + * @language en_US + */ + /** + * 被引用的 KTXData 对象。 + * @version Egret 5.2.21 + * @platform Web,Native + * @language zh_CN + */ + ktxData: ArrayBuffer; + /** + * Set the KTXData object. + * @version Egret 3.2.1 + * @platform Web,Native + * @language en_US + */ + /** + * 设置 KTXData 对象。 + * @version Egret 3.2.1 + * @platform Web,Native + * @language zh_CN + */ + _setKtxData(value: ArrayBuffer): 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 像素区域的宽度 + * @param height 像素区域的高度 + * @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; + /** + * Set children sort mode. + * @param value {string} The sort mode + * @see egret.ChildrenSortMode + * @version Egret 5.2.19 + * @platform Native + * @language en_US + */ + /** + * 设置子项目的排序方式 + * @param value {string} 排序方式 + * @see egret.ChildrenSortMode + * @version Egret 5.2.19 + * @platform Native + * @language en_US + */ + setChildrenSortMode(value: string): void; + /** + * 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; + private _sortChildrenFunc(a, b); + sortChildren(): void; + } +} +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; + function nrGetCustomImageId(type: number): number; + function nrSetCustomImageData(customImageId: number, pvrtcData: any, width: any, height: any, mipmapsCount: any, format: any): 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 NativeBitmapData { + $init(): any; + $id: any; + } + /** + * @private + */ + class NativeDisplayObject { + id: number; + constructor(type: number); + setChildrenSortMode(mode: string): void; + 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; + static setSourceToNativeBitmapData(nativeBitmapData: egret_native.NativeBitmapData, source: any): any; + setTexture(texture: egret.Texture): void; + setBitmapDataToMesh(texture: egret.Texture): void; + setBitmapDataToParticle(texture: egret.Texture): 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 disposeNativeBitmapData(nativeBitmapData: egret_native.NativeBitmapData): 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 { + /** + * 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 { + /** + * 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 ChildrenSortMode class defines a pattern enumeration for children sort mode of egret.DisplayObjectContainer. + * @version Egret 5.2.19 + * @platform Native + * @language en_US + */ + /** + * BitmapFillMode 类定义egret.DisplayObjectContainer的子项目排序方式。 + * @version Egret 5.2.19 + * @platform Native + * @language zh_CN + */ + const ChildrenSortMode: { + DEFAULT: string; + INCREASE_Y: string; + DECREASE_Y: 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(webglTexture: WebGLTexture): void; + /** + * inspired by pixi.js + */ + static premultiplyTint(tint: number, alpha: number): number; + } +} +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 { + class CompressedTextureData { + glInternalFormat: number; + width: number; + height: number; + byteArray: Uint8Array; + face: number; + level: number; + } + const etc_alpha_mask = "etc_alpha_mask"; + const engine_default_empty_texture = "engine_default_empty_texture"; + const is_compressed_texture = "is_compressed_texture"; + const glContext = "glContext"; + const UNPACK_PREMULTIPLY_ALPHA_WEBGL = "UNPACK_PREMULTIPLY_ALPHA_WEBGL"; + /** + * 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 + */ + $nativeBitmapData: egret_native.NativeBitmapData; + /** + * @private + * + */ + readonly compressedTextureData: Array>; + debugCompressedTextureURL: string; + etcAlphaMask: Nullable; + /** + * 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); + 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; + private _getCompressedTextureData(level, face); + getCompressed2dTextureData(): CompressedTextureData; + hasCompressed2d(): boolean; + clearCompressedTextureData(): 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; + /** + * Can be set to a time in milliseconds.When set to a non-zero value will cause fetching to terminate after the given time has passed. + * @default egret.HttpResponseType.TEXT + * @version Egret 5.2.15 + * @platform Web,Native + * @language en_US + */ + /** + * 代表着一个请求在被自动终止前所消耗的毫秒数。默认值为 0,意味着没有超时。 + * @default egret.HttpResponseType.TEXT + * @version Egret 5.2.15 + * @platform Web,Native + * @language zh_CN + */ + timeout: number; + /** + * 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; + /** + * 以下目前仅供小游戏使用 + * The following are for mini-games only + */ + entryClassName?: string; + scaleMode?: string; + frameRate?: number; + contentWidth?: number; + contentHeight?: number; + orientation?: string; + maxTouches?: number; + showFPS?: boolean; + showLog?: boolean; + fpsStyles?: 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; +} +declare namespace egret { + /** !!!!!!!!inspired by Babylon.js!!!!!!!!!!!!! + * for description see https://www.khronos.org/opengles/sdk/tools/KTX/ + * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/ + * Current families are astc, dxt, pvrtc, etc2, & etc1. + * @returns The extension selected. + */ + class KTXContainer { + /** contents of the KTX container file */ arrayBuffer: any; + private static readonly HEADER_LEN; + private static readonly COMPRESSED_2D; + private static readonly COMPRESSED_3D; + private static readonly TEX_2D; + private static readonly TEX_3D; + /** + * Gets the openGL type + */ + glType: number; + /** + * Gets the openGL type size + */ + glTypeSize: number; + /** + * Gets the openGL format + */ + glFormat: number; + /** + * Gets the openGL internal format + */ + glInternalFormat: number; + /** + * Gets the base internal format + */ + glBaseInternalFormat: number; + /** + * Gets image width in pixel + */ + pixelWidth: number; + /** + * Gets image height in pixel + */ + pixelHeight: number; + /** + * Gets image depth in pixels + */ + pixelDepth: number; + /** + * Gets the number of array elements + */ + numberOfArrayElements: number; + /** + * Gets the number of faces + */ + numberOfFaces: number; + /** + * Gets the number of mipmap levels + */ + numberOfMipmapLevels: number; + /** + * Gets the bytes of key value data + */ + bytesOfKeyValueData: number; + /** + * Gets the load type + */ + loadType: number; + /** + * If the container has been made invalid (eg. constructor failed to correctly load array buffer) + */ + isInvalid: boolean; + /** + * Creates a new KhronosTextureContainer + * @param arrayBuffer contents of the KTX container file + * @param facesExpected should be either 1 or 6, based whether a cube texture or or + * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented + * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented + */ + constructor(/** contents of the KTX container file */ arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean); + /** + * Uploads KTX content to a Babylon Texture. + * It is assumed that the texture has already been created & is currently bound + * @hidden + */ + uploadLevels(bitmapData: egret.BitmapData, loadMipmaps: boolean): void; + private _upload2DCompressedLevels(bitmapData, loadMipmaps); + } +} +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; + }; +} +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; + } + /** + * + */ + interface RenderContext { + } + /** + * 创建一个canvas。 + */ + function mainCanvas(width?: number, height?: number): HTMLCanvasElement; + function createCanvas(width?: number, height?: number): HTMLCanvasElement; + /** + * 重新设置主canvas的大小 + */ + function resizeContext(renderContext: RenderContext, width: number, height: number, useMaxSize?: boolean): void; + /** + * 获得系统的渲染运行时 + */ + function getContextWebGL(surface: HTMLCanvasElement): WebGLRenderingContext; + function getContext2d(surface: HTMLCanvasElement): CanvasRenderingContext2D; + /** + * 仅通过bitmapData创建纹理 + */ + function createTexture(renderContext: RenderContext, bitmapData: BitmapData | HTMLCanvasElement): WebGLTexture; + /** + * 通过 width, height, data创建纹理 + */ + function _createTexture(renderContext: RenderContext, width: number, height: number, data: any): WebGLTexture; + /** + * 画texture + **/ + function drawTextureElements(renderContext: RenderContext, data: any, offset: number): number; + /** + * 测量文本的宽度 + * @param context + * @param text + */ + function measureTextWith(context: CanvasRenderingContext2D, text: string): number; + /** + * 为CanvasRenderBuffer创建一个canvas + * @param defaultFunc + * @param width + * @param height + * @param root + */ + function createCanvasRenderBufferSurface(defaultFunc: (width?: number, height?: number) => HTMLCanvasElement, width?: number, height?: number, root?: boolean): HTMLCanvasElement; + /** + * 改变渲染缓冲的大小并清空缓冲区 + * @param renderContext + * @param width + * @param height + * @param useMaxSize + */ + function resizeCanvasRenderBuffer(renderContext: RenderContext, width: number, height: number, useMaxSize?: 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(forceUpdate?: boolean): 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 { + /** + * @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 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 { + /** + * OrientationMode 类为舞台初始旋转模式提供值。 + */ + const OrientationMode: { + AUTO: string; + PORTRAIT: string; + LANDSCAPE: string; + LANDSCAPE_FLIPPED: string; + }; +} +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 Alipay + * @version Egret 5.2.23 + * @platform All + * @language en_US + */ + /** + * 运行在支付宝小游戏上 + * @version Egret 5.2.26 + * @platform All + * @language zh_CN + */ + const MYGAME = "mygame"; + /** + * 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"; + /** + * Running on Baidu mini game + * @version Egret 5.2.13 + * @platform All + * @language en_US + */ + /** + * 运行在百度小游戏上 + * @version Egret 5.2.13 + * @platform All + * @language zh_CN + */ + const BAIDUGAME = "baidugame"; + /** + * Running on Xiaomi quick game + * @version Egret 5.2.14 + * @platform All + * @language en_US + */ + /** + * 运行在小米快游戏上 + * @version Egret 5.2.14 + * @platform All + * @language zh_CN + */ + const QGAME = "qgame"; + /** + * Running on OPPO mini game + * @version Egret 5.2.14 + * @platform All + * @language en_US + */ + /** + * 运行在 Oppo 小游戏上 + * @version Egret 5.2.14 + * @platform All + * @language zh_CN + */ + const OPPOGAME = "oppogame"; + /** + * Running on QQ mini game + * @version Egret 5.2.25 + * @platform All + * @language en_US + */ + /** + * 运行在 QQ 小游戏上 + * @version Egret 5.2.25 + * @platform All + * @language zh_CN + */ + const QQGAME = "qqgame"; + /** + * Running on vivo mini game + * @version Egret 5.2.23 + * @platform All + * @language en_US + */ + /** + * 运行在 vivo 小游戏上 + * @version Egret 5.2.23 + * @platform All + * @language zh_CN + */ + const VIVOGAME = "vivogame"; + } + interface SupportedCompressedTexture { + pvrtc: boolean; + etc1: boolean; + } + /** + * 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; + /*** + * supported compressed texture + * @version Egret 5.2.19 + * @platform Web,Native + * @language en_US + */ + /*** + * supported compressed texture + * @version Egret 5.2.19 + * @platform Web,Native + * @language zh_CN + */ + static supportedCompressedTexture: SupportedCompressedTexture; + } +} +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 { + /** + * 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 { + /** + * 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 { + /** + * 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 + */ + stageText: egret.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; + protected inputUtils: InputController; + /** + * @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 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 { + /** + * 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 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 { + /** + * 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); + static convertStringToHashCode(str: string): number; + } +} +/** + * @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; +} +/** + * @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; +} diff --git a/libs/modules/egret/egret.js b/libs/modules/egret/egret.js new file mode 100644 index 0000000..8872baa --- /dev/null +++ b/libs/modules/egret/egret.js @@ -0,0 +1,25845 @@ +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; + /** + * inspired by pixi.js + */ + _this._tint = 0; + /** + * @private + */ + _this.$tintRGB = 0; + /** + * @private + * inspired by pixi.js + */ + _this.$sortDirty = false; + /** + * @private + */ + _this._zIndex = 0; + /** + * @private + */ + _this.$lastSortedIndex = 0; + /** + * Allow objects to use zIndex sorting + * @version Egret 5.2.24 + * @platform Web,Native + * @language en_US + */ + /** + * 允许对象使用 zIndex 排序 + * @version Egret 5.2.24 + * @platform Web,Native + * @language zh_CN + */ + _this.sortableChildren = false; + if (egret.nativeRender) { + _this.createNativeDisplayObject(); + } + //默认都是纯白 + _this.tint = 0xFFFFFF; + 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; + if (self.$scaleX == value) { + return; + } + 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; + if (self.$scaleY == value) { + return; + } + 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 + self.$rotation) / 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) { + value = isNaN(value) ? NaN : value; + if (this.$explicitWidth == value) { + return; + } + this.$explicitWidth = 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) { + value = isNaN(value) ? NaN : value; + if (this.$explicitHeight == value) { + return; + } + this.$explicitHeight = 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; + if (self.$anchorOffsetX == value) { + return; + } + self.$anchorOffsetX = value; + if (egret.nativeRender) { + self.$nativeDisplayObject.setAnchorOffsetX(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, "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; + if (self.$anchorOffsetY == value) { + return; + } + self.$anchorOffsetY = value; + if (egret.nativeRender) { + self.$nativeDisplayObject.setAnchorOffsetY(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, "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; + if (self.$visible == value) { + return; + } + 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; + if (self.$alpha == value) { + return; + } + 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(); + 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, "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); + if (self.$blendMode == mode) { + return; + } + 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 ((!egret.nativeRender && !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; + }; + Object.defineProperty(DisplayObject.prototype, "tint", { + /** + * Set a tint color for the current object + * @version Egret 5.2.24 + * @platform Web,Native + * @language en_US + */ + /** + * 给当前对象设置填充色 + * @version Egret 5.2.24 + * @platform Web,Native + * @language zh_CN + */ + get: function () { + return this._tint; + }, + set: function (value) { + this._tint = value; + this.$tintRGB = (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); + }, + enumerable: true, + configurable: true + }); + DisplayObject.prototype.sortChildren = function () { + this.$sortDirty = false; + }; + Object.defineProperty(DisplayObject.prototype, "zIndex", { + /** + * the z-order (front-to-back order) of the object + * @version Egret 5.2.24 + * @platform Web,Native + * @language en_US + */ + /** + * 设置对象的 Z 轴顺序(前后顺序) + * @version Egret 5.2.24 + * @platform Web,Native + * @language zh_CN + */ + get: function () { + return this._zIndex; + }, + set: function (value) { + this._zIndex = value; + if (this.parent) { + this.parent.$sortDirty = true; + } + }, + enumerable: true, + configurable: true + }); + /** + * @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.$ktxData = 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.$ktxData = null; + 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); + }; + Object.defineProperty(Texture.prototype, "ktxData", { + /** + * The KTX object being referenced. + * @version Egret 5.2.21 + * @platform Web,Native + * @language en_US + */ + /** + * 被引用的 KTXData 对象。 + * @version Egret 5.2.21 + * @platform Web,Native + * @language zh_CN + */ + get: function () { + return this.$ktxData; + }, + set: function (data) { + this._setKtxData(data); + }, + enumerable: true, + configurable: true + }); + /** + * Set the KTXData object. + * @version Egret 3.2.1 + * @platform Web,Native + * @language en_US + */ + /** + * 设置 KTXData 对象。 + * @version Egret 3.2.1 + * @platform Web,Native + * @language zh_CN + */ + Texture.prototype._setKtxData = function (value) { + if (!value) { + egret.error('ktx data is null'); + return; + } + if (value == this.$ktxData) { + return; + } + var ktx = new egret.KTXContainer(value, 1); + if (ktx.isInvalid) { + egret.error('ktx data is invalid'); + return; + } + this.$ktxData = value; + var bitmapData = new egret.BitmapData(value); + bitmapData.format = 'ktx'; + ktx.uploadLevels(bitmapData, false); + this._setBitmapData(bitmapData); + }; + /** + * @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 像素区域的宽度 + * @param height 像素区域的高度 + * @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; + } + }; + 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; + var hasEventPool = EventClass.hasOwnProperty("eventPool"); + if (hasEventPool) { + 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 + }); + /** + * Set children sort mode. + * @param value {string} The sort mode + * @see egret.ChildrenSortMode + * @version Egret 5.2.19 + * @platform Native + * @language en_US + */ + /** + * 设置子项目的排序方式 + * @param value {string} 排序方式 + * @see egret.ChildrenSortMode + * @version Egret 5.2.19 + * @platform Native + * @language en_US + */ + DisplayObjectContainer.prototype.setChildrenSortMode = function (value) { + if (egret.nativeRender && this.$nativeDisplayObject.setChildrenSortMode) { + this.$nativeDisplayObject.setChildrenSortMode(value); + } + }; + /** + * 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); + if (egret.nativeRender) { + self.$nativeDisplayObject.addChildAt(child.$nativeDisplayObject.id, index); + } + 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) { + 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); + }; + DisplayObjectContainer.prototype._sortChildrenFunc = function (a, b) { + if (a.zIndex === b.zIndex) { + return a.$lastSortedIndex - b.$lastSortedIndex; + } + return a.zIndex - b.zIndex; + }; + DisplayObjectContainer.prototype.sortChildren = function () { + //关掉脏的标记 + _super.prototype.sortChildren.call(this); + this.$sortDirty = false; + //准备重新排序 + var sortRequired = false; + var children = this.$children; + var child = null; + for (var i = 0, j = children.length; i < j; ++i) { + child = children[i]; + child.$lastSortedIndex = i; + if (!sortRequired && child.zIndex !== 0) { + sortRequired = true; + } + } + if (sortRequired && children.length > 1) { + //开始排 + children.sort(this._sortChildrenFunc); + } + }; + /** + * @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.setTexture(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) { + var self = this; + if (value == self.$fillMode) { + return false; + } + self.$fillMode = value; + if (egret.nativeRender) { + self.$nativeDisplayObject.setBitmapFillMode(self.$fillMode); + } + else { + 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; + }; + 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) { + var self = this; + if (value == this.$smoothing) { + return; + } + this.$smoothing = value; + this.$renderNode.smoothing = value; + if (!egret.nativeRender) { + 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 + }); + /** + * @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) { + /** + * 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) { + //混合模式在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 ChildrenSortMode class defines a pattern enumeration for children sort mode of egret.DisplayObjectContainer. + * @version Egret 5.2.19 + * @platform Native + * @language en_US + */ + /** + * BitmapFillMode 类定义egret.DisplayObjectContainer的子项目排序方式。 + * @version Egret 5.2.19 + * @platform Native + * @language zh_CN + */ + egret.ChildrenSortMode = { + /** + * Default mode. + * @version Egret 5.2.19 + * @platform Native + * @language en_US + */ + /** + * 默认方式。 + * @version Egret 5.2.19 + * @platform Native + * @language zh_CN + */ + DEFAULT: "default", + /** + * Y increase mode. Automatic sorted ascending by y coordinates. + * @version Egret 5.2.19 + * @platform Native + * @language en_US + */ + /** + * Y递增模式。自动按y坐标升序排序。 + * @version Egret 5.2.19 + * @platform Native + * @language en_US + */ + INCREASE_Y: "increaseY", + /** + * Y decrease mode. Automatic sorted descending by y coordinates. + * @version Egret 5.2.19 + * @platform Native + * @language en_US + */ + /** + * Y递减模式。自动按y坐标降序排序。 + * @version Egret 5.2.19 + * @platform Native + * @language en_US + */ + DECREASE_Y: "decreaseY" + }; +})(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 (webglTexture) { + if (!webglTexture) { + return; + } + if (webglTexture[egret.engine_default_empty_texture]) { + if (true) { + //引擎默认的空白纹理,不允许删除 + console.warn('deleteWebGLTexture:' + egret.engine_default_empty_texture); + } + return; + } + var gl = webglTexture[egret.glContext]; + if (gl) { + gl.deleteTexture(webglTexture); + } + else { + if (true) { + console.error('deleteWebGLTexture gl = ' + gl); + } + } + /*old + if (webglTexture && !webglTexture['engine_default_empty_texture']) { + const gl = webglTexture['glContext'] as WebGLRenderingContext;//bitmapData.glContext; + if (gl) { + gl.deleteTexture(webglTexture); + } + else { + console.error('deleteWebGLTexture gl = ' + gl); + } + } + */ + }; + /** + * inspired by pixi.js + */ + WebGLUtils.premultiplyTint = function (tint, alpha) { + if (alpha === 1.0) { + return (alpha * 255 << 24) + tint; + } + if (alpha === 0.0) { + return 0; + } + var R = ((tint >> 16) & 0xFF); + var G = ((tint >> 8) & 0xFF); + var B = (tint & 0xFF); + R = ((R * alpha) + 0.5) | 0; + G = ((G * alpha) + 0.5) | 0; + B = ((B * alpha) + 0.5) | 0; + return (alpha * 255 << 24) + (R << 16) + (G << 8) + B; + }; + 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) { + //refactor + var CompressedTextureData = (function () { + function CompressedTextureData() { + } + return CompressedTextureData; + }()); + egret.CompressedTextureData = CompressedTextureData; + __reflect(CompressedTextureData.prototype, "egret.CompressedTextureData"); + egret.etc_alpha_mask = 'etc_alpha_mask'; + egret.engine_default_empty_texture = 'engine_default_empty_texture'; + egret.is_compressed_texture = 'is_compressed_texture'; + egret.glContext = 'glContext'; + egret.UNPACK_PREMULTIPLY_ALPHA_WEBGL = 'UNPACK_PREMULTIPLY_ALPHA_WEBGL'; + /** + * 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; + /** + * @private + * + */ + _this.compressedTextureData = []; + _this.debugCompressedTextureURL = ''; + _this.etcAlphaMask = null; + if (egret.nativeRender) { + var nativeBitmapData = new egret_native.NativeBitmapData(); + nativeBitmapData.$init(); + _this.$nativeBitmapData = nativeBitmapData; + } + _this.source = source; + // this.width = source.width; + // this.height = source.height; + _this.source = source; + if (_this.source) { + _this.width = +source.width; + _this.height = +source.height; + } + else { + ///compressed texture? + } + return _this; + } + Object.defineProperty(BitmapData.prototype, "source", { + get: function () { + return this.$source; + }, + set: function (value) { + this.$source = value; + if (egret.nativeRender) { + egret_native.NativeDisplayObject.setSourceToNativeBitmapData(this.$nativeBitmapData, value); + } + }, + enumerable: true, + configurable: true + }); + 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(); + } + // WeChat Memory leakage bug + if (this.source && this.source.src) { + this.source.src = ""; + } + this.source = null; + ///dispose compressed texture info + //this.bitmapCompressedData.length = 0; + this.clearCompressedTextureData(); + this.debugCompressedTextureURL = ''; + this.etcAlphaMask = null; + /// + if (egret.nativeRender) { + egret_native.NativeDisplayObject.disposeNativeBitmapData(this.$nativeBitmapData); + } + 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(); + } + } + delete BitmapData._displayList[hashCode]; + }; + BitmapData.prototype._getCompressedTextureData = function (level, face) { + var levelData = this.compressedTextureData[level]; + return levelData ? levelData[face] : null; + }; + BitmapData.prototype.getCompressed2dTextureData = function () { + return this._getCompressedTextureData(0, 0); + }; + BitmapData.prototype.hasCompressed2d = function () { + return !!this.getCompressed2dTextureData(); + }; + BitmapData.prototype.clearCompressedTextureData = function () { + this.compressedTextureData.length = 0; + }; + 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}"; + locale_strings[1051] = "runtime only support webgl render mode"; + locale_strings[1052] = "network request timeout{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"; + //RES 3200-3299 + locale_strings[3200] = "getResByUrl must be called after loadConfig"; + //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!"; + //4500-5000 platform + locale_strings[4500] = "The platform does not support {0} adapter mode and has been automatically replaced with {1} mode, please modify your code adapter logic"; +})(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 + //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}"; + locale_strings[1051] = "runtime 只支持 webgl 渲染模式"; + locale_strings[1052] = "网络请求超时:{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为二进制类型"; + //RES 3200-3299 + locale_strings[3200] = "getResByUrl 必须在 loadConfig 之后调用"; + //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!"; + //4500-5000 platform + locale_strings[4500] = "该平台不支持 {0} 适配模式,已经自动替换为 {1} 模式,请修改您的代码适配逻辑"; +})(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 = 5; + if (nrABIVersion < requiredNrABIVersion) { + egret.nativeRender = false; + var msg = "需要升级微端版本到 0.1.14 才可以开启原生渲染加速"; + 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. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + /** !!!!!!!!inspired by Babylon.js!!!!!!!!!!!!! + * for description see https://www.khronos.org/opengles/sdk/tools/KTX/ + * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/ + * Current families are astc, dxt, pvrtc, etc2, & etc1. + * @returns The extension selected. + */ + var KTXContainer = (function () { + /** + * Creates a new KhronosTextureContainer + * @param arrayBuffer contents of the KTX container file + * @param facesExpected should be either 1 or 6, based whether a cube texture or or + * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented + * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented + */ + function KTXContainer(/** contents of the KTX container file */ arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) { + this.arrayBuffer = arrayBuffer; + /** + * If the container has been made invalid (eg. constructor failed to correctly load array buffer) + */ + this.isInvalid = false; + // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is: + // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n' + // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A + var identifier = new Uint8Array(this.arrayBuffer, 0, 12); + if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 || + identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) { + this.isInvalid = true; + //Logger.Error("texture missing KTX identifier"); + console.error("texture missing KTX identifier"); + return; + } + // load the reset of the header in native 32 bit uint + var dataSize = Uint32Array.BYTES_PER_ELEMENT; + var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize); + var endianness = headerDataView.getUint32(0, true); + var littleEndian = endianness === 0x04030201; + this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures + this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures + this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures + this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,) + this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only) + this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,) + this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,) + this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,) + this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays + this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6 + this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures + this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data + // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing. + if (this.glType !== 0) { + console.error("only compressed formats currently supported"); + return; + } + else { + // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard. + this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels); + } + if (this.pixelHeight === 0 || this.pixelDepth !== 0) { + console.error("only 2D textures currently supported"); + return; + } + if (this.numberOfArrayElements !== 0) { + console.error("texture arrays not currently supported"); + return; + } + if (this.numberOfFaces !== facesExpected) { + console.error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces); + return; + } + // we now have a completely validated file, so could use existence of loadType as success + // would need to make this more elaborate & adjust checks above to support more than one load type + this.loadType = KTXContainer.COMPRESSED_2D; + } + /** + * Uploads KTX content to a Babylon Texture. + * It is assumed that the texture has already been created & is currently bound + * @hidden + */ + KTXContainer.prototype.uploadLevels = function (bitmapData, loadMipmaps) { + if (this.loadType === KTXContainer.COMPRESSED_2D) { + this._upload2DCompressedLevels(bitmapData, loadMipmaps); + } + }; + KTXContainer.prototype._upload2DCompressedLevels = function (bitmapData, loadMipmaps) { + bitmapData.clearCompressedTextureData(); + var compressedTextureData = bitmapData.compressedTextureData; + // initialize width & height for level 1 + var dataOffset = KTXContainer.HEADER_LEN + this.bytesOfKeyValueData; + var width = this.pixelWidth; + var height = this.pixelHeight; + var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1; + for (var level = 0; level < mipmapCount; level++) { + var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps + dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above. + var levelData = []; + for (var face = 0; face < this.numberOfFaces; face++) { + var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize); + var compressedData = new egret.CompressedTextureData; + compressedData.glInternalFormat = this.glInternalFormat; + compressedData.width = width; + compressedData.height = height; + compressedData.byteArray = byteArray; + compressedData.face = face; + compressedData.level = level; + levelData.push(compressedData); + dataOffset += imageSize; // add size of the image for the next face/mipmap + dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image + } + compressedTextureData.push(levelData); + width = Math.max(1.0, width * 0.5); + height = Math.max(1.0, height * 0.5); + } + var compressed2d = bitmapData.getCompressed2dTextureData(); + if (compressed2d) { + bitmapData.width = compressed2d.width; + bitmapData.height = compressed2d.height; + } + }; + KTXContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs) + // load types + KTXContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D() + KTXContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D() + KTXContainer.TEX_2D = 2; // uses a gl.texImage2D() + KTXContainer.TEX_3D = 3; // uses a gl.texImage3D() + return KTXContainer; + }()); + egret.KTXContainer = KTXContainer; + __reflect(KTXContainer.prototype, "egret.KTXContainer"); +})(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. +// +////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// +// +// 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; + } + if (egret.Capabilities.runtimeType != egret.RuntimeType.WXGAME) { + //宽高不是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) { + /** + * 创建一个canvas。 + */ + function mainCanvas(width, height) { + console.error("empty sys.mainCanvas = " + width + ", " + height); + return null; + } + sys.mainCanvas = mainCanvas; + function createCanvas(width, height) { + console.error("empty sys.createCanvas = " + width + ", " + height); + return null; + } + sys.createCanvas = createCanvas; + /** + * 重新设置主canvas的大小 + */ + function resizeContext(renderContext, width, height, useMaxSize) { + console.error("empty sys.resizeContext = " + renderContext + ", " + width + ", " + height + ", " + useMaxSize); + } + sys.resizeContext = resizeContext; + /** + * 获得系统的渲染运行时 + */ + function getContextWebGL(surface) { + console.error("empty sys.getContextWebGL = " + surface); + return null; + } + sys.getContextWebGL = getContextWebGL; + function getContext2d(surface) { + console.error("empty sys.getContext2d = " + surface); + return null; + } + sys.getContext2d = getContext2d; + /** + * 仅通过bitmapData创建纹理 + */ + function createTexture(renderContext, bitmapData) { + console.error("empty sys.createTexture = " + bitmapData); + return null; + } + sys.createTexture = createTexture; + /** + * 通过 width, height, data创建纹理 + */ + function _createTexture(renderContext, width, height, data) { + console.error("empty sys._createTexture = " + width + ", " + height + ", " + data); + return null; + } + sys._createTexture = _createTexture; + /** + * 画texture + **/ + function drawTextureElements(renderContext, data, offset) { + console.error("empty sys.drawTextureElements = " + renderContext + ", " + data + ", " + offset); + return 0; + } + sys.drawTextureElements = drawTextureElements; + /** + * 测量文本的宽度 + * @param context + * @param text + */ + function measureTextWith(context, text) { + console.error("empty sys.measureTextWith = " + context + ", " + text); + return 0; + } + sys.measureTextWith = measureTextWith; + /** + * 为CanvasRenderBuffer创建一个canvas + * @param defaultFunc + * @param width + * @param height + * @param root + */ + function createCanvasRenderBufferSurface(defaultFunc, width, height, root) { + console.error("empty sys.createCanvasRenderBufferSurface = " + width + ", " + height); + return null; + } + sys.createCanvasRenderBufferSurface = createCanvasRenderBufferSurface; + /** + * 改变渲染缓冲的大小并清空缓冲区 + * @param renderContext + * @param width + * @param height + * @param useMaxSize + */ + function resizeCanvasRenderBuffer(renderContext, width, height, useMaxSize) { + console.error("empty sys.resizeContext = " + renderContext + ", " + width + ", " + height + ", " + useMaxSize); + } + sys.resizeCanvasRenderBuffer = resizeCanvasRenderBuffer; + })(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 (forceUpdate) { + 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 || forceUpdate) { + 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) { + /** + * @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 + * 文本渲染节点 + */ + 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) { + /** + * 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. +// +////////////////////////////////////////////////////////////////////////////////////// +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; + } + //遮罩是单纯的填充图形,且alpha为1,性能优化 + if (mask) { + var maskRenderNode = mask.$getRenderNode(); + if ((!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); + maskMatrix.prepend(1, 0, 0, 1, offsetX, offsetY); + context.transform(maskMatrix.a, maskMatrix.b, maskMatrix.c, maskMatrix.d, maskMatrix.tx, maskMatrix.ty); + var calls = this.drawDisplayObject(mask, context, 0, 0); + 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; + if (displayBoundsWidth <= 0 || displayBoundsHeight <= 0) { + return drawCalls; + } + 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 maskRenderNode = mask.$getRenderNode(); + 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 Alipay + * @version Egret 5.2.23 + * @platform All + * @language en_US + */ + /** + * 运行在支付宝小游戏上 + * @version Egret 5.2.26 + * @platform All + * @language zh_CN + */ + RuntimeType.MYGAME = "mygame"; + /** + * 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"; + /** + * Running on Baidu mini game + * @version Egret 5.2.13 + * @platform All + * @language en_US + */ + /** + * 运行在百度小游戏上 + * @version Egret 5.2.13 + * @platform All + * @language zh_CN + */ + RuntimeType.BAIDUGAME = "baidugame"; + /** + * Running on Xiaomi quick game + * @version Egret 5.2.14 + * @platform All + * @language en_US + */ + /** + * 运行在小米快游戏上 + * @version Egret 5.2.14 + * @platform All + * @language zh_CN + */ + RuntimeType.QGAME = "qgame"; + /** + * Running on OPPO mini game + * @version Egret 5.2.14 + * @platform All + * @language en_US + */ + /** + * 运行在 Oppo 小游戏上 + * @version Egret 5.2.14 + * @platform All + * @language zh_CN + */ + RuntimeType.OPPOGAME = "oppogame"; + /** + * Running on QQ mini game + * @version Egret 5.2.25 + * @platform All + * @language en_US + */ + /** + * 运行在 QQ 小游戏上 + * @version Egret 5.2.25 + * @platform All + * @language zh_CN + */ + RuntimeType.QQGAME = "qqgame"; + /** + * Running on vivo mini game + * @version Egret 5.2.23 + * @platform All + * @language en_US + */ + /** + * 运行在 vivo 小游戏上 + * @version Egret 5.2.23 + * @platform All + * @language zh_CN + */ + RuntimeType.VIVOGAME = "vivogame"; + })(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.31"; + /*** + * 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) { + /** + * 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 = {})); +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) { + /** + * 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 = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// 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; + if (!egret.nativeRender) { + 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(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) { + if (egret.nativeRender && self.$font) { + self.$nativeDisplayObject.setDataToBitmapNode(self.$nativeDisplayObject.id, self.$font.$texture, []); + self.$nativeDisplayObject.setWidth(0); + self.$nativeDisplayObject.setHeight(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; + _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) { + if (this.$TextField[37 /* inputType */] == value) { + return; + } + 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) { + value = Math.max(value, 1); + if (value == this.$TextField[28 /* scrollV */]) { + return; + } + this.$TextField[28 /* scrollV */] = value; + 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) { + if (this.$TextField[30 /* multiline */] == value) { + return false; + } + 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; + if (this.$TextField[31 /* border */] == value) { + return; + } + this.$TextField[31 /* border */] = value; + this.$invalidateTextField(); + 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; + if (this.$TextField[32 /* borderColor */] == value) { + return; + } + this.$TextField[32 /* borderColor */] = value; + this.$invalidateTextField(); + 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) { + if (this.$TextField[33 /* background */] == value) { + return; + } + this.$TextField[33 /* background */] = value; + this.$invalidateTextField(); + 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) { + if (this.$TextField[34 /* backgroundColor */] == value) { + return; + } + this.$TextField[34 /* backgroundColor */] = value; + this.$invalidateTextField(); + 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 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) { + /** + * 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; + Object.defineProperty(prototype, '__class__', { + value: className, + enumerable: false, + writable: true + }); + 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); + } + } + } + Object.defineProperty(prototype, '__types__', { + value: types, + enumerable: false, + writable: true + }); + } + 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 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) { + /** + * 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]; + }; + NumberUtils.convertStringToHashCode = function (str) { + if (str.length === 0) { + return 0; + } + var hash = 0; + for (var i = 0, length_9 = str.length; i < length_9; ++i) { + var chr = str.charCodeAt(i); + hash = ((hash << 5) - hash) + chr; + hash |= 0; // Convert to 32bit integer + } + return hash; + }; + 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); + if (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. +// +////////////////////////////////////////////////////////////////////////////////////// diff --git a/libs/modules/egret/egret.min.js b/libs/modules/egret/egret.min.js new file mode 100644 index 0000000..b60b29e --- /dev/null +++ b/libs/modules/egret/egret.min.js @@ -0,0 +1,7 @@ +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,e._tint=0,e.$tintRGB=0,e.$sortDirty=!1,e._zIndex=0,e.$lastSortedIndex=0,e.sortableChildren=!1,t.nativeRender&&e.createNativeDisplayObject(),e.tint=16777215,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)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)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+r.$rotation)/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){t=isNaN(t)?0/0:t,this.$explicitWidth!=t&&(this.$explicitWidth=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){t=isNaN(t)?0/0:t,this.$explicitHeight!=t&&(this.$explicitHeight=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;if(i.$anchorOffsetX!=e)if(i.$anchorOffsetX=e,t.nativeRender)i.$nativeDisplayObject.setAnchorOffsetX(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,"anchorOffsetY",{get:function(){return this.$anchorOffsetY},set:function(t){this.$setAnchorOffsetY(t)},enumerable:!0,configurable:!0}),r.prototype.$setAnchorOffsetY=function(e){var i=this;if(i.$anchorOffsetY!=e)if(i.$anchorOffsetY=e,t.nativeRender)i.$nativeDisplayObject.setAnchorOffsetY(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,"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)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)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;if(!e&&!i.$scrollRect)return void i.$updateRenderMode();if(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)),!t.nativeRender){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,"blendMode",{get:function(){return t.sys.numberToBlendMode(this.$blendMode)},set:function(e){var i=this,r=t.sys.blendModeToNumber(e);if(i.$blendMode!=r)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(e,i){var r=this;if(!t.nativeRender&&!r.$renderNode||!r.$visible||0==r.$scaleX||0==r.$scaleY)return null;var n=r.$getInvertedConcatenatedMatrix();if(0==n.a&&0==n.b&&0==n.c&&0==n.d)return null;var a=r.$getContentBounds(),o=n.a*e+n.c*i+n.tx,s=n.b*e+n.d*i+n.ty;if(a.contains(o,s)){if(!r.$children){var h=r.$scrollRect?r.$scrollRect:r.$maskRect;if(h&&!h.contains(o,s))return null;if(r.$mask&&!r.$mask.$hitTest(e,i))return null}return r}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},Object.defineProperty(r.prototype,"tint",{get:function(){return this._tint},set:function(t){this._tint=t,this.$tintRGB=(t>>16)+(65280&t)+((255&t)<<16)},enumerable:!0,configurable:!0}),r.prototype.sortChildren=function(){this.$sortDirty=!1},Object.defineProperty(r.prototype,"zIndex",{get:function(){return this._zIndex},set:function(t){this._zIndex=t,this.parent&&(this.parent.$sortDirty=!0)},enumerable:!0,configurable:!0}),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.$ktxData=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.$ktxData=null,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)},Object.defineProperty(i.prototype,"ktxData",{get:function(){return this.$ktxData},set:function(t){this._setKtxData(t)},enumerable:!0,configurable:!0}),i.prototype._setKtxData=function(e){if(!e)return void t.error("ktx data is null");if(e!=this.$ktxData){var i=new t.KTXContainer(e,1);if(i.isInvalid)return void t.error("ktx data is invalid");this.$ktxData=e;var r=new t.BitmapData(e);r.format="ktx",i.uploadLevels(r,!1),this._setBitmapData(r)}},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)},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,a=t.hasOwnProperty("eventPool");if(a&&(n=t.eventPool),n||(n=t.eventPool=[]),n.length){var o=n.pop();return o.$type=e,o.$bubbles=!!i,o.$cancelable=!!r,o.$isDefaultPrevented=!1,o.$isPropagationStopped=!1,o.$isPropagationImmediateStopped=!1,o.$eventPhase=2,o}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.setChildrenSortMode=function(e){t.nativeRender&&this.$nativeDisplayObject.setChildrenSortMode&&this.$nativeDisplayObject.setChildrenSortMode(e) +},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),t.nativeRender&&a.$nativeDisplayObject.addChildAt(e.$nativeDisplayObject.id,r);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&&(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.prototype._sortChildrenFunc=function(t,e){return t.zIndex===e.zIndex?t.$lastSortedIndex-e.$lastSortedIndex:t.zIndex-e.zIndex},i.prototype.sortChildren=function(){e.prototype.sortChildren.call(this),this.$sortDirty=!1;for(var t=!1,i=this.$children,r=null,n=0,a=i.length;a>n;++n)r=i[n],r.$lastSortedIndex=n,t||0===r.zIndex||(t=!0);t&&i.length>1&&i.sort(this._sortChildrenFunc)},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.setTexture(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){var i=this;if(e==i.$fillMode)return!1;if(i.$fillMode=e,t.nativeRender)i.$nativeDisplayObject.setBitmapFillMode(i.$fillMode);else{i.$renderDirty=!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())}return!0},Object.defineProperty(i.prototype,"smoothing",{get:function(){return this.$smoothing},set:function(e){var i=this;if(e!=this.$smoothing&&(this.$smoothing=e,this.$renderNode.smoothing=e,!t.nativeRender)){var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},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 m=l+d*$*i,b=u-p*$*r;if(this.cubicCurveTo(y,v,m,b,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(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 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.ChildrenSortMode={DEFAULT:"default",INCREASE_Y:"increaseY",DECREASE_Y:"decreaseY"}}(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(e){if(e&&!e[t.engine_default_empty_texture]){var i=e[t.glContext];i&&i.deleteTexture(e)}},e.premultiplyTint=function(t,e){if(1===e)return(255*e<<24)+t;if(0===e)return 0;var i=t>>16&255,r=t>>8&255,n=255&t;return i=i*e+.5|0,r=r*e+.5|0,n=n*e+.5|0,(255*e<<24)+(i<<16)+(r<<8)+n},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(){function t(){}return t}();t.CompressedTextureData=e,__reflect(e.prototype,"egret.CompressedTextureData"),t.etc_alpha_mask="etc_alpha_mask",t.engine_default_empty_texture="engine_default_empty_texture",t.is_compressed_texture="is_compressed_texture",t.glContext="glContext",t.UNPACK_PREMULTIPLY_ALPHA_WEBGL="UNPACK_PREMULTIPLY_ALPHA_WEBGL";var i=function(e){function i(i){var r=e.call(this)||this;if(r.format="image",r.$deleteSource=!0,r.compressedTextureData=[],r.debugCompressedTextureURL="",r.etcAlphaMask=null,t.nativeRender){var n=new egret_native.NativeBitmapData;n.$init(),r.$nativeBitmapData=n}return r.source=i,r.source=i,r.source&&(r.width=+i.width,r.height=+i.height),r}return __extends(i,e),Object.defineProperty(i.prototype,"source",{get:function(){return this.$source},set:function(e){this.$source=e,t.nativeRender&&egret_native.NativeDisplayObject.setSourceToNativeBitmapData(this.$nativeBitmapData,e)},enumerable:!0,configurable:!0}),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&&this.source.src&&(this.source.src=""),this.source=null,this.clearCompressedTextureData(),this.debugCompressedTextureURL="",this.etcAlphaMask=null,t.nativeRender&&egret_native.NativeDisplayObject.disposeNativeBitmapData(this.$nativeBitmapData),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,m=0;u>d&&(m=u,u=d,d=m),g>y&&(m=g,g=y,y=m),t.x=Math.floor(g>u?u:g),t.width=Math.ceil((d>y?d:y)-t.x),p>f&&(m=p,p=f,f=m),$>v&&(m=$,$=v,v=m),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[1051]="runtime only support webgl render mode",e[1052]="network request timeout{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[3200]="getResByUrl must be called after loadConfig",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!",e[4500]="The platform does not support {0} adapter mode and has been automatically replaced with {1} mode, please modify your code adapter logic"}(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[1051]="runtime 只支持 webgl 渲染模式",e[1052]="网络请求超时:{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[3200]="getResByUrl 必须在 loadConfig 之后调用",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!",e[4500]="该平台不支持 {0} 适配模式,已经自动替换为 {1} 模式,请修改您的代码适配逻辑" +}(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=5;if(r>e){t.nativeRender=!1;var n="需要升级微端版本到 0.1.14 才可以开启原生渲染加速";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(){function e(t,i,r,n){this.arrayBuffer=t,this.isInvalid=!1;var a=new Uint8Array(this.arrayBuffer,0,12);if(171!==a[0]||75!==a[1]||84!==a[2]||88!==a[3]||32!==a[4]||49!==a[5]||49!==a[6]||187!==a[7]||13!==a[8]||10!==a[9]||26!==a[10]||10!==a[11])return this.isInvalid=!0,void console.error("texture missing KTX identifier");var o=Uint32Array.BYTES_PER_ELEMENT,s=new DataView(this.arrayBuffer,12,13*o),h=s.getUint32(0,!0),c=67305985===h;return this.glType=s.getUint32(1*o,c),this.glTypeSize=s.getUint32(2*o,c),this.glFormat=s.getUint32(3*o,c),this.glInternalFormat=s.getUint32(4*o,c),this.glBaseInternalFormat=s.getUint32(5*o,c),this.pixelWidth=s.getUint32(6*o,c),this.pixelHeight=s.getUint32(7*o,c),this.pixelDepth=s.getUint32(8*o,c),this.numberOfArrayElements=s.getUint32(9*o,c),this.numberOfFaces=s.getUint32(10*o,c),this.numberOfMipmapLevels=s.getUint32(11*o,c),this.bytesOfKeyValueData=s.getUint32(12*o,c),0!==this.glType?void console.error("only compressed formats currently supported"):(this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels),0===this.pixelHeight||0!==this.pixelDepth?void console.error("only 2D textures currently supported"):0!==this.numberOfArrayElements?void console.error("texture arrays not currently supported"):this.numberOfFaces!==i?void console.error("number of faces expected"+i+", but found "+this.numberOfFaces):void(this.loadType=e.COMPRESSED_2D))}return e.prototype.uploadLevels=function(t,i){this.loadType===e.COMPRESSED_2D&&this._upload2DCompressedLevels(t,i)},e.prototype._upload2DCompressedLevels=function(i,r){i.clearCompressedTextureData();for(var n=i.compressedTextureData,a=e.HEADER_LEN+this.bytesOfKeyValueData,o=this.pixelWidth,s=this.pixelHeight,h=r?this.numberOfMipmapLevels:1,c=0;h>c;c++){var l=new Int32Array(this.arrayBuffer,a,1)[0];a+=4;for(var u=[],p=0;pu?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 t.Capabilities.runtimeType!=t.RuntimeType.WXGAME&&(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){function e(t,e){return console.error("empty sys.mainCanvas = "+t+", "+e),null}function i(t,e){return console.error("empty sys.createCanvas = "+t+", "+e),null}function r(t,e,i,r){console.error("empty sys.resizeContext = "+t+", "+e+", "+i+", "+r)}function n(t){return console.error("empty sys.getContextWebGL = "+t),null}function a(t){return console.error("empty sys.getContext2d = "+t),null}function o(t,e){return console.error("empty sys.createTexture = "+e),null}function s(t,e,i,r){return console.error("empty sys._createTexture = "+e+", "+i+", "+r),null}function h(t,e,i){return console.error("empty sys.drawTextureElements = "+t+", "+e+", "+i),0}function c(t,e){return console.error("empty sys.measureTextWith = "+t+", "+e),0}function l(t,e,i,r){return console.error("empty sys.createCanvasRenderBufferSurface = "+e+", "+i),null}function u(t,e,i,r){console.error("empty sys.resizeContext = "+t+", "+e+", "+i+", "+r)}t.mainCanvas=e,t.createCanvas=i,t.resizeContext=r,t.getContextWebGL=n,t.getContext2d=a,t.createTexture=o,t._createTexture=s,t.drawTextureElements=h,t.measureTextWith=c,t.createCanvasRenderBufferSurface=l,t.resizeCanvasRenderBuffer=u}(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(i){for(var r=t.getTimer(),n=this.callBackList,a=this.thisObjectList,o=n.length,s=e.$requestRenderingFlag,h=t.getTimer(),c=t.lifecycle.contexts,l=0,u=c;ld;d++)n[d].call(a[d],h)&&(s=!0);var f=t.getTimer(),g=h-this.lastTimeStamp;if(this.lastTimeStamp=h,g>=this.frameDeltaTime||i)this.lastCount=this.frameInterval;else{if(this.lastCount-=1e3,this.lastCount>0)return void(s&&this.render(!1,this.costEnterFrame+f-r));this.lastCount+=this.frameInterval}this.render(!0,this.costEnterFrame+f-r);var $=t.getTimer();this.broadcastEnterFrame();var y=t.getTimer();this.costEnterFrame=y-$},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 m=p/l*v,b=d/u*v;e.drawImage(n,a,o,s,m*h,b*c,m*o,b*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 m=r.x-h,b=r.y-c,x=m/t.$TextureScaleFactor,T=b/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,C=S+T,F=C+D,P=v-T-D,M=R*t.$TextureScaleFactor,j=P*t.$TextureScaleFactor;if((x+R)*t.$TextureScaleFactor>p||(T+P)*t.$TextureScaleFactor>d)return void e.drawImage(n,a,o,s,h,c,p,d);var A=h,B=A+m,N=A+(p-M),k=p-m-M,L=c,I=L+b,U=L+d-j,H=d-b-j;T>0&&(x>0&&e.drawImage(O,S,x,T,A,L,m,b),_>0&&e.drawImage(w,S,_,T,B,L,k,b),R>0&&e.drawImage(E,S,R,T,N,L,M,b)),D>0&&(x>0&&e.drawImage(O,C,x,D,A,I,m,H),_>0&&e.drawImage(w,C,_,D,B,I,k,H),R>0&&e.drawImage(E,C,R,D,N,I,M,H)),P>0&&(x>0&&e.drawImage(O,F,x,P,A,U,m,j),_>0&&e.drawImage(w,F,_,P,B,U,k,j),R>0&&e.drawImage(E,F,R,P,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){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.height>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],m=r[15],b=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]=m*w+b*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,m=0,b=$-4*r,x=$+4*(r+1);y>$;$+=4,m+=4,x+=4,b+=4)0===d?(a[m+0]=0,a[m+1]=0,a[m+2]=0,a[m+3]=0):(a[m+0]=l/d,a[m+1]=u/d,a[m+2]=p/d,a[m+3]=d/s),f=t[x+3],g=t[b+3],f||0==f?g||0==g?(l+=t[x+0]*f-t[b+0]*g,u+=t[x+1]*f-t[b+1]*g,p+=t[x+2]*f-t[b+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[b+0]*g,u+=-t[b+1]*g,p+=-t[b+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,m=h-r*a,b=h+(r+1)*a;$>g;g+=a,v+=4,b+=a,m+=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[b+3],f=t[m+3],d||0==d?f||0==f?(c+=t[b+0]*d-t[m+0]*f,l+=t[b+1]*d-t[m+1]*f,u+=t[b+2]*d-t[m+2]*f,p+=d-f):(c+=t[b+0]*d,l+=t[b+1]*d,u+=t[b+2]*d,p+=d):(f||0==f)&&(c+=-t[m+0]*f,l+=-t[m+1]*f,u+=-t[m+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,m=0,b=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 C=0,F=S*e*4+4*R,P=0,M=0,j=t[F+0]/255,A=t[F+1]/255,B=t[F+2]/255,N=t[F+3]/255,k=0;2*O>=k;k+=2*O/D){g=Math.cos(k+C),$=Math.sin(k+C);for(var L=0;T>L;L++){v=L*w*g,m=L*E*$;var I=Math.round(R+v-b),U=Math.round(S+m-x),H=0;if(I>=e||0>I||0>U||U>=i)H=0;else{var X=U*e*4+4*I;H=t[X+3]/255}P+=(T-L)*H,M+=T-L}}N=Math.max(N,1e-4);var Y=P/M*c*y*(1-l)*Math.max(Math.min(p,u),1-N),W=(M-P)/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),K=Y/(W+N+Y),J=f(z,r[0],K),Q=f(V,r[1],K),Z=f(q,r[2],K),te=Math.min(N+Y+W,1); +d[F+0]=255*J,d[F+1]=255*Q,d[F+2]=255*Z,d[F+3]=255*te}_?t.set(d):n(t,d)}var $=["source-over","lighter","destination-out"],y="source-over",v="#000000",m={none:"butt",square:"square",round:"round"},b=[],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){b.length>6&&(b.length=6);for(var h=b.length,c=0;h>c;c++)b[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,m=p.height;if(0>=v||0>=m)return s;var b=this.createRenderBuffer(v-d,m-f,!0),T=b.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,b.surface.width,b.surface.height),D=0;l>D;D++){var O=h[D];if("colorTransform"==O.type)a(_.data,b.surface.width,b.surface.height,O.$matrix);else if("blur"==O.type)o(_.data,b.surface.width,b.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,b.surface.width,b.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,b.surface.width,b.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(b.surface,i+d,r+f),u&&(e.globalCompositeOperation=y)}return x.push(b),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;if(c){var u=c.$getRenderNode();if((!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),p.prepend(1,0,0,1,r,n),i.transform(p.a,p.b,p.c,p.d,p.tx,p.ty);var d=this.drawDisplayObject(c,i,0,0);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,m=f.width,x=f.height;if(0>=m||0>=x)return o;var T=this.createRenderBuffer(m,x),_=T.context;if(!_)return o+=this.drawDisplayObject(e,i,r,n);if(o+=this.drawDisplayObject(e,_,-g,-v),c){var u=c.$getRenderNode(),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(m,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),b.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)),b.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],m=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,m,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),b.push(E)}else for(;s>h;)if(f++,t.rotated){var v=o[h++],m=o[h++],T=o[h++],x=o[h++],C=o[h++],F=o[h++],w=o[h++],O=o[h++];e.save(),e.transform(0,-1,1,0,0,O),e.drawImage(i.source,v,m,x,T,C+e.$offsetX,F+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=m[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():b.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.MYGAME="mygame",t.WXGAME="wxgame",t.BAIDUGAME="baidugame",t.QGAME="qgame",t.OPPOGAME="oppogame",t.QQGAME="qqgame",t.VIVOGAME="vivogame"}(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.31",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;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){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(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){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(e){var i=this;if(e!=i.$smoothing&&(i.$smoothing=e,!t.nativeRender)){var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},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)return void(t.nativeRender&&e.$font&&(e.$nativeDisplayObject.setDataToBitmapNode(e.$nativeDisplayObject.id,e.$font.$texture,[]),e.$nativeDisplayObject.setWidth(0),e.$nativeDisplayObject.setHeight(0)));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 m=y[v];if(u&&v>0&&$+m>f)break;var b=r[v],x=b.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=b.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)}$+=m+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 m&&n.length>0&&f>m?!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,m=r.$textFieldHeight,b=r.$font,x=b._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 C=0;S>C;C++){s||(l+=p);var F=R.charAt(C),P=void 0,M=void 0,j=0,A=0,B=b.getTexture(F);if(B)P=B.$getTextureWidth(),M=B.$getTextureHeight(),j=B.$offsetX,A=B.$offsetY;else{if(" "!=F){t.$warn(1046,F),s&&(s=!1);continue}P=T,M=x}if(s&&(s=!1),w&&(w=!1),y&&C>0&&l+P>v){if(!e(R.substring(0,C)))break;R=R.substring(C),S=R.length,C=0,l=C==S-1?P:b.getConfig(F,"xadvance")||P,c=M}else l+=C==S-1?P:b.getConfig(F,"xadvance")||P,c=Math.max(M,c)}if(m&&E>0&&f>m)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))),m>f&&(N=r.$verticalAlign,N==t.VerticalAlign.BOTTOM?this.$textStartY=m-f:N==t.VerticalAlign.MIDDLE&&(this.$textStartY=Math.floor((m-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&&(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){e=Math.max(e,1),e!=this.$TextField[28]&&(this.$TextField[28]=e,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?!1:(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&&(this.$TextField[31]=e,this.$invalidateTextField(),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&&(this.$TextField[32]=e,this.$invalidateTextField(),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&&(this.$TextField[33]=e,this.$invalidateTextField(),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&&(this.$TextField[34]=e,this.$invalidateTextField(),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 m=!0;if(""==$[y])y==v-1&&(m=!1);else{var b=e($[y],r,f.style);if(isNaN(a))h+=b,c+=$[y].length,o.elements.push({width:b,text:$[y],style:f.style}),y==v-1&&(m=!1);else if(a>=h+b)o.elements.push({width:b,text:$[y],style:f.style}),h+=b,c+=$[y].length,y==v-1&&(m=!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),C=D[x+1].charCodeAt(0);if(S>=55296&&56319>=S&&56320==(64512&C)){var F=D[x]+D[x+1];E=2,R=!0,b=e(F,r,f.style)}else b=e(D[x],r,f.style)}else b=e(D[x],r,f.style);if(0!=h&&h+b>a&&h+x!=0)break;if(T+b>a)for(var P=D[x].match(/./g),M=0,j=P.length;j>M;M++){var E=P[M].length,A=!1;if(1==E&&j-1>M){var S=P[M].charCodeAt(0),C=P[M+1].charCodeAt(0);if(S>=55296&&56319>=S&&56320==(64512&C)){var F=P[M]+P[M+1];E=2,A=!0,b=e(F,r,f.style)}else b=e(P[M],r,f.style)}else b=e(P[M],r,f.style);if(M>0&&h+b>a)break;w+=E,T+=b,h+=b,c+=w,A&&M++}else w+=E,T+=b,h+=b,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--,m=!1)}}m&&(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,m=$.elements.length;m>v;v++){var b=$.elements[v],x=b.style.size||i[0];e.drawText(p,s+(y-x)/2,b.text,b.style),b.style.underline&&d.push(p,s+y/2,b.width,b.style.textColor),p+=b.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;i=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){function e(t,e,i){var r=t.prototype;Object.defineProperty(r,"__class__",{value:e,enumerable:!1,writable:!0});var n=[e];i&&(n=n.concat(i));var a=r.__types__;if(r.__types__)for(var o=a.length,s=0;o>s;s++){var h=a[s];-1==n.indexOf(h)&&n.push(h)}Object.defineProperty(r,"__types__",{value:n,enumerable:!1,writable:!0})}t.registerClass=e}(egret||(egret={}));var egret;!function(t){t.BitmapFillMode={REPEAT:"repeat",SCALE:"scale",CLIP:"clip"}}(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.convertStringToHashCode=function(t){if(0===t.length)return 0;for(var e=0,i=0,r=t.length;r>i;++i){var n=t.charCodeAt(i);e=(e<<5)-e+n,e|=0}return e},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(0==this.repeatCount||this._currentCount<=this.repeatCount)&&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={})); \ No newline at end of file diff --git a/libs/modules/egret/egret.web.js b/libs/modules/egret/egret.web.js new file mode 100644 index 0000000..15d58a7 --- /dev/null +++ b/libs/modules/egret/egret.web.js @@ -0,0 +1,9806 @@ +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 egret; +(function (egret) { + var web; + (function (web) { + /** + * @private + */ + var WebGeolocation = (function (_super) { + __extends(WebGeolocation, _super); + /** + * @private + */ + function WebGeolocation(option) { + var _this = _super.call(this) || this; + /** + * @private + */ + _this.onUpdate = function (position) { + var event = new egret.GeolocationEvent(egret.Event.CHANGE); + var coords = position.coords; + event.altitude = coords.altitude; + event.heading = coords.heading; + event.accuracy = coords.accuracy; + event.latitude = coords.latitude; + event.longitude = coords.longitude; + event.speed = coords.speed; + event.altitudeAccuracy = coords.altitudeAccuracy; + _this.dispatchEvent(event); + }; + /** + * @private + */ + _this.onError = function (error) { + var errorType = egret.GeolocationEvent.UNAVAILABLE; + if (error.code == error.PERMISSION_DENIED) + errorType = egret.GeolocationEvent.PERMISSION_DENIED; + var event = new egret.GeolocationEvent(egret.IOErrorEvent.IO_ERROR); + event.errorType = errorType; + event.errorMessage = error.message; + _this.dispatchEvent(event); + }; + _this.geolocation = navigator.geolocation; + return _this; + } + /** + * @private + * + */ + WebGeolocation.prototype.start = function () { + var geo = this.geolocation; + if (geo) + this.watchId = geo.watchPosition(this.onUpdate, this.onError); + else + this.onError({ + code: 2, + message: egret.sys.tr(3004), + PERMISSION_DENIED: 1, + POSITION_UNAVAILABLE: 2 + }); + }; + /** + * @private + * + */ + WebGeolocation.prototype.stop = function () { + var geo = this.geolocation; + geo.clearWatch(this.watchId); + }; + return WebGeolocation; + }(egret.EventDispatcher)); + web.WebGeolocation = WebGeolocation; + __reflect(WebGeolocation.prototype, "egret.web.WebGeolocation", ["egret.Geolocation"]); + })(web = egret.web || (egret.web = {})); +})(egret || (egret = {})); +var egret; +(function (egret) { + var web; + (function (web) { + /** + * @private + */ + var WebMotion = (function (_super) { + __extends(WebMotion, _super); + function WebMotion() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.onChange = function (e) { + var event = new egret.MotionEvent(egret.Event.CHANGE); + var acceleration = { + x: e.acceleration.x, + y: e.acceleration.y, + z: e.acceleration.z + }; + var accelerationIncludingGravity = { + x: e.accelerationIncludingGravity.x, + y: e.accelerationIncludingGravity.y, + z: e.accelerationIncludingGravity.z + }; + var rotation = { + alpha: e.rotationRate.alpha, + beta: e.rotationRate.beta, + gamma: e.rotationRate.gamma + }; + event.acceleration = acceleration; + event.accelerationIncludingGravity = accelerationIncludingGravity; + event.rotationRate = rotation; + _this.dispatchEvent(event); + }; + return _this; + } + /** + * @private + * + */ + WebMotion.prototype.start = function () { + window.addEventListener("devicemotion", this.onChange); + }; + /** + * @private + * + */ + WebMotion.prototype.stop = function () { + window.removeEventListener("devicemotion", this.onChange); + }; + return WebMotion; + }(egret.EventDispatcher)); + web.WebMotion = WebMotion; + __reflect(WebMotion.prototype, "egret.web.WebMotion", ["egret.Motion"]); + })(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 + */ + 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 + * @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 () { + egret.log('sound decode error'); + 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.addEventListener("load", function () { + var ioError = (request.status >= 400); + 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.addEventListener("error", function () { + self.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); + }); + 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; + } + WebVideo.prototype.createNativeDisplayObject = function () { + this.$nativeDisplayObject = new egret_native.NativeDisplayObject(1 /* BITMAP */); + }; + /** + * @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; + this.video.pause(); + 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(); + if (egret.nativeRender) { + var texture = new egret.Texture(); + texture._setBitmapData(_this.posterData); + _this.$nativeDisplayObject.setTexture(texture); + } + }, 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; + if (this.paused) { + var self_1 = this; + this.$renderDirty = true; + window.setTimeout(function () { + self_1.$renderDirty = false; + }, 200); + } + _super.prototype.$setHeight.call(this, value); + }; + /** + * @private + * 设置显示宽度 + */ + WebVideo.prototype.$setWidth = function (value) { + this.widthSet = value; + if (this.paused) { + var self_2 = this; + this.$renderDirty = true; + window.setTimeout(function () { + self_2.$renderDirty = false; + }, 200); + } + _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; + /** + * + */ + _this.timeout = 0; + /** + * @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; + } + var xhr = this.getXHR(); //new XMLHttpRequest(); + if (window["XMLHttpRequest"]) { + xhr.addEventListener("load", this.onload.bind(this)); + xhr.addEventListener("error", this.onerror.bind(this)); + } + else { + xhr.onreadystatechange = this.onReadyStateChange.bind(this); + } + xhr.onprogress = this.updateProgress.bind(this); + xhr.ontimeout = this.onTimeout.bind(this); + xhr.open(this._method, this._url, true); + this._xhr = xhr; + }; + /** + * @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.timeout = this.timeout; + 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.onTimeout = function () { + if (true) { + egret.$warn(1052, this._url); + } + this.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); + }; + /** + * @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_3 = this; + window.setTimeout(function () { + if (ioError_1) { + if (true && !self_3.hasEventListener(egret.IOErrorEvent.IO_ERROR)) { + egret.$error(1011, url_1); + } + self_3.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); + } + else { + self_3.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); + } + }; + /** + * @private + */ + WebHttpRequest.prototype.onload = function () { + var self = this; + var xhr = this._xhr; + var url = this._url; + var ioError = (xhr.status >= 400); + window.setTimeout(function () { + if (ioError) { + if (true && !self.hasEventListener(egret.IOErrorEvent.IO_ERROR)) { + egret.$error(1011, url); + } + self.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); + } + else { + self.dispatchEventWith(egret.Event.COMPLETE); + } + }, 0); + }; + /** + * @private + */ + WebHttpRequest.prototype.onerror = function () { + var url = this._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); + }; + 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.onFocusHandler = function () { + //the soft keyboard will cover the input box in some cases + var self = this; + window.setTimeout(function () { + if (self.inputElement) { + self.inputElement.scrollIntoView(); + } + }, 200); + }; + /** + * @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); + } + if (this.inputElement.onfocus == null) { + this.inputElement.onfocus = this.onFocusHandler.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) { + if (this._inputElement) { + this._inputElement.blur(); + } + this.clearInputElement(); + } + this._needShow = false; + }; + /** + * @private + * + */ + HTMLInput.prototype.clearInputElement = function () { + var self = this; + if (self._inputElement) { + self._inputElement.value = ""; + self._inputElement.onblur = null; + self._inputElement.onfocus = 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 egret.sys.measureTextWith(context, text); + } + /** + * @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 = egret.sys.createCanvas(width, 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 = egret.sys.createCanvasRenderBufferSurface(__createCanvas__, width, height, root); + this.context = this.surface.getContext("2d"); + if (this.context) { + this.context.$offsetX = 0; + this.context.$offsetY = 0; + } + this.resize(width, height); + } + 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) { + egret.sys.resizeCanvasRenderBuffer(this, width, height, useMaxSize); + }; + /** + * 获取指定区域的像素 + */ + 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"]; + var isIos = ua.indexOf("iphone") >= 0 || ua.indexOf("ipad") >= 0 || ua.indexOf("ipod") >= 0; + 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 if (!isIos && ua.indexOf("safari") >= 0 && ua.indexOf("chrome") === -1) { + // In Safari browser on Mac,use web audio + checkAudioType = false; + Html5Capatibility.setAudioType(AudioType.WEB_AUDIO); + } + else { + checkAudioType = true; + Html5Capatibility.setAudioType(AudioType.HTML5_AUDIO); + } + if (ua.indexOf("android") >= 0) { + if (checkAudioType && canUseWebAudio) { + Html5Capatibility.setAudioType(AudioType.WEB_AUDIO); + } + } + else if (isIos) { + 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) { + /** + * 创建一个canvas。 + */ + function mainCanvas(width, height) { + return createCanvas(width, height); + } + egret.sys.mainCanvas = mainCanvas; + function createCanvas(width, height) { + var canvas = document.createElement("canvas"); + if (!isNaN(width) && !isNaN(height)) { + canvas.width = width; + canvas.height = height; + } + return canvas; + } + egret.sys.createCanvas = createCanvas; + /** + * sys.resizeContext。 + */ + function resizeContext(renderContext, width, height, useMaxSize) { + if (!renderContext) { + return; + } + var webglrendercontext = renderContext; + var surface = webglrendercontext.surface; + if (useMaxSize) { + if (surface.width < width) { + surface.width = width; + } + if (surface.height < height) { + surface.height = height; + } + } + else { + if (surface.width !== width) { + surface.width = width; + } + if (surface.height !== height) { + surface.height = height; + } + } + webglrendercontext.onResize(); + } + web.resizeContext = resizeContext; + egret.sys.resizeContext = resizeContext; + /** + * sys.getContextWebGL + */ + function getContextWebGL(surface) { + var options = { + antialias: web.WebGLRenderContext.antialias, + stencil: true //设置可以使用模板(用于不规则遮罩) + }; + var gl = null; + //todo 是否使用chrome源码names + //let contextNames = ["moz-webgl", "webkit-3d", "experimental-webgl", "webgl", "3d"]; + var names = ["webgl", "experimental-webgl"]; + for (var i = 0; i < names.length; ++i) { + try { + gl = surface.getContext(names[i], options); + } + catch (e) { + } + if (gl) { + break; + } + } + if (!gl) { + egret.$error(1021); + } + return gl; + } + egret.sys.getContextWebGL = getContextWebGL; + /** + * sys.getContext2d + */ + function getContext2d(surface) { + return surface ? surface.getContext('2d') : null; + } + web.getContext2d = getContext2d; + egret.sys.getContext2d = getContext2d; + /** + * 创建一个WebGLTexture + */ + function createTexture(renderContext, bitmapData) { + var webglrendercontext = renderContext; + var gl = webglrendercontext.context; + var texture = gl.createTexture(); + if (!texture) { + //先创建texture失败,然后lost事件才发出来.. + webglrendercontext.contextLost = true; + return; + } + texture[egret.glContext] = gl; + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1); + texture[egret.UNPACK_PREMULTIPLY_ALPHA_WEBGL] = true; + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, bitmapData); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + return texture; + } + egret.sys.createTexture = createTexture; + /** + * 创建一个WebGLTexture + */ + function _createTexture(renderContext, width, height, data) { + var webglrendercontext = renderContext; + var gl = webglrendercontext.context; + var texture = gl.createTexture(); + if (!texture) { + //先创建texture失败,然后lost事件才发出来.. + webglrendercontext.contextLost = true; + return null; + } + // + texture[egret.glContext] = gl; + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1); + texture[egret.UNPACK_PREMULTIPLY_ALPHA_WEBGL] = true; + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, data); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + return texture; + } + egret.sys._createTexture = _createTexture; + /** + * 画texture + **/ + function drawTextureElements(renderContext, data, offset) { + var webglrendercontext = renderContext; + var gl = webglrendercontext.context; + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, data.texture); + var size = data.count * 3; + gl.drawElements(gl.TRIANGLES, size, gl.UNSIGNED_SHORT, offset * 2); + return size; + } + egret.sys.drawTextureElements = drawTextureElements; + /** + * 测量文本的宽度 + * @param context + * @param text + */ + function measureTextWith(context, text) { + return context.measureText(text).width; + } + egret.sys.measureTextWith = measureTextWith; + /** + * 为CanvasRenderBuffer创建一个HTMLCanvasElement + * @param defaultFunc + * @param width + * @param height + * @param root + */ + function createCanvasRenderBufferSurface(defaultFunc, width, height, root) { + return defaultFunc(width, height); + } + egret.sys.createCanvasRenderBufferSurface = createCanvasRenderBufferSurface; + /** + * 改变渲染缓冲的大小并清空缓冲区 + * @param renderContext + * @param width + * @param height + * @param useMaxSize + */ + function resizeCanvasRenderBuffer(renderContext, width, height, useMaxSize) { + var canvasRenderBuffer = renderContext; + var surface = canvasRenderBuffer.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) { + canvasRenderBuffer.context.globalCompositeOperation = "source-over"; + canvasRenderBuffer.context.setTransform(1, 0, 0, 1, 0, 0); + canvasRenderBuffer.context.globalAlpha = 1; + } + } + else { + if (surface.width != width) { + surface.width = width; + } + if (surface.height != height) { + surface.height = height; + } + } + canvasRenderBuffer.clear(); + } + egret.sys.resizeCanvasRenderBuffer = resizeCanvasRenderBuffer; + egret.Geolocation = egret.web.WebGeolocation; + egret.Motion = egret.web.WebMotion; + })(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(); + var renderMode = options.renderMode; + // WebGL上下文参数自定义 + if (renderMode == "webgl") { + // WebGL抗锯齿默认关闭,提升PC及某些平台性能 + var antialias = options.antialias; + web.WebGLRenderContext.antialias = !!antialias; + // WebGLRenderContext.antialias = (typeof antialias == undefined) ? true : antialias; + } + egret.sys.CanvasRenderBuffer = web.CanvasRenderBuffer; + if (ua.indexOf("egretnative") >= 0 && renderMode != "webgl") { + egret.$warn(1051); + renderMode = "webgl"; + } + setRenderMode(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() { + requestAnimationFrame(onTick); + ticker.update(); + } + } + //覆盖原生的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 (navigator.platform == "MacIntel" && navigator.maxTouchPoints > 1) { + capabilities["os" + ""] = "iOS"; + capabilities["isMobile" + ""] = true; + } + 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",o.id="egret-fps-panel",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 l=document.createElement("div");this.divCost=l,l.innerHTML='0 0',o.appendChild(l),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],l=this.arrFps[0],c=0;o>c;c++){var h=this.arrFps[c];a+=h,s>h?s=h:h>l&&(l=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 x=Math.floor(n/2);1>x?x=1:x>20&&(x=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-x,1,x);var y=Math.floor(a/o),m=r+" FPS "+this.renderMode;this.showPanle&&(m+="
      min"+s+" max"+l+" avg"+y,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){console.log("Egret Engine Version:",e.Capabilities.engineVersion);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 l=new t.WebTouchHandler(a,s),c=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||c.displayFPS(n.showFPS,n.showLog,n.logFilter,n.fpsStyles)),this.playerOption=n,this.container=r,this.canvas=s,this.stage=a,this.player=c,this.webTouchHandler=l,this.webInput=h,e.web.$cacheTextAdapter(h,a,r,s),this.updateScreenSize(),this.updateMaxTouches(),c.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||l==e.OrientationMode.PORTRAIT&&a>o);var c=s?o:a,h=s?a:o;e.Capabilities.boundingClientWidth=c,e.Capabilities.boundingClientHeight=h;var u=e.sys.screenAdapter.calculateStageSize(this.stage.$scaleMode,c,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?l==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 x=p/d,y=v/f,m=x*e.sys.DisplayList.$canvasScaleFactor,b=y*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(x/m,y/b),w.rotate(g*Math.PI/180);var T="matrix("+w.a+","+w.b+","+w.c+","+w.d+","+w.tx+","+w.ty+")";e.Matrix.release(w),t.style[e.web.getPrefixStyleName("transform")]=T,e.sys.DisplayList.$setCanvasScale(m,b),this.webTouchHandler.updateScaleMode(x,y,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=e.sys.createCanvas(),l=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,c=s;if(c.style.width=a+"px",c.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,l=n.length,c=0;l>c;c++){var h=n[c],u=h.name;0!=u.indexOf("xmlns:")&&(s[u]=h.value,r["$"+u]=h.value)}var d=e.childNodes;l=d.length;for(var f=r.children,c=0;l>c;c++){var p=d[c],v=p.nodeType,g=null;if(1==v)g=i(p,r);else if(3==v){var x=p.textContent.trim();x&&(g=new o(x,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(){function e(){}return e.call=function(e,t){},e.addCallback=function(e,t){},e}();t.WebExternalInterface=r,__reflect(r.prototype,"egret.web.WebExternalInterface",["egret.ExternalInterface"]);var i=navigator.userAgent.toLowerCase();i.indexOf("egretnative")<0&&(e.ExternalInterface=r)}(t=e.web||(e.web={}))}(egret||(egret={})),function(e){var t;!function(t){function r(t){var r=JSON.parse(t),n=r.functionName,a=i[n];if(a){var o=r.value;a.call(null,o)}else e.$warn(1050,n)}var i={},n=function(){function e(){}return e.call=function(e,t){var r={};r.functionName=e,r.value=t,egret_native.sendInfoToPlugin(JSON.stringify(r))},e.addCallback=function(e,t){i[e]=t},e}();t.NativeExternalInterface=n,__reflect(n.prototype,"egret.web.NativeExternalInterface",["egret.ExternalInterface"]);var a=navigator.userAgent.toLowerCase();a.indexOf("egretnative")>=0&&(e.ExternalInterface=n,egret_native.receivedPluginInfo=r)}(t=e.web||(e.web={}))}(egret||(egret={})),function(e){var t;!function(t){var r={},i=function(){function t(){}return t.call=function(e,t){__global.ExternalInterface.call(e,t)},t.addCallback=function(e,t){r[e]=t},t.invokeCallback=function(t,i){var n=r[t];n?n.call(null,i):e.$warn(1050,t)},t}();t.WebViewExternalInterface=i,__reflect(i.prototype,"egret.web.WebViewExternalInterface",["egret.ExternalInterface"]);var n=navigator.userAgent.toLowerCase();n.indexOf("egretwebview")>=0&&(e.ExternalInterface=i)}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(r){function i(){var e=r.call(this)||this;return e.loaded=!1,e}return __extends(i,r),Object.defineProperty(i.prototype,"length",{get:function(){if(this.originAudio)return this.originAudio.duration;throw new Error("sound not loaded!")},enumerable:!0,configurable:!0}),i.prototype.load=function(t){function r(){i.$recycle(o.url,s),a(),l.indexOf("firefox")>=0&&(s.pause(),s.muted=!1),c&&document.body.appendChild(s),o.loaded=!0,o.dispatchEventWith(e.Event.COMPLETE)}function n(){a(),o.dispatchEventWith(e.IOErrorEvent.IO_ERROR)}function a(){s.removeEventListener("canplaythrough",r),s.removeEventListener("error",n),c&&document.body.removeChild(s)}var o=this;this.url=t;var s=new Audio(t);s.addEventListener("canplaythrough",r),s.addEventListener("error",n);var l=navigator.userAgent.toLowerCase();l.indexOf("firefox")>=0&&(s.autoplay=!0,s.muted=!0);var c=l.indexOf("edge")>=0||l.indexOf("trident")>=0;c&&document.body.appendChild(s),s.load(),this.originAudio=s,i.clearAudios[this.url]&&delete i.clearAudios[this.url]},i.prototype.play=function(r,n){r=+r||0,n=+n||0;var a=i.$pop(this.url);null==a&&(a=this.originAudio.cloneNode()),a.autoplay=!0;var o=new t.HtmlSoundChannel(a);return o.$url=this.url,o.$loops=n,o.$startTime=r,o.$play(),e.sys.$pushSoundChannel(o),o},i.prototype.close=function(){this.loaded&&this.originAudio&&(this.originAudio.src=""),this.originAudio&&(this.originAudio=null),i.$clear(this.url),this.loaded=!1},i.$clear=function(e){i.clearAudios[e]=!0;var t=i.audios[e];t&&(t.length=0)},i.$pop=function(e){var t=i.audios[e];return t&&t.length>0?t.pop():null},i.$recycle=function(e,t){if(!i.clearAudios[e]){var r=i.audios[e];null==i.audios[e]&&(r=i.audios[e]=[]),r.push(t)}},i.MUSIC="music",i.EFFECT="effect",i.audios={},i.clearAudios={},i}(e.EventDispatcher);t.HtmlSound=r,__reflect(r.prototype,"egret.web.HtmlSound",["egret.Sound"])}(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 t.prototype.reachMaxSize=function(e,t){return void 0===e&&(e=4),void 0===t&&(t=6),this.vertexIndex>this.maxVertexCount-e||this.indexIndex>this.maxIndicesCount-t},t.prototype.getVertices=function(){var e=this.vertices.subarray(0,this.vertexIndex*this.vertSize);return e},t.prototype.getIndices=function(){return this.indices},t.prototype.getMeshIndices=function(){return this.indicesForMesh},t.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}},t.prototype.isMesh=function(){return this.hasMesh},t.prototype.cacheArrays=function(t,r,i,n,a,o,s,l,c,h,u,d,f,p,v){var g=t.globalAlpha;g=Math.min(g,1);var x=t.globalTintColor||16777215,y=t.currentTexture;g=1>g&&y&&y[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL]?e.WebGLUtils.premultiplyTint(x,g):x+(255*g<<24);var m=t.globalMatrix,b=m.a,w=m.b,T=m.c,E=m.d,_=m.tx,C=m.ty,S=t.$offsetX,R=t.$offsetY;if((0!=S||0!=R)&&(_=S*b+R*T+_,C=S*w+R*E+C),!f){(0!=o||0!=s)&&(_=o*b+s*T+_,C=o*w+s*E+C);var L=l/n;1!=L&&(b=L*b,w=L*w);var D=c/a;1!=D&&(T=D*T,E=D*E)}if(f){var A=this.vertices,I=this._verticesUint32View,$=this.vertexIndex*this.vertSize,M=0,B=0,O=0,P=0,W=0,k=0,G=0;for(M=0,O=d.length;O>M;M+=2)B=$+5*M/2,k=f[M],G=f[M+1],P=d[M],W=d[M+1],A[B+0]=b*k+T*G+_,A[B+1]=w*k+E*G+C,v?(A[B+2]=(r+(1-W)*a)/h,A[B+3]=(i+P*n)/u):(A[B+2]=(r+P*n)/h,A[B+3]=(i+W*a)/u),I[B+4]=g;if(this.hasMesh)for(var H=0,F=p.length;F>H;++H)this.indicesForMesh[this.indexIndex+H]=p[H]+this.vertexIndex;this.vertexIndex+=d.length/2,this.indexIndex+=p.length}else{var U=h,N=u,X=n,z=a;r/=U,i/=N;var A=this.vertices,I=this._verticesUint32View,$=this.vertexIndex*this.vertSize;if(v){var Y=n;n=a/U,a=Y/N,A[$++]=_,A[$++]=C,A[$++]=n+r,A[$++]=i,I[$++]=g,A[$++]=b*X+_,A[$++]=w*X+C,A[$++]=n+r,A[$++]=a+i,I[$++]=g,A[$++]=b*X+T*z+_,A[$++]=E*z+w*X+C,A[$++]=r,A[$++]=a+i,I[$++]=g,A[$++]=T*z+_,A[$++]=E*z+C,A[$++]=r,A[$++]=i,I[$++]=g}else n/=U,a/=N,A[$++]=_,A[$++]=C,A[$++]=r,A[$++]=i,I[$++]=g,A[$++]=b*X+_,A[$++]=w*X+C,A[$++]=n+r,A[$++]=i,I[$++]=g,A[$++]=b*X+T*z+_,A[$++]=E*z+w*X+C,A[$++]=n+r,A[$++]=a+i,I[$++]=g,A[$++]=T*z+_,A[$++]=E*z+C,A[$++]=r,A[$++]=a+i,I[$++]=g;if(this.hasMesh){var V=this.indicesForMesh;V[this.indexIndex+0]=0+this.vertexIndex,V[this.indexIndex+1]=1+this.vertexIndex,V[this.indexIndex+2]=2+this.vertexIndex,V[this.indexIndex+3]=0+this.vertexIndex,V[this.indexIndex+4]=2+this.vertexIndex,V[this.indexIndex+5]=3+this.vertexIndex}this.vertexIndex+=4,this.indexIndex+=6}},t.prototype.clear=function(){this.hasMesh=!1,this.vertexIndex=0,this.indexIndex=0},t}();t.WebGLVertexArrayObject=r,__reflect(r.prototype,"egret.web.WebGLVertexArrayObject")}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(r){function i(e,t,i){var n=r.call(this)||this;return n.clearColor=[0,0,0,0],n.useFrameBuffer=!0,n.gl=e,n._resize(t,i),n}return __extends(i,r),i.prototype._resize=function(e,t){e=e||1,t=t||1,1>e&&(e=1),1>t&&(t=1),this.width=e,this.height=t},i.prototype.resize=function(e,t){this._resize(e,t);var r=this.gl;this.frameBuffer&&(r.bindTexture(r.TEXTURE_2D,this.texture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,this.width,this.height,0,r.RGBA,r.UNSIGNED_BYTE,null)),this.stencilBuffer&&(r.deleteRenderbuffer(this.stencilBuffer),this.stencilBuffer=null)},i.prototype.activate=function(){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,this.getFrameBuffer())},i.prototype.getFrameBuffer=function(){return this.useFrameBuffer?this.frameBuffer:null},i.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)}},i.prototype.createTexture=function(){var r=t.WebGLRenderContext.getInstance(0,0);return e.sys._createTexture(r,this.width,this.height,null)},i.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)},i.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)}},i.prototype.dispose=function(){e.WebGLUtils.deleteWebGLTexture(this.texture)},i}(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){var r={},i=function(){function i(r,i){if(this._defaultEmptyTexture=null,this.glID=null,this.projectionX=0/0,this.projectionY=0/0,this.contextLost=!1,this._supportedCompressedTextureInfo=[],this.$scissorState=!1,this.vertSize=5,this.surface=e.sys.mainCanvas(r,i),!e.nativeRender){this.initWebGL(),this.$bufferStack=[];var n=this.context;this.vertexBuffer=n.createBuffer(),this.indexBuffer=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,this.vertexBuffer),n.bindBuffer(n.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(t,r,i){e.sys.resizeContext(this,t,r,i)},i.prototype._buildSupportedCompressedTextureInfo=function(e){for(var t=[],r=0,i=e;rr;++r)for(var n=e[r],a=n.supportedFormats,o=0,s=a.length;s>o;++o)if(a[o][1]===t)return!0;return!1},i.prototype.$debugLogCompressedTextureNotSupported=function(t,i){if(!r[i]){r[i]=!0,e.log("internalFormat = "+i+":0x"+i.toString(16)+", the current hardware does not support the corresponding compression format.");for(var n=0,a=t.length;a>n;++n){var o=t[n];if(o.supportedFormats.length>0){e.log("support = "+o.extensionName);for(var s=0,l=o.supportedFormats.length;l>s;++s){var c=o.supportedFormats[s];e.log(c[0]+" : "+c[1]+" : 0x"+c[1].toString(16))}}}}},i.prototype.createCompressedTexture=function(t,r,i,n,a){var o=this.checkCompressedTextureInternalFormat(this._supportedCompressedTextureInfo,a);if(!o)return this.$debugLogCompressedTextureNotSupported(this._supportedCompressedTextureInfo,a),this.defaultEmptyTexture;var s=this.context,l=s.createTexture();return l?(l[e.glContext]=s,l[e.is_compressed_texture]=!0,s.bindTexture(s.TEXTURE_2D,l),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),l[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL]=!0,s.compressedTexImage2D(s.TEXTURE_2D,n,a,r,i,0,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.bindTexture(s.TEXTURE_2D,null),l):void(this.contextLost=!0)},i.prototype.updateTexture=function(e,t){var r=this.context;r.bindTexture(r.TEXTURE_2D,e),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t)},Object.defineProperty(i.prototype,"defaultEmptyTexture",{get:function(){if(!this._defaultEmptyTexture){var t=16,r=e.sys.createCanvas(t,t),i=e.sys.getContext2d(r);i.fillStyle="white",i.fillRect(0,0,t,t),this._defaultEmptyTexture=this.createTexture(r),this._defaultEmptyTexture[e.engine_default_empty_texture]=!0}return this._defaultEmptyTexture},enumerable:!0,configurable:!0}),i.prototype.getWebGLTexture=function(t){if(!t.webGLTexture){if("image"!=t.format||t.hasCompressed2d()){if(t.hasCompressed2d()){var r=t.getCompressed2dTextureData();t.webGLTexture=this.createCompressedTexture(r.byteArray,r.width,r.height,r.level,r.glInternalFormat);var i=t.etcAlphaMask;if(i){var n=this.getWebGLTexture(i);n&&(t.webGLTexture[e.etc_alpha_mask]=n)}}}else t.webGLTexture=this.createTexture(t.source);t.$deleteSource&&t.webGLTexture&&(t.source&&(t.source.src="",t.source=null),t.clearCompressedTextureData()),t.webGLTexture&&(t.webGLTexture.smoothing=!0)}return t.webGLTexture},i.prototype.clearRect=function(e,t,r,i){if(0!=e||0!=t||r!=this.surface.width||i!=this.surface.height){var n=this.currentBuffer;if(n.$hasScissor)this.setGlobalCompositeOperation("destination-out"),this.drawRect(e,t,r,i),this.setGlobalCompositeOperation("source-over");else{var a=n.globalMatrix;0==a.b&&0==a.c?(e=e*a.a+a.tx,t=t*a.d+a.ty,r*=a.a,i*=a.d,this.enableScissor(e,-t-i+n.height,r,i),this.clear(),this.disableScissor()):(this.setGlobalCompositeOperation("destination-out"),this.drawRect(e,t,r,i),this.setGlobalCompositeOperation("source-over"))}}else this.clear()},i.prototype.setGlobalCompositeOperation=function(e){this.drawCmdManager.pushSetBlend(e)},i.prototype.drawImage=function(e,t,r,i,n,a,o,s,l,c,h,u,d){var f=this.currentBuffer;if(!this.contextLost&&e&&f){var p,v,g;if(e.texture||e.source&&e.source.texture)p=e.texture||e.source.texture,f.saveTransform(),v=f.$offsetX,g=f.$offsetY,f.useOffset(),f.transform(1,0,0,-1,0,l+2*o);else{if(!e.source&&!e.webGLTexture)return;p=this.getWebGLTexture(e)}p&&(this.drawTexture(p,t,r,i,n,a,o,s,l,c,h,void 0,void 0,void 0,void 0,u,d),e.source&&e.source.texture&&(f.$offsetX=v,f.$offsetY=g,f.restoreTransform()))}},i.prototype.drawMesh=function(e,t,r,i,n,a,o,s,l,c,h,u,d,f,p,v,g){var x=this.currentBuffer;if(!this.contextLost&&e&&x){var y,m,b;if(e.texture||e.source&&e.source.texture)y=e.texture||e.source.texture,x.saveTransform(),m=x.$offsetX,b=x.$offsetY,x.useOffset(),x.transform(1,0,0,-1,0,l+2*o);else{if(!e.source&&!e.webGLTexture)return;y=this.getWebGLTexture(e)}y&&(this.drawTexture(y,t,r,i,n,a,o,s,l,c,h,u,d,f,p,v,g),(e.texture||e.source&&e.source.texture)&&(x.$offsetX=m,x.$offsetY=b,x.restoreTransform()))}},i.prototype.drawTexture=function(e,t,r,i,n,a,o,s,l,c,h,u,d,f,p,v,g){var x=this.currentBuffer;if(!this.contextLost&&e&&x){d&&f?this.vao.reachMaxSize(d.length/2,f.length)&&this.$drawWebGL():this.vao.reachMaxSize()&&this.$drawWebGL(),void 0!=g&&e.smoothing!=g&&this.drawCmdManager.pushChangeSmoothing(e,g),u&&this.vao.changeToMeshIndices();var y=f?f.length/3:2;this.drawCmdManager.pushDrawTexture(e,y,this.$filter,c,h),x.currentTexture=e,this.vao.cacheArrays(x,t,r,i,n,a,o,s,l,c,h,u,d,f,v)}},i.prototype.drawRect=function(e,t,r,i){var n=this.currentBuffer;!this.contextLost&&n&&(this.vao.reachMaxSize()&&this.$drawWebGL(),this.drawCmdManager.pushDrawRect(),n.currentTexture=null,this.vao.cacheArrays(n,0,0,r,i,e,t,r,i,r,i))},i.prototype.pushMask=function(e,t,r,i){var n=this.currentBuffer;!this.contextLost&&n&&(n.$stencilList.push({x:e,y:t,width:r,height:i}),this.vao.reachMaxSize()&&this.$drawWebGL(),this.drawCmdManager.pushPushMask(),n.currentTexture=null,this.vao.cacheArrays(n,0,0,r,i,e,t,r,i,r,i))},i.prototype.popMask=function(){var e=this.currentBuffer;if(!this.contextLost&&e){var t=e.$stencilList.pop();this.vao.reachMaxSize()&&this.$drawWebGL(),this.drawCmdManager.pushPopMask(),e.currentTexture=null,this.vao.cacheArrays(e,0,0,t.width,t.height,t.x,t.y,t.width,t.height,t.width,t.height)}},i.prototype.clear=function(){this.drawCmdManager.pushClearColor()},i.prototype.enableScissor=function(e,t,r,i){var n=this.currentBuffer;this.drawCmdManager.pushEnableScissor(e,t,r,i),n.$hasScissor=!0},i.prototype.disableScissor=function(){var e=this.currentBuffer;this.drawCmdManager.pushDisableScissor(),e.$hasScissor=!1},i.prototype.$drawWebGL=function(){if(0!=this.drawCmdManager.drawDataLen&&!this.contextLost){this.uploadVerticesArray(this.vao.getVertices()),this.vao.isMesh()&&this.uploadIndicesArray(this.vao.getMeshIndices());for(var e=this.drawCmdManager.drawDataLen,t=0,r=0;e>r;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(r,i){if(r){var n,a=this.context,o=r.filter;switch(r.type){case 0:o?"custom"===o.type?n=t.EgretWebGLProgram.getProgram(a,o.$vertexSrc,o.$fragmentSrc,o.$shaderKey):"colorTransform"===o.type?r.texture[e.etc_alpha_mask]?(a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,r.texture[e.etc_alpha_mask]),n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.colorTransform_frag_etc_alphamask_frag,"colorTransform_frag_etc_alphamask_frag")):n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.colorTransform_frag,"colorTransform"):"blurX"===o.type?n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.blur_frag,"blur"):"blurY"===o.type?n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.blur_frag,"blur"):"glow"===o.type&&(n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.glow_frag,"glow")):r.texture[e.etc_alpha_mask]?(n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.texture_etc_alphamask_frag,e.etc_alpha_mask),a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,r.texture[e.etc_alpha_mask])):n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.texture_frag,"texture"),this.activeProgram(a,n),this.syncUniforms(n,o,r.textureWidth,r.textureHeight),i+=this.drawTextureElements(r,i);break;case 1:n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.primitive_frag,"primitive"),this.activeProgram(a,n),this.syncUniforms(n,o,r.textureWidth,r.textureHeight),i+=this.drawRectElements(r,i);break;case 2:n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.primitive_frag,"primitive"),this.activeProgram(a,n),this.syncUniforms(n,o,r.textureWidth,r.textureHeight),i+=this.drawPushMaskElements(r,i);break;case 3:n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.primitive_frag,"primitive"),this.activeProgram(a,n),this.syncUniforms(n,o,r.textureWidth,r.textureHeight),i+=this.drawPopMaskElements(r,i);break;case 4:this.setBlendMode(r.value);break;case 5:r.buffer.rootRenderTarget.resize(r.width,r.height),this.onResize(r.width,r.height);break;case 6:if(this.activatedBuffer){var s=this.activatedBuffer.rootRenderTarget;(0!=s.width||0!=s.height)&&s.clear(!0)}break;case 7:this.activateBuffer(r.buffer,r.width,r.height);break;case 8:var l=this.activatedBuffer;l&&(l.rootRenderTarget&&l.rootRenderTarget.enabledStencil(),l.enableScissor(r.x,r.y,r.width,r.height));break;case 9:l=this.activatedBuffer,l&&l.disableScissor();break;case 10:a.bindTexture(a.TEXTURE_2D,r.texture),r.smoothing?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR)):(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST))}return i}},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,4,e.UNSIGNED_BYTE,!0,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)n[a].setValue(0);else if("uSamplerAlphaMask"===a)n[a].setValue(1);else{var o=t.$uniforms[a];void 0!==o&&n[a].setValue(o)}},i.prototype.drawTextureElements=function(t,r){return e.sys.drawTextureElements(this,t,r)},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],l=r.rootRenderTarget.width,c=r.rootRenderTarget.height;i=t.WebGLRenderBuffer.create(l,c),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 l=e.blurXFilter,c=e.blurYFilter;0!=l.blurX&&0!=c.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=c):e=0===l.blurX?c:l}i.saveTransform(),i.transform(1,0,0,-1,0,s),i.currentTexture=r.rootRenderTarget.texture,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",["egret.sys.RenderContext"]),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.currentTexture=null,o.globalAlpha=1,o.globalTintColor=16777215,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):(this.context.pushBuffer(this),(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.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),l=0;n>l;l++)for(var c=0;i>c;c++){var h=4*(i*(n-l-1)+c),u=4*(i*l+c),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,l){void 0===l&&(l=!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"),l&&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,l){void 0===l&&(l=!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"),l&&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,l=o.b,c=o.c,h=o.d;(1!=e||0!=t||0!=r||1!=i)&&(o.a=e*s+t*c,o.b=e*l+t*h,o.c=r*s+i*c,o.d=r*l+i*h),o.tx=n*s+a*c+o.tx,o.ty=n*l+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.wxiOS10=!1,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 l=o.$drawCalls;o.onRenderFinish(),s.popBuffer();var c=e.Matrix.create();if(i.$invertInto(c),o.transform(c.a,c.b,c.c,c.d,0,0),e.Matrix.release(c),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 l},a.prototype.drawDisplayObject=function(t,r,i,n,a){var o,s=0,l=t.$displayList;if(l&&!a?((t.$cacheDirty||t.$renderDirty||l.$canvasScaleX!=e.sys.DisplayList.$canvasScaleX||l.$canvasScaleY!=e.sys.DisplayList.$canvasScaleY)&&(s+=l.drawToSurface()),o=l.$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(l&&!a)return s;var c=t.$children;if(c){t.sortableChildren&&t.$sortDirty&&t.sortChildren();for(var h=c.length,u=0;h>u;u++){var d=c[u],f=void 0,p=void 0,v=void 0,g=void 0;1!=d.$alpha&&(v=r.globalAlpha,r.globalAlpha*=d.$alpha),16777215!==d.tint&&(g=r.globalTintColor,r.globalTintColor=d.$tintRGB);var x=void 0;if(d.$useTranslate){var y=d.$getMatrix();f=i+d.$x,p=n+d.$y;var m=r.globalMatrix;x=e.Matrix.create(),x.a=m.a,x.b=m.b,x.c=m.c,x.d=m.d,x.tx=m.tx,x.ty=m.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&&(r.globalTintColor=g),x){var y=r.globalMatrix;y.a=x.a,y.b=x.b,y.c=x.c,y.d=x.d,y.tx=x.tx,y.ty=x.ty,e.Matrix.release(x)}}}return s},a.prototype.drawWithFilter=function(t,a,o,s){var l=0;if(t.$children&&0==t.$children.length&&(!t.$renderNode||0==t.$renderNode.$getRenderCount()))return l;var c,h=t.$filters,u=0!==t.$blendMode;u&&(c=r[t.$blendMode],c||(c=i));var d=t.$getOriginalBounds(),f=d.x,p=d.y,v=d.width,g=d.height;if(0>=v||0>=g)return l;if(!t.mask&&1==h.length&&("colorTransform"==h[0].type||"custom"===h[0].type&&0===h[0].padding)){var x=this.getRenderCount(t);if(!t.$children||1==x)return u&&a.context.setGlobalCompositeOperation(c),a.context.$filter=h[0],l+=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),l}var y=this.createRenderBuffer(v,g);if(y.context.pushBuffer(y),l+=t.$mask?this.drawWithClip(t,y,-f,-p):t.$scrollRect||t.$maskRect?this.drawWithScrollRect(t,y,-f,-p):this.drawDisplayObject(t,y,-f,-p),y.context.popBuffer(),l>0){u&&a.context.setGlobalCompositeOperation(c),l++,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,y),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(y),l},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 l,c=0,h=0!==t.$blendMode;h&&(l=r[t.$blendMode],l||(l=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 c}if(d||t.$children&&0!=t.$children.length){var p=t.$getOriginalBounds(),v=p.x,g=p.y,x=p.width,y=p.height;if(0>=x||0>=y)return c;var m=this.createRenderBuffer(x,y);if(m.context.pushBuffer(m),c+=this.drawDisplayObject(t,m,-v,-g),d){var b=this.createRenderBuffer(x,y);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),c+=this.drawDisplayObject(d,b,0,0),b.context.popBuffer(),m.context.setGlobalCompositeOperation("destination-in"),m.setTransform(1,0,0,-1,0,b.height);var T=b.rootRenderTarget.width,E=b.rootRenderTarget.height;m.context.drawTexture(b.rootRenderTarget.texture,0,0,T,E,0,0,T,E,T,E),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(),c>0){c++,h&&a.context.setGlobalCompositeOperation(l),u&&a.context.pushMask(u.x+o,u.y+s,u.width,u.height);var _=e.Matrix.create(),C=a.globalMatrix;_.a=C.a,_.b=C.b,_.c=C.c,_.d=C.d,_.tx=C.tx,_.ty=C.ty,C.append(1,0,0,-1,o+v,s+g+m.height);var S=m.rootRenderTarget.width,R=m.rootRenderTarget.height;a.context.drawTexture(m.rootRenderTarget.texture,0,0,S,R,0,0,S,R,S,R),u&&m.context.popMask(),h&&a.context.setGlobalCompositeOperation(i);var L=a.globalMatrix;L.a=_.a,L.b=_.b,L.c=_.c,L.d=_.d,L.tx=_.tx,L.ty=_.ty,e.Matrix.release(_)}return n.push(m),c}return u&&a.context.pushMask(u.x+o,u.y+s,u.width,u.height),h&&a.context.setGlobalCompositeOperation(l),c+=this.drawDisplayObject(t,a,o,s),h&&a.context.setGlobalCompositeOperation(i),u&&a.context.popMask(),c},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,l=!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 c=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,x=void 0,y=void 0,m=void 0,b=void 0;if(1==c&&1==h)x=f+u,y=p+d,m=v+u,b=g+d;else{var w=c*f+u,T=h*p+d,E=c*v+u,_=h*p+d,C=c*v+u,S=h*g+d,R=c*f+u,L=h*g+d,D=0;w>E&&(D=w,w=E,E=D),C>R&&(D=C,C=R,R=D),x=C>w?w:C,m=E>R?E:R,T>_&&(D=T,T=_,_=D),S>L&&(D=S,S=L,L=D),y=S>T?T:S,b=_>L?_:L}s.enableScissor(x,-b+t.height,m-x,b-y),l=!0}return n+=this.drawDisplayObject(e,t,r,i),l?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 l=a[s];switch(l.$renderMode){case 1:break;case 2:n+=this.drawWithFilter(l,t,0,0);break;case 3:n+=this.drawWithClip(l,t,0,0);break;case 4:n+=this.drawWithScrollRect(l,t,0,0);break;default:n+=this.drawDisplayObject(l,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,l,c=t.drawData,h=c.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,l=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,c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],t.imageWidth,t.imageHeight,t.rotated,t.smoothing);n.context.$filter=null}else for(;h>u;)n.context.drawImage(a,c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],t.imageWidth,t.imageHeight,t.rotated,t.smoothing);if(f&&n.context.setGlobalCompositeOperation(i),p==p&&(n.globalAlpha=g),d){var x=n.globalMatrix;x.a=o.a,x.b=o.b,x.c=o.c,x.d=o.d,x.tx=o.tx,x.ty=o.ty,n.$offsetX=s,n.$offsetY=l,e.Matrix.release(o)}}},a.prototype.renderMesh=function(t,n){var a,o,s,l=t.image,c=t.drawData,h=c.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(l,c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[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(l,c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[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 x=n.globalMatrix;x.a=a.a,x.b=a.b,x.c=a.c,x.d=a.d,x.tx=a.tx,x.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,l=i.context.$maxTextureSize;n*o>l&&(o*=l/(n*o)),a*s>l&&(s*=l/(a*s)),n*=o,a*=s;var c=r.x*o,h=r.y*s;(r.$canvasScaleX!==o||r.$canvasScaleY!==s)&&(r.$canvasScaleX=o,r.$canvasScaleY=s,r.dirtyRender=!0),(c||h)&&i.transform(1,0,0,1,c/o,h/s),r.dirtyRender&&t.TextAtlasRender.analysisTextNodeAndFlushDrawLabel(r);var u=r[t.property_drawLabel];if(u&&u.length>0){for(var d=i.$offsetX,f=i.$offsetY,p=null,v=0,g=0,x=null,y=null,m=null,b=0,w=u.length;w>b;++b){p=u[b],v=p.anchorX,g=p.anchorY,x=p.textBlocks,i.$offsetX=d+v;for(var T=0,E=x.length;E>T;++T)y=x[T],T>0&&(i.$offsetX-=y.canvasWidthOffset),i.$offsetY=f+g-(y.measureHeight+(y.stroke2?y.canvasHeightOffset:0))/2,m=y.line.page,i.context.drawTexture(m.webGLTexture,y.u,y.v,y.contentWidth,y.contentHeight,0,0,y.contentWidth,y.contentHeight,m.pageWidth,m.pageHeight),i.$offsetX+=y.contentWidth-y.canvasWidthOffset}i.$offsetX=d,i.$offsetY=f}(c||h)&&i.transform(1,0,0,1,-c/o,-h/s),r.dirtyRender=!1}},a.prototype.renderText=function(r,i){if(t.textAtlasRenderEnable)return void this.___renderText____(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,l=i.context.$maxTextureSize;n*o>l&&(o*=l/(n*o)),a*s>l&&(s*=l/(a*s)),n*=o,a*=s;var c=r.x*o,h=r.y*s;if((r.$canvasScaleX!=o||r.$canvasScaleY!=s)&&(r.$canvasScaleX=o,r.$canvasScaleY=s,r.dirtyRender=!0),this.wxiOS10?(this.canvasRenderer||(this.canvasRenderer=new e.CanvasRenderer),r.dirtyRender&&(this.canvasRenderBuffer=new t.CanvasRenderBuffer(n,a))):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),c||h?(r.dirtyRender&&this.canvasRenderBuffer.context.setTransform(o,0,0,s,-c,-h),i.transform(1,0,0,1,c/o,h/s)):(1!=o||1!=s)&&this.canvasRenderBuffer.context.setTransform(o,0,0,s,0,0),r.dirtyRender){var u=this.canvasRenderBuffer.surface;if(this.canvasRenderer.renderText(r,this.canvasRenderBuffer.context),this.wxiOS10)u.isCanvas=!0,r.$texture=u;else{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),(c||h)&&(r.dirtyRender&&this.canvasRenderBuffer.context.setTransform(o,0,0,s,0,0),i.transform(1,0,0,1,-c/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,l=e.sys.DisplayList.$canvasScaleY;(1>a*s||1>o*l)&&(s=l=1),(r.$canvasScaleX!=s||r.$canvasScaleY!=l)&&(r.$canvasScaleX=s,r.$canvasScaleY=l,r.dirtyRender=!0),a*=s,o*=l;var c=Math.ceil(a),h=Math.ceil(o);if(s*=c/a,l*=h/o,a=c,o=h,this.wxiOS10?(this.canvasRenderer||(this.canvasRenderer=new e.CanvasRenderer),r.dirtyRender&&(this.canvasRenderBuffer=new t.CanvasRenderBuffer(a,o))):this.canvasRenderBuffer&&this.canvasRenderBuffer.context?r.dirtyRender&&this.canvasRenderBuffer.resize(a,o):(this.canvasRenderer=new e.CanvasRenderer,this.canvasRenderBuffer=new t.CanvasRenderBuffer(a,o)),this.canvasRenderBuffer.context){(1!=s||1!=l)&&this.canvasRenderBuffer.context.setTransform(s,0,0,l,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);var d=void 0;this.wxiOS10?(u.isCanvas=!0,d=u):(e.WebGLUtils.deleteWebGLTexture(u),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){if(this.canvasRenderer.renderGraphics(r,this.canvasRenderBuffer.context),this.wxiOS10)u.isCanvas=!0,r.$texture=u;else{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/l,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 l=t.drawData,c=l.length,h=0;c>h;h++){var u=l[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(t){var r=function(e){function t(t,r,i,n,a,o,s,l){var c=e.call(this)||this;return c._width=0,c._height=0,c._border=0,c.line=null,c.x=0,c.y=0,c.u=0,c.v=0,c.tag="",c.measureWidth=0,c.measureHeight=0,c.canvasWidthOffset=0,c.canvasHeightOffset=0,c.stroke2=0,c._width=t,c._height=r,c._border=l,c.measureWidth=i,c.measureHeight=n,c.canvasWidthOffset=a,c.canvasHeightOffset=o,c.stroke2=s,c}return __extends(t,e),Object.defineProperty(t.prototype,"border",{get:function(){return this._border},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._width+2*this.border},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height+2*this.border},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"contentWidth",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"contentHeight",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"page",{get:function(){return this.line?this.line.page:null},enumerable:!0,configurable:!0}),t.prototype.updateUV=function(){var e=this.line;return e?(this.u=e.x+this.x+1*this.border,this.v=e.y+this.y+1*this.border,!0):!1},Object.defineProperty(t.prototype,"subImageOffsetX",{get:function(){var e=this.line;return e?e.x+this.x+this.border:0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subImageOffsetY",{get:function(){var e=this.line;return e?e.y+this.y+this.border:0},enumerable:!0,configurable:!0}),t}(e.HashObject);t.TextBlock=r,__reflect(r.prototype,"egret.web.TextBlock");var i=function(e){function t(t){var r=e.call(this)||this;return r.page=null,r.textBlocks=[],r.dynamicMaxHeight=0,r.maxWidth=0,r.x=0,r.y=0,r.maxWidth=t,r}return __extends(t,e),t.prototype.isCapacityOf=function(e){if(!e)return!1;var t=0,r=0,i=this.lastTextBlock();return i&&(t=i.x+i.width,r=i.y),t+e.width>this.maxWidth?!1:this.dynamicMaxHeight>0&&(e.height>this.dynamicMaxHeight||e.height/this.dynamicMaxHeight<.5)?!1:!0},t.prototype.lastTextBlock=function(){var e=this.textBlocks;return e.length>0?e[e.length-1]:null},t.prototype.addTextBlock=function(e,t){if(!e)return!1;if(t&&!this.isCapacityOf(e))return!1;var r=0,i=0,n=this.lastTextBlock();return n&&(r=n.x+n.width,i=n.y),e.x=r,e.y=i,e.line=this,this.textBlocks.push(e),this.dynamicMaxHeight=Math.max(this.dynamicMaxHeight,e.height),!0},t}(e.HashObject);t.Line=i,__reflect(i.prototype,"egret.web.Line");var n=function(e){function t(t,r){var i=e.call(this)||this;return i.lines=[],i.pageWidth=0,i.pageHeight=0,i.webGLTexture=null,i.pageWidth=t,i.pageHeight=r,i}return __extends(t,e),t.prototype.addLine=function(e){if(!e)return!1;var t=0,r=0,i=this.lines;if(i.length>0){var n=i[i.length-1];t=n.x,r=n.y+n.dynamicMaxHeight}return e.maxWidth>this.pageWidth?(console.error("line.maxWidth = "+e.maxWidth+", this.pageWidth = "+this.pageWidth),!1):r+e.dynamicMaxHeight>this.pageHeight?!1:(e.x=t,e.y=r,e.page=this,this.lines.push(e),!0)},t}(e.HashObject);t.Page=n,__reflect(n.prototype,"egret.web.Page");var a=function(e){function t(t,r){var i=e.call(this)||this;return i._pages=[],i._sortLines=[],i._maxSize=1024,i._border=1,i._maxSize=t,i._border=r,i}return __extends(t,e),t.prototype.addTextBlock=function(e){var t=this._addTextBlock(e);if(!t)return!1;e.updateUV();for(var r=!1,i=t,n=this._sortLines,a=0,o=n;athis._maxSize||e.height>this._maxSize)return null;for(var t=this._sortLines,r=0,n=t.length;n>r;++r){var a=t[r];if(a.isCapacityOf(e)&&a.addTextBlock(e,!1))return[a.page,a]}var o=new i(this._maxSize);if(!o.addTextBlock(e,!0))return console.error("_addTextBlock !newLine.addTextBlock(textBlock, true)"),null;for(var s=this._pages,r=0,l=s.length;l>r;++r){var c=s[r];if(c.addLine(o))return[c,o]}var h=this.createPage(this._maxSize,this._maxSize);return h.addLine(o)?[h,o]:(console.error("_addText newPage.addLine failed"),null)},t.prototype.createPage=function(e,t){var r=new n(e,t);return this._pages.push(r),r},t.prototype.sort=function(){if(!(this._sortLines.length<=1)){var e=function(e,t){return e.dynamicMaxHeight=0)return void console.error("DrawLabel.back repeat");e.clear(),i.push(e)}},t.pool=[],t}(e.HashObject);t.DrawLabel=i,__reflect(i.prototype,"egret.web.DrawLabel");var n=function(t){function i(i,n){var a=t.call(this)||this;a.format=null;var o=0;r&&(o=i.textColor,i.textColor=16711680),a.textColor=i.textColor,a.strokeColor=i.strokeColor,a.size=i.size,a.stroke=i.stroke,a.bold=i.bold,a.italic=i.italic,a.fontFamily=i.fontFamily,a.format=n,a.font=e.getFontString(i,a.format);var s=n.textColor?n.textColor:i.textColor,l=n.strokeColor?n.strokeColor:i.strokeColor,c=n.stroke?n.stroke:i.stroke,h=n.size?n.size:i.size;return a.description=""+a.font+"-"+h,a.description+="-"+e.toColorString(s),a.description+="-"+e.toColorString(l),c&&(a.description+="-"+2*c),r&&(i.textColor=o),a}return __extends(i,t),i}(e.HashObject);__reflect(n.prototype,"StyleInfo");var a=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e["char"]="",e.styleInfo=null,e.hashCodeString="",e.charWithStyleHashCode=0,e.measureWidth=0,e.measureHeight=0,e.canvasWidthOffset=0,e.canvasHeightOffset=0,e.stroke2=0,e}return __extends(r,t),r.prototype.reset=function(t,r){return this["char"]=t,this.styleInfo=r,this.hashCodeString=t+":"+r.description,this.charWithStyleHashCode=e.NumberUtils.convertStringToHashCode(this.hashCodeString),this.canvasWidthOffset=0,this.canvasHeightOffset=0,this.stroke2=0,this},r.prototype.measureAndDraw=function(t){var r=t;if(r){var i=this["char"],n=this.styleInfo.format,a=n.textColor?n.textColor:this.styleInfo.textColor,o=n.strokeColor?n.strokeColor:this.styleInfo.strokeColor,s=n.stroke?n.stroke:this.styleInfo.stroke,l=n.size?n.size:this.styleInfo.size;this.measureWidth=this.measure(i,this.styleInfo,l),this.measureHeight=l;var c=this.measureWidth,h=this.measureHeight,u=2*s;u>0&&(c+=2*u,h+=2*u),this.stroke2=u,r.width=c=Math.ceil(c)+4,r.height=h=Math.ceil(h)+4,this.canvasWidthOffset=(r.width-this.measureWidth)/2,this.canvasHeightOffset=(r.height-this.measureHeight)/2;var d=3,f=Math.pow(10,d);this.canvasWidthOffset=Math.floor(this.canvasWidthOffset*f)/f,this.canvasHeightOffset=Math.floor(this.canvasHeightOffset*f)/f;var p=e.sys.getContext2d(r);p.save(),p.textAlign="center",p.textBaseline="middle",p.lineJoin="round",p.font=this.styleInfo.font,p.fillStyle=e.toColorString(a),p.strokeStyle=e.toColorString(o),p.clearRect(0,0,r.width,r.height),s&&(p.lineWidth=2*s,p.strokeText(i,r.width/2,r.height/2)),p.fillText(i,r.width/2,r.height/2),p.restore()}},r.prototype.measure=function(t,i,n){var a=r.chineseCharactersRegExp.test(t);if(a&&r.chineseCharacterMeasureFastMap[i.font])return r.chineseCharacterMeasureFastMap[i.font];var o=e.sys.measureText(t,i.fontFamily,n||i.size,i.bold,i.italic);return a&&(r.chineseCharacterMeasureFastMap[i.font]=o),o},r.chineseCharactersRegExp=new RegExp("^[一-龥]$"),r.chineseCharacterMeasureFastMap={},r}(e.HashObject);__reflect(a.prototype,"CharImageRender");var o=function(o){function s(e,r,i){var n=o.call(this)||this;return n.book=null,n.charImageRender=new a,n.textBlockMap={},n._canvas=null,n.textAtlasTextureCache=[],n.webglRenderContext=null,n.webglRenderContext=e,n.book=new t.Book(r,i),n}return __extends(s,o),s.analysisTextNodeAndFlushDrawLabel=function(a){if(a){if(!t.__textAtlasRender__){var o=e.web.WebGLRenderContext.getInstance(0,0);t.__textAtlasRender__=new s(o,512,r?12:1)}a[t.property_drawLabel]=a[t.property_drawLabel]||[];for(var l=a[t.property_drawLabel],c=0,h=l;cm;m+=d){p=f[m+0],v=f[m+1],g=f[m+2],x=f[m+3]||{},y.length=0,t.__textAtlasRender__.convertLabelStringToTextAtlas(g,new n(a,x),y);var u=i.create();u.anchorX=p,u.anchorY=v,u.textBlocks=[].concat(y),l.push(u)}}},s.prototype.convertLabelStringToTextAtlas=function(t,i,n){for(var a=this.canvas,o=this.charImageRender,s=this.textBlockMap,l=0,c=t;la;a++){var o=t.getActiveAttrib(r,a),s=o.name,l=new e.EgretWebGLAttribute(t,r,o);i[s]=l}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,l=new e.EgretWebGLUniform(t,r,o);i[s]=l}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(){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 5126:case 35678:case 35680:case 35670:case 5124:this.value=0;break;case 35664:case 35671:case 35667:this.value=[0,0];break;case 35665:case 35672:case 35668:this.value=[0,0,0];break;case 35666:case 35673:case 35669:this.value=[0,0,0,0];break;case 35674:this.value=new Float32Array([1,0,0,1]);break;case 35675:this.value=new Float32Array([1,0,0,0,1,0,0,0,1]);break;case 35676: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 5126:case 35678:case 35680:case 35670:case 5124:this.setValue=function(e){var t=this.value!==e;this.value=e,t&&this.upload()};break;case 35664:case 35671:case 35667: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 35665:case 35672:case 35668:this.setValue=function(e){this.value[0]=e.x,this.value[1]=e.y,this.value[2]=e.z,this.upload()};break;case 35666:case 35673:case 35669: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 35674:case 35675:case 35676:this.setValue=function(e){this.value.set(e),this.upload()}}},e.prototype.generateUpload=function(){var e=this.gl,t=this.type,r=this.location;switch(t){case 5126:this.upload=function(){var t=this.value;e.uniform1f(r,t)};break;case 35664:this.upload=function(){var t=this.value;e.uniform2f(r,t[0],t[1])};break;case 35665:this.upload=function(){var t=this.value;e.uniform3f(r,t[0],t[1],t[2])};break;case 35666:this.upload=function(){var t=this.value;e.uniform4f(r,t[0],t[1],t[2],t[3])};break;case 35678:case 35680:case 35670:case 5124:this.upload=function(){var t=this.value;e.uniform1i(r,t)};break;case 35671:case 35667:this.upload=function(){var t=this.value;e.uniform2i(r,t[0],t[1])};break;case 35672:case 35668:this.upload=function(){var t=this.value;e.uniform3i(r,t[0],t[1],t[2])};break;case 35673:case 35669:this.upload=function(){var t=this.value;e.uniform4i(r,t[0],t[1],t[2],t[3])};break;case 35674:this.upload=function(){var t=this.value;e.uniformMatrix2fv(r,!1,t)};break;case 35675:this.upload=function(){var t=this.value;e.uniformMatrix3fv(r,!1,t)};break;case 35676:this.upload=function(){var t=this.value;e.uniformMatrix4fv(r,!1,t)}}},e}();e.EgretWebGLUniform=t,__reflect(t.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;\r\nuniform vec2 blur;\r\nuniform sampler2D uSampler;\r\nvarying vec2 vTextureCoord;\r\nuniform vec2 uTextureSize;\r\nvoid main()\r\n{\r\n const int sampleRadius = 5;\r\n const int samples = sampleRadius * 2 + 1;\r\n vec2 blurUv = blur / uTextureSize;\r\n vec4 color = vec4(0, 0, 0, 0);\r\n vec2 uv = vec2(0.0, 0.0);\r\n blurUv /= float(sampleRadius);\r\n\r\n for (int i = -sampleRadius; i <= sampleRadius; i++) {\r\n uv.x = vTextureCoord.x + float(i) * blurUv.x;\r\n uv.y = vTextureCoord.y + float(i) * blurUv.y;\r\n color += texture2D(uSampler, uv);\r\n }\r\n\r\n color /= float(samples);\r\n gl_FragColor = color;\r\n}",e.colorTransform_frag="precision mediump float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\nuniform mat4 matrix;\r\nuniform vec4 colorAdd;\r\nuniform sampler2D uSampler;\r\n\r\nvoid main(void) {\r\n vec4 texColor = texture2D(uSampler, vTextureCoord);\r\n if(texColor.a > 0.) {\r\n // 抵消预乘的alpha通道\r\n texColor = vec4(texColor.rgb / texColor.a, texColor.a);\r\n }\r\n vec4 locColor = clamp(texColor * matrix + colorAdd, 0., 1.);\r\n gl_FragColor = vColor * vec4(locColor.rgb * locColor.a, locColor.a);\r\n}",e.default_vert="attribute vec2 aVertexPosition;\r\nattribute vec2 aTextureCoord;\r\nattribute vec4 aColor;\r\n\r\nuniform vec2 projectionVector;\r\n// uniform vec2 offsetVector;\r\n\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\n\r\nconst vec2 center = vec2(-1.0, 1.0);\r\n\r\nvoid main(void) {\r\n gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\r\n vTextureCoord = aTextureCoord;\r\n vColor = aColor;\r\n}",e.glow_frag="precision highp float;\r\nvarying vec2 vTextureCoord;\r\n\r\nuniform sampler2D uSampler;\r\n\r\nuniform float dist;\r\nuniform float angle;\r\nuniform vec4 color;\r\nuniform float alpha;\r\nuniform float blurX;\r\nuniform float blurY;\r\n// uniform vec4 quality;\r\nuniform float strength;\r\nuniform float inner;\r\nuniform float knockout;\r\nuniform float hideObject;\r\n\r\nuniform vec2 uTextureSize;\r\n\r\nfloat random(vec2 scale)\r\n{\r\n return fract(sin(dot(gl_FragCoord.xy, scale)) * 43758.5453);\r\n}\r\n\r\nvoid main(void) {\r\n vec2 px = vec2(1.0 / uTextureSize.x, 1.0 / uTextureSize.y);\r\n // TODO 自动调节采样次数?\r\n const float linearSamplingTimes = 7.0;\r\n const float circleSamplingTimes = 12.0;\r\n vec4 ownColor = texture2D(uSampler, vTextureCoord);\r\n vec4 curColor;\r\n float totalAlpha = 0.0;\r\n float maxTotalAlpha = 0.0;\r\n float curDistanceX = 0.0;\r\n float curDistanceY = 0.0;\r\n float offsetX = dist * cos(angle) * px.x;\r\n float offsetY = dist * sin(angle) * px.y;\r\n\r\n const float PI = 3.14159265358979323846264;\r\n float cosAngle;\r\n float sinAngle;\r\n float offset = PI * 2.0 / circleSamplingTimes * random(vec2(12.9898, 78.233));\r\n float stepX = blurX * px.x / linearSamplingTimes;\r\n float stepY = blurY * px.y / linearSamplingTimes;\r\n for (float a = 0.0; a <= PI * 2.0; a += PI * 2.0 / circleSamplingTimes) {\r\n cosAngle = cos(a + offset);\r\n sinAngle = sin(a + offset);\r\n for (float i = 1.0; i <= linearSamplingTimes; i++) {\r\n curDistanceX = i * stepX * cosAngle;\r\n curDistanceY = i * stepY * sinAngle;\r\n if (vTextureCoord.x + curDistanceX - offsetX >= 0.0 && vTextureCoord.y + curDistanceY + offsetY <= 1.0){\r\n curColor = texture2D(uSampler, vec2(vTextureCoord.x + curDistanceX - offsetX, vTextureCoord.y + curDistanceY + offsetY));\r\n totalAlpha += (linearSamplingTimes - i) * curColor.a;\r\n }\r\n maxTotalAlpha += (linearSamplingTimes - i);\r\n }\r\n }\r\n\r\n ownColor.a = max(ownColor.a, 0.0001);\r\n ownColor.rgb = ownColor.rgb / ownColor.a;\r\n\r\n float outerGlowAlpha = (totalAlpha / maxTotalAlpha) * strength * alpha * (1. - inner) * max(min(hideObject, knockout), 1. - ownColor.a);\r\n float innerGlowAlpha = ((maxTotalAlpha - totalAlpha) / maxTotalAlpha) * strength * alpha * inner * ownColor.a;\r\n\r\n ownColor.a = max(ownColor.a * knockout * (1. - hideObject), 0.0001);\r\n vec3 mix1 = mix(ownColor.rgb, color.rgb, innerGlowAlpha / (innerGlowAlpha + ownColor.a));\r\n vec3 mix2 = mix(mix1, color.rgb, outerGlowAlpha / (innerGlowAlpha + ownColor.a + outerGlowAlpha));\r\n float resultAlpha = min(ownColor.a + outerGlowAlpha + innerGlowAlpha, 1.);\r\n gl_FragColor = vec4(mix2 * resultAlpha, resultAlpha);\r\n}",e.primitive_frag="precision lowp float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\n\r\nvoid main(void) {\r\n gl_FragColor = vColor;\r\n}",e.texture_frag="precision lowp float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\nuniform sampler2D uSampler;\r\n\r\nvoid main(void) {\r\n gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;\r\n}",e.texture_etc_alphamask_frag="precision lowp float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\nuniform sampler2D uSampler;\r\nuniform sampler2D uSamplerAlphaMask;\r\nvoid main(void) {\r\nfloat alpha = texture2D(uSamplerAlphaMask, vTextureCoord).r;\r\nif (alpha < 0.0039) { discard; }\r\nvec4 v4Color = texture2D(uSampler, vTextureCoord);\r\nv4Color.rgb = v4Color.rgb * alpha;\r\nv4Color.a = alpha;\r\ngl_FragColor = v4Color * vColor;\r\n}",e.colorTransform_frag_etc_alphamask_frag="precision mediump float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\nuniform mat4 matrix;\r\nuniform vec4 colorAdd;\r\nuniform sampler2D uSampler;\r\nuniform sampler2D uSamplerAlphaMask;\r\n\r\nvoid main(void){\r\nfloat alpha = texture2D(uSamplerAlphaMask, vTextureCoord).r;\r\nif (alpha < 0.0039) { discard; }\r\nvec4 texColor = texture2D(uSampler, vTextureCoord);\r\nif(texColor.a > 0.0) {\r\n // 抵消预乘的alpha通道\r\ntexColor = vec4(texColor.rgb / texColor.a, texColor.a);\r\n}\r\nvec4 v4Color = clamp(texColor * matrix + colorAdd, 0.0, 1.0);\r\nv4Color.rgb = v4Color.rgb * alpha;\r\nv4Color.a = alpha;\r\ngl_FragColor = v4Color * vColor;\r\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/libs/modules/game/game.d.ts b/libs/modules/game/game.d.ts new file mode 100644 index 0000000..fd2bcc8 --- /dev/null +++ b/libs/modules/game/game.d.ts @@ -0,0 +1,2482 @@ +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/libs/modules/game/game.js b/libs/modules/game/game.js new file mode 100644 index 0000000..93199aa --- /dev/null +++ b/libs/modules/game/game.js @@ -0,0 +1,4817 @@ +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; + if (bitmapData.source.setAttribute) { + bitmapData.source.setAttribute("bitmapSrc", virtualUrl); + } + var texture = new egret.Texture(); + texture._setBitmapData(bitmapData); + loader.data = texture; + window.setTimeout(function () { + loader.dispatchEventWith(egret.Event.COMPLETE); + }, 0); + } + 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"] || !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) { + clearTimeout(key2); + data.listener.apply(data.thisObject, data.params); + } + } + return false; + } +})(egret || (egret = {})); diff --git a/libs/modules/game/game.min.js b/libs/modules/game/game.min.js new file mode 100644 index 0000000..85fb4ee --- /dev/null +++ b/libs/modules/game/game.min.js @@ -0,0 +1,2 @@ +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&&i.source.setAttribute("bitmapSrc",a);var o=new t.Texture;o._setBitmapData(i),e.data=o,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.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 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/libs/modules/promise/promise.min.js b/libs/modules/promise/promise.min.js new file mode 100644 index 0000000..765fa21 --- /dev/null +++ b/libs/modules/promise/promise.min.js @@ -0,0 +1 @@ +!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/libs/modules/tween/tween.d.ts b/libs/modules/tween/tween.d.ts new file mode 100644 index 0000000..6a3093a --- /dev/null +++ b/libs/modules/tween/tween.d.ts @@ -0,0 +1,1350 @@ +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/libs/modules/tween/tween.js b/libs/modules/tween/tween.js new file mode 100644 index 0000000..7ac1d95 --- /dev/null +++ b/libs/modules/tween/tween.js @@ -0,0 +1,2095 @@ +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/libs/modules/tween/tween.min.js b/libs/modules/tween/tween.min.js new file mode 100644 index 0000000..abe1c4b --- /dev/null +++ b/libs/modules/tween/tween.min.js @@ -0,0 +1 @@ +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/resource/default.res.json b/resource/default.res.json new file mode 100644 index 0000000..cf4941e --- /dev/null +++ b/resource/default.res.json @@ -0,0 +1,80 @@ +{ + "groups": [ + { + "keys": "egret_icon_png,description_json,bg_png,ball_png,paddle_4_png,paddle_3_png,paddle_2_png,paddle_1_png,launch_mp3,die_mp3,point_mp3,scale_loop_mp3,scale_intro_mp3,scoreboard_png", + "name": "preload" + } + ], + "resources": [ + { + "url": "assets/egret_icon.png", + "type": "image", + "name": "egret_icon_png" + }, + { + "url": "config/description.json", + "type": "json", + "name": "description_json" + }, + { + "url": "assets/bg.png", + "type": "image", + "name": "bg_png" + }, + { + "url": "assets/ball.png", + "type": "image", + "name": "ball_png" + }, + { + "url": "assets/paddle_2.png", + "type": "image", + "name": "paddle_1_png" + }, + { + "url": "assets/paddle2_2.png", + "type": "image", + "name": "paddle_2_png" + }, + { + "url": "assets/paddle3_2.png", + "type": "image", + "name": "paddle_3_png" + }, + { + "url": "assets/paddle4_1.png", + "type": "image", + "name": "paddle_4_png" + }, + { + "url": "assets/die.mp3", + "type": "sound", + "name": "die_mp3" + }, + { + "url": "assets/launch.mp3", + "type": "sound", + "name": "launch_mp3" + }, + { + "url": "assets/point.mp3", + "type": "sound", + "name": "point_mp3" + }, + { + "url": "assets/scale_intro.mp3", + "type": "sound", + "name": "scale_intro_mp3" + }, + { + "url": "assets/scale_loop.mp3", + "type": "sound", + "name": "scale_loop_mp3" + }, + { + "url": "assets/scoreboard.png", + "type": "image", + "name": "scoreboard_png" + } + ] +} \ No newline at end of file diff --git a/scripts/api.d.ts b/scripts/api.d.ts new file mode 100644 index 0000000..8428bc4 --- /dev/null +++ b/scripts/api.d.ts @@ -0,0 +1,448 @@ + +/** + * 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); + + } + + /** + * 发布策略 + * * debug : 默认策略,用于开发环境 + * * contents : 将 EXML 的内容写入到主题文件中 + * * gjs : 将生成的JS文件写入到主题文件中 + * * commonjs : 将EXML合并为一个 CommonJS 风格的文件 + * * commonjs2 : 将EXML合并为一个含有解析方法和皮肤定义的文件,且皮肤抽离为一份配置 + * * json : 将每个EXML文件生成一份配置 + */ + type EXML_Publish_Policy = "debug" | "contents" | "gjs" | "commonjs" | "commonjs2" | "json" + + + + + /** + * 生成 manifest 文件,这个文件会被用于记录 JavaScript 文件的版本号 + */ + export class ManifestPlugin implements plugins.Command { + constructor(options?: ManifestPluginOptions) + } + + /** + * 生成文件的文件名 + * 支持 json 与 js 两种格式 + */ + type ManifestPluginOptions = { + + output: string, + + hash?: "crc32", + + /** + * 是否输出转换过程 + */ + verbose?: boolean, + /** + * 其他传递的消息参数 + */ + info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: 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; + + TM_Verbose: boolean; + } + + export class ConvertResConfigFilePlugin implements plugins.Command { + + constructor(options: ConvertResourceConfigPluginOption); + } + + + /** + * 增量编译 + * 这个插件生成的 JavaScript 代码不会被添加到构建管线中,后续其他插件无法获取生成的 js 文件 + * 这个功能将会在未来被 watch 模式代替掉 + */ + export class IncrementCompilePlugin implements plugins.Command { + + } + + type TextureMergerOptions = { + textureMergerRoot: string[]; + } + + /** + * 使用 TextureMerger 实现纹理自动合并,依赖 TextureMerger 1.7 以上的版本 + */ + export class TextureMergerPlugin implements plugins.Command { + + constructor(options: TextureMergerOptions); + + } + + type CleanPluginOptions = { + + matchers: string[] + } + + + export class CleanPlugin implements plugins.Command { + constructor(options: CleanPluginOptions); + } + + + type RenamePluginOptions = { + + /** + * 是否输出日志 + * Whether to output the log + */ + verbose?: boolean + + /** + * 采用何种 hash 算法,目前暂时只支持 crc32 + * What hash algorithm is used, currently only crc32 is supported + */ + hash?: "crc32" + + + /** + * 设置匹配规则,将指定文件进行改名 + * 该参数是个数组,允许设置多个匹配规则 + * Set up matching rules to copy specified files to other folders + * This parameter is an array that allows multiple matching rules to be set + */ + matchers: Matcher[] + + /** + * 回调函数,返回值里包括文件的一些信息 + * The callback function, return value includes some information about the file + */ + callback?: Function + } + + + /** + * 修改文件名插件 + */ + export class RenamePlugin implements plugins.Command { + constructor(options: RenamePluginOptions); + } + + type ResSplitPluginOptions = { + + /** + * 是否输出日志 + * Whether to output the log + */ + verbose?: boolean + + /** + * 设置匹配规则,将指定文件拷贝至其他文件夹 + * 该参数是个数组,允许设置多个匹配规则 + * Set up matching rules to copy specified files to other folders + * This parameter is an array that allows multiple matching rules to be set + */ + 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); + } + + type MergeEuiJsonPluginOptions = { + + mergeSelector?: (p: string) => string | null, + + createConfig?: boolean + } + export class MergeEuiJsonPlugin implements plugins.Command { + + constructor(option?: MergeEuiJsonPluginOptions); + } +} diff --git a/scripts/baidugame/baidugame.ts b/scripts/baidugame/baidugame.ts new file mode 100644 index 0000000..c3edb95 --- /dev/null +++ b/scripts/baidugame/baidugame.ts @@ -0,0 +1,82 @@ +import * as fs from 'fs'; +import * as path from 'path'; +export class BaidugamePlugin 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 += "\n;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"); + if(!fs.existsSync(gameJSPath)) { + console.log(`${gameJSPath}不存在,请先使用 Launcher 发布百度小游戏`); + return; + } + 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/scripts/bricks/bricks.ts b/scripts/bricks/bricks.ts new file mode 100644 index 0000000..2cfe04d --- /dev/null +++ b/scripts/bricks/bricks.ts @@ -0,0 +1,64 @@ +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.basename; + 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` + } + } + for (let item of jsonData.game) { + content += `BK.Script.loadlib("GameRes://${item}");\n` + } + content += `BK.Script.loadlib("GameRes://egret.bricks.js");\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); + } else if (filename == 'promise.js') { + return null; + } + return file; + } + async onFinish(pluginContext: plugins.CommandContext) { + //同步index.html 配置到main.js + let mainJSPath = path.join(pluginContext.outputDir, 'main.js'); + let mainJSContent = fs.readFileSync(mainJSPath, { encoding: "utf8" }); + let projectConfig = pluginContext.buildConfig.projectConfig; + + mainJSContent = mainJSContent.replace(/frameRate: 30/gm, `frameRate: ${projectConfig.frameRate}`); + mainJSContent = mainJSContent.replace(/contentWidth: 640/gm, `contentWidth: ${projectConfig.contentWidth}`); + mainJSContent = mainJSContent.replace(/contentHeight: 1136/gm, `contentHeight: ${projectConfig.contentHeight}`); + mainJSContent = mainJSContent.replace(/entryClassName: "Main"/gm, `entryClassName: ${projectConfig.entryClassName}`); + mainJSContent = mainJSContent.replace(/scaleMode: "showAll"/gm, `scaleMode: ${projectConfig.scaleMode}`); + mainJSContent = mainJSContent.replace(/orientation: "auto"/gm, `orientation: ${projectConfig.orientation}`); + fs.writeFileSync(mainJSPath, mainJSContent); + } +} + +declare var egret; \ No newline at end of file diff --git a/scripts/config.android.ts b/scripts/config.android.ts new file mode 100644 index 0000000..b4d7dea --- /dev/null +++ b/scripts/config.android.ts @@ -0,0 +1,52 @@ +/// 阅读 api.d.ts 查看文档 +/// + +import * as path from 'path'; +import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in'; +import * as defaultConfig from './config'; + +const config: ResourceManagerConfig = { + + buildConfig: (params) => { + const { target, command, projectName, version } = params; + const outputDir = `../${projectName}_android/assets/game`; + 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 ManifestPlugin({ output: 'manifest.json' }) + ] + } + } + 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 UglifyPlugin([{ + sources: ["main.js"], + target: "main.min.js" + } + ]), + new ManifestPlugin({ output: 'manifest.json' }) + ] + } + } + else { + throw `unknown command : ${params.command}`; + } + }, + + mergeSelector: defaultConfig.mergeSelector, + + typeSelector: defaultConfig.typeSelector +} + + + +export = config; diff --git a/scripts/config.baidugame.ts b/scripts/config.baidugame.ts new file mode 100644 index 0000000..cda2702 --- /dev/null +++ b/scripts/config.baidugame.ts @@ -0,0 +1,60 @@ +/// 阅读 api.d.ts 查看文档 +/// + +import * as path from 'path'; +import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in'; +import { BaidugamePlugin } from './baidugame/baidugame'; +import { CustomPlugin } from './myplugin'; +import * as defaultConfig from './config'; + +const config: ResourceManagerConfig = { + + buildConfig: (params) => { + + const { target, command, projectName, version } = params; + const outputDir = `../${projectName}_baidugame`; + 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 BaidugamePlugin(), + 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 BaidugamePlugin(), + new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { + 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/scripts/config.bricks.ts b/scripts/config.bricks.ts new file mode 100644 index 0000000..6c5d05a --- /dev/null +++ b/scripts/config.bricks.ts @@ -0,0 +1,55 @@ +/// 阅读 api.d.ts 查看文档 +/// + +import * as path from 'path'; +import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } 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`; + if (command == 'build') { + return { + outputDir, + commands: [ + new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), + new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 + new ManifestPlugin({ output: 'manifest.json' }), + new BricksPlugin() + ] + } + } + else if (command == 'publish') { + console.log('执行publish') + return { + outputDir, + commands: [ + new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), + new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 + new ManifestPlugin({ output: 'manifest.json' }), + new UglifyPlugin([{ + sources: ["main.js"], + target: "js/main.min.js" + } + ]), + new BricksPlugin(), + ] + } + } else { + throw `unknown command : ${params.command}`; + } + }, + + mergeSelector: defaultConfig.mergeSelector, + + typeSelector: defaultConfig.typeSelector +} + + + +export = config; diff --git a/scripts/config.ios.ts b/scripts/config.ios.ts new file mode 100644 index 0000000..2592c1a --- /dev/null +++ b/scripts/config.ios.ts @@ -0,0 +1,52 @@ +/// 阅读 api.d.ts 查看文档 +/// + +import * as path from 'path'; +import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in'; +import * as defaultConfig from './config'; + +const config: ResourceManagerConfig = { + + buildConfig: (params) => { + const { target, command, projectName, version } = params; + const outputDir = `../${projectName}_ios/assets/game`; + 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 ManifestPlugin({ output: 'manifest.json' }) + ] + } + } + 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 UglifyPlugin([{ + sources: ["main.js"], + target: "main.min.js" + } + ]), + new ManifestPlugin({ output: 'manifest.json' }) + ] + } + } + else { + throw `unknown command : ${params.command}`; + } + }, + + mergeSelector: defaultConfig.mergeSelector, + + typeSelector: defaultConfig.typeSelector +} + + + +export = config; diff --git a/scripts/config.oppogame.ts b/scripts/config.oppogame.ts new file mode 100644 index 0000000..6e10087 --- /dev/null +++ b/scripts/config.oppogame.ts @@ -0,0 +1,59 @@ +/// 阅读 api.d.ts 查看文档 +/// + +import * as path from 'path'; +import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, ResSplitPlugin, CleanPlugin } from 'built-in'; +import { OppogamePlugin } from './oppogame/oppogame'; +import * as defaultConfig from './config'; + +const config: ResourceManagerConfig = { + + buildConfig: (params) => { + + const { target, command, projectName, version } = params; + const outputDir = `../${projectName}_oppogame`; + 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 OppogamePlugin(), + 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 OppogamePlugin(), + new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { + 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/scripts/config.qgame.ts b/scripts/config.qgame.ts new file mode 100644 index 0000000..38fa1cc --- /dev/null +++ b/scripts/config.qgame.ts @@ -0,0 +1,59 @@ +/// 阅读 api.d.ts 查看文档 +/// + +import * as path from 'path'; +import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, ResSplitPlugin, CleanPlugin } from 'built-in'; +import { MiqgamePlugin } from './qgame/qgame'; +import * as defaultConfig from './config'; + +const config: ResourceManagerConfig = { + + buildConfig: (params) => { + + const { target, command, projectName, version } = params; + const outputDir = `../${projectName}_qgame`; + 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 MiqgamePlugin(), + 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 MiqgamePlugin(), + new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { + 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/scripts/config.qqgame.ts b/scripts/config.qqgame.ts new file mode 100644 index 0000000..dc50644 --- /dev/null +++ b/scripts/config.qqgame.ts @@ -0,0 +1,60 @@ +/// 阅读 api.d.ts 查看文档 +/// + +import * as path from 'path'; +import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in'; +import { QQgamePlugin } from './qqgame/qqgame'; +import { CustomPlugin } from './myplugin'; +import * as defaultConfig from './config'; + +const config: ResourceManagerConfig = { + + buildConfig: (params) => { + + const { target, command, projectName, version } = params; + const outputDir = `../${projectName}_qqgame`; + 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 QQgamePlugin(), + 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 QQgamePlugin(), + new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { + 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/scripts/config.ts b/scripts/config.ts new file mode 100644 index 0000000..71c5e99 --- /dev/null +++ b/scripts/config.ts @@ -0,0 +1,95 @@ +/// 阅读 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/scripts/config.vivogame.ts b/scripts/config.vivogame.ts new file mode 100644 index 0000000..dbcfb5c --- /dev/null +++ b/scripts/config.vivogame.ts @@ -0,0 +1,59 @@ +/// 阅读 api.d.ts 查看文档 +/// + +import * as path from 'path'; +import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, ResSplitPlugin, CleanPlugin } from 'built-in'; +import { VivogamePlugin } from './vivogame/vivogame'; +import * as defaultConfig from './config'; + +const config: ResourceManagerConfig = { + + buildConfig: (params) => { + + const { target, command, projectName, version } = params; + const outputDir = `../${projectName}_vivogame/src`; + if (command == 'build') { + return { + outputDir, + commands: [ + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), + new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), + new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 + new VivogamePlugin(), + new ManifestPlugin({ output: 'manifest.js', info: { target: 'vivogame' } }) + ] + } + } + else if (command == 'publish') { + return { + outputDir, + commands: [ + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), + new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), + new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 + new VivogamePlugin(), + new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { + sources: ["main.js"], + target: "main.min.js" + } + ]), + new ManifestPlugin({ output: 'manifest.js', info: { target: 'vivogame' } }) + ] + } + } + else { + throw `unknown command : ${params.command}`; + } + }, + + mergeSelector: defaultConfig.mergeSelector, + + typeSelector: defaultConfig.typeSelector +} + + + +export = config; diff --git a/scripts/config.wxgame.ts b/scripts/config.wxgame.ts new file mode 100644 index 0000000..4a661af --- /dev/null +++ b/scripts/config.wxgame.ts @@ -0,0 +1,62 @@ +/// 阅读 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 useWxPlugin:boolean = false; +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", "egret-library"] }), + new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), + new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 + new WxgamePlugin(useWxPlugin), + new ManifestPlugin({ output: 'manifest.js' }) + ] + } + } + else if (command == 'publish') { + return { + outputDir, + commands: [ + new CleanPlugin({ matchers: ["js", "resource", "egret-library"] }), + new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), + new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 + new WxgamePlugin(useWxPlugin), + new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { + sources: ["main.js"], + target: "main.min.js" + } + ]), + new ManifestPlugin({ output: 'manifest.js', useWxPlugin: useWxPlugin }) + ] + } + } + else { + throw `unknown command : ${params.command}`; + } + }, + + mergeSelector: defaultConfig.mergeSelector, + + typeSelector: defaultConfig.typeSelector +} + + + +export = config; diff --git a/scripts/myplugin.ts b/scripts/myplugin.ts new file mode 100644 index 0000000..096133a --- /dev/null +++ b/scripts/myplugin.ts @@ -0,0 +1,17 @@ +/** + * 示例自定义插件,您可以查阅 http://developer.egret.com/cn/github/egret-docs/Engine2D/projectConfig/cmdExtensionPlugin/index.html + * 了解如何开发一个自定义插件 + */ +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/scripts/node.d.ts b/scripts/node.d.ts new file mode 100644 index 0000000..239fd38 --- /dev/null +++ b/scripts/node.d.ts @@ -0,0 +1,4209 @@ +// 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/scripts/oppogame/oppogame.ts b/scripts/oppogame/oppogame.ts new file mode 100644 index 0000000..f6142d3 --- /dev/null +++ b/scripts/oppogame/oppogame.ts @@ -0,0 +1,90 @@ +import * as fs from 'fs'; +import * as path from 'path'; +export class OppogamePlugin 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/eui/eui.js"){ + content = content.replace("function getRepeatedIds","window.getRepeatedIds=function getRepeatedIds"); + content = content.replace("function getIds","window.getIds=function getIds"); + content = content.replace("function toXMLString","window.toXMLString=function toXMLString"); + content = content.replace("function checkDeclarations","window.checkDeclarations=function checkDeclarations"); + content = content.replace("function getPropertyStr","window.getPropertyStr=function getPropertyStr"); + } + } + 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 += "\n;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, "main.js"); + if(!fs.existsSync(gameJSPath)) { + console.log(`${gameJSPath}不存在,请先使用 Launcher 发布Oppo快游戏`); + return; + } + 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, "manifest.json"); + let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); + gameJSONContent.orientation = orientation; + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); + } +} diff --git a/scripts/qgame/qgame.ts b/scripts/qgame/qgame.ts new file mode 100644 index 0000000..949226d --- /dev/null +++ b/scripts/qgame/qgame.ts @@ -0,0 +1,90 @@ +import * as fs from 'fs'; +import * as path from 'path'; +export class MiqgamePlugin 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/eui/eui.js"){ + content = content.replace("function getRepeatedIds","window.getRepeatedIds=function getRepeatedIds"); + content = content.replace("function getIds","window.getIds=function getIds"); + content = content.replace("function toXMLString","window.toXMLString=function toXMLString"); + content = content.replace("function checkDeclarations","window.checkDeclarations=function checkDeclarations"); + content = content.replace("function getPropertyStr","window.getPropertyStr=function getPropertyStr"); + } + } + 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 += "\n;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, "main.js"); + if(!fs.existsSync(gameJSPath)) { + console.log(`${gameJSPath}不存在,请先使用 Launcher 发布小米快游戏`); + return; + } + 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, "manifest.json"); + let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); + gameJSONContent.orientation = orientation; + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); + } +} diff --git a/scripts/qqgame/qqgame.ts b/scripts/qqgame/qqgame.ts new file mode 100644 index 0000000..918fc63 --- /dev/null +++ b/scripts/qqgame/qqgame.ts @@ -0,0 +1,82 @@ +import * as fs from 'fs'; +import * as path from 'path'; +export class QQgamePlugin 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 += "\n;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"); + if(!fs.existsSync(gameJSPath)) { + console.log(`${gameJSPath}不存在,请先使用 Launcher 发布QQ小游戏`); + return; + } + 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/scripts/tsconfig.json b/scripts/tsconfig.json new file mode 100644 index 0000000..1868374 --- /dev/null +++ b/scripts/tsconfig.json @@ -0,0 +1,50 @@ +{ + "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/scripts/vivogame/vivogame.ts b/scripts/vivogame/vivogame.ts new file mode 100644 index 0000000..84756dd --- /dev/null +++ b/scripts/vivogame/vivogame.ts @@ -0,0 +1,126 @@ +import * as fs from 'fs'; +import * as path from 'path'; +export class VivogamePlugin implements plugins.Command { + jsFileList: any = [] + 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; + } + this.jsFileList.push(file.basename) + 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/eui/eui.js") { + content = content.replace("function getRepeatedIds", "window.getRepeatedIds=function getRepeatedIds"); + content = content.replace("function getIds", "window.getIds=function getIds"); + content = content.replace("function toXMLString", "window.toXMLString=function toXMLString"); + content = content.replace("function checkDeclarations", "window.checkDeclarations=function checkDeclarations"); + content = content.replace("function getPropertyStr", "window.getPropertyStr=function getPropertyStr"); + } + } + 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 += "\n;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"); + if (!fs.existsSync(gameJSPath)) { + console.log(`${gameJSPath}不存在,请先使用 Launcher 发布 Vivo 小游戏`); + return; + } + 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, "manifest.json"); + let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); + gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); + let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; + let configArr: any[] = [] + for (var i = 0, len = this.jsFileList.length; i < len; i++) { + let jsFile = this.jsFileList[i]; + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } + } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) + } + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); + } +} diff --git a/scripts/wxgame/wxgame.ts b/scripts/wxgame/wxgame.ts new file mode 100644 index 0000000..be86560 --- /dev/null +++ b/scripts/wxgame/wxgame.ts @@ -0,0 +1,146 @@ +import * as fs from 'fs'; +import * as path from 'path'; +const crypto = require('crypto'); +export class WxgamePlugin implements plugins.Command { + private useWxPlugin:boolean = false; + constructor(useWxPlugin:boolean) { + this.useWxPlugin = useWxPlugin + } + md5Obj = {} + md5(content) { + let md5 = crypto.createHash('md5'); + return md5.update(content).digest('hex'); + } + 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"); + this.md5Obj[path.basename(filename)] = this.md5(content) + 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 += "\n;window.Main = Main;" + } + this.md5Obj[path.basename(filename)] = this.md5(content) + file.contents = new Buffer(content); + } + } + return file; + } + async onFinish(pluginContext: plugins.CommandContext) { + let { projectRoot, outputDir, buildConfig } = pluginContext + //同步 index.html 配置到 game.js + const gameJSPath = path.join(outputDir, "game.js"); + if (!fs.existsSync(gameJSPath)) { + console.log(`${gameJSPath}不存在,请先使用 Launcher 发布微信小游戏`); + return; + } + let gameJSContent = fs.readFileSync(gameJSPath, { encoding: "utf8" }); + const projectConfig = 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(outputDir, "game.json"); + let gameJSONContent = this.readData(gameJSONPath) + gameJSONContent.deviceOrientation = orientation; + if (buildConfig.command !== "publish" && gameJSONContent.plugins && gameJSONContent.plugins['egret-library']) { + delete gameJSONContent.plugins["egret-library"] + } + this.writeData(gameJSONContent, gameJSONPath) + + //下面的流程是配置开启微信插件的功能 + let engineVersion = this.readData(path.join(projectRoot, "egretProperties.json")).engineVersion; + if (!gameJSONContent.plugins) { + gameJSONContent.plugins = {} + } + if(buildConfig.command == "publish" && this.useWxPlugin){ + gameJSONContent.plugins["egret-library"] = { + "provider": "wx7e2186943221985d", + "version": engineVersion, + "path": "egret-library" + } + }else{ + gameJSONContent.plugins = {} + } + + this.writeData(gameJSONContent, gameJSONPath) + + if (buildConfig.command !== "publish" || !this.useWxPlugin) { + return + } + + let libDir = path.join(outputDir, "egret-library") + fs.mkdirSync(libDir) + let pluginData = { "main": "index.js" } + this.writeData(pluginData, path.join(libDir, "plugin.json")) + let engineJS = ['assetsmanager', 'dragonBones', 'egret', 'game', 'eui', 'socket', 'tween'] + let signatureData: any = { + "provider": "wx7e2186943221985d", + "signature": [] + } + for (let i in engineJS) { + let name = engineJS[i] + '.min.js' + if (this.md5Obj[name]) { + let jsInfo: any = { + "path": name, + "md5": this.md5Obj[name] + } + signatureData.signature.push(jsInfo) + } + } + this.writeData(signatureData, path.join(libDir, "signature.json")) + fs.writeFileSync(path.join(libDir, "index.js"), null); + + } + + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); + } + writeData(data: object, filePath: string) { + fs.writeFileSync(filePath, JSON.stringify(data, null, "\t")); + } +} diff --git a/src/Ball.ts b/src/Ball.ts new file mode 100644 index 0000000..7727d75 --- /dev/null +++ b/src/Ball.ts @@ -0,0 +1,27 @@ +class Ball extends egret.Sprite { + private ball: egret.Bitmap; + + constructor() { + super() + this.createScene() + } + + + private createScene() { + this.ball = this.createBitmapByName('ball_png'); + this.ball.width = 10 + this.ball.height = 10 + this.addChild(this.ball) + } + + /** + * 根据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; + } +} \ No newline at end of file diff --git a/src/CXK.ts b/src/CXK.ts new file mode 100644 index 0000000..0c28dcf --- /dev/null +++ b/src/CXK.ts @@ -0,0 +1,101 @@ +class CXK extends egret.DisplayObjectContainer { + + private cxk: egret.Bitmap; + private ball: egret.Bitmap; + private speedBall: number = 0; + private status: number = 1; + + private step: number = 0; + + private shotStatus = 0; + + constructor() { + super() + this.createScene() + this.addEventListener(egret.Event.ENTER_FRAME, this.changeIkun, this) + } + + public reset() { + this.step = 0 + } + + public prepare() { + this.step = 1 + } + + public shot() { + this.step = 2 + } + + + createScene() { + this.cxk = new egret.Bitmap(); + this.cxk.width = 40 + this.cxk.height = 60 + + this.ball = this.createBitmapByName('ball_png'); + this.ball.width = 10 + this.ball.height = 10 + this.ball.x = 15 + this.addChild(this.ball) + this.addChild(this.cxk) + } + + + private changeIkun() { + if (this.step === 0) { + this.cxk.height = 60 + this.shotStatus = 0 + this.cxk.y = 0 + if (this.status > 3) { + this.status = 1; + this.speedBall = 0 + } + if (this.status > 2) { + this.cxk.texture = RES.getRes('paddle_2_png') + } else { + this.cxk.texture = RES.getRes('paddle_1_png') + } + this.status = this.status + 0.1 + + this.changeBall() + } else if (this.step === 1) { + this.cxk.texture = RES.getRes('paddle_2_png') + this.ball.y = 30 + if (this.cxk.height > 40) { + this.cxk.height -= .6 + this.cxk.y += .6 + } + } else if (this.step === 2) { + this.cxk.texture = RES.getRes('paddle_3_png') + this.cxk.height = 62 + this.cxk.y = 0 + this.shotStatus += 0.4 + if (this.shotStatus > 1) { + this.cxk.texture = RES.getRes('paddle_4_png') + } + } + } + + private changeBall() { + if (this.status > 2) { + this.ball.y = 15 + 10 * (this.speedBall) + } else { + this.ball.y = 40 - 10 * (this.speedBall) + } + this.speedBall += 0.15 + } + + + /** + * 根据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; + } + +} \ No newline at end of file diff --git a/src/LoadingUI.ts b/src/LoadingUI.ts new file mode 100644 index 0000000..a405ac6 --- /dev/null +++ b/src/LoadingUI.ts @@ -0,0 +1,50 @@ +////////////////////////////////////////////////////////////////////////////////////// +// +// 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.textColor = 0x55c04b + this.textField.width = 480; + this.textField.height = 100; + } + + public onProgress(current: number, total: number): void { + this.textField.text = `正在加载...${current}/${total}`; + } +} diff --git a/src/Main.ts b/src/Main.ts new file mode 100644 index 0000000..44f76c4 --- /dev/null +++ b/src/Main.ts @@ -0,0 +1,330 @@ +////////////////////////////////////////////////////////////////////////////////////// +// +// 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. +// +////////////////////////////////////////////////////////////////////////////////////// + +import getTimer = egret.getTimer; + +class Main extends egret.DisplayObjectContainer { + + + private cxk: CXK; + private ball: Ball; + private ball2: Ball; + private ball3: egret.Bitmap; + + private pointText: egret.TextField; + private ballCountText: egret.TextField; + + private scale_intro: egret.Sound; + private scale_circle: egret.Sound; + + private shotSound: egret.Sound; + private bingoSound: egret.Sound; + private dieSound: egret.Sound; + + + private scaleChannel: egret.SoundChannel + + private ballT: number = 0; + + private gameStatus: number = 0;//游戏状态 0 未开始 1 按压 2 正在投篮 3命中 4积分 + + private powerEarn: number = 0;//力量 0-1 + private scoreboardImg: ScoreBoard; + + private ballCount: number = 10; + private totalPoint: number = 0; + + public constructor() { + super(); + this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this); + this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBeginState, this) + this.addEventListener(egret.TouchEvent.TOUCH_END, this.onTouchEndState, this) + this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this) + } + + private onAddToStage(event: egret.Event) { + + egret.lifecycle.addLifecycleListener((context) => { + // custom lifecycle plugin + + context.onUpdate = () => { + + } + }) + + egret.lifecycle.onPause = () => { + egret.ticker.pause(); + } + + egret.lifecycle.onResume = () => { + egret.ticker.resume(); + } + + this.runGame().catch(e => { + console.log(e); + }) + + } + + private async runGame() { + await this.loadResource() + this.createGameScene(); + } + + private async loadResource() { + try { + const loadingView = new LoadingUI(); + this.stage.addChild(loadingView); + await RES.loadConfig("resource/default.res.json", "resource/"); + await RES.loadGroup("preload", 0, loadingView); + this.scale_intro = RES.getRes('scale_intro_mp3') + this.scale_circle = RES.getRes('scale_loop_mp3') + this.shotSound = RES.getRes('launch_mp3') + this.bingoSound = RES.getRes('point_mp3') + this.dieSound = RES.getRes('die_mp3') + this.stage.removeChild(loadingView); + } + catch (e) { + console.error(e); + } + } + + + private drawBallCountAndScore() { + this.ballCountText.text = 'x' + this.ballCount.toString() + this.pointText.text = '得分:' + this.totalPoint.toString() + } + + + /** + * 创建游戏场景 + * Create a game scene + */ + private createGameScene() { + let stageW = this.stage.stageWidth; + let stageH = this.stage.stageHeight; + // 白色背景 + let shp: egret.Shape = new egret.Shape(); + shp.graphics.beginFill(0xffffff, 1); + shp.graphics.drawRect(0, 0, stageW, stageH); + shp.graphics.endFill(); + this.addChild(shp); + //篮球场背景 + let sky = this.createBitmapByName("bg_png"); + this.addChild(sky); + sky.width = stageW; + sky.height = stageW / (1102 / 1172) + sky.y = (stageH - sky.height) / 2 + + + this.cxk = new CXK() + this.addChild(this.cxk) + this.cxk.x = 349 + this.cxk.y = sky.y + 231 + + let ball2 = new Ball(); + this.addChild(ball2) + ball2.x = 156 + ball2.y = 325 + ball2.alpha = 0; + this.ball2 = ball2 + this.touchEnabled = true + this.scoreboardImg = new ScoreBoard(); + this.scoreboardImg.touchEnabled = true + this.scoreboardImg.addEventListener(egret.TouchEvent.TOUCH_TAP, this.restart, this) + + let tipText = new egret.TextField(); + this.addChild(tipText) + tipText.textColor = 0x1aad19 + tipText.x = 200 + tipText.y = 900 + tipText.text = '长按蓄力,松开投球' + + this.pointText = new egret.TextField() + this.addChild(this.pointText) + this.pointText.x = 400 + this.pointText.y = 5 + this.pointText.textColor = 0x333333 + this.pointText.size = 28 + + this.ballCountText = new egret.TextField() + this.addChild(this.ballCountText) + this.ballCountText.x = 60 + this.ballCountText.y = 5 + this.ballCountText.size = 28 + this.ballCountText.textColor = 0x333333 + + this.ball3 = this.createBitmapByName('ball_png') + this.addChild(this.ball3) + this.ball3.y = 5 + this.ball3.x = 25 + this.ball3.width = 25 + this.ball3.height = 25 + + this.drawBallCountAndScore() + } + + private restart() { + console.log('restart') + if (this.gameStatus === 4) { + this.removeChild(this.scoreboardImg) + this.gameStatus = 0 + this.totalPoint = 0 + this.ballCount = 10 + this.drawBallCountAndScore() + } + } + + private onEnterFrame() { + if (this.gameStatus === 2 || this.gameStatus === 3) { + this.ballSport() + } + + if (this.gameStatus === 1) { + //蓄力过程 + this.powerEarn = this.powerEarn + (1 / 66) + } + + } + + onTouchBeginState() { + console.log('touch begin') + if (this.gameStatus === 0) { + this.gameStatus = 1 + this.powerEarn = 0 + this.ballT = 0 + this.scaleChannel = this.scale_intro.play(0, 1) + setTimeout(() => { + if (this.gameStatus === 1) { + this.scaleChannel.stop() + this.scaleChannel = this.scale_circle.play(0, 0) + } + }, 2200) + this.cxk.prepare() + } + } + + onTouchEndState() { + console.log('touch end') + if (this.gameStatus === 1) { + this.ballT = 0 + this.gameStatus = 2 + this.scaleChannel.stop() + this.shotSound.play(0, 1) + this.cxk.shot() + this.ballCount-- + this.drawBallCountAndScore() + this.ball = new Ball(); + this.addChild(this.ball) + this.ball.alpha = 0 + } + } + + + ballSport() { + //篮球弧线 + let speed = 0.015; + let t = this.ballT + let p0 = {x: 350, y: 445}; + // let p1 = {x: 250, y: 200}; + let p1 = {x: 250, y: 200 + (0.5 - this.powerEarn) * 320}; + let p2 = {...p1}; + let p3 = {x: 100 + (0.5 - this.powerEarn) * 160, y: 400}; + + let cx = 3 * (p1.x - p0.x); + let bx = 3 * (p2.x - p1.x) - cx; + let ax = p3.x - p0.x - cx - bx; + + let cy = 3 * (p1.y - p0.y); + let by = 3 * (p2.y - p1.y) - cy; + let ay = p3.y - p0.y - cy - by; + + let xt = ax * (t * t * t) + bx * (t * t) + cx * t + p0.x; + let yt = ay * (t * t * t) + by * (t * t) + cy * t + p0.y; + + this.ballT += speed + + if (this.ballT > 1) { + this.ballT = 1 + } + this.ball.alpha = 1 + + //结束这一步 + const stepOver = () => { + this.gameStatus = 0 + this.cxk.reset() + this.removeChild(this.ball) + if (this.ballCount <= 0) { + this.gameStatus = 4 + this.addChildAt(this.scoreboardImg, 10); + this.scoreboardImg.x = (this.stage.stageWidth - this.scoreboardImg.scoreBoard.width) / 2; + this.scoreboardImg.y = (this.stage.stageHeight - this.scoreboardImg.scoreBoard.height) / 2; + console.log(this.scoreboardImg.x, this.scoreboardImg.y) + this.scoreboardImg.setCurrentPoint(this.totalPoint); + } + this.drawBallCountAndScore() + } + + if (this.gameStatus === 3) {//中了之后 + this.ball.y = yt + if (yt >= p3.y - 1) { + this.totalPoint++ + stepOver() + } + } else if (this.gameStatus === 2) { + let isHit = this.ball2.hitTestPoint(this.ball.x + 5, this.ball.y + 5) + if (isHit) { + this.bingoSound.play(0, 1) + this.gameStatus = 3 + } + this.ball.x = xt + this.ball.y = yt + } + + if (this.ball.y >= p3.y - 1 && this.ball.x <= p3.x + 1) { + if (this.gameStatus === 2) { + this.dieSound.play(0, 1) + stepOver() + } + } + + } + + + /** + * 根据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; + } +} \ No newline at end of file diff --git a/src/ScoreBoard.ts b/src/ScoreBoard.ts new file mode 100644 index 0000000..c8f88ee --- /dev/null +++ b/src/ScoreBoard.ts @@ -0,0 +1,61 @@ +class ScoreBoard extends egret.DisplayObjectContainer { + + public scoreBoard: egret.Bitmap;//人物的bitmap图 + //任务移动的方向 + + private currentPoint: number = 0; + private maxPoint: number = 0; + + private currentPointText: egret.TextField; + private maxPointText: egret.TextField; + + constructor() { + super(); + // this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this); + this.addEventListener(egret.Event.ADDED_TO_STAGE, this.init, this); + } + + /** + * 根据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(); + result.texture = RES.getRes(name); + return result; + } + + setCurrentPoint(point: number) { + this.currentPoint = point; + if (point > this.maxPoint) { + this.maxPoint = point; + } + this.currentPointText.text = this.currentPoint + ""; + this.maxPointText.text = this.maxPoint + ""; + } + + private init() { + let shp = new egret.DisplayObjectContainer(); + + this.scoreBoard = this.createBitmapByName('scoreboard_png'); + + shp.width = this.scoreBoard.width; + shp.height = this.scoreBoard.height; + this.width = shp.width; + this.height = shp.height; + shp.addChild(this.scoreBoard); + this.currentPointText = new egret.TextField(); + this.maxPointText = new egret.TextField(); + shp.addChild(this.currentPointText); + shp.addChild(this.maxPointText); + + this.currentPointText.y = this.scoreBoard.height / 2.5; + this.currentPointText.textColor = 0xcc0000; + this.maxPointText.textColor = 0xcc0000; + this.maxPointText.y = this.scoreBoard.height / 1.65; + this.currentPointText.x = this.scoreBoard.width / 2; + this.maxPointText.x = this.scoreBoard.width / 2; + this.addChild(shp); + + } +} \ No newline at end of file diff --git a/template/runtime/native_loader.js b/template/runtime/native_loader.js new file mode 100644 index 0000000..ad94285 --- /dev/null +++ b/template/runtime/native_loader.js @@ -0,0 +1,8 @@ +require("launcher/native_require.js"); + +egret_native.egtMain = function () { + egret_native.nativeType = "native"; + + egret_native.egretInit(); + egret_native.egretStart(); +}; diff --git a/template/runtime/native_require.js b/template/runtime/native_require.js new file mode 100644 index 0000000..3b7e504 --- /dev/null +++ b/template/runtime/native_require.js @@ -0,0 +1,53 @@ +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/template/runtime/runtime_loader.js b/template/runtime/runtime_loader.js new file mode 100644 index 0000000..5b5f76b --- /dev/null +++ b/template/runtime/runtime_loader.js @@ -0,0 +1,8 @@ +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/template/web/index.html b/template/web/index.html new file mode 100644 index 0000000..3d8ce27 --- /dev/null +++ b/template/web/index.html @@ -0,0 +1,102 @@ + + + + + + Egret + + + + + + + + + + +
      正在加载...0/14
      +
      +
      + + + + \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..905433a --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +{ + "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/wingProperties.json b/wingProperties.json new file mode 100644 index 0000000..31cf46d --- /dev/null +++ b/wingProperties.json @@ -0,0 +1,9 @@ +{ + "resourcePlugin":{ + "configs":[{ + "configPath":"resource/default.res.json", + "relativePath":"resource/" + }] + }, + "theme":"resource/default.thm.json" +} \ No newline at end of file