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 @@ + + + +
+ ++ * 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
+ * let myMatrix:Matrix = myDisplayObject.matrix; + * myMatrix.tx += 10; + * myDisplayObject.matrix = myMatrix; + *+ * @version Egret 2.4 + * @platform Web,Native + * @language en_US + */ + /** + * 一个 Matrix 对象,其中包含更改显示对象的缩放、旋转和平移的值。
+ * 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.
+ * 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 度,并且您左右滚动它,则实际上显示对象会上下滚动。
+ * 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).
+ * 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
+ * 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() 这一对方法来创建和释放事件对象, + * 这一对方法会将事件实例在内部缓存下来供下次循环使用,减少对象的创建次数,从而获得更高的代码运行性能。
+ * 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
+ * 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() 这一对方法来创建和释放事件对象, + * 这一对方法会将事件实例在内部缓存下来供下次循环使用,减少对象的创建次数,从而获得更高的代码运行性能。
+ * 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
fillMode
+ * is BitmapFillMode.SCALE
.
+ *
+ * @version Egret 2.4
+ * @platform Web,Native
+ * @language en_US
+ */
+ /**
+ * 矩形区域,它定义素材对象的九个缩放区域。
+ * 注意:此属性仅在fillMode
为BitmapFillMode.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.
BitmapFillMode.SCALE
+ *
+ * @version Egret 2.4
+ * @platform Web
+ * @language en_US
+ */
+ /**
+ * 确定位图填充尺寸的方式。
+ * 设置为 BitmapFillMode.REPEAT
时,位图将重复以填充区域。
设置为 BitmapFillMode.SCALE
时,位图将拉伸以填充区域。
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.+ * 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.
+ * 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
+ * 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.
+ * let myMatrix:Matrix = myDisplayObject.matrix; + * myMatrix.tx += 10; + * myDisplayObject.matrix = myMatrix; + *+ * @version Egret 2.4 + * @platform Web,Native + * @language en_US + */ + /** + * 一个 Matrix 对象,其中包含更改显示对象的缩放、旋转和平移的值。
+ * 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.
+ * 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 度,并且您左右滚动它,则实际上显示对象会上下滚动。
+ * 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).
+ * 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.
+ * 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() 这一对方法来创建和释放事件对象, + * 这一对方法会将事件实例在内部缓存下来供下次循环使用,减少对象的创建次数,从而获得更高的代码运行性能。
+ * 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.
+ * 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() 这一对方法来创建和释放事件对象, + * 这一对方法会将事件实例在内部缓存下来供下次循环使用,减少对象的创建次数,从而获得更高的代码运行性能。
+ * 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
+ */
+ /**
+ * 矩形区域,它定义素材对象的九个缩放区域。
+ * 注意:此属性仅在fillMode
为BitmapFillMode.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.
BitmapFillMode.SCALE
+ *
+ * @version Egret 2.4
+ * @platform Web
+ * @language en_US
+ */
+ /**
+ * 确定位图填充尺寸的方式。
+ * 设置为 BitmapFillMode.REPEAT
时,位图将重复以填充区域。
设置为 BitmapFillMode.SCALE
时,位图将拉伸以填充区域。
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.+ * 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.
+ * 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
+ * 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.
+ * 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:
+ * ```
+ * + * 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:
+ * ```
+ *