Commit 29b570c6 by Matt

init egret game project

parent b8fea860
{
"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":5747
},
{
"name": "Launch Chrome",
"type": "chrome",
"request": "launch",
"file": "index.html",
"useBuildInServer": true,
"sourceMaps": true,
"webRoot": "${workspaceRoot}",
"preLaunchTask":"build",
"userDataDir":"${tmpdir}",
"port":5747
}
]
}
\ No newline at end of file
{
"search.exclude": {
"**/bin-debug": true,
"**/bin-release": true
}
}
\ No newline at end of file
{
"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
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
var __reflect = (this && this.__reflect) || function (p, c, t) {
p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;
};
var __extends = this && this.__extends || function __extends(t, e) {
function r() {
this.constructor = t;
}
for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]);
r.prototype = e.prototype, t.prototype = new r();
};
var LoadingUI = (function (_super) {
__extends(LoadingUI, _super);
function LoadingUI() {
var _this = _super.call(this) || this;
_this.createView();
return _this;
}
LoadingUI.prototype.createView = function () {
this.textField = new egret.TextField();
this.addChild(this.textField);
this.textField.y = 300;
this.textField.width = 480;
this.textField.height = 100;
this.textField.textAlign = "center";
};
LoadingUI.prototype.onProgress = function (current, total) {
this.textField.text = "Loading..." + current + "/" + total;
};
return LoadingUI;
}(egret.Sprite));
__reflect(LoadingUI.prototype, "LoadingUI", ["RES.PromiseTaskReporter"]);
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// 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 __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 Main = (function (_super) {
__extends(Main, _super);
function Main() {
var _this = _super.call(this) || this;
_this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.onAddToStage, _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 () {
var result, userInfo;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.loadResource()];
case 1:
_a.sent();
this.createGameScene();
return [4 /*yield*/, RES.getResAsync("description_json")];
case 2:
result = _a.sent();
this.startAnimation(result);
return [4 /*yield*/, platform.login()];
case 3:
_a.sent();
return [4 /*yield*/, platform.getUserInfo()];
case 4:
userInfo = _a.sent();
console.log(userInfo);
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.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*/];
}
});
});
};
/**
* 创建游戏场景
* Create a game scene
*/
Main.prototype.createGameScene = function () {
var sky = this.createBitmapByName("bg_jpg");
this.addChild(sky);
var stageW = this.stage.stageWidth;
var stageH = this.stage.stageHeight;
sky.width = stageW;
sky.height = stageH;
var topMask = new egret.Shape();
topMask.graphics.beginFill(0x000000, 0.5);
topMask.graphics.drawRect(0, 0, stageW, 172);
topMask.graphics.endFill();
topMask.y = 33;
this.addChild(topMask);
var icon = this.createBitmapByName("egret_icon_png");
this.addChild(icon);
icon.x = 26;
icon.y = 33;
var line = new egret.Shape();
line.graphics.lineStyle(2, 0xffffff);
line.graphics.moveTo(0, 0);
line.graphics.lineTo(0, 117);
line.graphics.endFill();
line.x = 172;
line.y = 61;
this.addChild(line);
var colorLabel = new egret.TextField();
colorLabel.textColor = 0xffffff;
colorLabel.width = stageW - 172;
colorLabel.textAlign = "center";
colorLabel.text = "Hello Egret";
colorLabel.size = 24;
colorLabel.x = 172;
colorLabel.y = 80;
this.addChild(colorLabel);
var textfield = new egret.TextField();
this.addChild(textfield);
textfield.alpha = 0;
textfield.width = stageW - 172;
textfield.textAlign = egret.HorizontalAlign.CENTER;
textfield.size = 24;
textfield.textColor = 0xffffff;
textfield.x = 172;
textfield.y = 135;
this.textfield = textfield;
};
/**
* 根据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;
};
/**
* 描述文件加载成功,开始播放动画
* Description file loading is successful, start to play the animation
*/
Main.prototype.startAnimation = function (result) {
var _this = this;
var parser = new egret.HtmlTextParser();
var textflowArr = result.map(function (text) { return parser.parse(text); });
var textfield = this.textfield;
var count = -1;
var change = function () {
count++;
if (count >= textflowArr.length) {
count = 0;
}
var textFlow = textflowArr[count];
// 切换描述内容
// Switch to described content
textfield.textFlow = textFlow;
var tw = egret.Tween.get(textfield);
tw.to({ "alpha": 1 }, 200);
tw.wait(2000);
tw.to({ "alpha": 0 }, 200);
tw.call(change, _this);
};
change();
};
return Main;
}(egret.DisplayObjectContainer));
__reflect(Main.prototype, "Main");
var __reflect = (this && this.__reflect) || function (p, c, t) {
p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var DebugPlatform = (function () {
function DebugPlatform() {
}
DebugPlatform.prototype.getUserInfo = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, { nickName: "username" }];
});
});
};
DebugPlatform.prototype.login = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/];
});
});
};
return DebugPlatform;
}());
__reflect(DebugPlatform.prototype, "DebugPlatform", ["Platform"]);
if (!window.platform) {
window.platform = new DebugPlatform();
}
{
"engineVersion": "5.1.10",
"compilerVersion": "5.1.10",
"template": {},
"target": {
"current": "web"
},
"modules": [
{
"name": "egret"
},
{
"name": "game"
},
{
"name": "tween"
},
{
"name": "assetsmanager"
},
{
"name": "promise"
}
]
}
\ No newline at end of file
File added
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Egret</title>
<meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="full-screen" content="true" />
<meta name="screen-orientation" content="portrait" />
<meta name="x5-fullscreen" content="true" />
<meta name="360-fullscreen" content="true" />
<style>
html, body {
-ms-touch-action: none;
background: #888888;
padding: 0;
border: 0;
margin: 0;
height: 100%;
}
</style>
</head>
<body>
<div style="margin: auto;width: 100%;height: 100%;" class="egret-player"
data-entry-class="Main"
data-orientation="landscape"
data-scale-mode="fixedWidth"
data-frame-rate="30"
data-content-width="640"
data-content-height="1136"
data-multi-fingered="2"
data-show-fps="false" data-show-log="false"
data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
</div>
<script>
var loadScript = function (list, callback) {
var loaded = 0;
var loadNext = function () {
loadSingleScript(list[loaded], function () {
loaded++;
if (loaded >= list.length) {
callback();
}
else {
loadNext();
}
})
};
loadNext();
};
var loadSingleScript = function (src, callback) {
var s = document.createElement('script');
s.async = false;
s.src = src;
s.addEventListener('load', function () {
s.parentNode.removeChild(s);
s.removeEventListener('load', arguments.callee, false);
callback();
}, false);
document.body.appendChild(s);
};
var xhr = new XMLHttpRequest();
xhr.open('GET', './manifest.json?v=' + Math.random(), true);
xhr.addEventListener("load", function () {
var manifest = JSON.parse(xhr.response);
var list = manifest.initial.concat(manifest.game);
loadScript(list, function () {
/**
* {
* "renderMode":, //Engine rendering mode, "canvas" or "webgl"
* "audioType": 0 //Use the audio type, 0: default, 2: web audio, 3: audio
* "antialias": //Whether the anti-aliasing is enabled in WebGL mode, true: on, false: off, defaults to false
* "calculateCanvasScaleFactor": //a function return canvas scale factor
* }
**/
egret.runEgret({ renderMode: "webgl", audioType: 0, calculateCanvasScaleFactor:function(context) {
var backingStore = context.backingStorePixelRatio ||
context.webkitBackingStorePixelRatio ||
context.mozBackingStorePixelRatio ||
context.msBackingStorePixelRatio ||
context.oBackingStorePixelRatio ||
context.backingStorePixelRatio || 1;
return (window.devicePixelRatio || 1) / backingStore;
}});
});
});
xhr.send(null);
</script>
</body>
</html>
\ No newline at end of file
declare type ResourceRootSelector<T extends string> = () => T;
declare type ResourceTypeSelector = (file: string) => string;
declare type ResourceNameSelector = (file: string) => string;
declare type ResourceMergerSelector = (file: string) => {
path: string;
alias: string;
};
declare module RES {
var resourceTypeSelector: ResourceTypeSelector;
var resourceNameSelector: ResourceNameSelector;
var resourceMergerSelector: ResourceMergerSelector | null;
function getResourceInfo(path: string): File | null;
function setConfigURL(url: string, root: string): void;
interface ResourceInfo {
url: string;
type: string;
root: string;
crc32?: string;
size?: number;
name: string;
soundType?: string;
scale9grid?: string;
groupNames?: string[];
promise?: Promise<any>;
}
interface Data {
resourceRoot: string;
typeSelector: ResourceTypeSelector;
mergeSelector: ResourceMergerSelector | null;
fileSystem: FileSystem;
groups: {
[groupName: string]: string[];
};
alias: {
[aliasName: string]: string;
};
}
/**
* @class RES.ResourceConfig
* @classdesc
* @private
*/
class ResourceConfig {
config: Data;
constructor();
init(): Promise<void>;
__temp__get__type__via__url(url_or_alias: string): string;
getKeyByAlias(aliasName: string): string;
/**
* 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。
* 可以监听ResourceEvent.CONFIG_COMPLETE事件来确认配置加载完成。
* @method RES.ResourceConfig#createGroup
* @param name {string} 要创建的加载资源组的组名
* @param keys {egret.Array<string>} 要包含的键名列表,key对应配置文件里的name属性或sbuKeys属性的一项或一个资源组名。
* @param override {boolean} 是否覆盖已经存在的同名资源组,默认false。
* @returns {boolean}
*/
createGroup(name: string, keys: Array<string>, override?: boolean): boolean;
/**
* 添加一个二级键名到配置列表。
* @method RES.ResourceConfig#addSubkey
* @param subkey {string} 要添加的二级键名
* @param name {string} 二级键名所属的资源name属性
*/
addSubkey(subkey: string, name: string): void;
addAlias(alias: any, key: any): void;
/**
* 获取加载项类型。
* @method RES.ResourceConfig#getType
* @param key {string} 对应配置文件里的name属性或sbuKeys属性的一项。
* @returns {string}
*/
getType(key: string): string;
addResourceData(data: {
name: string;
type?: string;
url: string;
root?: string;
}): void;
destory(): void;
}
}
declare module RES {
/**
* @class RES.ResourceLoader
* @classdesc
* @private
*/
class ResourceLoader {
/**
* 当前组加载的项总个数,key为groupName
*/
private groupTotalDic;
/**
* 已经加载的项个数,key为groupName
*/
private numLoadedDic;
/**
* 正在加载的组列表,key为groupName
*/
private itemListDic;
/**
* 加载失败的组,key为groupName
*/
private groupErrorDic;
private retryTimesDic;
maxRetryTimes: number;
/**
* 优先级队列,key为priority,value为groupName列表
*/
private priorityQueue;
private reporterDic;
private dispatcherDic;
private failedList;
private loadItemErrorDic;
private errorDic;
load(list: ResourceInfo[], groupName: string, priority: number, reporter?: PromiseTaskReporter): Promise<any>;
private loadingCount;
thread: number;
private next();
/**
* 从优先级队列中移除指定的组名
*/
private removeGroupName(groupName);
private queueIndex;
/**
* 获取下一个待加载项
*/
private getOneResourceInfo();
loadResource(r: ResourceInfo, p?: RES.processor.Processor): Promise<any>;
unloadResource(r: ResourceInfo): Promise<any>;
}
}
declare module RES {
/**
* 整个资源加载系统的进程id,协助管理回调派发机制
*/
var systemPid: number;
let checkCancelation: MethodDecorator;
function profile(): void;
var host: ProcessHost;
var config: ResourceConfig;
var queue: ResourceLoader;
interface ProcessHost {
state: {
[index: string]: number;
};
resourceConfig: ResourceConfig;
load: (resource: ResourceInfo, processor?: string | processor.Processor) => Promise<any>;
unload: (resource: ResourceInfo) => Promise<any>;
save: (rexource: ResourceInfo, data: any) => void;
get: (resource: ResourceInfo) => any;
remove: (resource: ResourceInfo) => void;
}
class ResourceManagerError extends Error {
static errorMessage: {
1001: string;
1002: string;
1005: string;
2001: string;
2002: string;
2003: string;
2004: string;
2005: string;
2006: string;
};
/**
* why instanceof e != ResourceManagerError ???
* see link : https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
*/
private __resource_manager_error__;
constructor(code: number, replacer?: Object, replacer2?: Object);
}
}
declare namespace RES {
/**
* Promise的回调函数集合
*/
interface PromiseTaskReporter {
/**
* 进度回调
*/
onProgress?: (current: number, total: number) => void;
/**
* 取消回调
*/
onCancel?: () => void;
}
}
declare module RES {
let checkNull: MethodDecorator;
/**
* 功能开关
* LOADING_STATE:处理重复加载
*/
let FEATURE_FLAG: {
FIX_DUPLICATE_LOAD: number;
};
namespace upgrade {
function setUpgradeGuideLevel(level: "warning" | "silent"): void;
}
}
declare module RES.processor {
interface Processor {
onLoadStart(host: ProcessHost, resource: ResourceInfo): Promise<any>;
onRemoveStart(host: ProcessHost, resource: ResourceInfo): Promise<any>;
getData?(host: ProcessHost, resource: ResourceInfo, key: string, subkey: string): any;
}
function isSupport(resource: ResourceInfo): Processor;
function map(type: string, processor: Processor): void;
function getRelativePath(url: string, file: string): string;
var ImageProcessor: Processor;
var BinaryProcessor: Processor;
var TextProcessor: Processor;
var JsonProcessor: Processor;
var XMLProcessor: Processor;
var CommonJSProcessor: Processor;
const SheetProcessor: Processor;
var FontProcessor: Processor;
var SoundProcessor: Processor;
var MovieClipProcessor: Processor;
const MergeJSONProcessor: Processor;
const ResourceConfigProcessor: Processor;
const LegacyResourceConfigProcessor: Processor;
var PVRProcessor: Processor;
const _map: {
[index: string]: Processor;
};
}
declare module RES {
interface File {
url: string;
type: string;
name: string;
root: string;
}
interface Dictionary {
[file: string]: File | Dictionary;
}
interface FileSystem {
addFile(filename: string, type?: string, root?: string): any;
getFile(filename: string): File | null;
profile(): void;
}
class NewFileSystem {
private data;
constructor(data: Dictionary);
profile(): void;
addFile(filename: string, type?: string): void;
getFile(filename: string): File | null;
private reslove(dirpath);
private mkdir(dirpath);
private exists(dirpath);
}
var fileSystem: FileSystem;
}
declare module RES {
/**
* The events of resource loading.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 资源加载事件。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
class ResourceEvent extends egret.Event {
/**
* Failure event for a load item.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 一个加载项加载失败事件。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static ITEM_LOAD_ERROR: string;
/**
* Configure file to load and parse the completion event. Note: if a configuration file is loaded, it will not be thrown out, and if you want to handle the configuration loading failure, monitor the CONFIG_LOAD_ERROR event.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 配置文件加载并解析完成事件。注意:若有配置文件加载失败,将不会抛出此事件,若要处理配置加载失败,请同时监听 CONFIG_LOAD_ERROR 事件。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static CONFIG_COMPLETE: string;
/**
* Configuration file failed to load.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 配置文件加载失败事件。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static CONFIG_LOAD_ERROR: string;
/**
* Delay load group resource loading progress event.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 延迟加载组资源加载进度事件。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static GROUP_PROGRESS: string;
/**
* Delay load group resource to complete event. Note: if you have a resource item loading failure, the event will not be thrown, if you want to handle the group load failure, please listen to the GROUP_LOAD_ERROR event.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 延迟加载组资源加载完成事件。注意:若组内有资源项加载失败,将不会抛出此事件,若要处理组加载失败,请同时监听 GROUP_LOAD_ERROR 事件。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static GROUP_COMPLETE: string;
/**
* Delayed load group resource failed event.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 延迟加载组资源加载失败事件。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static GROUP_LOAD_ERROR: string;
/**
* Creates an Event object to pass as a parameter to event listeners.
* @param type The type of the event, accessible as Event.type.
* @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false.
* @param cancelable Determines whether the Event object can be canceled. The default values is false.
* @version Egret 2.4
* @platform Web,Native
* @private
* @language en_US
*/
/**
* 创建一个作为参数传递给事件侦听器的 Event 对象。
* @param type 事件的类型,可以作为 Event.type 访问。
* @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。
* @param cancelable 确定是否可以取消 Event 对象。默认值为 false。
* @version Egret 2.4
* @platform Web,Native
* @private
* @language zh_CN
*/
constructor(type: string, bubbles?: boolean, cancelable?: boolean);
/**
* File number that has been loaded.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 已经加载的文件数。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
itemsLoaded: number;
/**
* Total file number to load.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 要加载的总文件数。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
itemsTotal: number;
/**
* Resource group name.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 资源组名。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
groupName: string;
/**
* An item of information that is finished by the end of a load.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 一次加载项加载结束的项信息对象。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
resItem: ResourceItem;
}
}
declare module RES {
/**
* Resource term. One of the resources arrays in resource.json.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 资源项。对应 resource.json 中 resources 数组中的一项。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
namespace ResourceItem {
/**
* XML file.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* XML 文件。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
const TYPE_XML: string;
/**
* Picture file.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 图片文件。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
const TYPE_IMAGE: string;
/**
* Binary file.
* @version Egret 2.4
* @platform Web
* @language en_US
*/
/**
* 二进制文件。
* @version Egret 2.4
* @platform Web
* @language zh_CN
*/
const TYPE_BIN: string;
/**
* Text file.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 文本文件。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
const TYPE_TEXT: string;
/**
* JSON file.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* JSON 文件。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
const TYPE_JSON: string;
/**
* SpriteSheet file.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* SpriteSheet 文件。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
const TYPE_SHEET: string;
/**
* BitmapTextSpriteSheet file.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* BitmapTextSpriteSheet 文件。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
const TYPE_FONT: string;
/**
* Sound file.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 声音文件。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
const TYPE_SOUND: string;
function convertToResItem(r: ResourceInfo): ResourceItem;
}
interface ResourceItem extends ResourceInfo {
/**
* Name of resource term.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 加载项名称。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
name: string;
/**
* URL of resource term.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 要加载的文件地址。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
url: string;
/**
* Type of resource term.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 加载项文件类型。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
type: string;
/**
* The raw data object to be referenced.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 被引用的原始数据对象。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
data: ResourceInfo;
crc32?: string;
size?: number;
soundType?: string;
}
}
declare namespace RES {
namespace path {
const normalize: (filename: string) => string;
const basename: (filename: string) => string;
const dirname: (path: string) => string;
}
}
declare namespace RES {
}
declare module RES {
type GetResAsyncCallback = (value?: any, key?: string) => any;
/**
* Conduct mapping injection with class definition as the value.
* @param type Injection type.
* @param analyzerClass Injection type classes need to be resolved.
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/resource/Resource.ts
* @language en_US
*/
/**
* 以类定义为值进行映射注入。
* @param type 注入的类型。
* @param analyzerClass 注入类型需要解析的类。
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/resource/Resource.ts
* @language zh_CN
*/
function registerAnalyzer(type: string, analyzerClass: any): void;
/**
* Load configuration file and parse.
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 加载配置文件并解析。
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
function loadConfig(url: string, resourceRoot: string): Promise<void>;
/**
* Load a set of resources according to the group name.
* @param name Group name to load the resource group.
* @param priority Load priority can be negative, the default value is 0.
* <br>A low priority group must wait for the high priority group to complete the end of the load to start, and the same priority group will be loaded at the same time.
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 根据组名加载一组资源。
* @param name 要加载资源组的组名。
* @param priority 加载优先级,可以为负数,默认值为 0。
* <br>低优先级的组必须等待高优先级组完全加载结束才能开始,同一优先级的组会同时加载。
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
function loadGroup(name: string, priority?: number, reporter?: PromiseTaskReporter): Promise<void>;
/**
* Check whether a resource group has been loaded.
* @param name Group name。
* @returns Is loading or not.
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 检查某个资源组是否已经加载完成。
* @param name 组名。
* @returns 是否正在加载。
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
function isGroupLoaded(name: string): boolean;
/**
* A list of groups of loading is obtained according to the group name.
* @param name Group name.
* @returns The resource item array of group.
* @see RES.ResourceItem
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 根据组名获取组加载项列表。
* @param name 组名。
* @returns 加载项列表。
* @see RES.ResourceItem
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
function getGroupByName(name: string): Array<ResourceItem>;
/**
* Create a custom load resource group, note that this method is valid only after the resource configuration file is loaded.
* <br>You can monitor the ResourceEvent.CONFIG_COMPLETE event to verify that the configuration is complete.
* @param name Group name to create the load resource group.
* @param keys To be included in the list of key keys, the corresponding configuration file in the name or sbuKeys property one or a resource group name.
* @param override Is the default false for the same name resource group already exists.
* @returns Create success or fail.
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。
* <br>可以监听 ResourceEvent.CONFIG_COMPLETE 事件来确认配置加载完成。
* @param name 要创建的加载资源组的组名。
* @param keys 要包含的键名列表,key 对应配置文件里的 name 属性或 sbuKeys 属性的一项或一个资源组名。
* @param override 是否覆盖已经存在的同名资源组,默认 false。
* @returns 是否创建成功。
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
function createGroup(name: string, keys: Array<string>, override?: boolean): boolean;
/**
* Check whether the configuration file contains the specified resources.
* @param key A sbuKeys attribute or name property in a configuration file.
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 检查配置文件里是否含有指定的资源。
* @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
function hasRes(key: string): boolean;
/**
* The synchronization method for obtaining the cache has been loaded with the success of the resource.
* <br>The type of resource and the corresponding return value types are as follows:
* <br>RES.ResourceItem.TYPE_BIN : ArrayBuffer JavaScript primary object
* <br>RES.ResourceItem.TYPE_IMAGE : img Html Object,or egret.BitmapData interface。
* <br>RES.ResourceItem.TYPE_JSON : Object
* <br>RES.ResourceItem.TYPE_SHEET : Object
* <br> 1. If the incoming parameter is the name of the entire SpriteSheet is returned is {image1: Texture, "image2": Texture}.
* <br> 2. If the incoming is "sheet.image1", the return is a single resource.
* <br> 3. If the incoming is the name of the "image1" single resource, the return is a single resource.
* But if there are two SpriteSheet in a single picture of the same name, the return of the image after the load.
* <br>RES.ResourceItem.TYPE_SOUND : HtmlSound Html Object
* <br>RES.ResourceItem.TYPE_TEXT : string
* @param key A subKeys attribute or name property in a configuration file.
* @see RES.ResourceItem
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 同步方式获取缓存的已经加载成功的资源。
* <br>资源类型和对应的返回值类型关系如下:
* <br>RES.ResourceItem.TYPE_BIN : ArrayBuffer JavaScript 原生对象
* <br>RES.ResourceItem.TYPE_IMAGE : img Html 对象,或者 egret.BitmapData 接口。
* <br>RES.ResourceItem.TYPE_JSON : Object
* <br>RES.ResourceItem.TYPE_SHEET : Object
* <br> 1. 如果传入的参数是整个 SpriteSheet 的名称返回的是 {"image1":Texture,"image2":Texture} 这样的格式。
* <br> 2. 如果传入的是 "sheet.image1",返回的是单个资源。
* <br> 3. 如果传入的是 "image1" 单个资源的名称,返回的是单个资源。但是如果有两张 SpriteSheet 中有单个图片资源名称相同,返回的是后加载的那个图片资源。
* <br>RES.ResourceItem.TYPE_SOUND : HtmlSound Html 对象
* <br>RES.ResourceItem.TYPE_TEXT : string
* @param key 对应配置文件里的 name 属性或 subKeys 属性的一项。
* @see RES.ResourceItem
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
function getRes(key: string): any;
/**
* Asynchronous mode to get the resources in the configuration. As long as the resources exist in the configuration file, you can get it in an asynchronous way.
* @param key A sbuKeys attribute or name property in a configuration file.
* @param compFunc Call back function. Example:compFunc(data,key):void.
* @param thisObject This pointer of call back function.
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 异步方式获取配置里的资源。只要是配置文件里存在的资源,都可以通过异步方式获取。
* @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。
* @param compFunc 回调函数。示例:compFunc(data,key):void。
* @param thisObject 回调函数的 this 引用。
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
function getResAsync(key: string): Promise<any>;
function getResAsync(key: string, compFunc: GetResAsyncCallback, thisObject: any): void;
/**
* Access to external resources through the full URL.
* @param url The external path to load the file.
* @param compFunc Call back function. Example:compFunc(data,url):void。
* @param thisObject This pointer of call back function.
* @param type File type (optional). Use the static constants defined in the ResourceItem class. If you do not set the file name extension.
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/resource/GetResByUrl.ts
* @language en_US
*/
/**
* 通过完整URL方式获取外部资源。
* @param url 要加载文件的外部路径。
* @param compFunc 回调函数。示例:compFunc(data,url):void。
* @param thisObject 回调函数的 this 引用。
* @param type 文件类型(可选)。请使用 ResourceItem 类中定义的静态常量。若不设置将根据文件扩展名生成。
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/resource/GetResByUrl.ts
* @language zh_CN
*/
function getResByUrl(url: string, compFunc: Function, thisObject: any, type?: string): void;
/**
* Destroy a single resource file or a set of resources to the cache data, to return whether to delete success.
* @param name Name attribute or resource group name of the load item in the configuration file.
* @param force Destruction of a resource group when the other resources groups have the same resource situation whether the resources will be deleted, the default value true.
* @returns Are successful destruction.
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。
* @param name 配置文件中加载项的name属性或资源组名。
* @param force 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值 true。
* @see #setMaxRetryTimes
* @returns 是否销毁成功。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
function destroyRes(name: string, force?: boolean): Promise<boolean>;
/**
* Sets the maximum number of concurrent load threads, the default value is 2.
* @param thread The number of concurrent loads to be set.
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 设置最大并发加载线程数量,默认值是 2。
* @param thread 要设置的并发加载数。
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
function setMaxLoadingThread(thread: number): void;
/**
* Sets the number of retry times when the resource failed to load, and the default value is 3.
* @param retry To set the retry count.
* @includeExample extension/resource/Resource.ts
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 设置资源加载失败时的重试次数,默认值是 3。
* @param retry 要设置的重试次数。
* @includeExample extension/resource/Resource.ts
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
function setMaxRetryTimes(retry: number): void;
/**
* Add event listeners, reference ResourceEvent defined constants.
* @param type Event name。
* @param listener Listener functions for handling events. This function must accept the Event object as its only parameter, and can't return any results,
* As shown in the following example: function (evt:Event):void can have any name.
* @param thisObject The this object that is bound to a function.
* @param useCapture Determine the listener is running on the capture or running on the target and the bubbling phase. Set useCapture to true,
* then the listener in the capture phase processing events, but not in the target or the bubbling phase processing events.
* If useCapture is false, then the listener only in the target or the bubbling phase processing events.
* To listen for events in all three stages, please call addEventListener two times: once the useCapture is set to true, once the useCapture is set to false.
* @param priority Event listener priority. Priority is specified by a 32 - bit integer with a symbol. The higher the number, the higher the priority.
* All listeners with a priority for n will be processed before the -1 n listener.
* If two or more listeners share the same priority, they are processed in accordance with the order of their added. The default priority is 0.
* @see RES.ResourceEvent
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 添加事件侦听器,参考 ResourceEvent 定义的常量。
* @param type 事件的类型。
* @param listener 处理事件的侦听器函数。此函数必须接受 Event 对象作为其唯一的参数,并且不能返回任何结果,
* 如下面的示例所示: function(evt:Event):void 函数可以有任何名称。
* @param thisObject 侦听函数绑定的 this 对象。
* @param useCapture 确定侦听器是运行于捕获阶段还是运行于目标和冒泡阶段。如果将 useCapture 设置为 true,
* 则侦听器只在捕获阶段处理事件,而不在目标或冒泡阶段处理事件。如果 useCapture 为 false,则侦听器只在目标或冒泡阶段处理事件。
* 要在所有三个阶段都侦听事件,请调用 addEventListener 两次:一次将 useCapture 设置为 true,一次将 useCapture 设置为 false。
* @param priority 事件侦听器的优先级。优先级由一个带符号的 32 位整数指定。数字越大,优先级越高。优先级为 n 的所有侦听器会在
* 优先级为 n -1 的侦听器之前得到处理。如果两个或更多个侦听器共享相同的优先级,则按照它们的添加顺序进行处理。默认优先级为 0。
* @see RES.ResourceEvent
* @see #setMaxRetryTimes
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
function addEventListener(type: string, listener: (event: egret.Event) => void, thisObject: any, useCapture?: boolean, priority?: number): void;
/**
* Remove event listeners, reference ResourceEvent defined constants.
* @param type Event name。
* @param listener Listening function。
* @param thisObject The this object that is bound to a function.
* @param useCapture Is used to capture, and this property is only valid in the display list.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 移除事件侦听器,参考ResourceEvent定义的常量。
* @param type 事件名。
* @param listener 侦听函数。
* @param thisObject 侦听函数绑定的this对象。
* @param useCapture 是否使用捕获,这个属性只在显示列表中生效。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
function removeEventListener(type: string, listener: (event: egret.Event) => void, thisObject: any, useCapture?: boolean): void;
/**
* Adding a custom resource configuration.
* @param data To add configuration.
* @version Egret 3.1.6
* @platform Web,Native
* @language en_US
*/
/**
* 自定义添加一项资源配置。
* @param data 要添加的配置。
* @version Egret 3.1.6
* @platform Web,Native
* @language zh_CN
*/
function $addResourceData(data: {
name: string;
type: string;
url: string;
}): void;
/**
* @private
*/
class Resource extends egret.EventDispatcher {
/**
* 开始加载配置
* @method RES.loadConfig
*/
loadConfig(): Promise<void>;
/**
* 检查某个资源组是否已经加载完成
* @method RES.isGroupLoaded
* @param name {string}
*/
isGroupLoaded(name: string): boolean;
/**
* 根据组名获取组加载项列表
* @method RES.getGroupByName
* @param name {string}
*/
getGroupByName(name: string): Array<ResourceInfo>;
/**
* 根据组名加载一组资源
* @method RES.loadGroup
* @param name {string}
* @param priority {number}
*/
loadGroup(name: string, priority?: number, reporter?: PromiseTaskReporter): Promise<any>;
private _loadGroup(name, priority?, reporter?);
loadResources(keys: string[], reporter?: PromiseTaskReporter): Promise<any>;
/**
* 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。
* 可以监听ResourceEvent.CONFIG_COMPLETE事件来确认配置加载完成。
* @method RES.ResourceConfig#createGroup
* @param name {string} 要创建的加载资源组的组名
* @param keys {egret.Array<string>} 要包含的键名列表,key对应配置文件里的name属性或一个资源组名。
* @param override {boolean} 是否覆盖已经存在的同名资源组,默认false。
* @returns {boolean}
*/
createGroup(name: string, keys: Array<string>, override?: boolean): boolean;
/**
* 检查配置文件里是否含有指定的资源
* @method RES.hasRes
* @param key {string} 对应配置文件里的name属性或subKeys属性的一项。
* @returns {boolean}
*/
hasRes(key: string): boolean;
/**
* 通过key同步获取资源
* @method RES.getRes
* @param key {string}
* @returns {any}
*/
getRes(resKey: string): any;
/**
* 通过key异步获取资源
* @method RES.getResAsync
* @param key {string}
* @param compFunc {Function} 回调函数。示例:compFunc(data,url):void。
* @param thisObject {any}
*/
getResAsync(key: string): Promise<any>;
getResAsync(key: string, compFunc: GetResAsyncCallback, thisObject: any): void;
/**
* 通过url获取资源
* @method RES.getResByUrl
* @param url {string}
* @param compFunc {Function}
* @param thisObject {any}
* @param type {string}
*/
getResByUrl(url: string, compFunc: Function, thisObject: any, type?: string): Promise<any> | void;
/**
* 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。
* @method RES.destroyRes
* @param name {string} 配置文件中加载项的name属性或资源组名
* @param force {boolean} 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值true
* @returns {boolean}
*/
destroyRes(name: string, force?: boolean): Promise<boolean>;
/**
* 设置最大并发加载线程数量,默认值是2.
* @method RES.setMaxLoadingThread
* @param thread {number} 要设置的并发加载数。
*/
setMaxLoadingThread(thread: number): void;
/**
* 设置资源加载失败时的重试次数。
* @param retry 要设置的重试次数。
*/
setMaxRetryTimes(retry: number): void;
addResourceData(data: {
name: string;
type: string;
url: string;
}): void;
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
var __reflect=this&&this.__reflect||function(e,r,t){e.__class__=r,t?t.push(r):t=[r],e.__types__=e.__types__?t.concat(e.__types__):t},__extends=this&&this.__extends||function(e,r){function t(){this.constructor=e}for(var o in r)r.hasOwnProperty(o)&&(e[o]=r[o]);t.prototype=r.prototype,e.prototype=new t},__awaiter=this&&this.__awaiter||function(e,r,t,o){return new(t||(t=Promise))(function(n,i){function a(e){try{u(o.next(e))}catch(r){i(r)}}function s(e){try{u(o["throw"](e))}catch(r){i(r)}}function u(e){e.done?n(e.value):new t(function(r){r(e.value)}).then(a,s)}u((o=o.apply(e,r||[])).next())})},__generator=this&&this.__generator||function(e,r){function t(e){return function(r){return o([e,r])}}function o(t){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,i&&(a=i[2&t[0]?"return":t[0]?"throw":"next"])&&!(a=a.call(i,t[1])).done)return a;switch(i=0,a&&(t=[0,a.value]),t[0]){case 0:case 1:a=t;break;case 4:return u.label++,{value:t[1],done:!1};case 5:u.label++,i=t[1],t=[0];continue;case 7:t=u.ops.pop(),u.trys.pop();continue;default:if(a=u.trys,!(a=a.length>0&&a[a.length-1])&&(6===t[0]||2===t[0])){u=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3])){u.label=t[1];break}if(6===t[0]&&u.label<a[1]){u.label=a[1],a=t;break}if(a&&u.label<a[2]){u.label=a[2],u.ops.push(t);break}a[2]&&u.ops.pop(),u.trys.pop();continue}t=r.call(e,u)}catch(o){t=[6,o],i=0}finally{n=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}var n,i,a,s,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:t(0),"throw":t(1),"return":t(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s},__decorate=this&&this.__decorate||function(e,r,t,o){var n,i=arguments.length,a=3>i?r:null===o?o=Object.getOwnPropertyDescriptor(r,t):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,r,t,o);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(3>i?n(a):i>3?n(r,t,a):n(r,t))||a);return i>3&&a&&Object.defineProperty(r,t,a),a},RES;!function(e){function r(r){var t=e.fileSystem.getFile(r);return t||(r=e.resourceNameSelector(r),t=e.fileSystem.getFile(r)),t}function t(e,r){var t;t=e.indexOf(".json")>=0?"legacyResourceConfig":"resourceConfig",o={type:t,root:r,url:e,name:e}}e.resourceNameSelector=function(e){return e},e.getResourceInfo=r;var o;e.setConfigURL=t;var n=function(){function t(){}return t.prototype.init=function(){var r=this;return this.config||(this.config={alias:{},groups:{},resourceRoot:o.root,typeSelector:function(){return"unknown"},mergeSelector:null,fileSystem:null}),e.queue.loadResource(o).then(function(e){return r.parseConfig(e)})["catch"](function(r){return r.__resource_manager_error__||(console.error(r.stack),r=new e.ResourceManagerError(1002)),Promise.reject(r)})},t.prototype.getGroupByName=function(r,t){var o=this.config.groups[r],n=[];if(!o){if(t)throw new e.ResourceManagerError(2005,r);return null}for(var i=0,a=o;i<a.length;i++){var s=a[i],u=e.config.getResourceWithSubkey(s,!0),c=u.key,f=(u.subkey,e.config.getResource(c,!0));-1==n.indexOf(f)&&n.push(f)}return n},t.prototype.__temp__get__type__via__url=function(r){var t=this.config.alias[r];if(t||(t=r),e.resourceTypeSelector){var o=e.resourceTypeSelector(t);if(!o)throw new e.ResourceManagerError(2004,t);return o}return console.warn("RES.mapConfig 并未设置 typeSelector"),"unknown"},t.prototype.getResourceWithSubkey=function(r,t){r=this.getKeyByAlias(r);var o=r.indexOf("#"),n="";o>=0&&(n=r.substr(o+1),r=r.substr(0,o));var i=this.getResource(r);if(i)return{r:i,key:r,subkey:n};if(t){var a=n?r+"#"+n:r;throw new e.ResourceManagerError(2006,a)}return null},t.prototype.getKeyByAlias=function(e){return this.config.alias[e]?this.config.alias[e]:e},t.prototype.getResource=function(t,o){var n=this.config.alias[t];n||(n=t);var i=r(n);if(!i){if(o)throw new e.ResourceManagerError(2006,t);return null}return i},t.prototype.getGroup=function(e){return this.getGroupByName(e)},t.prototype.createGroup=function(e,r,t){if(void 0===t&&(t=!1),!t&&this.config.groups[e]||!r||0==r.length)return!1;for(var o=[],n=0,i=r;n<i.length;n++){var a=i[n];if(this.config.groups[a]){var s=this.config.groups[a];o=o.concat(s)}else o.push(a)}return this.config.groups[e]=o,!0},t.prototype.parseConfig=function(r){this.config=r,e.fileSystem=r.fileSystem},t.prototype.addSubkey=function(e,r){this.addAlias(e,r+"#"+e)},t.prototype.addAlias=function(e,r){this.config.alias[r]&&(r=this.config.alias[r]),this.config.alias[e]=r},t.prototype.getType=function(e){return this.getResource(e,!0).type},t.prototype.addResourceData=function(r){r.type||(r.type=this.__temp__get__type__via__url(r.url)),e.fileSystem.addFile(r.url,r.type,r.root),r.name&&(this.config.alias[r.name]=r.url)},t.prototype.destory=function(){e.systemPid++;var r={getFile:function(){return null},addFile:function(){},profile:function(){}};this.config={groups:{},alias:{},fileSystem:r,typeSelector:function(e){return e},resourceRoot:"resources",mergeSelector:null}},t}();e.ResourceConfig=n,__reflect(n.prototype,"RES.ResourceConfig")}(RES||(RES={}));var RES;!function(e){var r=function(){function r(){this.groupTotalDic={},this.numLoadedDic={},this.itemListDic={},this.groupErrorDic={},this.retryTimesDic={},this.maxRetryTimes=3,this.priorityQueue={},this.reporterDic={},this.dispatcherDic={},this.failedList=new Array,this.loadItemErrorDic={},this.errorDic={},this.loadingCount=0,this.thread=4,this.queueIndex=0}return r.prototype.load=function(e,r,t,o){if(this.itemListDic[r])return Promise.resolve();for(var n=e.length,i=0;n>i;i++){var a=e[i];a.groupNames||(a.groupNames=[]),a.groupNames.push(r)}this.itemListDic[r]=e,this.groupTotalDic[r]=e.length,this.numLoadedDic[r]=0,this.priorityQueue[t]?this.priorityQueue[t].push(r):this.priorityQueue[t]=[r],this.reporterDic[r]=o;var s=new egret.EventDispatcher;this.dispatcherDic[r]=s;var u=new Promise(function(e,r){s.addEventListener("complete",e,null),s.addEventListener("error",function(e){r(e.data)},null)});return this.next(),u},r.prototype.next=function(){for(var r=this,t=function(){var t=o.getOneResourceInfo();return t?(o.loadingCount++,void o.loadResource(t).then(function(o){r.loadingCount--,e.host.save(t,o);var n=t.groupNames.shift();0==t.groupNames.length&&(t.groupNames=void 0);var i=r.reporterDic[n];r.numLoadedDic[n]++;var a=r.numLoadedDic[n],s=r.groupTotalDic[n];if(i&&i.onProgress&&i.onProgress(a,s),a==s){var u=r.groupErrorDic[n];r.removeGroupName(n),delete r.groupTotalDic[n],delete r.numLoadedDic[n],delete r.itemListDic[n],delete r.groupErrorDic[n];var c=r.dispatcherDic[n];if(u){var f=r.loadItemErrorDic[n];delete r.loadItemErrorDic[n];var l=r.errorDic[n];delete r.errorDic[n],c.dispatchEventWith("error",!1,{itemList:f,error:l})}else c.dispatchEventWith("complete")}r.next()})["catch"](function(o){if(!o.__resource_manager_error__)throw o;r.loadingCount--,delete e.host.state[t.root+t.name];var n=r.retryTimesDic[t.name]||1;if(!(n>r.maxRetryTimes))return r.retryTimesDic[t.name]=n+1,r.failedList.push(t),void r.next();delete r.retryTimesDic[t.name];var i=t.groupNames.shift();0==t.groupNames.length&&delete t.groupNames,r.loadItemErrorDic[i]||(r.loadItemErrorDic[i]=[]),-1==r.loadItemErrorDic[i].indexOf(t)&&r.loadItemErrorDic[i].push(t),r.groupErrorDic[i]=!0;var a=r.reporterDic[i];r.numLoadedDic[i]++;var s=r.numLoadedDic[i],u=r.groupTotalDic[i];if(a&&a.onProgress&&a.onProgress(s,u),s==u){r.groupErrorDic[i];r.removeGroupName(i),delete r.groupTotalDic[i],delete r.numLoadedDic[i],delete r.itemListDic[i],delete r.groupErrorDic[i];var c=r.loadItemErrorDic[i];delete r.loadItemErrorDic[i];var f=r.dispatcherDic[i];f.dispatchEventWith("error",!1,{itemList:c,error:o})}else r.errorDic[i]=o;r.next()})):"break"},o=this;this.loadingCount<this.thread;){var n=t();if("break"===n)break}},r.prototype.removeGroupName=function(e){for(var r in this.priorityQueue){for(var t=this.priorityQueue[r],o=0,n=!1,i=t.length,a=0;i>a;a++){var s=t[a];if(s==e){t.splice(o,1),n=!0;break}o++}if(n){0==t.length&&delete this.priorityQueue[r];break}}},r.prototype.getOneResourceInfo=function(){if(this.failedList.length>0)return this.failedList.shift();var e=Number.NEGATIVE_INFINITY;for(var r in this.priorityQueue)e=Math.max(e,r);var t=this.priorityQueue[e];if(t&&0!=t.length){for(var o=t.length,n=[],i=0;o>i&&(this.queueIndex>=o&&(this.queueIndex=0),n=this.itemListDic[t[this.queueIndex]],!(n.length>0));i++)this.queueIndex++;if(0!=n.length)return n.shift()}},r.prototype.loadResource=function(r,t){if(!t){if(1==e.FEATURE_FLAG.FIX_DUPLICATE_LOAD){var o=e.host.state[r.root+r.name];if(2==o)return Promise.resolve(e.host.get(r));if(1==o)return r.promise}t=e.processor.isSupport(r)}if(!t)throw new e.ResourceManagerError(2001,r.name,r.type);e.host.state[r.root+r.name]=1;var n=t.onLoadStart(e.host,r);return r.promise=n,n},r.prototype.unloadResource=function(r){var t=e.host.get(r);if(!t)return console.warn("尝试释放不存在的资源:",r.name),Promise.resolve();var o=e.processor.isSupport(r);if(o){e.host.state[r.root+r.name]=3;var n=o.onRemoveStart(e.host,r);return e.host.remove(r),n}return Promise.resolve()},r}();e.ResourceLoader=r,__reflect(r.prototype,"RES.ResourceLoader")}(RES||(RES={}));var RES;!function(e){function r(){e.fileSystem.profile(),console.log(t);var r=0;for(var o in t){var n=t[o];n instanceof egret.Texture&&(r+=n.$bitmapWidth*n.$bitmapHeight*4)}console.log("gpu size : "+(r/1024).toFixed(3)+"kb")}var t={};e.systemPid=0,e.checkCancelation=function(r,t,n){var i=n.value;n.value=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var n=e.systemPid,a=i.apply(this,r);return a.then(function(t){if(e.systemPid!=n)throw new o(1005,r[0]);return t})}},e.profile=r,e.host={state:{},get resourceConfig(){return e.config},load:function(r,t){var o="string"==typeof t?e.processor._map[t]:t;return e.queue.loadResource(r,o)},unload:function(r){return e.queue.unloadResource(r)},save:function(r,o){e.host.state[r.root+r.name]=2,r.promise=void 0,t[r.url]=o},get:function(e){return t[e.url]},remove:function(r){e.host.state[r.root+r.name]=0,delete t[r.url]}},e.config=new e.ResourceConfig,e.queue=new e.ResourceLoader;var o=function(e){function r(t,o,n){var i=e.call(this)||this;return i.__resource_manager_error__=!0,i.name=t.toString(),i.message=r.errorMessage[t].replace("{0}",o).replace("{1}",n),i}return __extends(r,e),r.errorMessage={1001:"文件加载失败:{0}",1002:"ResourceManager 初始化失败:配置文件加载失败",1005:"ResourceManager 已被销毁,文件加载失败:{0}",2001:"{0}解析失败,不支持指定解析类型:'{1}',请编写自定义 Processor ,更多内容请参见 https://github.com/egret-labs/resourcemanager/blob/master/docs/README.md#processor",2002:"Analyzer 相关API 在 ResourceManager 中不再支持,请编写自定义 Processor ,更多内容请参见 https://github.com/egret-labs/resourcemanager/blob/master/docs/README.md#processor",2003:"{0}解析失败,错误原因:{1}",2004:"无法找到文件类型:{0}",2005:"资源配置文件中无法找到特定的资源组:{0}",2006:"资源配置文件中无法找到特定的资源:{0}"},r}(Error);e.ResourceManagerError=o,__reflect(o.prototype,"RES.ResourceManagerError")}(RES||(RES={}));var RES;!function(e){e.checkNull=function(e,r,t){var o=t.value;t.value=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e[0]?o.apply(this,e):(console.warn("方法"+r+"的参数不能为null"),null)}},e.FEATURE_FLAG={FIX_DUPLICATE_LOAD:1};var r;!function(e){function r(e){t=e}var t="warning";e.setUpgradeGuideLevel=r}(r=e.upgrade||(e.upgrade={}))}(RES||(RES={}));var RES;!function(e){var r;!function(r){function t(e){return r._map[e.type]}function o(e,t){r._map[e]=t}function n(r,t){return __awaiter(this,void 0,void 0,function(){var o=this;return __generator(this,function(n){return[2,new Promise(function(n,i){var a=function(){var e=r.data?r.data:r.response;n(e)},s=function(){var r=new e.ResourceManagerError(1001,t.url);i(r)};r.addEventListener(egret.Event.COMPLETE,a,o),r.addEventListener(egret.IOErrorEvent.IO_ERROR,s,o)})]})})}function i(r){if(-1!=r.url.indexOf("://"))return r.url;var t=r.root,o=t+r.url;return e.getRealURL?e.getRealURL(o):o}function a(e,r){if(-1!=r.indexOf("://"))return r;e=e.split("\\").join("/");var t=e.match(/#.*|\?.*/),o="";t&&(o=t[0]);var n=e.lastIndexOf("/");return e=-1!=n?e.substring(0,n+1)+r:r,e+o}function s(e,r,t){switch(e){case c.COMPRESSED_RGB_PVRTC_4BPPV1_IMG:case c.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:return Math.floor((Math.max(r,8)*Math.max(t,8)*4+7)/8);case c.COMPRESSED_RGB_PVRTC_2BPPV1_IMG:case c.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:return Math.floor((Math.max(r,16)*Math.max(t,8)*2+7)/8);default:return 0}}r.isSupport=t,r.map=o,r.getRelativePath=a,r.ImageProcessor={onLoadStart:function(e,r){return __awaiter(this,void 0,void 0,function(){var t,o,a,s,u;return __generator(this,function(c){switch(c.label){case 0:return t=new egret.ImageLoader,t.load(i(r)),[4,n(t,r)];case 1:return o=c.sent(),a=new egret.Texture,a._setBitmapData(o),s=e.resourceConfig.getResource(r.name),s&&s.scale9grid&&(u=s.scale9grid.split(","),a.scale9Grid=new egret.Rectangle(parseInt(u[0]),parseInt(u[1]),parseInt(u[2]),parseInt(u[3]))),[2,a]}})})},onRemoveStart:function(e,r){var t=e.get(r);return t.dispose(),Promise.resolve()}},r.BinaryProcessor={onLoadStart:function(e,r){return __awaiter(this,void 0,void 0,function(){var e,t;return __generator(this,function(o){switch(o.label){case 0:return e=new egret.HttpRequest,e.responseType=egret.HttpResponseType.ARRAY_BUFFER,e.open(i(r),"get"),e.send(),[4,n(e,r)];case 1:return t=o.sent(),[2,t]}})})},onRemoveStart:function(e,r){return Promise.resolve()}},r.TextProcessor={onLoadStart:function(e,r){return __awaiter(this,void 0,void 0,function(){var e,t;return __generator(this,function(o){switch(o.label){case 0:return e=new egret.HttpRequest,e.responseType=egret.HttpResponseType.TEXT,e.open(i(r),"get"),e.send(),[4,n(e,r)];case 1:return t=o.sent(),[2,t]}})})},onRemoveStart:function(e,r){return Promise.resolve()}},r.JsonProcessor={onLoadStart:function(e,r){return __awaiter(this,void 0,void 0,function(){var t,o;return __generator(this,function(n){switch(n.label){case 0:return[4,e.load(r,"text")];case 1:return t=n.sent(),o=JSON.parse(t),[2,o]}})})},onRemoveStart:function(e,r){return Promise.resolve()}},r.XMLProcessor={onLoadStart:function(e,r){return __awaiter(this,void 0,void 0,function(){var t,o;return __generator(this,function(n){switch(n.label){case 0:return[4,e.load(r,"text")];case 1:return t=n.sent(),o=egret.XML.parse(t),[2,o]}})})},onRemoveStart:function(e,r){return Promise.resolve()}},r.CommonJSProcessor={onLoadStart:function(r,t){return __awaiter(this,void 0,void 0,function(){var o,n,i,a;return __generator(this,function(s){switch(s.label){case 0:return[4,r.load(t,"text")];case 1:o=s.sent(),n=new Function("require","exports",o),i=function(){},a={};try{n(i,a)}catch(u){throw new e.ResourceManagerError(2003,t.name,u.message)}return[2,a]}})})},onRemoveStart:function(e,r){return Promise.resolve()}},r.SheetProcessor={onLoadStart:function(e,r){return __awaiter(this,void 0,void 0,function(){var t,o,n,i,s,u,c,f,i;return __generator(this,function(l){switch(l.label){case 0:return[4,e.load(r,"json")];case 1:return t=l.sent(),o=a(r.url,t.file),n=e.resourceConfig.getResource(t.file),n||(n={name:o,url:o,type:"image",root:r.root}),[4,e.load(n)];case 2:i=l.sent(),s=t.frames,u=new egret.SpriteSheet(i),u.$resourceInfo=n;for(c in s)f=s[c],i=u.createTexture(c,f.x,f.y,f.w,f.h,f.offX,f.offY,f.sourceW,f.sourceH);return e.save(n,i),[2,u]}})})},getData:function(e,r,t,o){var n=e.get(r);return n?n.getTexture(o):(console.error("missing resource : "+t+"#"+o),null)},onRemoveStart:function(e,r){var t=e.get(r),o=t.$resourceInfo;return e.unload(o),Promise.resolve()}};var u=function(e,r){var t="",o=r.split("\n"),n=o[2],i=n.indexOf('file="');-1!=i&&(n=n.substring(i+6),i=n.indexOf('"'),t=n.substring(0,i)),e=e.split("\\").join("/");var i=e.lastIndexOf("/");return e=-1!=i?e.substring(0,i+1)+t:t};r.FontProcessor={onLoadStart:function(e,r){return __awaiter(this,void 0,void 0,function(){var t,o,n,i,s,c;return __generator(this,function(f){switch(f.label){case 0:return[4,e.load(r,"text")];case 1:t=f.sent();try{o=JSON.parse(t)}catch(l){o=t}return n=r.name.replace("fnt","png"),i=e.resourceConfig.getResource(n),i||(n="string"==typeof o?u(r.url,o):a(r.url,o.file),i={name:n,url:n,type:"image",root:r.root}),[4,e.load(i)];case 2:return s=f.sent(),c=new egret.BitmapFont(s,o),c.$resourceInfo=i,e.save(i,s),[2,c]}})})},onRemoveStart:function(e,r){var t=e.get(r),o=t.$resourceInfo;return e.unload(o),Promise.resolve()}},r.SoundProcessor={onLoadStart:function(e,r){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(t){switch(t.label){case 0:return e=new egret.Sound,e.load(i(r)),[4,n(e,r)];case 1:return t.sent(),[2,e]}})})},onRemoveStart:function(e,r){return Promise.resolve()}},r.MovieClipProcessor={onLoadStart:function(r,t){var o,n;return r.load(t,"json").then(function(i){o=i;var a=t.name,s=a.substring(0,a.lastIndexOf("."))+".png";if(n=r.resourceConfig.getResource(s,!0),!n)throw new e.ResourceManagerError(1001,s);return r.load(n)}).then(function(e){r.save(n,e);var t=e,i=new egret.MovieClipDataFactory(o,t);return i})},onRemoveStart:function(e,r){var t=e.get(r);t.clearCache(),t.$spriteSheet.dispose();var o=r.name,n=o.substring(0,o.lastIndexOf("."))+".png",i=e.resourceConfig.getResource(n,!0);return e.unload(i)}},r.MergeJSONProcessor={onLoadStart:function(r,t){return __awaiter(this,void 0,void 0,function(){var o,n;return __generator(this,function(i){switch(i.label){case 0:return[4,r.load(t,"json")];case 1:o=i.sent();for(n in o)e.config.addSubkey(n,t.name);return[2,o]}})})},getData:function(e,r,t,o){var n=e.get(r);return n?n[o]:(console.error("missing resource :"+r.name),null)},onRemoveStart:function(e,r){return Promise.resolve()}},r.ResourceConfigProcessor={onLoadStart:function(r,t){return __awaiter(this,void 0,void 0,function(){var o,n;return __generator(this,function(i){switch(i.label){case 0:return[4,r.load(t,"commonjs")];case 1:return o=i.sent(),n=new e.NewFileSystem(o.resources),o.fileSystem=n,delete o.resource,e.resourceTypeSelector=o.typeSelector,e.resourceNameSelector=o.nameSelector?o.nameSelector:function(e){return e},[2,o]}})})},onRemoveStart:function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return[2]})})}},r.LegacyResourceConfigProcessor={onLoadStart:function(r,t){return r.load(t,"json").then(function(r){var o=e.config.config,n=t.root,i=o.fileSystem;i||(i={fsData:{},getFile:function(e){return l[e]},addFile:function(e,r,t){r||(r=""),void 0==t&&(t=""),l[e]={name:e,type:r,url:e,root:t}},profile:function(){console.log(l)}},o.fileSystem=i);for(var a=o.groups,s=0,u=r.groups;s<u.length;s++){var c=u[s];a[c.name]=c.keys.split(",")}for(var f=o.alias,l=i.fsData,p=function(e){l[e.name]=e,l[e.name].root=n,e.subkeys&&e.subkeys.split(",").forEach(function(r){f[r]=e.name+"#"+r,f[e.name+"."+r]=e.name+"#"+r})},g=0,d=r.resources;g<d.length;g++){var v=d[g];p(v)}return o})},onRemoveStart:function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return[2]})})}};var c=function(){function e(){}return e.parse=function(r,t,o){var n=13,i=new Uint32Array(r,0,n),a={buffer:r,header:i};55727696===i[0]?e._parseV3(a,t,o):559044176===i[11]?e._parseV2(a,t,o):o(a,"pvr parse error!")},e._parseV2=function(r,t,o){var n,i,a=r.header,s=a[0],u=a[1],c=a[2],f=a[3],l=a[4],n=(a[5],a[6]),p=(a[7],a[8],a[9],a[10]),g=(a[11],a[12]),d=255,v=24,h=25,_=l&d,R=p>0;_===h?(i=R?e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,n=4):_===v?(i=R?e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,n=2):(o(r,"pvr v2 parse error"),console.log("unknow format flags::"+_));var m=s;r.pvrtcData=new Uint8Array(r.buffer,m),r.bpp=n,r.format=i,r.width=c,r.height=u,r.surfacesCount=g,r.mipmapsCount=f+1,r.isCubemap=6===r.surfacesCount,t(r)},e._parseV3=function(r,t,o){var n,i,a=r.header,s=a[2];switch(s){case 0:n=2,i=e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;break;case 1:n=2,i=e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;break;case 2:n=4,i=e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;break;case 3:n=4,i=e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;break;default:o(r,"pvr v3 parse error"),console.log("unknow pixel format::"+s)}var u=52+a[12];r.pvrtcData=new Uint8Array(r.buffer,u),r.bpp=n,r.format=i,r.width=a[7],r.height=a[6],r.surfacesCount=a[10],r.mipmapsCount=a[11],r.isCubemap=6===r.surfacesCount,t(r)},e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840,e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841,e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842,e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843,e}();__reflect(c.prototype,"PVRParser"),"undefined"!=typeof egret&&egret&&egret.web&&egret.web.WebGLRenderContext&&(egret.web.WebGLRenderContext.prototype.createTextureFromCompressedData=function(e,r,t,o,n){var i=this.context;this.pvrtcExt||(this.pvrtcExt=i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"));var a=i.createTexture();i.bindTexture(i.TEXTURE_2D,a);for(var u=0,c=0;o>c;++c){var f=s(n,r,t),l=new Uint8Array(e.buffer,e.byteOffset+u,f);i.compressedTexImage2D(i.TEXTURE_2D,c,n,r,t,0,l),r>>=1,1>r&&(r=1),t>>=1,1>t&&(t=1),u+=f}return i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),a}),r.PVRProcessor={onLoadStart:function(e,r){return __awaiter(this,void 0,void 0,function(){var t,o,n,i,a,s,u,f,l,p,g,d,v;return __generator(this,function(h){switch(h.label){case 0:return[4,e.load(r,"bin")];case 1:for(t=h.sent(),o=512,n=512,i=0,a=0,s=new egret.ByteArray(t),s.position=7,u=["body","ext"],l=0;l<u.length;l++)switch(p=void 0,u[l]){case"body":s.position+=2,g=s.readUnsignedInt(),f=s.buffer.slice(s.position,s.position+g),s.position+=g;break;case"ext":s.position+=6,o=s.readUnsignedShort(),n=s.readUnsignedShort(),i=s.readUnsignedShort(),a=s.readUnsignedShort()}return d=this,c.parse(f,function(e){var r=new egret.BitmapData(e);r.format="pvr",v=new egret.Texture,v._setBitmapData(r),v.$initData(i,a,o,n,0,0,o,n,r.width,r.height)},function(){console.log("pvr error")}),[2,v]}})})},onRemoveStart:function(e,r){return Promise.resolve()}},r._map={image:r.ImageProcessor,json:r.JsonProcessor,text:r.TextProcessor,xml:r.XMLProcessor,sheet:r.SheetProcessor,font:r.FontProcessor,bin:r.BinaryProcessor,commonjs:r.CommonJSProcessor,sound:r.SoundProcessor,movieclip:r.MovieClipProcessor,pvr:r.PVRProcessor,mergeJson:r.MergeJSONProcessor,resourceConfig:r.ResourceConfigProcessor,legacyResourceConfig:r.LegacyResourceConfigProcessor}}(r=e.processor||(e.processor={}))}(RES||(RES={}));var RES;!function(e){function r(r,t){throw new e.ResourceManagerError(2002)}function t(r,t){if(t.indexOf("://")>=0){var o=t.split("://");t=o[0]+"://"+e.path.normalize(o[1]+"/")}else t=e.path.normalize(t+"/"),r=r.replace(t,"");return e.setConfigURL(r,t),R||(R=new _),R.loadConfig()}function o(e,r,t){return void 0===r&&(r=0),R.loadGroup(e,r,t)}function n(e){return R.isGroupLoaded(e)}function i(r){return R.getGroupByName(r).map(function(r){return e.ResourceItem.convertToResItem(r)})}function a(e,r,t){return void 0===t&&(t=!1),R.createGroup(e,r,t)}function s(e){return R.hasRes(e)}function u(e){return R.getRes(e)}function c(e,r,t){return R.getResAsync.apply(R,arguments)}function f(e,r,t,o){void 0===o&&(o=""),R.getResByUrl(e,r,t,o)}function l(e,r){return R.destroyRes(e,r)}function p(e){R||(R=new _),R.setMaxLoadingThread(e)}function g(e){R.setMaxRetryTimes(e)}function d(e,r,t,o,n){void 0===o&&(o=!1),void 0===n&&(n=0),R||(R=new _),R.addEventListener(e,r,t,o,n)}function v(e,r,t,o){void 0===o&&(o=!1),R.removeEventListener(e,r,t,o)}function h(e){R.addResourceData(e)}e.registerAnalyzer=r,e.loadConfig=t,e.loadGroup=o,e.isGroupLoaded=n,e.getGroupByName=i,e.createGroup=a,e.hasRes=s,e.getRes=u,e.getResAsync=c,e.getResByUrl=f,e.destroyRes=l,e.setMaxLoadingThread=p,e.setMaxRetryTimes=g,e.addEventListener=d,e.removeEventListener=v,e.$addResourceData=h;var _=function(r){function t(){return null!==r&&r.apply(this,arguments)||this}return __extends(t,r),t.prototype.loadConfig=function(){var r=this;return e.native_init(),e.config.init().then(function(t){e.ResourceEvent.dispatchResourceEvent(r,e.ResourceEvent.CONFIG_COMPLETE)},function(t){return e.ResourceEvent.dispatchResourceEvent(r,e.ResourceEvent.CONFIG_LOAD_ERROR),Promise.reject(t)})},t.prototype.isGroupLoaded=function(r){var t=e.config.getGroupByName(r,!0);return t.every(function(r){return null!=e.host.get(r)})},t.prototype.getGroupByName=function(r){return e.config.getGroupByName(r,!0)},t.prototype.loadGroup=function(r,t,o){var n=this;void 0===t&&(t=0);var i={onProgress:function(t,i){o&&o.onProgress&&o.onProgress(t,i),e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.GROUP_PROGRESS,r,void 0,t,i)}};return this._loadGroup(r,t,i).then(function(t){e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.GROUP_COMPLETE,r)},function(t){for(var o=t.itemList,i=o.length,a=0;i>a;a++){var s=o[a];delete s.promise,e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.ITEM_LOAD_ERROR,r,s)}return e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.GROUP_LOAD_ERROR,r),Promise.reject(t.error)})},t.prototype._loadGroup=function(r,t,o){void 0===t&&(t=0);var n=e.config.getGroupByName(r,!0);return e.queue.load(n,r,t,o)},t.prototype.loadResources=function(r,t){var o=r.map(function(r){var t=e.config.getResourceWithSubkey(r,!0);return t.r});return e.queue.load(o,"name",0,t)},t.prototype.createGroup=function(r,t,o){return void 0===o&&(o=!1),e.config.createGroup(r,t,o)},t.prototype.hasRes=function(r){return null!=e.config.getResourceWithSubkey(r)},t.prototype.getRes=function(r){var t=e.config.getResourceWithSubkey(r);if(t){var o=t.r,n=t.key,i=t.subkey,a=e.processor.isSupport(o);return a&&a.getData&&i?a.getData(e.host,o,n,i):e.host.get(o)}return null},t.prototype.getResAsync=function(r,t,o){var n=r,i=e.config.getResourceWithSubkey(r,!0),a=i.r,s=i.subkey;return e.queue.loadResource(a).then(function(i){e.host.save(a,i);var u=e.processor.isSupport(a);return u&&u.getData&&s&&(i=u.getData(e.host,a,r,s)),t&&t.call(o,i,n),i})},t.prototype.getResByUrl=function(r,t,o,n){void 0===n&&(n="");var i=e.config.getResource(r);if(!i&&(n||(n=e.config.__temp__get__type__via__url(r)),i={name:r,url:r,type:n,root:""},e.config.addResourceData(i),i=e.config.getResource(r),!i))throw"never";return e.queue.loadResource(i).then(function(e){return t&&i&&t.call(o,e,i.url),e})},t.prototype.destroyRes=function(r,t){return void 0===t&&(t=!0),__awaiter(this,void 0,void 0,function(){var t,o,n,i,a,a;return __generator(this,function(s){switch(s.label){case 0:if(t=e.config.getGroup(r),o=function(r){return e.queue.unloadResource(r)},!(t&&t.length>0))return[3,5];n=0,i=t,s.label=1;case 1:return n<i.length?(a=i[n],[4,o(a)]):[3,4];case 2:s.sent(),s.label=3;case 3:return n++,[3,1];case 4:return[2,!0];case 5:return a=e.config.getResource(r),a?[4,o(a)]:[3,7];case 6:return s.sent(),[2,!0];case 7:return console.warn("无法删除指定组:"+r),[2,!1]}})})},t.prototype.setMaxLoadingThread=function(r){1>r&&(r=1),e.queue.thread=r},t.prototype.setMaxRetryTimes=function(r){r=Math.max(r,0),e.queue.maxRetryTimes=r},t.prototype.addResourceData=function(r){e.config.addResourceData(r)},__decorate([e.checkCancelation],t.prototype,"loadConfig",null),__decorate([e.checkCancelation],t.prototype,"_loadGroup",null),__decorate([e.checkNull],t.prototype,"hasRes",null),__decorate([e.checkNull],t.prototype,"getRes",null),__decorate([e.checkNull,e.checkCancelation],t.prototype,"getResAsync",null),__decorate([e.checkNull,e.checkCancelation],t.prototype,"getResByUrl",null),t}(egret.EventDispatcher);e.Resource=_,__reflect(_.prototype,"RES.Resource");var R}(RES||(RES={}));var RES;!function(e){var r=function(r){function t(e,t,o){void 0===t&&(t=!1),void 0===o&&(o=!1);var n=r.call(this,e,t,o)||this;return n.itemsLoaded=0,n.itemsTotal=0,n.groupName="",n}return __extends(t,r),t.dispatchResourceEvent=function(r,o,n,i,a,s){void 0===n&&(n=""),void 0===i&&(i=void 0),void 0===a&&(a=0),void 0===s&&(s=0);var u=egret.Event.create(t,o);u.groupName=n,i&&(u.resItem=e.ResourceItem.convertToResItem(i)),u.itemsLoaded=a,u.itemsTotal=s;var c=r.dispatchEvent(u);return egret.Event.release(u),c},t.ITEM_LOAD_ERROR="itemLoadError",t.CONFIG_COMPLETE="configComplete",t.CONFIG_LOAD_ERROR="configLoadError",t.GROUP_PROGRESS="groupProgress",t.GROUP_COMPLETE="groupComplete",t.GROUP_LOAD_ERROR="groupLoadError",t}(egret.Event);e.ResourceEvent=r,__reflect(r.prototype,"RES.ResourceEvent")}(RES||(RES={}));var RES;!function(e){var r;!function(r){function t(r){var t=r.name;if(e.config.config)for(var o in e.config.config.alias)e.config.config.alias[o]==r.url&&(t=o);else t=r.url;var n={name:t,url:r.url,type:r.type,data:r,root:r.root};return n}r.TYPE_XML="xml",r.TYPE_IMAGE="image",r.TYPE_BIN="bin",r.TYPE_TEXT="text",r.TYPE_JSON="json",r.TYPE_SHEET="sheet",r.TYPE_FONT="font",r.TYPE_SOUND="sound",r.convertToResItem=t}(r=e.ResourceItem||(e.ResourceItem={}))}(RES||(RES={}));var RES;!function(e){var r;!function(e){e.normalize=function(e){var r=e.split("/");return r.filter(function(e,t){return!!e||t==r.length-1}).join("/")},e.basename=function(e){return e.substr(e.lastIndexOf("/")+1)},e.dirname=function(e){return e.substr(0,e.lastIndexOf("/"))}}(r=e.path||(e.path={}))}(RES||(RES={}));var RES;!function(e){function r(){egret.Capabilities.runtimeType==egret.RuntimeType.NATIVE&&(n=o("all.manifest"))}function t(e){return n&&n[e]?"resource/"+n[e].v.substring(0,2)+"/"+n[e].v+"_"+n[e].s+"."+e.substring(e.lastIndexOf(".")+1):e}function o(e){if(egret_native.readUpdateFileSync&&egret_native.readResourceFileSync){var r=egret_native.readUpdateFileSync(e);if(null!=r)return JSON.parse(r);if(r=egret_native.readResourceFileSync(e),null!=r)return JSON.parse(r)}return null}var n;e.native_init=r,e.getRealURL=t}(RES||(RES={}));var RES;!function(e){var r=function(){function r(e){this.data=e}return r.prototype.profile=function(){console.log(this.data)},r.prototype.addFile=function(r,t){t||(t=""),r=e.path.normalize(r);var o=e.path.basename(r),n=e.path.dirname(r);this.exists(n)||this.mkdir(n);var i=this.reslove(n);i[o]={url:r,type:t}},r.prototype.getFile=function(e){var r=this.reslove(e);return r&&(r.name=e),r},r.prototype.reslove=function(r){if(""==r)return this.data;r=e.path.normalize(r);for(var t=r.split("/"),o=this.data,n=0,i=t;n<i.length;n++){var a=i[n];if(!o)return o;o=o[a]}return o},r.prototype.mkdir=function(r){r=e.path.normalize(r);for(var t=r.split("/"),o=this.data,n=0,i=t;n<i.length;n++){var a=i[n];o[a]||(o[a]={}),o=o[a]}},r.prototype.exists=function(r){if(""==r)return!0;r=e.path.normalize(r);for(var t=r.split("/"),o=this.data,n=0,i=t;n<i.length;n++){var a=i[n];if(!o[a])return!1;o=o[a]}return!0},r}();e.NewFileSystem=r,__reflect(r.prototype,"RES.NewFileSystem")}(RES||(RES={}));
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
declare namespace egret {
/**
* The URLLoaderDataFormat class provides values that specify how downloaded data is received.
* @see http://edn.egret.com/cn/docs/page/600 Read different data format
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/net/URLLoaderDataFormat.ts
* @language en_US
*/
/**
* URLLoaderDataFormat 类提供了一些用于指定如何接收已下载数据的值。
* @see http://edn.egret.com/cn/docs/page/600 读取不同数据格式
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/net/URLLoaderDataFormat.ts
* @language zh_CN
*/
class URLLoaderDataFormat {
/**
* Specify that downloaded data is received as raw binary data.
* @version Egret 2.4
* @platform Web
* @language en_US
*/
/**
* 指定以原始二进制数据形式接收下载的数据。
* @version Egret 2.4
* @platform Web
* @language zh_CN
*/
static BINARY: string;
/**
* Specify that downloaded data is received as text.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 指定以文本形式接收已下载的数据。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static TEXT: string;
/**
* Specify that downloaded data is received as URL-encoded variables.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 指定以 URL 编码变量形式接收下载的数据。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static VARIABLES: string;
/**
* Specify that downloaded data is received as bitmap texture.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 指定以位图纹理形式接收已下载的数据。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static TEXTURE: string;
/**
* Specify that downloaded data is received as sound.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 指定以声音形式接收已下载的数据。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static SOUND: string;
}
}
declare namespace egret {
/**
* @version Egret 2.4
* @platform Web,Native
* @private
*/
class FrameLabel extends EventDispatcher {
/**
* @private
*/
private _name;
/**
* @private
*/
private _frame;
/**
* @private
*/
private _end;
/**
* @version Egret 2.4
* @platform Web,Native
*/
constructor(name: string, frame: number, end?: number);
/**
* Frame number
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 标签名
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
readonly name: string;
/**
* Frame serial number of the label
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 标签所在帧序号
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
readonly frame: number;
/**
* Frame serial number, the end of the label
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 标签对应的结束帧序号
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
readonly end: number;
/**
* Duplicate the current frame label object
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 复制当前帧标签对象
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
clone(): FrameLabel;
}
}
declare namespace egret {
/**
* @classdesc 使用 MovieClipData 类,您可以创建 MovieClip 对象和处理 MovieClip 对象的数据。MovieClipData 一般由MovieClipDataFactory生成
* @see http://edn.egret.com/cn/docs/page/596 MovieClip序列帧动画
* @version Egret 2.4
* @platform Web,Native
*/
class MovieClipData extends HashObject {
/**
* @private
* MovieClip数据
*/
$mcData: any;
/**
* 总帧数
* @version Egret 2.4
* @platform Web,Native
*/
numFrames: number;
/**
* 帧数据列表
* @version Egret 2.4
* @platform Web,Native
*/
frames: any[];
/**
* 帧标签列表
* @version Egret 2.4
* @platform Web,Native
*/
labels: any[];
/**
* 帧事件列表
* @version Egret 2.4
* @platform Web,Native
*/
events: any[];
/**
* 帧率
* @version Egret 2.4
* @platform Web,Native
*/
frameRate: number;
/**
* 纹理数据
* @version Egret 2.4
* @platform Web,Native
*/
textureData: any;
/**
* 纹理集
* @version Egret 2.4
* @platform Web,Native
*/
spriteSheet: SpriteSheet;
/**
* 创建一个 egret.MovieClipData 对象
* @version Egret 2.4
* @platform Web,Native
*/
constructor();
/**
* @private
*
* @param mcData
* @param textureData
* @param spriteSheet
*/
$init(mcData: any, textureData: any, spriteSheet: SpriteSheet): void;
/**
* 根据指定帧序号获取该帧对应的关键帧数据
* @param frame {number} 帧序号
* @returns {any} 帧数据对象
* @version Egret 2.4
* @platform Web,Native
*/
getKeyFrameData(frame: number): any;
/**
* 根据指定帧序号获取该帧对应的Texture对象
* @param frame {number} 帧序号
* @returns {egret.Texture} Texture对象
* @version Egret 2.4
* @platform Web,Native
*/
getTextureByFrame(frame: number): Texture;
$getOffsetByFrame(frame: number, point: Point): void;
/**
* @private
*
* @param resName
* @returns
*/
private getTextureByResName(resName);
/**
* @private
*
* @returns
*/
$isDataValid(): boolean;
/**
* @private
*
* @returns
*/
$isTextureValid(): boolean;
/**
* @private
*
* @param mcData
*/
$fillMCData(mcData: any): void;
/**
* @private
*
* @param framesData
*/
private fillFramesData(framesData);
/**
* @private
*
* @param frameLabelsData
*/
private fillFrameLabelsData(frameLabelsData);
/**
* @private
*
* @param frameEventsData
*/
private fillFrameEventsData(frameEventsData);
/**
* @version Egret 2.4
* @platform Web,Native
*/
/**
* MovieClip数据源
*/
mcData: MovieClipData;
/**
* @private
*
* @param value
*/
private setMCData(value);
}
}
declare namespace egret {
/**
* @classdesc 使用 MovieClipDataFactory 类,可以生成 MovieClipData 对象用于创建MovieClip
* @see http://edn.egret.com/cn/docs/page/596 MovieClip序列帧动画
* @version Egret 2.4
* @platform Web,Native
*/
class MovieClipDataFactory extends EventDispatcher {
/**
* 是否开启缓存
* @version Egret 2.4
* @platform Web,Native
*/
enableCache: boolean;
/**
* @private
*/
$mcDataSet: any;
/**
* @private
*/
$spriteSheet: SpriteSheet;
/**
* @private
*/
$mcDataCache: any;
/**
* 创建一个 egret.MovieClipDataFactory 对象
* @param movieClipDataSet {any} MovieClip数据集,该数据集必须由Egret官方工具生成
* @param texture {Texture} 纹理
* @version Egret 2.4
* @platform Web,Native
*/
constructor(movieClipDataSet?: any, texture?: Texture);
/**
* 清空缓存
* @version Egret 2.4
* @platform Web,Native
*/
clearCache(): void;
/**
* 根据名字生成一个MovieClipData实例。可以用于创建MovieClip。
* @param movieClipName {string} MovieClip名字. 可选参数,默认为"", 相当于取第一个MovieClip数据
* @returns {MovieClipData} 生成的MovieClipData对象
* @version Egret 2.4
* @platform Web,Native
*/
generateMovieClipData(movieClipName?: string): MovieClipData;
/**
* @private
*
* @param movieClipName
* @param cache
* @returns
*/
private findFromCache(movieClipName, cache);
/**
* @private
*
* @param movieClipName
* @param movieClip
* @param cache
*/
private fillData(movieClipName, movieClip, cache);
/**
* MovieClip数据集
* @version Egret 2.4
* @platform Web,Native
*/
mcDataSet: any;
/**
* MovieClip需要使用的纹理图
*/
texture: Texture;
/**
* 由纹理图生成的精灵表
* @version Egret 2.4
* @platform Web,Native
*/
readonly spriteSheet: SpriteSheet;
/**
* @private
*
* @param value
*/
private setTexture(value);
}
}
declare namespace egret {
/**
* When the movieClip's current frame have a frameLabel, dispatches MovieClipEvent object. FrameLabel Event type: MovieClipEvent.FRAME_LABEL
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 当动画的当前帧有事件,将调度 MovieClipEvent 对象。帧事件类型 MovieClipEvent.FRAME_LABEL.
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
class MovieClipEvent extends Event {
/**
* TextEvent create an object that contains information about movieClip events.
* @param type Type of event, you can access the MovieClipEvent.type.
* @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false.
* @param cancelable Determine whether the Event object can be canceled. The default value is false.
* @param frameLabel When the current frame have a frameLabel, the event listeners can access this information through the frameLabel property.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 创建一个 MovieClipEvent 对象,其中包含有关帧事件的信息。
* @param type 事件的类型,可以作为 MovieClipEvent.type 访问。
* @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。
* @param cancelable 确定是否可以取消 Event 对象。默认值为 false。
* @param frameLabel 动画上的帧事件。事件侦听器可以通过 frameLabel 属性访问此信息。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
constructor(type: string, bubbles?: boolean, cancelable?: boolean, frameLabel?: string);
/**
* Dispatched whenever the current frame have a frameLabel.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 动画的当前帧上有事件时调度
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static FRAME_LABEL: string;
/**
* In MovieClipEvent.FRAME_LABEL event, event corresponding string.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 在 MovieClipEvent.FRAME_LABEL 事件中,event对应的字符串。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
frameLabel: string;
/**
* EventDispatcher object using the specified event object thrown MovieClipEvent. The objects will be thrown in the object cache pool for the next round robin.
* @param type The type of the event, accessible as Event.type.
* @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false.
* @param frameLabel MovieClipEvent object frameLabel
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 使用指定的EventDispatcher对象来抛出 MovieClipEvent 事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。
* @param target 派发事件目标
* @param type 事件类型
* @param frameLabel MovieClipEvent 对象的 frameLabel 赋值
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static dispatchMovieClipEvent(target: IEventDispatcher, type: string, frameLabel?: string): boolean;
}
}
declare namespace egret {
/**
* @private
*/
class ScrollEase {
/**
* @version Egret 2.4
* @platform Web,Native
*/
constructor();
/**
*
* @param amount
* @returns
* @version Egret 2.4
* @platform Web,Native
*/
static get(amount: any): Function;
/**
* @version Egret 2.4
* @platform Web,Native
*/
static quintOut: Function;
/**
*
* @param pow
* @returns
* @version Egret 2.4
* @platform Web,Native
*/
static getPowOut(pow: any): Function;
/**
* @version Egret 2.4
* @platform Web,Native
*/
static quartOut: Function;
}
/**
* @private
*/
class ScrollTween extends EventDispatcher {
/**
* @private
*/
private static _tweens;
/**
* @private
*/
private static IGNORE;
/**
* @private
*/
private static _plugins;
/**
* @private
*/
private static _inited;
/**
* @private
*/
private _target;
/**
* @private
*/
private _useTicks;
/**
* @private
*/
private ignoreGlobalPause;
/**
* @private
*/
private loop;
/**
* @private
*/
private pluginData;
/**
* @private
*/
private _curQueueProps;
/**
* @private
*/
private _initQueueProps;
/**
* @private
*/
private _steps;
/**
* @private
*/
private _actions;
/**
* @private
*/
private paused;
/**
* @private
*/
private duration;
/**
* @private
*/
private _prevPos;
/**
* @private
*/
private position;
/**
* @private
*/
private _prevPosition;
/**
* @private
*/
private _stepPosition;
/**
* @private
*/
private passive;
/**
* Activate an object and add a ScrollTween animation to the object
* @param target {any} The object to be activated
* @param props {any} Parameters, support loop onChange onChangeObj
* @param pluginData {any} Write realized
* @param override {boolean} Whether to remove the object before adding a tween, the default value false
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 激活一个对象,对其添加 ScrollTween 动画
* @param target {any} 要激活 ScrollTween 的对象
* @param props {any} 参数,支持loop(循环播放) onChange(变化函数) onChangeObj(变化函数作用域)
* @param pluginData {any} 暂未实现
* @param override {boolean} 是否移除对象之前添加的tween,默认值false
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static get(target: any, props?: any, pluginData?: any, override?: boolean): ScrollTween;
/**
* Delete all ScrollTween animations from an object
* @param target The object whose ScrollTween to be deleted
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 删除一个对象上的全部 ScrollTween 动画
* @param target 需要移除 ScrollTween 的对象
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static removeTweens(target: any): void;
/**
* @private
*
* @param delta
* @param paused
*/
private static tick(timeStamp, paused?);
private static _lastTime;
/**
* @private
*
* @param tween
* @param value
*/
private static _register(tween, value);
/**
* 创建一个 egret.ScrollTween 对象
* @private
* @version Egret 2.4
* @platform Web,Native
*/
constructor(target: any, props: any, pluginData: any);
/**
* @private
*
* @param target
* @param props
* @param pluginData
*/
private initialize(target, props, pluginData);
/**
* @private
*
* @param value
* @param actionsMode
* @returns
*/
private setPosition(value, actionsMode?);
/**
* @private
*
* @param startPos
* @param endPos
* @param includeStart
*/
private _runActions(startPos, endPos, includeStart?);
/**
* @private
*
* @param step
* @param ratio
*/
private _updateTargetProps(step, ratio);
/**
* Whether setting is paused
* @param value {boolean} Whether to pause
* @returns ScrollTween object itself
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 设置是否暂停
* @param value {boolean} 是否暂停
* @returns Tween对象本身
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
setPaused(value: boolean): ScrollTween;
/**
* @private
*
* @param props
* @returns
*/
private _cloneProps(props);
/**
* @private
*
* @param o
* @returns
*/
private _addStep(o);
/**
* @private
*
* @param o
* @returns
*/
private _appendQueueProps(o);
/**
* @private
*
* @param o
* @returns
*/
private _addAction(o);
/**
* Modify the property of the specified display object to a specified value
* @param props {Object} Property set of an object
* @param duration {number} Duration
* @param ease {egret.ScrollEase} Easing algorithm
* @returns {egret.ScrollTween} ScrollTween object itself
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 将指定显示对象的属性修改为指定值
* @param props {Object} 对象的属性集合
* @param duration {number} 持续时间
* @param ease {egret.ScrollEase} 缓动算法
* @returns {egret.ScrollTween} Tween对象本身
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
to(props: any, duration?: number, ease?: Function): ScrollTween;
/**
* Execute callback function
* @param callback {Function} Callback method
* @param thisObj {any} this action scope of the callback method
* @param params {any[]} Parameter of the callback method
* @returns {egret.ScrollTween} ScrollTween object itself
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 执行回调函数
* @param callback {Function} 回调方法
* @param thisObj {any} 回调方法this作用域
* @param params {any[]} 回调方法参数
* @returns {egret.ScrollTween} Tween对象本身
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
call(callback: Function, thisObj?: any, params?: any[]): ScrollTween;
/**
* @method egret.ScrollTween#tick
* @param delta {number}
* @private
* @version Egret 2.4
* @platform Web,Native
*/
tick(delta: number): void;
}
}
declare namespace egret {
/**
* ScrollView auxiliary classes for slides, you will pass a display object constructor. It can display more than the range display object within the specified size range. And can easily drag in this range.
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/display/ScrollView.ts
* @language en_US
*/
/**
* ScrollView 是用于滑动的辅助类,将一个显示对象传入构造函数即可。可以在指定的尺寸范围内显示超过该范围的显示对象。并可以在此范围内随意拖动。
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/display/ScrollView.ts
* @language zh_CN
*/
class ScrollView extends DisplayObjectContainer {
/**
* @private
*/
_ScrV_Props_: ScrollViewProperties;
/**
* Start rolling threshold when the touch point from the initial touch point at a distance exceeding this value will trigger roll
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 开始滚动的阈值,当触摸点偏离初始触摸点的距离超过这个值时才会触发滚动
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
scrollBeginThreshold: number;
/**
* Scrolling speed, the speed is required and the default speed ratio.
* The range of scrollSpeed> 0 assigned to 2:00, the speed is 2 times the default speed
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 滚动速度,这个值为需要的速度与默认速度的比值。
* 取值范围为 scrollSpeed > 0 赋值为 2 时,速度是默认速度的 2 倍
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
scrollSpeed: number;
/**
* Whether to enable rebound, rebound When enabled, ScrollView contents allowed to continue to drag the border after arriving at the end user drag operation, and then bounce back boundary position
* @default true
* @version Egret 2.4
* @language en_US
*/
/**
* 是否启用回弹,当启用回弹后,ScrollView中内容在到达边界后允许继续拖动,在用户拖动操作结束后,再反弹回边界位置
* @default true
* @version Egret 2.4
* @language zh_CN
*/
bounces: boolean;
/**
* Create a egret.ScrollView objects
* @param content {egret.DisplayObject} You need to scroll object
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 创建一个 egret.ScrollView 对象
* @param content {egret.DisplayObject} 需要滚动的对象
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
constructor(content?: DisplayObject);
/**
* @private
*/
_content: DisplayObject;
/**
* Set to scroll object
* @param content {egret.DisplayObject} You need to scroll object
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 设置需要滚动的对象
* @param content {egret.DisplayObject} 需要滚动的对象
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
setContent(content: DisplayObject): void;
/**
* Remove rolling objects
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 移除滚动的对象
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
removeContent(): void;
/**
* Vertical scroll bar display policy, on / off / auto.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 垂直滚动条显示策略,on/off/auto。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
verticalScrollPolicy: string;
/**
* The horizontal scroll bar display policy, on / off / auto.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 水平滚动条显示策略,on/off/auto。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
horizontalScrollPolicy: string;
/**
* Gets or sets the horizontal scroll position
* @returns {number}
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 获取或设置水平滚动位置,
* @returns {number}
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
scrollLeft: number;
/**
* Gets or sets the vertical scroll position
* @returns {number}
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 获取或设置垂直滚动位置,
* @returns {number}
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
scrollTop: number;
/**
* Set scroll position
* @param top {number} The vertical scroll position
* @param left {number} The horizontal scroll position
* @param isOffset {boolean} Optional parameter, the default is false, whether it is the amount of scrolling increase as top = 1 on behalf of one pixel scroll up
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 设置滚动位置
* @param top {number} 垂直滚动位置
* @param left {number} 水平滚动位置
* @param isOffset {boolean} 可选参数,默认是false,是否是滚动增加量,如 top=1 代表往上滚动1像素
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
setScrollPosition(top: number, left: number, isOffset?: boolean): void;
/**
* @private
*
* @param top
* @param left
*/
private _validatePosition(top?, left?);
/**
* @private
* @inheritDoc
*/
$setWidth(value: number): void;
/**
* @private
* @inheritDoc
*/
$setHeight(value: number): void;
/**
* @private
*
*/
_updateContentPosition(): void;
/**
* @private
*
* @returns
*/
_checkScrollPolicy(): boolean;
/**
* @private
*
* @param policy
* @param contentLength
* @param viewLength
* @returns
*/
private __checkScrollPolicy(policy, contentLength, viewLength);
/**
* @private
*
* @returns
*/
_addEvents(): void;
/**
* @private
*
* @returns
*/
_removeEvents(): void;
private _tempStage;
/**
* @private
*
* @param e
*/
_onTouchBegin(e: TouchEvent): void;
/**
* @private
*/
private delayTouchBeginEvent;
/**
* @private
*/
private touchBeginTimer;
/**
* @private
*
* @param event
*/
_onTouchBeginCapture(event: TouchEvent): void;
/**
* @private
*
* @param event
* @returns
*/
private _onTouchEndCapture(event);
/**
* @private
*
*/
private _onTouchBeginTimer();
/**
* @private
*
* @param event
* @returns
*/
private dispatchPropagationEvent(event);
/**
* @private
*
* @param event
* @returns
*/
_onTouchMove(event: TouchEvent): void;
/**
* @private
*
* @param event
* @returns
*/
_onTouchEnd(event: TouchEvent): void;
/**
* @private
*
* @param event
* @returns
*/
_onEnterFrame(event: Event): void;
/**
* @private
*
* @param e
* @returns
*/
private _logTouchEvent(e);
/**
* @private
*
* @param e
* @returns
*/
private _getPointChange(e);
/**
* @private
*
* @param e
* @returns
*/
private _calcVelocitys(e);
/**
* @private
*
* @returns
*/
_getContentWidth(): number;
/**
* @private
*
* @returns
*/
_getContentHeight(): number;
/**
* The left side of the maximum distance
* @returns The left side of the maximum distance
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 距离左侧的最大值
* @returns 距离左侧最大值
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
getMaxScrollLeft(): number;
/**
* Above the maximum distance
* @returns Above the maximum distance
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 距离上方最大值
* @returns 距离上方最大值
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
getMaxScrollTop(): number;
/**
* @private
*/
private static weight;
/**
* @private
*
*/
private _moveAfterTouchEnd();
/**
* @private
*
* @param tw
*/
private onTweenFinished(tw);
/**
* @private
*
* @returns
*/
_onScrollStarted(): void;
/**
* @private
*
* @returns
*/
_onScrollFinished(): void;
/**
* Set the scroll position above the distance
* @param scrollTop Position above distance
* @param duration Easing of time, in milliseconds
* @returns Get tween vertical scrolling
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 设置滚动距离上方的位置
* @param scrollTop 距离上方的位置
* @param duration 缓动时间,毫秒单位
* @returns 获取垂直滚动的tween
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
setScrollTop(scrollTop: number, duration?: number): void;
/**
* Set the scroll position from the left side
* @param scrollLeft From the position on the left side
* @param duration Get tween vertical scrolling
* @returns Gets the horizontal scroll tween
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 设置滚动距离左侧的位置
* @param scrollLeft 距离左侧的位置
* @param duration 缓动时间,毫秒单位
* @returns 获取水平滚动的tween
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
setScrollLeft(scrollLeft: number, duration?: number): void;
/**
* @private
*
* @param pixelsPerMS
* @param curPos
* @param maxPos
* @returns
*/
private getAnimationDatas(pixelsPerMS, curPos, maxPos);
/**
* @private
*
* @param event
* @returns
*/
private cloneTouchEvent(event);
/**
* @private
*
* @returns
*/
private throwNotSupportedError();
/**
* @deprecated
* @inheritDoc
* @inheritDoc
* @version Egret 2.4
* @platform Web,Native
*/
addChild(child: DisplayObject): DisplayObject;
/**
* @deprecated
* @inheritDoc
* @version Egret 2.4
* @platform Web,Native
*/
addChildAt(child: DisplayObject, index: number): DisplayObject;
/**
* @deprecated
* @inheritDoc
* @version Egret 2.4
* @platform Web,Native
*/
removeChild(child: DisplayObject): DisplayObject;
/**
* @deprecated
* @inheritDoc
* @version Egret 2.4
* @platform Web,Native
*/
removeChildAt(index: number): DisplayObject;
/**
* @deprecated
* @inheritDoc
* @version Egret 2.4
* @platform Web,Native
*/
setChildIndex(child: DisplayObject, index: number): void;
/**
* @deprecated
* @inheritDoc
* @version Egret 2.4
* @platform Web,Native
*/
swapChildren(child1: DisplayObject, child2: DisplayObject): void;
/**
* @deprecated
* @inheritDoc
* @version Egret 2.4
* @platform Web,Native
*/
swapChildrenAt(index1: number, index2: number): void;
}
}
declare namespace egret {
/**
* @private
* @version Egret 2.4
* @platform Web,Native
*/
class ScrollViewProperties {
/**
* @private
*/
_verticalScrollPolicy: string;
/**
* @private
*/
_horizontalScrollPolicy: string;
/**
* @private
*/
_scrollLeft: number;
/**
* @private
*/
_scrollTop: number;
/**
* @private
*/
_hCanScroll: boolean;
/**
* @private
*/
_vCanScroll: boolean;
/**
* @private
*/
_lastTouchPosition: egret.Point;
/**
* @private
*/
_touchStartPosition: egret.Point;
/**
* @private
*/
_scrollStarted: boolean;
/**
* @private
*/
_lastTouchTime: number;
/**
* @private
*/
_lastTouchEvent: TouchEvent;
/**
* @private
*/
_velocitys: Array<{
x: number;
y: number;
}>;
/**
* @private
*/
_isHTweenPlaying: boolean;
/**
* @private
*/
_isVTweenPlaying: boolean;
/**
* @private
*/
_hScrollTween: ScrollTween;
/**
* @private
*/
_vScrollTween: ScrollTween;
/**
* @private
*/
_bounces: boolean;
}
}
declare namespace egret {
/**
* UThe URLLoader class downloads data from a URL as text, binary data, or URL-encoded variables. It is useful for downloading text files, XML, or other information to be used in a dynamic, data-driven application.
* A URLLoader object downloads all of the data from a URL before making it available to code in the applications. It sends out notifications about the progress of the download,
* which you can monitor through bytesLoaded and bytesTotal properties, as well as through dispatched events.
* @see http://edn.egret.com/cn/docs/page/601 Build communication request
* @event egret.Event.COMPLETE Dispatched when the net request is complete.
* @event egret.IOErrorEvent.IO_ERROR io error.
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/net/URLLoader.ts
* @language en_US
*/
/**
* URLLoader 类以文本、二进制数据或 URL 编码变量的形式从 URL 下载数据。在下载文本文件、XML 或其他用于动态数据驱动应用程序的信息时,它很有用。
* URLLoader 对象会先从 URL 中下载所有数据,然后才将数据用于应用程序中的代码。它会发出有关下载进度的通知,
* 通过 bytesLoaded 和 bytesTotal 属性以及已调度的事件,可以监视下载进度。
* @see http://edn.egret.com/cn/docs/page/601 构建通信请求
* @event egret.Event.COMPLETE 加载完成后调度。
* @event egret.IOErrorEvent.IO_ERROR 加载错误后调度。
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/net/URLLoader.ts
* @language zh_CN
*/
class URLLoader extends EventDispatcher {
/**
* Create an egret.URLLoader object
* @param request {URLRequest} A URLRequest object specifies the URL to be downloaded.
* If this parameter is omitted, no load operation begins. If a parameter is specified, the load operation begins immediately
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 创建 egret.URLLoader 对象
* @param request {URLRequest} 一个 URLRequest 对象,指定要下载的 URL。
* 如果省略该参数,则不开始加载操作。如果已指定参数,则立即开始加载操作
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
constructor(request?: URLRequest);
/**
* Control whether the downloaded data is received as text (URLLoaderDataFormat.TEXT), raw binary data (URLLoaderDataFormat.BINARY), or URL-encoded variables (URLLoaderDataFormat.VARIABLES).
* If the value of the dataFormat property is URLLoaderDataFormat.TEXT, the received data is a string containing the text of the loaded file.
* If the value of the dataFormat property is URLLoaderDataFormat.BINARY, the received data is a ByteArray object containing the raw binary data.
* If the value of the dataFormat property is URLLoaderDataFormat.TEXTURE, the received data is a Texture object containing the bitmap data.
* If the value of the dataFormat property is URLLoaderDataFormat.VARIABLES, the received data is a URLVariables object containing the URL-encoded variables.
* The default value is URLLoaderDataFormat.TEXT.
* @default egret.URLLoaderDataFormat.TEXT
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 控制是以文本 (URLLoaderDataFormat.TEXT)、原始二进制数据 (URLLoaderDataFormat.BINARY) 还是 URL 编码变量 (URLLoaderDataFormat.VARIABLES) 接收下载的数据。
* 如果 dataFormat 属性的值是 URLLoaderDataFormat.TEXT,则所接收的数据是一个包含已加载文件文本的字符串。
* 如果 dataFormat 属性的值是 URLLoaderDataFormat.BINARY,则所接收的数据是一个包含原始二进制数据的 ByteArray 对象。
* 如果 dataFormat 属性的值是 URLLoaderDataFormat.TEXTURE,则所接收的数据是一个包含位图数据的Texture对象。
* 如果 dataFormat 属性的值是 URLLoaderDataFormat.VARIABLES,则所接收的数据是一个包含 URL 编码变量的 URLVariables 对象。
* @default egret.URLLoaderDataFormat.TEXT
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
dataFormat: string;
/**
* The data received from the load operation. This property is populated only when the load operation is complete. The format of the data depends on the setting of the dataFormat property:
* If the dataFormat property is URLLoaderDataFormat.TEXT, the received data is a string containing the text of the loaded file.
* If the dataFormat property is URLLoaderDataFormat.BINARY, the received data is a ByteArray object containing the raw binary data.
* If the dataFormat property is URLLoaderDataFormat.TEXTURE, the received data is a Texture object containing the bitmap data.
* If the dataFormat property is URLLoaderDataFormat.VARIABLES, the received data is a URLVariables object containing the URL-encoded variables.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 从加载操作接收的数据。只有完成加载操作时,才会填充该属性。该数据的格式取决于 dataFormat 属性的设置:
* 如果 dataFormat 属性是 URLLoaderDataFormat.TEXT,则所接收的数据是一个包含已加载文件文本的字符串。
* 如果 dataFormat 属性是 URLLoaderDataFormat.BINARY,则所接收的数据是一个包含原始二进制数据的 ByteArray 对象。
* 如果 dataFormat 属性是 URLLoaderDataFormat.TEXTURE,则所接收的数据是一个包含位图数据的Texture对象。
* 如果 dataFormat 属性是 URLLoaderDataFormat.VARIABLES,则所接收的数据是一个包含 URL 编码变量的 URLVariables 对象。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
data: any;
/**
* @private
*/
_request: URLRequest;
/**
* Send and load data from the specified URL. The data can be received as text, raw binary data, or URL-encoded variables, depending on the value you set for the dataFormat property.
* Note that the default value of the dataFormat property is text. If you want to send data to the specified URL, you can set the data property in the URLRequest object.
* @param request {URLRequest} A URLRequest object specifies the URL to be downloaded.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 从指定的 URL 发送和加载数据。可以以文本、原始二进制数据或 URL 编码变量格式接收数据,这取决于为 dataFormat 属性所设置的值。
* 请注意 dataFormat 属性的默认值为文本。如果想将数据发送至指定的 URL,则可以在 URLRequest 对象中设置 data 属性。
* @param request {URLRequest} 一个 URLRequest 对象,指定要下载的 URL。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
load(request: URLRequest): void;
private getResponseType(dataFormat);
/**
* @private
*
* @param loader
*/
private loadSound(loader);
/**
* @private
*
* @param loader
*/
private loadTexture(loader);
/**
* @private
*/
_status: number;
/**
* @private
*
*/
__recycle(): void;
}
}
declare namespace egret {
/**
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/display/MovieClip.ts
* @language en_US
*/
/**
* 影片剪辑,可以通过影片剪辑播放序列帧动画。MovieClip 类从以下类继承而来:DisplayObject 和 EventDispatcher。不同于 DisplayObject 对象,MovieClip 对象拥有一个时间轴。
* @extends egret.DisplayObject
* @event egret.Event.COMPLETE 动画播放完成。
* @event egret.Event.LOOP_COMPLETE 动画循环播放完成。循环最后一次只派发 COMPLETE 事件,不派发 LOOP_COMPLETE 事件。
* @see http://edn.egret.com/cn/docs/page/596 MovieClip序列帧动画
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/display/MovieClip.ts
* @language zh_CN
*/
class MovieClip extends DisplayObject {
$texture: Texture;
private offsetPoint;
$movieClipData: MovieClipData;
/**
* @private
*/
private frames;
/**
* @private
*/
$totalFrames: number;
/**
* @version Egret 2.4
* @platform Web,Native
* @private
*/
frameLabels: any[];
/**
* @private
*/
$frameLabelStart: number;
/**
* @private
*/
$frameLabelEnd: number;
/**
* @version Egret 2.4
* @platform Web,Native
* @private
*/
frameEvents: any[];
/**
* @private
*/
private frameIntervalTime;
/**
* @private
*/
$eventPool: string[];
$isPlaying: boolean;
/**
* @private
*/
private isStopped;
/**
* @private
*/
private playTimes;
/**
* @private
*/
$currentFrameNum: number;
/**
* @private
*/
$nextFrameNum: number;
/**
* @private
*/
private displayedKeyFrameNum;
/**
* @private
*/
private passedTime;
/**
* @private
*/
private $frameRate;
/**
* 创建新的 MovieClip 实例。创建 MovieClip 之后,调用舞台上的显示对象容器的addElement方法。
* @param movieClipData {movieClipData} 被引用的 movieClipData 对象
* @version Egret 2.4
* @platform Web,Native
*/
constructor(movieClipData?: MovieClipData);
protected createNativeDisplayObject(): void;
/**
* @private
*/
$smoothing: boolean;
/**
* Whether or not is smoothed when scaled.
* @version Egret 3.0
* @platform Web
* @language en_US
*/
/**
* 控制在缩放时是否进行平滑处理。
* @version Egret 3.0
* @platform Web
* @language zh_CN
*/
smoothing: boolean;
/**
* @private
*
*/
$init(): void;
/**
* @private
*
*/
$reset(): void;
/**
* @private
*
*/
private _initFrame();
/**
* @private
*/
$updateRenderNode(): void;
/**
* @private
*/
$measureContentBounds(bounds: Rectangle): void;
/**
* @private
*
* @param stage
* @param nestLevel
*/
$onAddToStage(stage: Stage, nestLevel: number): void;
/**
* @private
*
*/
$onRemoveFromStage(): void;
/**
* @private
* 返回帧标签为指定字符串的FrameLabel对象
* @param labelName {string} 帧标签名
* @param ignoreCase {boolean} 是否忽略大小写,可选参数,默认false
* @returns {egret.FrameLabel} FrameLabel对象
*/
private getFrameLabelByName(labelName, ignoreCase?);
/**
* @private
* 根据帧标签,设置开始和结束的帧数
* @param labelName {string} 帧标签名
*/
private getFrameStartEnd(labelName);
/**
* @private
* 返回指定序号的帧的FrameLabel对象
* @param frame {number} 帧序号
* @returns {egret.FrameLabel} FrameLabel对象
*/
private getFrameLabelByFrame(frame);
/**
* @private
* 返回指定序号的帧对应的FrameLabel对象,如果当前帧没有标签,则返回前面最近的有标签的帧的FrameLabel对象
* @method egret.MovieClip#getFrameLabelForFrame
* @param frame {number} 帧序号
* @returns {egret.FrameLabel} FrameLabel对象
*/
private getFrameLabelForFrame(frame);
/**
* 继续播放当前动画
* @param playTimes {number} 播放次数。 参数为整数,可选参数,>=1:设定播放次数,<0:循环播放,默认值 0:不改变播放次数(MovieClip初始播放次数设置为1),
* @version Egret 2.4
* @platform Web,Native
*/
play(playTimes?: number): void;
/**
* 暂停播放动画
* @version Egret 2.4
* @platform Web,Native
*/
stop(): void;
/**
* 将播放头移到前一帧并停止
* @version Egret 2.4
* @platform Web,Native
*/
prevFrame(): void;
/**
* 跳到后一帧并停止
* @version Egret 2.4
* @platform Web,Native
*/
nextFrame(): void;
/**
* 将播放头移到指定帧并播放
* @param frame {any} 指定帧的帧号或帧标签
* @param playTimes {number} 播放次数。 参数为整数,可选参数,>=1:设定播放次数,<0:循环播放,默认值 0:不改变播放次数,
* @version Egret 2.4
* @platform Web,Native
*/
gotoAndPlay(frame: string | number, playTimes?: number): void;
/**
* 将播放头移到指定帧并停止
* @param frame {any} 指定帧的帧号或帧标签
* @version Egret 2.4
* @platform Web,Native
*/
gotoAndStop(frame: string | number): void;
/**
* @private
*
* @param frame
*/
private gotoFrame(frame);
/**
* @private
*/
private lastTime;
/**
* @private
*
* @param advancedTime
* @returns
*/
private advanceTime(timeStamp);
/**
* @private
*
*/
private advanceFrame();
/**
* @private
*
*/
private constructFrame();
/**
* @private
*
*/
$renderFrame(): void;
/**
* @private
*
*/
private handlePendingEvent();
/**
* MovieClip 实例中帧的总数
* @version Egret 2.4
* @platform Web,Native
*/
readonly totalFrames: number;
/**
* MovieClip 实例当前播放的帧的序号
* @version Egret 2.4
* @platform Web,Native
*/
readonly currentFrame: number;
/**
* MovieClip 实例当前播放的帧的标签。如果当前帧没有标签,则 currentFrameLabel返回null。
* @version Egret 2.4
* @platform Web,Native
*/
readonly currentFrameLabel: string;
/**
* 当前播放的帧对应的标签,如果当前帧没有标签,则currentLabel返回包含标签的先前帧的标签。如果当前帧和先前帧都不包含标签,currentLabel返回null。
* @version Egret 2.4
* @platform Web,Native
*/
readonly currentLabel: string;
/**
* MovieClip 实例的帧频
* @version Egret 2.4
* @platform Web,Native
*/
frameRate: number;
/**
* MovieClip 实例当前是否正在播放
* @version Egret 2.4
* @platform Web,Native
*/
readonly isPlaying: boolean;
/**
* @version Egret 2.4
* @platform Web,Native
*/
/**
* MovieClip数据源
*/
movieClipData: MovieClipData;
/**
* @private
*
* @param value
*/
private setMovieClipData(value);
/**
* @private
*
* @param value
*/
private setPlayTimes(value);
/**
* @private
*
* @param value
*/
private setIsStopped(value);
}
}
declare namespace egret {
/**
* The URLRequest class captures all of the information in a single HTTP request.
* @see http://edn.egret.com/cn/index.php/article/index/id/601 Build communication request
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/net/URLRequest.ts
* @language en_US
*/
/**
* URLRequest 类可捕获单个 HTTP 请求中的所有信息。
* @see http://edn.egret.com/cn/index.php/article/index/id/601 构建通信请求
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/net/URLRequest.ts
* @language zh_CN
*/
class URLRequest extends HashObject {
/**
* Create an egret.URLRequest object
* @param url {string} Addresses for URL requests
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 创建一个 egret.URLRequest 对象
* @param url {string} 进行网络请求的地址
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
constructor(url?: string);
/**
* An object contains data to be transmitted with the URL request.
* This property is used in conjunction with the method property. When the value of method is GET, the value of data is appended to the value of URLRequest.url, using HTTP query-string syntax.
* When the method value is POST (or any value other than GET), the value of data is transmitted in the body of the HTTP request.
* The URLRequest API offers binary POST support and support for URL-encoded variables, as well as support for strings. The data object can be a ArrayBuffer, URLVariables, or String object.
* The way in which the data is used depends on the type of object used:
* If the object is a ArrayBuffer object, the binary data of the ArrayBuffer object is used as POST data. For GET, data of ArrayBuffer type is not supported.
* If the object is a URLVariables object and the method is POST, then the variables are encoded using x-www-form-urlencoded format and the resulting string is used as POST data.
* If the object is a URLVariables object and the method is GET, the URLVariables object will define variables to be sent with the URLRequest object.
* Otherwise, the object is converted into a string, and the string is used as the POST or GET data.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 一个对象,它包含将随 URL 请求一起传输的数据。
* 该属性与 method 属性配合使用。当 method 值为 GET 时,将使用 HTTP 查询字符串语法将 data 值追加到 URLRequest.url 值。
* 当 method 值为 POST(或 GET 之外的任何值)时,将在 HTTP 请求体中传输 data 值。
* URLRequest API 支持二进制 POST,并支持 URL 编码变量和字符串。该数据对象可以是 ArrayBuffer、URLVariables 或 String 对象。
* 该数据的使用方式取决于所用对象的类型:
* 如果该对象为 ArrayBuffer 对象,则 ArrayBuffer 对象的二进制数据用作 POST 数据。对于 GET,不支持 ArrayBuffer 类型的数据。
* 如果该对象是 URLVariables 对象,并且该方法是 POST,则使用 x-www-form-urlencoded 格式对变量进行编码,并且生成的字符串会用作 POST 数据。
* 如果该对象是 URLVariables 对象,并且该方法是 GET,则 URLVariables 对象将定义要随 URLRequest 对象一起发送的变量。
* 否则,该对象会转换为字符串,并且该字符串会用作 POST 或 GET 数据。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
data: any;
/**
* Request method, valid values are URLRequestMethod.GET or URLRequestMethod.POST.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 请求方式,有效值为URLRequestMethod.GET 或 URLRequestMethod.POST。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
method: string;
/**
* The requested URL.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 所请求的 URL。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
url: string;
/**
* The array of HTTP request headers to be appended to the HTTP request. The array is composed of URLRequestHeader objects.
* Each object in the array must be a URLRequestHeader object that contains a name string and a value string.
* Because of browser compatibility, this property has not been achieved in html5
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 要追加到 HTTP 请求的 HTTP 请求标头的数组。该数组由 URLRequestHeader 对象组成。
* 数组中的每一对象必须是包含一个名称字符串和一个值字符串的 URLRequestHeader 对象。
* 由于浏览器兼容性原因,该属性在 html5 中并未实现
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
requestHeaders: Array<URLRequestHeader>;
}
}
declare namespace egret {
/**
* A URLRequestHeader object encapsulates a single HTTP request header and consists of a name/value pair. URLRequestHeader objects are used in the requestHeaders property of the URLRequest class.
* Note: Because of browser compatibility, this property has not been achieved in html5
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/net/URLRequestHeader.ts
* @language en_US
*/
/**
* URLRequestHeader 对象封装了一个 HTTP 请求标头并由一个名称/值对组成。URLRequestHeader 对象在 URLRequest 类的 requestHeaders 属性中使用。
* 注意:由于浏览器兼容性原因,在 html5 中并未实现
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/net/URLRequestHeader.ts
* @language zh_CN
*/
class URLRequestHeader {
/**
* HTTP request header name, such as Content-Type
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* HTTP 请求标头名称,如 Content-Type
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
name: string;
/**
* The values associated with the name property (such as text/plain).
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 与 name 属性相关联的值,如 text/plain
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
value: string;
/**
* Create an egret.URLRequestHeader object
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 创建一个 egret.URLRequestHeader 对象
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
constructor(name: string, value: string);
}
}
declare namespace egret {
/**
* The URLRequestMethod class provides values that specify whether the
* URLRequest object should use the POST method or the GET method when sending data to a server.
* @see http://edn.egret.com/cn/docs/page/599 POST与GET
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/net/URLRequestMethod.ts
* @language en_US
*/
/**
* URLRequestMethod 类提供了一些值,这些值可指定在将数据发送到服务器时,
* URLRequest 对象应使用 POST 方法还是 GET 方法。
* @see http://edn.egret.com/cn/docs/page/599 POST与GET
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/net/URLRequestMethod.ts
* @language zh_CN
*/
class URLRequestMethod {
/**
* Specify that the URLRequest object is a GET.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 表示 URLRequest 对象是一个 GET。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static GET: string;
/**
* Specify that the URLRequest object is a POST.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 表示 URLRequest 对象是一个 POST。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static POST: string;
}
}
declare namespace egret {
/**
* The URLVariables class allows you to transfer variables between an application and a server.
* Use URLVariables objects with methods of the URLLoader class and the data property of the URLRequest class.
* @see http://edn.egret.com/cn/docs/page/598 Send the request with parameters
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/net/URLVariables.ts
* @language en_US
*/
/**
* 使用 URLVariables 类可以在应用程序和服务器之间传输变量。
* 将 URLVariables 对象与 URLLoader 类的方法、URLRequest 类的 data 属性一起使用。
* @see http://edn.egret.com/cn/docs/page/598 发送带参数的请求
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/net/URLVariables.ts
* @language zh_CN
*/
class URLVariables extends HashObject {
/**
* Create an egret.URLVariable object
* @param source {String} A URL-encoded string containing name/value pairs.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 创建一个 egret.URLVariables 对象
* @param source {String} 包含名称/值对的 URL 编码的字符串。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
constructor(source?: string);
/**
* Key-value pair data object saved in this URLVariables object
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 此 URLVariables 储存的键值对数据对象。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
variables: Object;
/**
* Convert the variable string into the property of this URLVariables.variables object.
* @param source {string}
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 将变量字符串转换为此 URLVariables.variables 对象的属性。
* @param source {string}
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
decode(source: string): void;
/**
* Return a string containing all enumerable variables using the MIME content encoding format : application/x-www-form-urlencoded.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 以 MIME 内容编码格式 application/x-www-form-urlencoded 返回包含所有可枚举变量的字符串。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
toString(): string;
/**
* @private
*
* @param key
* @param value
*/
private encodeValue(key, value);
/**
* @private
*
* @param key
* @param value
*/
private encodeArray(key, value);
}
}
declare namespace egret {
/**
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/player/Ticker.ts
* @language en_US
*/
/**
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/player/Ticker.ts
* @language zh_CN
*/
class Ticker extends EventDispatcher {
/**
* @deprecated
* @version Egret 2.4
* @platform Web,Native
*/
constructor();
private _timeScale;
private _paused;
private _callIndex;
private _callList;
private _lastTime;
private update(timeStamp);
private callBackList;
/**
* 注册帧回调事件,同一函数的重复监听会被忽略。推荐使用 egret.startTick 替代此方法。
* @method egret.Ticker#register
* @param listener {Function} 帧回调函数,参数返回上一帧和这帧的间隔时间。示例:onEnterFrame(frameTime:number):void
* @param thisObject {any} 帧回调函数的this对象
* @param priority {number} 事件优先级,开发者请勿传递 Number.NEGATIVE_INFINITY 和 Number.POSITIVE_INFINITY
* @version Egret 2.4
* @platform Web,Native
* @deprecated
*/
register(listener: Function, thisObject: any, priority?: number): void;
/**
* 取消侦听enterFrame事件。推荐使用 egret.stopTick 替代此方法。
* @method egret.Ticker#unregister
* @param listener {Function} 事件侦听函数
* @param thisObject {any} 侦听函数的this对象
* @version Egret 2.4
* @platform Web,Native
* @deprecated
*/
unregister(listener: Function, thisObject: any): void;
/**
* @deprecated
* @param timeScale {number}
* @private
*/
setTimeScale(timeScale: number): void;
/**
* @deprecated
* @method egret.Ticker#getTimeScale
* @private
*/
getTimeScale(): number;
/**
* 暂停
* @deprecated
* @method egret.Ticker#pause
*/
pause(): void;
/**
* 继续
* @deprecated
* @method egret.Ticker#resume
*/
resume(): void;
/**
* @private
*/
private static instance;
/**
* @method egret.Ticker.getInstance
* @returns {Ticker}
* @version Egret 2.4
* @platform Web,Native
* @deprecated
*/
static getInstance(): egret.Ticker;
}
}
declare namespace egret {
/**
* @class egret.MainContext
* @classdesc
* MainContext是游戏的核心跨平台接口,组合了多个功能Context,并是游戏启动的主入口
* @extends egret.EventDispatcher
* @private
* @version Egret 2.4
* @platform Web,Native
*/
class MainContext extends EventDispatcher {
/**
* @version Egret 2.4
* @platform Web,Native
*/
constructor();
/**
* 渲染Context
* @member egret.MainContext#rendererContext
* @version Egret 2.4
* @platform Web,Native
*/
/**
* 触摸Context
* @member egret.MainContext#touchContext
* @version Egret 2.4
* @platform Web,Native
*/
/**
* 设备divice
* @member egret.MainContext#deviceContext
* @version Egret 2.4
* @platform Web,Native
*/
/**
* 舞台
* @member egret.MainContext#stage
* @version Egret 2.4
* @platform Web,Native
*/
readonly stage: Stage;
/**
* @version Egret 2.4
* @platform Web,Native
*/
static deviceType: string;
/**
* @version Egret 2.4
* @platform Web,Native
*/
static DEVICE_PC: string;
/**
* @version Egret 2.4
* @platform Web,Native
*/
static DEVICE_MOBILE: string;
/**
* 游戏启动,开启主循环,参考Flash的滑动跑道模型
* @method egret.MainContext#run
* @version Egret 2.4
* @platform Web,Native
*/
/**
* @private
*/
private static _instance;
/**
* @method egret.Ticker.getInstance
* @returns {Ticker}
* @version Egret 2.4
* @platform Web,Native
*/
static readonly instance: egret.MainContext;
}
}
declare namespace egret {
/**
* Tool class for object cache repeat use, which can be used to construct an object pool. Objects are automatically recycled after a certain duration.
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/utils/Recycler.ts
* @private
* @language en_US
*/
/**
* 对象缓存复用工具类,可用于构建对象池,一段时间后会自动回收对象。
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/utils/Recycler.ts
* @private
* @language zh_CN
*/
class Recycler extends HashObject {
/**
* Create an egret.Recycler object
* @param autoDisposeTime {number} Number of frames when objects are destroyed automatically. Default value: 300
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 创建一个 egret.Recycler 对象
* @param autoDisposeTime {number} 多少帧后自动销毁对象,默认值300
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
constructor(autoDisposeTime?: number);
/**
* @private
*/
static _callBackList: any[];
static $init(): void;
static onUpdate(timeStamp: number): boolean;
/**
* @private
* 多少帧后自动销毁对象。
*/
private autoDisposeTime;
/**
* @private
*/
private frameCount;
/**
* @private
*
*/
$checkFrame(): void;
/**
* @private
*/
private objectPool;
/**
* @private
*/
private _length;
/**
* Number of cached objects"
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 缓存的对象数量
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
readonly length: number;
/**
* Cache an object for repeat use
* @param object {any} The object to be cached
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 缓存一个对象以复用
* @param object {any} 需要缓存的对象
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
push(object: any): void;
/**
* Obtain a cached object
* @returns {any} The obtained cached object
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 获取一个缓存的对象
* @returns {any} 获得的缓存对象
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
pop(): any;
/**
* Immediately clear all cached objects.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 立即清空所有缓存的对象。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
dispose(): void;
}
}
declare namespace egret {
/**
* To specify a delay (in milliseconds) calls the function specified interval loop.
* @param listener {Function} Listener function
* @param thisObject {any} this object
* @param delay {number} Delay time, in milliseconds
* @param ...args {any} Parameter list
* @returns {number} Return index which can be used for clearInterval
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/utils/setInterval.ts
* @language en_US
*/
/**
* 以指定的延迟(以毫秒为单位)间隔循环调用指定的函数。
* @param listener {Function} 侦听函数
* @param thisObject {any} this对象
* @param delay {number} 延迟时间,以毫秒为单位
* @param ...args {any} 参数列表
* @returns {number} 返回索引,可以用于 clearInterval
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/utils/setInterval.ts
* @language zh_CN
*/
function setInterval<Z>(listener: (this: Z, ...arg) => void, thisObject: Z, delay: number, ...args: any[]): number;
/**
* Clear function to run after a specified delay.
* @param key {number} Index that egret.setInterval returns
* @version Egret 2.4
* @platform Web,Native
* @includeExample egret/utils/setInterval.ts
* @language en_US
*/
/**
* 清除指定延迟后运行的函数。
* @param key {number} egret.setInterval所返回的索引
* @version Egret 2.4
* @platform Web,Native
* @includeExample egret/utils/setInterval.ts
* @language zh_CN
*/
function clearInterval(key: number): void;
}
declare namespace egret {
/**
* Run the designated function in specified delay (in milliseconds).
* @param listener {Function} Listener function
* @param thisObject {any} this object
* @param delay {number} Delay time, in milliseconds
* @param ...args {any} Parameter list
* @returns {number} Return index which can be used for clearTimeout
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/utils/setTimeout.ts
* @language en_US
*/
/**
* 在指定的延迟(以毫秒为单位)后运行指定的函数。
* @param listener {Function} 侦听函数
* @param thisObject {any} this对象
* @param delay {number} 延迟时间,以毫秒为单位
* @param ...args {any} 参数列表
* @returns {number} 返回索引,可以用于 clearTimeout
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/utils/setTimeout.ts
* @language zh_CN
*/
function setTimeout<Z>(listener: (this: Z, ...arg) => void, thisObject: Z, delay: number, ...args: any[]): number;
/**
* Function run after the specified delay is cleared.
* @param key {number} Index that egret.setTimeout returns
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 清除指定延迟后运行的函数。
* @param key {number} egret.setTimeout所返回的索引
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
function clearTimeout(key: number): void;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
var __reflect=this&&this.__reflect||function(t,e,r){t.__class__=e,r?r.push(e):r=[e],t.__types__=t.__types__?r.concat(t.__types__):r},__extends=this&&this.__extends||function(t,e){function r(){this.constructor=t}for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);r.prototype=e.prototype,t.prototype=new r},egret;!function(t){var e=function(){function t(){}return t.BINARY="binary",t.TEXT="text",t.VARIABLES="variables",t.TEXTURE="texture",t.SOUND="sound",t}();t.URLLoaderDataFormat=e,__reflect(e.prototype,"egret.URLLoaderDataFormat")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e,r,i){var o=t.call(this)||this;return o._name=e,o._frame=0|r,i&&(o._end=0|i),o}return __extends(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"frame",{get:function(){return this._frame},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"end",{get:function(){return this._end},enumerable:!0,configurable:!0}),e.prototype.clone=function(){return new e(this._name,this._frame,this._end)},e}(t.EventDispatcher);t.FrameLabel=e,__reflect(e.prototype,"egret.FrameLabel")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(){var t=e.call(this)||this;return t.$mcData=null,t.numFrames=1,t.frames=[],t.labels=null,t.events=[],t.frameRate=0,t.textureData=null,t.spriteSheet=null,t}return __extends(r,e),r.prototype.$init=function(t,e,r){this.textureData=e,this.spriteSheet=r,this.setMCData(t)},r.prototype.getKeyFrameData=function(t){var e=this.frames[t-1];return e.frame&&(e=this.frames[e.frame-1]),e},r.prototype.getTextureByFrame=function(t){var e=this.getKeyFrameData(t);if(e.res){var r=this.getTextureByResName(e.res);return r}return null},r.prototype.$getOffsetByFrame=function(t,e){var r=this.getKeyFrameData(t);r.res&&e.setTo(0|r.x,0|r.y)},r.prototype.getTextureByResName=function(t){if(null==this.spriteSheet)return null;var e=this.spriteSheet.getTexture(t);if(!e){var r=this.textureData[t];e=this.spriteSheet.createTexture(t,r.x,r.y,r.w,r.h)}return e},r.prototype.$isDataValid=function(){return this.frames.length>0},r.prototype.$isTextureValid=function(){return null!=this.textureData&&null!=this.spriteSheet},r.prototype.$fillMCData=function(t){this.frameRate=t.frameRate||24,this.fillFramesData(t.frames),this.fillFrameLabelsData(t.labels),this.fillFrameEventsData(t.events)},r.prototype.fillFramesData=function(t){for(var e,r=this.frames,i=t?t.length:0,o=0;i>o;o++){var n=t[o];if(r.push(n),n.duration){var s=parseInt(n.duration);if(s>1){e=r.length;for(var a=1;s>a;a++)r.push({frame:e})}}}this.numFrames=r.length},r.prototype.fillFrameLabelsData=function(e){if(e){var r=e.length;if(r>0){this.labels=[];for(var i=0;r>i;i++){var o=e[i];this.labels.push(new t.FrameLabel(o.name,o.frame,o.end))}}}},r.prototype.fillFrameEventsData=function(t){if(t){var e=t.length;if(e>0){this.events=[];for(var r=0;e>r;r++){var i=t[r];this.events[i.frame]=i.name}}}},Object.defineProperty(r.prototype,"mcData",{get:function(){return this.$mcData},set:function(t){this.setMCData(t)},enumerable:!0,configurable:!0}),r.prototype.setMCData=function(t){this.$mcData!=t&&(this.$mcData=t,t&&this.$fillMCData(t))},r}(t.HashObject);t.MovieClipData=e,__reflect(e.prototype,"egret.MovieClipData")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(t,r){var i=e.call(this)||this;return i.enableCache=!0,i.$mcDataCache={},i.$mcDataSet=t,i.setTexture(r),i}return __extends(r,e),r.prototype.clearCache=function(){this.$mcDataCache={}},r.prototype.generateMovieClipData=function(e){if(void 0===e&&(e=""),""==e&&this.$mcDataSet)for(e in this.$mcDataSet.mc)break;if(""==e)return null;var r=this.findFromCache(e,this.$mcDataCache);return r||(r=new t.MovieClipData,this.fillData(e,r,this.$mcDataCache)),r},r.prototype.findFromCache=function(t,e){return this.enableCache&&e[t]?e[t]:null},r.prototype.fillData=function(t,e,r){if(this.$mcDataSet){var i=this.$mcDataSet.mc[t];i&&(e.$init(i,this.$mcDataSet.res,this.$spriteSheet),this.enableCache&&(r[t]=e))}},Object.defineProperty(r.prototype,"mcDataSet",{get:function(){return this.$mcDataSet},set:function(t){this.$mcDataSet=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"texture",{set:function(t){this.setTexture(t)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"spriteSheet",{get:function(){return this.$spriteSheet},enumerable:!0,configurable:!0}),r.prototype.setTexture=function(e){this.$spriteSheet=e?new t.SpriteSheet(e):null},r}(t.EventDispatcher);t.MovieClipDataFactory=e,__reflect(e.prototype,"egret.MovieClipDataFactory")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(t,r,i,o){void 0===r&&(r=!1),void 0===i&&(i=!1),void 0===o&&(o=null);var n=e.call(this,t,r,i)||this;return n.frameLabel=null,n.frameLabel=o,n}return __extends(r,e),r.dispatchMovieClipEvent=function(e,i,o){void 0===o&&(o=null);var n=t.Event.create(r,i);n.frameLabel=o;var s=e.dispatchEvent(n);return t.Event.release(n),s},r.FRAME_LABEL="frame_label",r}(t.Event);t.MovieClipEvent=e,__reflect(e.prototype,"egret.MovieClipEvent")}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){t.$error(1014)}return e.get=function(t){return-1>t&&(t=-1),t>1&&(t=1),function(e){return 0==t?e:0>t?e*(e*-t+1+t):e*((2-e)*t+(1-t))}},e.getPowOut=function(t){return function(e){return 1-Math.pow(1-e,t)}},e.quintOut=e.getPowOut(5),e.quartOut=e.getPowOut(4),e}();t.ScrollEase=e,__reflect(e.prototype,"egret.ScrollEase");var r=function(e){function r(t,r,i){var o=e.call(this)||this;return o._target=null,o._useTicks=!1,o.ignoreGlobalPause=!1,o.loop=!1,o.pluginData=null,o._steps=null,o._actions=null,o.paused=!1,o.duration=0,o._prevPos=-1,o.position=null,o._prevPosition=0,o._stepPosition=0,o.passive=!1,o.initialize(t,r,i),o}return __extends(r,e),r.get=function(t,e,i,o){return void 0===e&&(e=null),void 0===i&&(i=null),void 0===o&&(o=!1),o&&r.removeTweens(t),new r(t,e,i)},r.removeTweens=function(t){if(t.tween_count){for(var e=r._tweens,i=e.length-1;i>=0;i--)e[i]._target==t&&(e[i].paused=!0,e.splice(i,1));t.tween_count=0}},r.tick=function(t,e){void 0===e&&(e=!1);var i=t-r._lastTime;r._lastTime=t;for(var o=r._tweens.concat(),n=o.length-1;n>=0;n--){var s=o[n];e&&!s.ignoreGlobalPause||s.paused||s.tick(s._useTicks?1:i)}return!1},r._register=function(e,i){var o=e._target,n=r._tweens;if(i)o&&(o.tween_count=o.tween_count>0?o.tween_count+1:1),n.push(e),r._inited||(r._lastTime=t.getTimer(),t.ticker.$startTick(r.tick,null),r._inited=!0);else{o&&o.tween_count--;for(var s=n.length;s--;)if(n[s]==e)return void n.splice(s,1)}},r.prototype.initialize=function(t,e,i){this._target=t,e&&(this._useTicks=e.useTicks,this.ignoreGlobalPause=e.ignoreGlobalPause,this.loop=e.loop,e.onChange&&this.addEventListener("change",e.onChange,e.onChangeObj),e.override&&r.removeTweens(t)),this.pluginData=i||{},this._curQueueProps={},this._initQueueProps={},this._steps=[],this._actions=[],e&&e.paused?this.paused=!0:r._register(this,!0),e&&null!=e.position&&this.setPosition(e.position)},r.prototype.setPosition=function(t,e){void 0===e&&(e=1),0>t&&(t=0);var r=t,i=!1;if(r>=this.duration&&(this.loop?r%=this.duration:(r=this.duration,i=!0)),r==this._prevPos)return i;var o=this._prevPos;if(this.position=this._prevPos=r,this._prevPosition=t,this._target)if(i)this._updateTargetProps(null,1);else if(this._steps.length>0){var n=void 0,s=this._steps.length;for(n=0;s>n&&!(this._steps[n].t>r);n++);var a=this._steps[n-1];this._updateTargetProps(a,(this._stepPosition=r-a.t)/a.d)}return i&&this.setPaused(!0),0!=e&&this._actions.length>0&&(this._useTicks?this._runActions(r,r):1==e&&o>r?(o!=this.duration&&this._runActions(o,this.duration),this._runActions(0,r,!0)):this._runActions(o,r)),this.dispatchEventWith("change"),i},r.prototype._runActions=function(t,e,r){void 0===r&&(r=!1);var i=t,o=e,n=-1,s=this._actions.length,a=1;for(t>e&&(i=e,o=t,n=s,s=a=-1);(n+=a)!=s;){var c=this._actions[n],l=c.t;(l==o||l>i&&o>l||r&&l==t)&&c.f.apply(c.o,c.p)}},r.prototype._updateTargetProps=function(t,e){var i,o,n,s,a,c;if(t||1!=e){if(this.passive=!!t.v,this.passive)return;t.e&&(e=t.e(e,0,1,1)),i=t.p0,o=t.p1}else this.passive=!1,i=o=this._curQueueProps;for(var l in this._initQueueProps){null==(s=i[l])&&(i[l]=s=this._initQueueProps[l]),null==(a=o[l])&&(o[l]=a=s),n=s==a||0==e||1==e||"number"!=typeof s?1==e?a:s:s+(a-s)*e;var h=!1;if(c=r._plugins[l])for(var u=0,p=c.length;p>u;u++){var _=c[u].tween(this,l,n,i,o,e,!!t&&i==o,!t);_==r.IGNORE?h=!0:n=_}h||(this._target[l]=n)}},r.prototype.setPaused=function(t){return this.paused=t,r._register(this,!t),this},r.prototype._cloneProps=function(t){var e={};for(var r in t)e[r]=t[r];return e},r.prototype._addStep=function(t){return t.d>0&&(this._steps.push(t),t.t=this.duration,this.duration+=t.d),this},r.prototype._appendQueueProps=function(t){var e,i,o,n,s;for(var a in t)if(void 0===this._initQueueProps[a]){if(i=this._target[a],e=r._plugins[a])for(o=0,n=e.length;n>o;o++)i=e[o].init(this,a,i);this._initQueueProps[a]=this._curQueueProps[a]=void 0===i?null:i}else i=this._curQueueProps[a];for(var a in t){if(i=this._curQueueProps[a],e=r._plugins[a])for(s=s||{},o=0,n=e.length;n>o;o++)e[o].step&&e[o].step(this,a,i,t[a],s);this._curQueueProps[a]=t[a]}return s&&this._appendQueueProps(s),this._curQueueProps},r.prototype._addAction=function(t){return t.t=this.duration,this._actions.push(t),this},r.prototype.to=function(t,e,r){return void 0===r&&(r=void 0),(isNaN(e)||0>e)&&(e=0),this._addStep({d:e||0,p0:this._cloneProps(this._curQueueProps),e:r,p1:this._cloneProps(this._appendQueueProps(t))})},r.prototype.call=function(t,e,r){return void 0===e&&(e=void 0),void 0===r&&(r=void 0),this._addAction({f:t,p:r?r:[],o:e?e:this._target})},r.prototype.tick=function(t){this.paused||this.setPosition(this._prevPosition+t)},r._tweens=[],r.IGNORE={},r._plugins={},r._inited=!1,r._lastTime=0,r}(t.EventDispatcher);t.ScrollTween=r,__reflect(r.prototype,"egret.ScrollTween")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(r){void 0===r&&(r=null);var i=e.call(this)||this;return i.scrollBeginThreshold=10,i.scrollSpeed=1,i._content=null,i.delayTouchBeginEvent=null,i.touchBeginTimer=null,i.touchEnabled=!0,i._ScrV_Props_=new t.ScrollViewProperties,r&&i.setContent(r),i}return __extends(r,e),Object.defineProperty(r.prototype,"bounces",{get:function(){return this._ScrV_Props_._bounces},set:function(t){this._ScrV_Props_._bounces=!!t},enumerable:!0,configurable:!0}),r.prototype.setContent=function(t){this._content!==t&&(this.removeContent(),t&&(this._content=t,e.prototype.addChild.call(this,t),this._addEvents()))},r.prototype.removeContent=function(){this._content&&(this._removeEvents(),e.prototype.removeChildAt.call(this,0)),this._content=null},Object.defineProperty(r.prototype,"verticalScrollPolicy",{get:function(){return this._ScrV_Props_._verticalScrollPolicy},set:function(t){t!=this._ScrV_Props_._verticalScrollPolicy&&(this._ScrV_Props_._verticalScrollPolicy=t)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"horizontalScrollPolicy",{get:function(){return this._ScrV_Props_._horizontalScrollPolicy},set:function(t){t!=this._ScrV_Props_._horizontalScrollPolicy&&(this._ScrV_Props_._horizontalScrollPolicy=t)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scrollLeft",{get:function(){return this._ScrV_Props_._scrollLeft},set:function(t){t!=this._ScrV_Props_._scrollLeft&&(this._ScrV_Props_._scrollLeft=t,this._validatePosition(!1,!0),this._updateContentPosition())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scrollTop",{get:function(){return this._ScrV_Props_._scrollTop},set:function(t){t!=this._ScrV_Props_._scrollTop&&(this._ScrV_Props_._scrollTop=t,this._validatePosition(!0,!1),this._updateContentPosition())},enumerable:!0,configurable:!0}),r.prototype.setScrollPosition=function(t,e,r){if(void 0===r&&(r=!1),(!r||0!=t||0!=e)&&(r||this._ScrV_Props_._scrollTop!=t||this._ScrV_Props_._scrollLeft!=e)){var i=this._ScrV_Props_._scrollTop,o=this._ScrV_Props_._scrollLeft;if(r){var n=this.getMaxScrollLeft(),s=this.getMaxScrollTop();(0>=i||i>=s)&&(t/=2),(0>=o||o>=n)&&(e/=2);var a=i+t,c=o+e,l=this._ScrV_Props_._bounces;l||((0>=a||a>=s)&&(a=Math.max(0,Math.min(a,s))),(0>=c||c>=n)&&(c=Math.max(0,Math.min(c,n)))),this._ScrV_Props_._scrollTop=a,this._ScrV_Props_._scrollLeft=c}else this._ScrV_Props_._scrollTop=t,this._ScrV_Props_._scrollLeft=e;this._validatePosition(!0,!0),this._updateContentPosition()}},r.prototype._validatePosition=function(t,e){if(void 0===t&&(t=!1),void 0===e&&(e=!1),t){var r=this.height,i=this._getContentHeight();this._ScrV_Props_._scrollTop=Math.max(this._ScrV_Props_._scrollTop,(0-r)/2),this._ScrV_Props_._scrollTop=Math.min(this._ScrV_Props_._scrollTop,i>r?i-r/2:r/2)}if(e){var o=this.width,n=this._getContentWidth();this._ScrV_Props_._scrollLeft=Math.max(this._ScrV_Props_._scrollLeft,(0-o)/2),this._ScrV_Props_._scrollLeft=Math.min(this._ScrV_Props_._scrollLeft,n>o?n-o/2:o/2)}},r.prototype.$setWidth=function(t){this.$explicitWidth!=t&&(e.prototype.$setWidth.call(this,t),this._updateContentPosition())},r.prototype.$setHeight=function(t){this.$explicitHeight!=t&&(e.prototype.$setHeight.call(this,t),this._updateContentPosition())},r.prototype._updateContentPosition=function(){var e=this.height,r=this.width;this.scrollRect=new t.Rectangle(Math.round(this._ScrV_Props_._scrollLeft),Math.round(this._ScrV_Props_._scrollTop),r,e),this.dispatchEvent(new t.Event(t.Event.CHANGE))},r.prototype._checkScrollPolicy=function(){var t=this._ScrV_Props_._horizontalScrollPolicy,e=this.__checkScrollPolicy(t,this._getContentWidth(),this.width);this._ScrV_Props_._hCanScroll=e;var r=this._ScrV_Props_._verticalScrollPolicy,i=this.__checkScrollPolicy(r,this._getContentHeight(),this.height);return this._ScrV_Props_._vCanScroll=i,e||i},r.prototype.__checkScrollPolicy=function(t,e,r){return"on"==t?!0:"off"==t?!1:e>r},r.prototype._addEvents=function(){this.addEventListener(t.TouchEvent.TOUCH_BEGIN,this._onTouchBegin,this),this.addEventListener(t.TouchEvent.TOUCH_BEGIN,this._onTouchBeginCapture,this,!0),this.addEventListener(t.TouchEvent.TOUCH_END,this._onTouchEndCapture,this,!0)},r.prototype._removeEvents=function(){this.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this._onTouchBegin,this),this.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this._onTouchBeginCapture,this,!0),this.removeEventListener(t.TouchEvent.TOUCH_END,this._onTouchEndCapture,this,!0)},r.prototype._onTouchBegin=function(e){if(!e.$isDefaultPrevented){var r=this._checkScrollPolicy();r&&(this._ScrV_Props_._touchStartPosition.x=e.stageX,this._ScrV_Props_._touchStartPosition.y=e.stageY,(this._ScrV_Props_._isHTweenPlaying||this._ScrV_Props_._isVTweenPlaying)&&this._onScrollFinished(),this._tempStage=this.stage,this._tempStage.addEventListener(t.TouchEvent.TOUCH_MOVE,this._onTouchMove,this),this._tempStage.addEventListener(t.TouchEvent.TOUCH_END,this._onTouchEnd,this),this._tempStage.addEventListener(t.TouchEvent.LEAVE_STAGE,this._onTouchEnd,this),this.addEventListener(t.Event.ENTER_FRAME,this._onEnterFrame,this),this._logTouchEvent(e),e.preventDefault())}},r.prototype._onTouchBeginCapture=function(e){var r=this._checkScrollPolicy();if(r){for(var i=e.target;i!=this;){if("_checkScrollPolicy"in i&&(r=i._checkScrollPolicy()))return;i=i.parent}e.stopPropagation();var o=this.cloneTouchEvent(e);this.delayTouchBeginEvent=o,this.touchBeginTimer||(this.touchBeginTimer=new t.Timer(100,1),this.touchBeginTimer.addEventListener(t.TimerEvent.TIMER_COMPLETE,this._onTouchBeginTimer,this)),this.touchBeginTimer.start(),this._onTouchBegin(e)}},r.prototype._onTouchEndCapture=function(e){var r=this;if(this.delayTouchBeginEvent){this._onTouchBeginTimer(),e.stopPropagation();var i=this.cloneTouchEvent(e);t.callLater(function(){r.stage&&r.dispatchPropagationEvent(i)},this)}},r.prototype._onTouchBeginTimer=function(){this.touchBeginTimer.stop();var t=this.delayTouchBeginEvent;this.delayTouchBeginEvent=null,this.stage&&this.dispatchPropagationEvent(t)},r.prototype.dispatchPropagationEvent=function(e){for(var r=e.$target,i=this.$getPropagationList(r),o=i.length,n=.5*i.length,s=-1,a=0;o>a;a++)if(i[a]===this._content){s=a;break}i.splice(0,s+1),n-=s+1,this.$dispatchPropagationEvent(e,i,n),t.Event.release(e)},r.prototype._onTouchMove=function(t){if(this._ScrV_Props_._lastTouchPosition.x!=t.stageX||this._ScrV_Props_._lastTouchPosition.y!=t.stageY){if(!this._ScrV_Props_._scrollStarted){var e=t.stageX-this._ScrV_Props_._touchStartPosition.x,r=t.stageY-this._ScrV_Props_._touchStartPosition.y,i=Math.sqrt(e*e+r*r);if(i<this.scrollBeginThreshold)return void this._logTouchEvent(t)}this._ScrV_Props_._scrollStarted=!0,this.delayTouchBeginEvent&&(this.delayTouchBeginEvent=null,this.touchBeginTimer.stop()),this.touchChildren=!1;var o=this._getPointChange(t);this.setScrollPosition(o.y,o.x,!0),this._calcVelocitys(t),this._logTouchEvent(t)}},r.prototype._onTouchEnd=function(e){this.touchChildren=!0,this._ScrV_Props_._scrollStarted=!1,this._tempStage.removeEventListener(t.TouchEvent.TOUCH_MOVE,this._onTouchMove,this),this._tempStage.removeEventListener(t.TouchEvent.TOUCH_END,this._onTouchEnd,this),this._tempStage.removeEventListener(t.TouchEvent.LEAVE_STAGE,this._onTouchEnd,this),this.removeEventListener(t.Event.ENTER_FRAME,this._onEnterFrame,this),this._moveAfterTouchEnd()},r.prototype._onEnterFrame=function(e){var r=t.getTimer();r-this._ScrV_Props_._lastTouchTime>100&&r-this._ScrV_Props_._lastTouchTime<300&&this._calcVelocitys(this._ScrV_Props_._lastTouchEvent)},r.prototype._logTouchEvent=function(e){this._ScrV_Props_._lastTouchPosition.x=e.stageX,this._ScrV_Props_._lastTouchPosition.y=e.stageY,this._ScrV_Props_._lastTouchEvent=this.cloneTouchEvent(e),this._ScrV_Props_._lastTouchTime=t.getTimer()},r.prototype._getPointChange=function(t){return{x:this._ScrV_Props_._hCanScroll===!1?0:this._ScrV_Props_._lastTouchPosition.x-t.stageX,y:this._ScrV_Props_._vCanScroll===!1?0:this._ScrV_Props_._lastTouchPosition.y-t.stageY}},r.prototype._calcVelocitys=function(e){var r=t.getTimer();if(0==this._ScrV_Props_._lastTouchTime)return void(this._ScrV_Props_._lastTouchTime=r);var i=this._getPointChange(e),o=r-this._ScrV_Props_._lastTouchTime;i.x/=o,i.y/=o,this._ScrV_Props_._velocitys.push(i),this._ScrV_Props_._velocitys.length>5&&this._ScrV_Props_._velocitys.shift(),this._ScrV_Props_._lastTouchPosition.x=e.stageX,this._ScrV_Props_._lastTouchPosition.y=e.stageY},r.prototype._getContentWidth=function(){return this._content.$explicitWidth||this._content.width},r.prototype._getContentHeight=function(){return this._content.$explicitHeight||this._content.height},r.prototype.getMaxScrollLeft=function(){var t=this._getContentWidth()-this.width;return Math.max(0,t)},r.prototype.getMaxScrollTop=function(){var t=this._getContentHeight()-this.height;return Math.max(0,t)},r.prototype._moveAfterTouchEnd=function(){if(0!=this._ScrV_Props_._velocitys.length){for(var t={x:0,y:0},e=0,i=0;i<this._ScrV_Props_._velocitys.length;i++){var o=this._ScrV_Props_._velocitys[i],n=r.weight[i];t.x+=o.x*n,t.y+=o.y*n,e+=n}this._ScrV_Props_._velocitys.length=0,this.scrollSpeed<=0&&(this.scrollSpeed=1);var s=t.x/e*this.scrollSpeed,a=t.y/e*this.scrollSpeed,c=Math.abs(s),l=Math.abs(a),h=this.getMaxScrollLeft(),u=this.getMaxScrollTop(),p=c>.02?this.getAnimationDatas(s,this._ScrV_Props_._scrollLeft,h):{position:this._ScrV_Props_._scrollLeft,duration:1},_=l>.02?this.getAnimationDatas(a,this._ScrV_Props_._scrollTop,u):{position:this._ScrV_Props_._scrollTop,duration:1};this.setScrollLeft(p.position,p.duration),this.setScrollTop(_.position,_.duration)}},r.prototype.onTweenFinished=function(t){t==this._ScrV_Props_._vScrollTween&&(this._ScrV_Props_._isVTweenPlaying=!1),t==this._ScrV_Props_._hScrollTween&&(this._ScrV_Props_._isHTweenPlaying=!1),0==this._ScrV_Props_._isHTweenPlaying&&0==this._ScrV_Props_._isVTweenPlaying&&this._onScrollFinished()},r.prototype._onScrollStarted=function(){},r.prototype._onScrollFinished=function(){t.ScrollTween.removeTweens(this),this._ScrV_Props_._hScrollTween=null,this._ScrV_Props_._vScrollTween=null,this._ScrV_Props_._isHTweenPlaying=!1,this._ScrV_Props_._isVTweenPlaying=!1,this.dispatchEvent(new t.Event(t.Event.COMPLETE))},r.prototype.setScrollTop=function(e,r){void 0===r&&(r=0);var i=Math.min(this.getMaxScrollTop(),Math.max(e,0));if(0==r)return void(this.scrollTop=i);0==this._ScrV_Props_._bounces&&(e=i);var o=t.ScrollTween.get(this).to({scrollTop:e},r,t.ScrollEase.quartOut);i!=e&&o.to({scrollTop:i},300,t.ScrollEase.quintOut),this._ScrV_Props_._isVTweenPlaying=!0,this._ScrV_Props_._vScrollTween=o,o.call(this.onTweenFinished,this,[o]),this._ScrV_Props_._isHTweenPlaying||this._onScrollStarted()},r.prototype.setScrollLeft=function(e,r){void 0===r&&(r=0);var i=Math.min(this.getMaxScrollLeft(),Math.max(e,0));if(0==r)return void(this.scrollLeft=i);0==this._ScrV_Props_._bounces&&(e=i);var o=t.ScrollTween.get(this).to({scrollLeft:e},r,t.ScrollEase.quartOut);i!=e&&o.to({scrollLeft:i},300,t.ScrollEase.quintOut),this._ScrV_Props_._isHTweenPlaying=!0,this._ScrV_Props_._hScrollTween=o,o.call(this.onTweenFinished,this,[o]),this._ScrV_Props_._isVTweenPlaying||this._onScrollStarted()},r.prototype.getAnimationDatas=function(t,e,r){var i=Math.abs(t),o=.95,n=0,s=.998,a=.02,c=e+500*t;if(0>c||c>r)for(c=e;Math.abs(t)!=1/0&&Math.abs(t)>a;)c+=t,t*=0>c||c>r?s*o:s,n++;else n=500*-Math.log(a/i);var l={position:Math.min(r+50,Math.max(c,-50)),duration:n};return l},r.prototype.cloneTouchEvent=function(e){var r=new t.TouchEvent(e.type,e.bubbles,e.cancelable);return r.touchPointID=e.touchPointID,r.$stageX=e.stageX,r.$stageY=e.stageY,r.touchDown=e.touchDown,r.$isDefaultPrevented=!1,r.$target=e.target,r},r.prototype.throwNotSupportedError=function(){t.$error(1023)},r.prototype.addChild=function(t){return this.throwNotSupportedError(),null},r.prototype.addChildAt=function(t,e){return this.throwNotSupportedError(),null},r.prototype.removeChild=function(t){return this.throwNotSupportedError(),null},r.prototype.removeChildAt=function(t){return this.throwNotSupportedError(),null},r.prototype.setChildIndex=function(t,e){this.throwNotSupportedError()},r.prototype.swapChildren=function(t,e){this.throwNotSupportedError()},r.prototype.swapChildrenAt=function(t,e){this.throwNotSupportedError()},r.weight=[1,1.33,1.66,2,2.33],r}(t.DisplayObjectContainer);t.ScrollView=e,__reflect(e.prototype,"egret.ScrollView")}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){this._verticalScrollPolicy="auto",this._horizontalScrollPolicy="auto",this._scrollLeft=0,this._scrollTop=0,this._hCanScroll=!1,this._vCanScroll=!1,this._lastTouchPosition=new t.Point(0,0),this._touchStartPosition=new t.Point(0,0),this._scrollStarted=!1,this._lastTouchTime=0,this._lastTouchEvent=null,this._velocitys=[],this._isHTweenPlaying=!1,this._isVTweenPlaying=!1,this._hScrollTween=null,this._vScrollTween=null,this._bounces=!0}return e}();t.ScrollViewProperties=e,__reflect(e.prototype,"egret.ScrollViewProperties")}(egret||(egret={}));var egret;!function(t){function e(e){var r=e.url;return-1==r.indexOf("?")&&e.method==t.URLRequestMethod.GET&&e.data&&e.data instanceof t.URLVariables&&(r=r+"?"+e.data.toString()),r}var r=function(r){function i(e){void 0===e&&(e=null);var i=r.call(this)||this;return i.dataFormat=t.URLLoaderDataFormat.TEXT,i.data=null,i._request=null,i._status=-1,e&&i.load(e),i}return __extends(i,r),i.prototype.load=function(r){this._request=r,this.data=null;var i=this;if(i.dataFormat==t.URLLoaderDataFormat.TEXTURE)return void this.loadTexture(i);if(i.dataFormat==t.URLLoaderDataFormat.SOUND)return void this.loadSound(i);var o=e(r),n=new t.HttpRequest;n.open(o,r.method==t.URLRequestMethod.POST?t.HttpMethod.POST:t.HttpMethod.GET);var s;if(r.method!=t.URLRequestMethod.GET&&r.data)if(r.data instanceof t.URLVariables){n.setRequestHeader("Content-Type","application/x-www-form-urlencoded");var a=r.data;s=a.toString()}else n.setRequestHeader("Content-Type","multipart/form-data"),s=r.data;else;for(var c=r.requestHeaders.length,l=0;c>l;l++){var h=r.requestHeaders[l];n.setRequestHeader(h.name,h.value)}n.addEventListener(t.Event.COMPLETE,function(){i.data=n.response,t.Event.dispatchEvent(i,t.Event.COMPLETE)},this),n.addEventListener(t.IOErrorEvent.IO_ERROR,function(){t.IOErrorEvent.dispatchIOErrorEvent(i)},this),n.responseType=i.dataFormat==t.URLLoaderDataFormat.BINARY?t.HttpResponseType.ARRAY_BUFFER:t.HttpResponseType.TEXT,n.send(s)},i.prototype.getResponseType=function(e){switch(e){case t.URLLoaderDataFormat.TEXT:case t.URLLoaderDataFormat.VARIABLES:return t.URLLoaderDataFormat.TEXT;case t.URLLoaderDataFormat.BINARY:return"arraybuffer";default:return e}},i.prototype.loadSound=function(e){function r(t){e.dispatchEvent(t)}function i(t){n(),e.dispatchEvent(t)}function o(r){n(),e.data=c,window.setTimeout(function(){e.dispatchEventWith(t.Event.COMPLETE)},0)}function n(){c.removeEventListener(t.Event.COMPLETE,o,s),c.removeEventListener(t.IOErrorEvent.IO_ERROR,i,s),c.removeEventListener(t.ProgressEvent.PROGRESS,r,s)}var s=this,a=e._request.url,c=new t.Sound;c.addEventListener(t.Event.COMPLETE,o,s),c.addEventListener(t.IOErrorEvent.IO_ERROR,i,s),c.addEventListener(t.ProgressEvent.PROGRESS,r,s),c.load(a)},i.prototype.loadTexture=function(e){function r(t){e.dispatchEvent(t)}function i(t){n(),e.dispatchEvent(t)}function o(r){n();var i=c.data;i.source.setAttribute("bitmapSrc",a);var o=new t.Texture;o._setBitmapData(i),e.data=o,window.setTimeout(function(){e.dispatchEventWith(t.Event.COMPLETE)},s)}function n(){c.removeEventListener(t.Event.COMPLETE,o,s),c.removeEventListener(t.IOErrorEvent.IO_ERROR,i,s),c.removeEventListener(t.ProgressEvent.PROGRESS,r,s)}var s=this,a=e._request.url,c=new t.ImageLoader;c.addEventListener(t.Event.COMPLETE,o,s),c.addEventListener(t.IOErrorEvent.IO_ERROR,i,s),c.addEventListener(t.ProgressEvent.PROGRESS,r,s),c.load(a)},i.prototype.__recycle=function(){this._request=null,this.data=null},i}(t.EventDispatcher);t.URLLoader=r,__reflect(r.prototype,"egret.URLLoader")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(r){var i=e.call(this)||this;return i.$texture=null,i.offsetPoint=t.Point.create(0,0),i.$movieClipData=null,i.frames=null,i.$totalFrames=0,i.frameLabels=null,i.$frameLabelStart=0,i.$frameLabelEnd=0,i.frameEvents=null,i.frameIntervalTime=0,i.$eventPool=null,i.$isPlaying=!1,i.isStopped=!0,i.playTimes=0,i.$currentFrameNum=0,i.$nextFrameNum=1,i.displayedKeyFrameNum=0,i.passedTime=0,i.$frameRate=0/0,i.lastTime=0,i.$smoothing=t.Bitmap.defaultSmoothing,i.setMovieClipData(r),t.nativeRender||(i.$renderNode=new t.sys.NormalBitmapNode),i}return __extends(r,e),r.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(11)},Object.defineProperty(r.prototype,"smoothing",{get:function(){return this.$smoothing},set:function(t){t!=this.$smoothing&&(this.$smoothing=t)},enumerable:!0,configurable:!0}),r.prototype.$init=function(){this.$reset();var t=this.$movieClipData;t&&t.$isDataValid()&&(this.frames=t.frames,this.$totalFrames=t.numFrames,this.frameLabels=t.labels,this.frameEvents=t.events,this.$frameRate=t.frameRate,this.frameIntervalTime=1e3/this.$frameRate,this._initFrame())},r.prototype.$reset=function(){this.frames=null,this.playTimes=0,this.$isPlaying=!1,this.setIsStopped(!0),this.$currentFrameNum=0,this.$nextFrameNum=1,this.displayedKeyFrameNum=0,this.passedTime=0,this.$eventPool=[]},r.prototype._initFrame=function(){this.$movieClipData.$isTextureValid()&&(this.advanceFrame(),this.constructFrame())},r.prototype.$updateRenderNode=function(){var e=this.$texture;if(e){var r=Math.round(this.offsetPoint.x),i=Math.round(this.offsetPoint.y),o=e.$bitmapWidth,n=e.$bitmapHeight,s=e.$getTextureWidth(),a=e.$getTextureHeight(),c=Math.round(e.$getScaleBitmapWidth()),l=Math.round(e.$getScaleBitmapHeight()),h=e.$sourceWidth,u=e.$sourceHeight;t.sys.BitmapNode.$updateTextureData(this.$renderNode,e.$bitmapData,e.$bitmapX,e.$bitmapY,o,n,r,i,s,a,c,l,h,u,t.BitmapFillMode.SCALE,this.$smoothing)}},r.prototype.$measureContentBounds=function(t){var e=this.$texture;if(e){var r=this.offsetPoint.x,i=this.offsetPoint.y,o=e.$getTextureWidth(),n=e.$getTextureHeight();t.setTo(r,i,o,n)}else t.setEmpty()},r.prototype.$onAddToStage=function(t,r){e.prototype.$onAddToStage.call(this,t,r),this.$isPlaying&&this.$totalFrames>1&&this.setIsStopped(!1)},r.prototype.$onRemoveFromStage=function(){e.prototype.$onRemoveFromStage.call(this),this.setIsStopped(!0)},r.prototype.getFrameLabelByName=function(t,e){void 0===e&&(e=!1),e&&(t=t.toLowerCase());var r=this.frameLabels;if(r)for(var i=null,o=0;o<r.length;o++)if(i=r[o],e?i.name.toLowerCase()==t:i.name==t)return i;return null},r.prototype.getFrameStartEnd=function(t){var e=this.frameLabels;if(e)for(var r=null,i=0;i<e.length;i++)if(r=e[i],t==r.name){this.$frameLabelStart=r.frame,this.$frameLabelEnd=r.end;break}},r.prototype.getFrameLabelByFrame=function(t){var e=this.frameLabels;if(e)for(var r=null,i=0;i<e.length;i++)if(r=e[i],r.frame==t)return r;return null},r.prototype.getFrameLabelForFrame=function(t){var e=null,r=null,i=this.frameLabels;if(i)for(var o=0;o<i.length;o++){if(r=i[o],r.frame>t)return e;e=r}return e},r.prototype.play=function(t){void 0===t&&(t=0),this.$isPlaying=!0,this.setPlayTimes(t),this.$totalFrames>1&&this.$stage&&this.setIsStopped(!1)},r.prototype.stop=function(){this.$isPlaying=!1,this.setIsStopped(!0)},r.prototype.prevFrame=function(){this.gotoAndStop(this.$currentFrameNum-1)},r.prototype.nextFrame=function(){this.gotoAndStop(this.$currentFrameNum+1)},r.prototype.gotoAndPlay=function(e,r){void 0===r&&(r=0),(0==arguments.length||arguments.length>2)&&t.$error(1022,"MovieClip.gotoAndPlay()"),"string"==typeof e?this.getFrameStartEnd(e):(this.$frameLabelStart=0,this.$frameLabelEnd=0),this.play(r),this.gotoFrame(e)},r.prototype.gotoAndStop=function(e){1!=arguments.length&&t.$error(1022,"MovieClip.gotoAndStop()"),this.stop(),this.gotoFrame(e)},r.prototype.gotoFrame=function(e){var r;"string"==typeof e?r=this.getFrameLabelByName(e).frame:(r=parseInt(e+"",10),r!=e&&t.$error(1022,"Frame Label Not Found")),1>r?r=1:r>this.$totalFrames&&(r=this.$totalFrames),r!=this.$nextFrameNum&&(this.$nextFrameNum=r,this.advanceFrame(),this.constructFrame(),this.handlePendingEvent())},r.prototype.advanceTime=function(e){var r=this,i=e-r.lastTime;r.lastTime=e;var o=r.frameIntervalTime,n=r.passedTime+i;r.passedTime=n%o;var s=n/o;if(1>s)return!1;for(;s>=1;){if(s--,r.$nextFrameNum++,r.$nextFrameNum>r.$totalFrames||r.$frameLabelStart>0&&r.$nextFrameNum>r.$frameLabelEnd)if(-1==r.playTimes)r.$eventPool.push(t.Event.LOOP_COMPLETE),r.$nextFrameNum=1;else{if(r.playTimes--,!(r.playTimes>0)){r.$nextFrameNum=r.$totalFrames,r.$eventPool.push(t.Event.COMPLETE),r.stop();break}r.$eventPool.push(t.Event.LOOP_COMPLETE),r.$nextFrameNum=1}r.$currentFrameNum==r.$frameLabelEnd&&(r.$nextFrameNum=r.$frameLabelStart),r.advanceFrame()}return r.constructFrame(),r.handlePendingEvent(),!1},r.prototype.advanceFrame=function(){this.$currentFrameNum=this.$nextFrameNum;var e=this.frameEvents[this.$nextFrameNum];e&&""!=e&&t.MovieClipEvent.dispatchMovieClipEvent(this,t.MovieClipEvent.FRAME_LABEL,e)},r.prototype.constructFrame=function(){var e=this,r=e.$currentFrameNum;if(e.displayedKeyFrameNum!=r){var i=e.$movieClipData.getTextureByFrame(r);if(e.$texture=i,e.$movieClipData.$getOffsetByFrame(r,e.offsetPoint),e.displayedKeyFrameNum=r,e.$renderDirty=!0,t.nativeRender)e.$nativeDisplayObject.setDataToBitmapNode(e.$nativeDisplayObject.id,i,[i.$bitmapX,i.$bitmapY,i.$bitmapWidth,i.$bitmapHeight,e.offsetPoint.x,e.offsetPoint.y,i.$getScaleBitmapWidth(),i.$getScaleBitmapHeight(),i.$sourceWidth,i.$sourceHeight]),e.$nativeDisplayObject.setWidth(i.$getTextureWidth()+e.offsetPoint.x),e.$nativeDisplayObject.setHeight(i.$getTextureHeight()+e.offsetPoint.y);else{var o=e.$parent;o&&!o.$cacheDirty&&(o.$cacheDirty=!0,o.$cacheDirtyUp());var n=e.$maskedObject;
n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}}},r.prototype.$renderFrame=function(){var t=this;t.$texture=t.$movieClipData.getTextureByFrame(t.$currentFrameNum),t.$renderDirty=!0;var e=t.$parent;e&&!e.$cacheDirty&&(e.$cacheDirty=!0,e.$cacheDirtyUp());var r=t.$maskedObject;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp())},r.prototype.handlePendingEvent=function(){if(0!=this.$eventPool.length){this.$eventPool.reverse();for(var e=this.$eventPool,r=e.length,i=!1,o=!1,n=0;r>n;n++){var s=e.pop();s==t.Event.LOOP_COMPLETE?o=!0:s==t.Event.COMPLETE?i=!0:this.dispatchEventWith(s)}o&&this.dispatchEventWith(t.Event.LOOP_COMPLETE),i&&this.dispatchEventWith(t.Event.COMPLETE)}},Object.defineProperty(r.prototype,"totalFrames",{get:function(){return this.$totalFrames},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"currentFrame",{get:function(){return this.$currentFrameNum},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"currentFrameLabel",{get:function(){var t=this.getFrameLabelByFrame(this.$currentFrameNum);return t&&t.name},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"currentLabel",{get:function(){var t=this.getFrameLabelForFrame(this.$currentFrameNum);return t?t.name:null},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"frameRate",{get:function(){return this.$frameRate},set:function(t){t!=this.$frameRate&&(this.$frameRate=t,this.frameIntervalTime=1e3/this.$frameRate)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isPlaying",{get:function(){return this.$isPlaying},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"movieClipData",{get:function(){return this.$movieClipData},set:function(t){this.setMovieClipData(t)},enumerable:!0,configurable:!0}),r.prototype.setMovieClipData=function(t){this.$movieClipData!=t&&(this.$movieClipData=t,this.$init())},r.prototype.setPlayTimes=function(t){(0>t||t>=1)&&(this.playTimes=0>t?-1:Math.floor(t))},r.prototype.setIsStopped=function(e){this.isStopped!=e&&(this.isStopped=e,e?t.ticker.$stopTick(this.advanceTime,this):(this.playTimes=0==this.playTimes?1:this.playTimes,this.lastTime=t.getTimer(),t.ticker.$startTick(this.advanceTime,this)))},r}(t.DisplayObject);t.MovieClip=e,__reflect(e.prototype,"egret.MovieClip")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(r){void 0===r&&(r=null);var i=e.call(this)||this;return i.data=null,i.method=t.URLRequestMethod.GET,i.url="",i.requestHeaders=[],i.url=r,i}return __extends(r,e),r}(t.HashObject);t.URLRequest=e,__reflect(e.prototype,"egret.URLRequest")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(t,e){this.name="",this.value="",this.name=t,this.value=e}return t}();t.URLRequestHeader=e,__reflect(e.prototype,"egret.URLRequestHeader")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.GET="get",t.POST="post",t}();t.URLRequestMethod=e,__reflect(e.prototype,"egret.URLRequestMethod")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e){void 0===e&&(e=null);var r=t.call(this)||this;return r.variables=null,null!==e&&r.decode(e),r}return __extends(e,t),e.prototype.decode=function(t){this.variables||(this.variables={}),t=t.split("+").join(" ");for(var e,r=/[?&]?([^=]+)=([^&]*)/g;e=r.exec(t);){var i=decodeURIComponent(e[1]),o=decodeURIComponent(e[2]);if(i in this.variables!=0){var n=this.variables[i];n instanceof Array?n.push(o):this.variables[i]=[n,o]}else this.variables[i]=o}},e.prototype.toString=function(){if(!this.variables)return"";var t=this.variables,e=[];for(var r in t)e.push(this.encodeValue(r,t[r]));return e.join("&")},e.prototype.encodeValue=function(t,e){return e instanceof Array?this.encodeArray(t,e):encodeURIComponent(t)+"="+encodeURIComponent(e)},e.prototype.encodeArray=function(t,e){return t?0==e.length?encodeURIComponent(t)+"=":e.map(function(e){return encodeURIComponent(t)+"="+encodeURIComponent(e)}).join("&"):""},e}(t.HashObject);t.URLVariables=e,__reflect(e.prototype,"egret.URLVariables")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(){var i=e.call(this)||this;return i._timeScale=1,i._paused=!1,i._callIndex=-1,i._lastTime=0,i.callBackList=[],null!=r.instance,t.ticker.$startTick(i.update,i),i._lastTime=t.getTimer(),i}return __extends(r,e),r.prototype.update=function(t){var e=t-this._lastTime;if(this._lastTime=t,this._paused)return!1;var r=e*this._timeScale;for(this._callList=this.callBackList.concat(),this._callIndex=0;this._callIndex<this._callList.length;this._callIndex++){var i=this._callList[this._callIndex];i.listener.call(i.thisObject,r)}return this._callIndex=-1,this._callList=null,!1},r.prototype.register=function(t,e,r){void 0===r&&(r=0),this.$insertEventBin(this.callBackList,"",t,e,!1,r,!1)},r.prototype.unregister=function(t,e){this.$removeEventBin(this.callBackList,t,e)},r.prototype.setTimeScale=function(t){this._timeScale=t},r.prototype.getTimeScale=function(){return this._timeScale},r.prototype.pause=function(){this._paused=!0},r.prototype.resume=function(){this._paused=!1},r.getInstance=function(){return null==r.instance&&(r.instance=new r),r.instance},r}(t.EventDispatcher);t.Ticker=e,__reflect(e.prototype,"egret.Ticker")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(){return e.call(this)||this}return __extends(r,e),Object.defineProperty(r.prototype,"stage",{get:function(){return t.sys.$TempStage},enumerable:!0,configurable:!0}),Object.defineProperty(r,"instance",{get:function(){return null==r._instance&&(r._instance=new r),r._instance},enumerable:!0,configurable:!0}),r.deviceType=null,r.DEVICE_PC="web",r.DEVICE_MOBILE="native",r}(t.EventDispatcher);t.MainContext=e,__reflect(e.prototype,"egret.MainContext")}(egret||(egret={})),egret.testDeviceType1=function(){if(!window.navigator)return!0;var t=navigator.userAgent.toLowerCase();return-1!=t.indexOf("mobile")||-1!=t.indexOf("android")},egret.MainContext.deviceType=egret.testDeviceType1()?egret.MainContext.DEVICE_MOBILE:egret.MainContext.DEVICE_PC,delete egret.testDeviceType1;var egret;!function(t){var e=function(e){function r(t){void 0===t&&(t=300);var r=e.call(this)||this;return r.objectPool=[],r._length=0,1>t&&(t=1),r.autoDisposeTime=t,r.frameCount=0,r}return __extends(r,e),r.$init=function(){t.ticker.$startTick(r.onUpdate,r)},r.onUpdate=function(t){for(var e=r._callBackList,i=e.length-1;i>=0;i--)e[i].$checkFrame();return!1},r.prototype.$checkFrame=function(){this.frameCount--,this.frameCount<=0&&this.dispose()},Object.defineProperty(r.prototype,"length",{get:function(){return this._length},enumerable:!0,configurable:!0}),r.prototype.push=function(t){var e=this.objectPool;-1==e.indexOf(t)&&(e.push(t),t.__recycle&&t.__recycle(),this._length++,0==this.frameCount&&(this.frameCount=this.autoDisposeTime,r._callBackList.push(this)))},r.prototype.pop=function(){return 0==this._length?null:(this._length--,this.objectPool.pop())},r.prototype.dispose=function(){this._length>0&&(this.objectPool=[],this._length=0),this.frameCount=0;var t=r._callBackList,e=t.indexOf(this);-1!=e&&t.splice(e,1)},r._callBackList=[],r}(t.HashObject);t.Recycler=e,__reflect(e.prototype,"egret.Recycler"),e.$init()}(egret||(egret={}));var egret;!function(t){function e(e,r,c){for(var l=[],h=3;h<arguments.length;h++)l[h-3]=arguments[h];var u={listener:e,thisObject:r,delay:c,originDelay:c,params:l};return s++,1==s&&(a=t.getTimer(),t.ticker.$startTick(i,null)),n++,o[n]=u,n}function r(e){o[e]&&(s--,delete o[e],0==s&&t.ticker.$stopTick(i,null))}function i(t){var e=t-a;a=t;for(var r in o){var i=o[r];i.delay-=e,i.delay<=0&&(i.delay=i.originDelay,i.listener.apply(i.thisObject,i.params))}return!1}var o={},n=0,s=0,a=0;t.setInterval=e,t.clearInterval=r}(egret||(egret={}));var egret;!function(t){function e(e,r,c){for(var l=[],h=3;h<arguments.length;h++)l[h-3]=arguments[h];var u={listener:e,thisObject:r,delay:c,params:l};return s++,1==s&&t.ticker&&(a=t.getTimer(),t.ticker.$startTick(i,null)),n++,o[n]=u,n}function r(e){o[e]&&(s--,delete o[e],0==s&&t.ticker&&t.ticker.$stopTick(i,null))}function i(t){var e=t-a;a=t;for(var i in o){var n=i,s=o[n];s.delay-=e,s.delay<=0&&(s.listener.apply(s.thisObject,s.params),r(n))}return!1}var o={},n=0,s=0,a=0;t.setTimeout=e,t.clearTimeout=r}(egret||(egret={}));
\ No newline at end of file
/*!
* @overview es6-promise - a tiny implementation of Promises/A+.
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
* @license Licensed under MIT license
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
* @version 4.0.5
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.ES6Promise = factory());
}(this, (function () { 'use strict';
function objectOrFunction(x) {
return typeof x === 'function' || typeof x === 'object' && x !== null;
}
function isFunction(x) {
return typeof x === 'function';
}
var _isArray = undefined;
if (!Array.isArray) {
_isArray = function (x) {
return Object.prototype.toString.call(x) === '[object Array]';
};
} else {
_isArray = Array.isArray;
}
var isArray = _isArray;
var len = 0;
var vertxNext = undefined;
var customSchedulerFn = undefined;
var asap = function asap(callback, arg) {
queue[len] = callback;
queue[len + 1] = arg;
len += 2;
if (len === 2) {
// If len is 2, that means that we need to schedule an async flush.
// If additional callbacks are queued before the queue is flushed, they
// will be processed by this flush that we are scheduling.
if (customSchedulerFn) {
customSchedulerFn(flush);
} else {
scheduleFlush();
}
}
};
function setScheduler(scheduleFn) {
customSchedulerFn = scheduleFn;
}
function setAsap(asapFn) {
asap = asapFn;
}
var browserWindow = typeof window !== 'undefined' ? window : undefined;
var browserGlobal = browserWindow || {};
var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]';
// test for web worker but not in IE10
var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined';
// node
function useNextTick() {
// node version 0.10.x displays a deprecation warning when nextTick is used recursively
// see https://github.com/cujojs/when/issues/410 for details
return function () {
return process.nextTick(flush);
};
}
// vertx
function useVertxTimer() {
if (typeof vertxNext !== 'undefined') {
return function () {
vertxNext(flush);
};
}
return useSetTimeout();
}
function useMutationObserver() {
var iterations = 0;
var observer = new BrowserMutationObserver(flush);
var node = document.createTextNode('');
observer.observe(node, { characterData: true });
return function () {
node.data = iterations = ++iterations % 2;
};
}
// web worker
function useMessageChannel() {
var channel = new MessageChannel();
channel.port1.onmessage = flush;
return function () {
return channel.port2.postMessage(0);
};
}
function useSetTimeout() {
// Store setTimeout reference so es6-promise will be unaffected by
// other code modifying setTimeout (like sinon.useFakeTimers())
var globalSetTimeout = setTimeout;
return function () {
return globalSetTimeout(flush, 1);
};
}
var queue = new Array(1000);
function flush() {
for (var i = 0; i < len; i += 2) {
var callback = queue[i];
var arg = queue[i + 1];
callback(arg);
queue[i] = undefined;
queue[i + 1] = undefined;
}
len = 0;
}
function attemptVertx() {
try {
var r = require;
var vertx = r('vertx');
vertxNext = vertx.runOnLoop || vertx.runOnContext;
return useVertxTimer();
} catch (e) {
return useSetTimeout();
}
}
var scheduleFlush = undefined;
// Decide what async method to use to triggering processing of queued callbacks:
if (isNode) {
scheduleFlush = useNextTick();
} else if (BrowserMutationObserver) {
scheduleFlush = useMutationObserver();
} else if (isWorker) {
scheduleFlush = useMessageChannel();
} else if (browserWindow === undefined && typeof require === 'function') {
scheduleFlush = attemptVertx();
} else {
scheduleFlush = useSetTimeout();
}
function then(onFulfillment, onRejection) {
var _arguments = arguments;
var parent = this;
var child = new this.constructor(noop);
if (child[PROMISE_ID] === undefined) {
makePromise(child);
}
var _state = parent._state;
if (_state) {
(function () {
var callback = _arguments[_state - 1];
asap(function () {
return invokeCallback(_state, child, callback, parent._result);
});
})();
} else {
subscribe(parent, child, onFulfillment, onRejection);
}
return child;
}
/**
`Promise.resolve` returns a promise that will become resolved with the
passed `value`. It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
resolve(1);
});
promise.then(function(value){
// value === 1
});
```
Instead of writing the above, your code now simply becomes the following:
```javascript
let promise = Promise.resolve(1);
promise.then(function(value){
// value === 1
});
```
@method resolve
@static
@param {Any} value value that the returned promise will be resolved with
Useful for tooling.
@return {Promise} a promise that will become fulfilled with the given
`value`
*/
function resolve(object) {
/*jshint validthis:true */
var Constructor = this;
if (object && typeof object === 'object' && object.constructor === Constructor) {
return object;
}
var promise = new Constructor(noop);
_resolve(promise, object);
return promise;
}
var PROMISE_ID = Math.random().toString(36).substring(16);
function noop() {}
var PENDING = void 0;
var FULFILLED = 1;
var REJECTED = 2;
var GET_THEN_ERROR = new ErrorObject();
function selfFulfillment() {
return new TypeError("You cannot resolve a promise with itself");
}
function cannotReturnOwn() {
return new TypeError('A promises callback cannot return that same promise.');
}
function getThen(promise) {
try {
return promise.then;
} catch (error) {
GET_THEN_ERROR.error = error;
return GET_THEN_ERROR;
}
}
function tryThen(then, value, fulfillmentHandler, rejectionHandler) {
try {
then.call(value, fulfillmentHandler, rejectionHandler);
} catch (e) {
return e;
}
}
function handleForeignThenable(promise, thenable, then) {
asap(function (promise) {
var sealed = false;
var error = tryThen(then, thenable, function (value) {
if (sealed) {
return;
}
sealed = true;
if (thenable !== value) {
_resolve(promise, value);
} else {
fulfill(promise, value);
}
}, function (reason) {
if (sealed) {
return;
}
sealed = true;
_reject(promise, reason);
}, 'Settle: ' + (promise._label || ' unknown promise'));
if (!sealed && error) {
sealed = true;
_reject(promise, error);
}
}, promise);
}
function handleOwnThenable(promise, thenable) {
if (thenable._state === FULFILLED) {
fulfill(promise, thenable._result);
} else if (thenable._state === REJECTED) {
_reject(promise, thenable._result);
} else {
subscribe(thenable, undefined, function (value) {
return _resolve(promise, value);
}, function (reason) {
return _reject(promise, reason);
});
}
}
function handleMaybeThenable(promise, maybeThenable, then$$) {
if (maybeThenable.constructor === promise.constructor && then$$ === then && maybeThenable.constructor.resolve === resolve) {
handleOwnThenable(promise, maybeThenable);
} else {
if (then$$ === GET_THEN_ERROR) {
_reject(promise, GET_THEN_ERROR.error);
} else if (then$$ === undefined) {
fulfill(promise, maybeThenable);
} else if (isFunction(then$$)) {
handleForeignThenable(promise, maybeThenable, then$$);
} else {
fulfill(promise, maybeThenable);
}
}
}
function _resolve(promise, value) {
if (promise === value) {
_reject(promise, selfFulfillment());
} else if (objectOrFunction(value)) {
handleMaybeThenable(promise, value, getThen(value));
} else {
fulfill(promise, value);
}
}
function publishRejection(promise) {
if (promise._onerror) {
promise._onerror(promise._result);
}
publish(promise);
}
function fulfill(promise, value) {
if (promise._state !== PENDING) {
return;
}
promise._result = value;
promise._state = FULFILLED;
if (promise._subscribers.length !== 0) {
asap(publish, promise);
}
}
function _reject(promise, reason) {
if (promise._state !== PENDING) {
return;
}
promise._state = REJECTED;
promise._result = reason;
asap(publishRejection, promise);
}
function subscribe(parent, child, onFulfillment, onRejection) {
var _subscribers = parent._subscribers;
var length = _subscribers.length;
parent._onerror = null;
_subscribers[length] = child;
_subscribers[length + FULFILLED] = onFulfillment;
_subscribers[length + REJECTED] = onRejection;
if (length === 0 && parent._state) {
asap(publish, parent);
}
}
function publish(promise) {
var subscribers = promise._subscribers;
var settled = promise._state;
if (subscribers.length === 0) {
return;
}
var child = undefined,
callback = undefined,
detail = promise._result;
for (var i = 0; i < subscribers.length; i += 3) {
child = subscribers[i];
callback = subscribers[i + settled];
if (child) {
invokeCallback(settled, child, callback, detail);
} else {
callback(detail);
}
}
promise._subscribers.length = 0;
}
function ErrorObject() {
this.error = null;
}
var TRY_CATCH_ERROR = new ErrorObject();
function tryCatch(callback, detail) {
try {
return callback(detail);
} catch (e) {
TRY_CATCH_ERROR.error = e;
return TRY_CATCH_ERROR;
}
}
function invokeCallback(settled, promise, callback, detail) {
var hasCallback = isFunction(callback),
value = undefined,
error = undefined,
succeeded = undefined,
failed = undefined;
if (hasCallback) {
value = tryCatch(callback, detail);
if (value === TRY_CATCH_ERROR) {
failed = true;
error = value.error;
value = null;
} else {
succeeded = true;
}
if (promise === value) {
_reject(promise, cannotReturnOwn());
return;
}
} else {
value = detail;
succeeded = true;
}
if (promise._state !== PENDING) {
// noop
} else if (hasCallback && succeeded) {
_resolve(promise, value);
} else if (failed) {
_reject(promise, error);
} else if (settled === FULFILLED) {
fulfill(promise, value);
} else if (settled === REJECTED) {
_reject(promise, value);
}
}
function initializePromise(promise, resolver) {
try {
resolver(function resolvePromise(value) {
_resolve(promise, value);
}, function rejectPromise(reason) {
_reject(promise, reason);
});
} catch (e) {
_reject(promise, e);
}
}
var id = 0;
function nextId() {
return id++;
}
function makePromise(promise) {
promise[PROMISE_ID] = id++;
promise._state = undefined;
promise._result = undefined;
promise._subscribers = [];
}
function Enumerator(Constructor, input) {
this._instanceConstructor = Constructor;
this.promise = new Constructor(noop);
if (!this.promise[PROMISE_ID]) {
makePromise(this.promise);
}
if (isArray(input)) {
this._input = input;
this.length = input.length;
this._remaining = input.length;
this._result = new Array(this.length);
if (this.length === 0) {
fulfill(this.promise, this._result);
} else {
this.length = this.length || 0;
this._enumerate();
if (this._remaining === 0) {
fulfill(this.promise, this._result);
}
}
} else {
_reject(this.promise, validationError());
}
}
function validationError() {
return new Error('Array Methods must be provided an Array');
};
Enumerator.prototype._enumerate = function () {
var length = this.length;
var _input = this._input;
for (var i = 0; this._state === PENDING && i < length; i++) {
this._eachEntry(_input[i], i);
}
};
Enumerator.prototype._eachEntry = function (entry, i) {
var c = this._instanceConstructor;
var resolve$$ = c.resolve;
if (resolve$$ === resolve) {
var _then = getThen(entry);
if (_then === then && entry._state !== PENDING) {
this._settledAt(entry._state, i, entry._result);
} else if (typeof _then !== 'function') {
this._remaining--;
this._result[i] = entry;
} else if (c === Promise) {
var promise = new c(noop);
handleMaybeThenable(promise, entry, _then);
this._willSettleAt(promise, i);
} else {
this._willSettleAt(new c(function (resolve$$) {
return resolve$$(entry);
}), i);
}
} else {
this._willSettleAt(resolve$$(entry), i);
}
};
Enumerator.prototype._settledAt = function (state, i, value) {
var promise = this.promise;
if (promise._state === PENDING) {
this._remaining--;
if (state === REJECTED) {
_reject(promise, value);
} else {
this._result[i] = value;
}
}
if (this._remaining === 0) {
fulfill(promise, this._result);
}
};
Enumerator.prototype._willSettleAt = function (promise, i) {
var enumerator = this;
subscribe(promise, undefined, function (value) {
return enumerator._settledAt(FULFILLED, i, value);
}, function (reason) {
return enumerator._settledAt(REJECTED, i, reason);
});
};
/**
`Promise.all` accepts an array of promises, and returns a new promise which
is fulfilled with an array of fulfillment values for the passed promises, or
rejected with the reason of the first passed promise to be rejected. It casts all
elements of the passed iterable to promises as it runs this algorithm.
Example:
```javascript
let promise1 = resolve(1);
let promise2 = resolve(2);
let promise3 = resolve(3);
let promises = [ promise1, promise2, promise3 ];
Promise.all(promises).then(function(array){
// The array here would be [ 1, 2, 3 ];
});
```
If any of the `promises` given to `all` are rejected, the first promise
that is rejected will be given as an argument to the returned promises's
rejection handler. For example:
Example:
```javascript
let promise1 = resolve(1);
let promise2 = reject(new Error("2"));
let promise3 = reject(new Error("3"));
let promises = [ promise1, promise2, promise3 ];
Promise.all(promises).then(function(array){
// Code here never runs because there are rejected promises!
}, function(error) {
// error.message === "2"
});
```
@method all
@static
@param {Array} entries array of promises
@param {String} label optional string for labeling the promise.
Useful for tooling.
@return {Promise} promise that is fulfilled when all `promises` have been
fulfilled, or rejected if any of them become rejected.
@static
*/
function all(entries) {
return new Enumerator(this, entries).promise;
}
/**
`Promise.race` returns a new promise which is settled in the same way as the
first passed promise to settle.
Example:
```javascript
let promise1 = new Promise(function(resolve, reject){
setTimeout(function(){
resolve('promise 1');
}, 200);
});
let promise2 = new Promise(function(resolve, reject){
setTimeout(function(){
resolve('promise 2');
}, 100);
});
Promise.race([promise1, promise2]).then(function(result){
// result === 'promise 2' because it was resolved before promise1
// was resolved.
});
```
`Promise.race` is deterministic in that only the state of the first
settled promise matters. For example, even if other promises given to the
`promises` array argument are resolved, but the first settled promise has
become rejected before the other promises became fulfilled, the returned
promise will become rejected:
```javascript
let promise1 = new Promise(function(resolve, reject){
setTimeout(function(){
resolve('promise 1');
}, 200);
});
let promise2 = new Promise(function(resolve, reject){
setTimeout(function(){
reject(new Error('promise 2'));
}, 100);
});
Promise.race([promise1, promise2]).then(function(result){
// Code here never runs
}, function(reason){
// reason.message === 'promise 2' because promise 2 became rejected before
// promise 1 became fulfilled
});
```
An example real-world use case is implementing timeouts:
```javascript
Promise.race([ajax('foo.json'), timeout(5000)])
```
@method race
@static
@param {Array} promises array of promises to observe
Useful for tooling.
@return {Promise} a promise which settles in the same way as the first passed
promise to settle.
*/
function race(entries) {
/*jshint validthis:true */
var Constructor = this;
if (!isArray(entries)) {
return new Constructor(function (_, reject) {
return reject(new TypeError('You must pass an array to race.'));
});
} else {
return new Constructor(function (resolve, reject) {
var length = entries.length;
for (var i = 0; i < length; i++) {
Constructor.resolve(entries[i]).then(resolve, reject);
}
});
}
}
/**
`Promise.reject` returns a promise rejected with the passed `reason`.
It is shorthand for the following:
```javascript
let promise = new Promise(function(resolve, reject){
reject(new Error('WHOOPS'));
});
promise.then(function(value){
// Code here doesn't run because the promise is rejected!
}, function(reason){
// reason.message === 'WHOOPS'
});
```
Instead of writing the above, your code now simply becomes the following:
```javascript
let promise = Promise.reject(new Error('WHOOPS'));
promise.then(function(value){
// Code here doesn't run because the promise is rejected!
}, function(reason){
// reason.message === 'WHOOPS'
});
```
@method reject
@static
@param {Any} reason value that the returned promise will be rejected with.
Useful for tooling.
@return {Promise} a promise rejected with the given `reason`.
*/
function reject(reason) {
/*jshint validthis:true */
var Constructor = this;
var promise = new Constructor(noop);
_reject(promise, reason);
return promise;
}
function needsResolver() {
throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
}
function needsNew() {
throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
}
/**
Promise objects represent the eventual result of an asynchronous operation. The
primary way of interacting with a promise is through its `then` method, which
registers callbacks to receive either a promise's eventual value or the reason
why the promise cannot be fulfilled.
Terminology
-----------
- `promise` is an object or function with a `then` method whose behavior conforms to this specification.
- `thenable` is an object or function that defines a `then` method.
- `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
- `exception` is a value that is thrown using the throw statement.
- `reason` is a value that indicates why a promise was rejected.
- `settled` the final resting state of a promise, fulfilled or rejected.
A promise can be in one of three states: pending, fulfilled, or rejected.
Promises that are fulfilled have a fulfillment value and are in the fulfilled
state. Promises that are rejected have a rejection reason and are in the
rejected state. A fulfillment value is never a thenable.
Promises can also be said to *resolve* a value. If this value is also a
promise, then the original promise's settled state will match the value's
settled state. So a promise that *resolves* a promise that rejects will
itself reject, and a promise that *resolves* a promise that fulfills will
itself fulfill.
Basic Usage:
------------
```js
let promise = new Promise(function(resolve, reject) {
// on success
resolve(value);
// on failure
reject(reason);
});
promise.then(function(value) {
// on fulfillment
}, function(reason) {
// on rejection
});
```
Advanced Usage:
---------------
Promises shine when abstracting away asynchronous interactions such as
`XMLHttpRequest`s.
```js
function getJSON(url) {
return new Promise(function(resolve, reject){
let xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onreadystatechange = handler;
xhr.responseType = 'json';
xhr.setRequestHeader('Accept', 'application/json');
xhr.send();
function handler() {
if (this.readyState === this.DONE) {
if (this.status === 200) {
resolve(this.response);
} else {
reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
}
}
};
});
}
getJSON('/posts.json').then(function(json) {
// on fulfillment
}, function(reason) {
// on rejection
});
```
Unlike callbacks, promises are great composable primitives.
```js
Promise.all([
getJSON('/posts'),
getJSON('/comments')
]).then(function(values){
values[0] // => postsJSON
values[1] // => commentsJSON
return values;
});
```
@class Promise
@param {function} resolver
Useful for tooling.
@constructor
*/
function Promise(resolver) {
this[PROMISE_ID] = nextId();
this._result = this._state = undefined;
this._subscribers = [];
if (noop !== resolver) {
typeof resolver !== 'function' && needsResolver();
this instanceof Promise ? initializePromise(this, resolver) : needsNew();
}
}
Promise.all = all;
Promise.race = race;
Promise.resolve = resolve;
Promise.reject = reject;
Promise._setScheduler = setScheduler;
Promise._setAsap = setAsap;
Promise._asap = asap;
Promise.prototype = {
constructor: Promise,
/**
The primary way of interacting with a promise is through its `then` method,
which registers callbacks to receive either a promise's eventual value or the
reason why the promise cannot be fulfilled.
```js
findUser().then(function(user){
// user is available
}, function(reason){
// user is unavailable, and you are given the reason why
});
```
Chaining
--------
The return value of `then` is itself a promise. This second, 'downstream'
promise is resolved with the return value of the first promise's fulfillment
or rejection handler, or rejected if the handler throws an exception.
```js
findUser().then(function (user) {
return user.name;
}, function (reason) {
return 'default name';
}).then(function (userName) {
// If `findUser` fulfilled, `userName` will be the user's name, otherwise it
// will be `'default name'`
});
findUser().then(function (user) {
throw new Error('Found user, but still unhappy');
}, function (reason) {
throw new Error('`findUser` rejected and we're unhappy');
}).then(function (value) {
// never reached
}, function (reason) {
// if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
// If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
});
```
If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
```js
findUser().then(function (user) {
throw new PedagogicalException('Upstream error');
}).then(function (value) {
// never reached
}).then(function (value) {
// never reached
}, function (reason) {
// The `PedgagocialException` is propagated all the way down to here
});
```
Assimilation
------------
Sometimes the value you want to propagate to a downstream promise can only be
retrieved asynchronously. This can be achieved by returning a promise in the
fulfillment or rejection handler. The downstream promise will then be pending
until the returned promise is settled. This is called *assimilation*.
```js
findUser().then(function (user) {
return findCommentsByAuthor(user);
}).then(function (comments) {
// The user's comments are now available
});
```
If the assimliated promise rejects, then the downstream promise will also reject.
```js
findUser().then(function (user) {
return findCommentsByAuthor(user);
}).then(function (comments) {
// If `findCommentsByAuthor` fulfills, we'll have the value here
}, function (reason) {
// If `findCommentsByAuthor` rejects, we'll have the reason here
});
```
Simple Example
--------------
Synchronous Example
```javascript
let result;
try {
result = findResult();
// success
} catch(reason) {
// failure
}
```
Errback Example
```js
findResult(function(result, err){
if (err) {
// failure
} else {
// success
}
});
```
Promise Example;
```javascript
findResult().then(function(result){
// success
}, function(reason){
// failure
});
```
Advanced Example
--------------
Synchronous Example
```javascript
let author, books;
try {
author = findAuthor();
books = findBooksByAuthor(author);
// success
} catch(reason) {
// failure
}
```
Errback Example
```js
function foundBooks(books) {
}
function failure(reason) {
}
findAuthor(function(author, err){
if (err) {
failure(err);
// failure
} else {
try {
findBoooksByAuthor(author, function(books, err) {
if (err) {
failure(err);
} else {
try {
foundBooks(books);
} catch(reason) {
failure(reason);
}
}
});
} catch(error) {
failure(err);
}
// success
}
});
```
Promise Example;
```javascript
findAuthor().
then(findBooksByAuthor).
then(function(books){
// found books
}).catch(function(reason){
// something went wrong
});
```
@method then
@param {Function} onFulfilled
@param {Function} onRejected
Useful for tooling.
@return {Promise}
*/
then: then,
/**
`catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
as the catch block of a try/catch statement.
```js
function findAuthor(){
throw new Error('couldn't find that author');
}
// synchronous
try {
findAuthor();
} catch(reason) {
// something went wrong
}
// async with promises
findAuthor().catch(function(reason){
// something went wrong
});
```
@method catch
@param {Function} onRejection
Useful for tooling.
@return {Promise}
*/
'catch': function _catch(onRejection) {
return this.then(null, onRejection);
}
};
function polyfill() {
var local = undefined;
if (typeof global !== 'undefined') {
local = global;
} else if (typeof self !== 'undefined') {
local = self;
} else {
try {
local = Function('return this')();
} catch (e) {
throw new Error('polyfill failed because global object is unavailable in this environment');
}
}
var P = local.Promise;
if (typeof egret_native != "undefined" && egret_native.capability && !egret_native.capability("Promise")) {
P = undefined;
}
if (P) {
var promiseToString = null;
try {
promiseToString = Object.prototype.toString.call(P.resolve());
} catch (e) {
// silently ignored
}
if (promiseToString === '[object Promise]' && !P.cast) {
return;
}
}
local.Promise = Promise;
}
// Strange compat..
Promise.polyfill = polyfill;
Promise.Promise = Promise;
return Promise;
})));
ES6Promise.polyfill();
\ No newline at end of file
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.ES6Promise=e()}(this,function(){"use strict";function t(t){return"function"==typeof t||"object"==typeof t&&null!==t}function e(t){return"function"==typeof t}function n(t){I=t}function r(t){J=t}function o(){return function(){return process.nextTick(a)}}function i(){return"undefined"!=typeof H?function(){H(a)}:c()}function s(){var t=0,e=new V(a),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function u(){var t=new MessageChannel;return t.port1.onmessage=a,function(){return t.port2.postMessage(0)}}function c(){var t=setTimeout;return function(){return t(a,1)}}function a(){for(var t=0;G>t;t+=2){var e=$[t],n=$[t+1];e(n),$[t]=void 0,$[t+1]=void 0}G=0}function f(){try{var t=require,e=t("vertx");return H=e.runOnLoop||e.runOnContext,i()}catch(n){return c()}}function l(t,e){var n=arguments,r=this,o=new this.constructor(p);void 0===o[ee]&&k(o);var i=r._state;return i?!function(){var t=n[i-1];J(function(){return x(i,o,t,r._result)})}():E(r,o,t,e),o}function h(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var n=new e(p);return w(n,t),n}function p(){}function v(){return new TypeError("You cannot resolve a promise with itself")}function d(){return new TypeError("A promises callback cannot return that same promise.")}function _(t){try{return t.then}catch(e){return ie.error=e,ie}}function y(t,e,n,r){try{t.call(e,n,r)}catch(o){return o}}function m(t,e,n){J(function(t){var r=!1,o=y(n,e,function(n){r||(r=!0,e!==n?w(t,n):S(t,n))},function(e){r||(r=!0,j(t,e))},"Settle: "+(t._label||" unknown promise"));!r&&o&&(r=!0,j(t,o))},t)}function b(t,e){e._state===re?S(t,e._result):e._state===oe?j(t,e._result):E(e,void 0,function(e){return w(t,e)},function(e){return j(t,e)})}function g(t,n,r){n.constructor===t.constructor&&r===l&&n.constructor.resolve===h?b(t,n):r===ie?j(t,ie.error):void 0===r?S(t,n):e(r)?m(t,n,r):S(t,n)}function w(e,n){e===n?j(e,v()):t(n)?g(e,n,_(n)):S(e,n)}function A(t){t._onerror&&t._onerror(t._result),P(t)}function S(t,e){t._state===ne&&(t._result=e,t._state=re,0!==t._subscribers.length&&J(P,t))}function j(t,e){t._state===ne&&(t._state=oe,t._result=e,J(A,t))}function E(t,e,n,r){var o=t._subscribers,i=o.length;t._onerror=null,o[i]=e,o[i+re]=n,o[i+oe]=r,0===i&&t._state&&J(P,t)}function P(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r=void 0,o=void 0,i=t._result,s=0;s<e.length;s+=3)r=e[s],o=e[s+n],r?x(n,r,o,i):o(i);t._subscribers.length=0}}function T(){this.error=null}function M(t,e){try{return t(e)}catch(n){return se.error=n,se}}function x(t,n,r,o){var i=e(r),s=void 0,u=void 0,c=void 0,a=void 0;if(i){if(s=M(r,o),s===se?(a=!0,u=s.error,s=null):c=!0,n===s)return void j(n,d())}else s=o,c=!0;n._state!==ne||(i&&c?w(n,s):a?j(n,u):t===re?S(n,s):t===oe&&j(n,s))}function C(t,e){try{e(function(e){w(t,e)},function(e){j(t,e)})}catch(n){j(t,n)}}function O(){return ue++}function k(t){t[ee]=ue++,t._state=void 0,t._result=void 0,t._subscribers=[]}function Y(t,e){this._instanceConstructor=t,this.promise=new t(p),this.promise[ee]||k(this.promise),B(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?S(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&S(this.promise,this._result))):j(this.promise,q())}function q(){return new Error("Array Methods must be provided an Array")}function F(t){return new Y(this,t).promise}function D(t){var e=this;return new e(B(t)?function(n,r){for(var o=t.length,i=0;o>i;i++)e.resolve(t[i]).then(n,r)}:function(t,e){return e(new TypeError("You must pass an array to race."))})}function K(t){var e=this,n=new e(p);return j(n,t),n}function L(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function N(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function U(t){this[ee]=O(),this._result=this._state=void 0,this._subscribers=[],p!==t&&("function"!=typeof t&&L(),this instanceof U?C(this,t):N())}function W(){var t=void 0;if("undefined"!=typeof global)t=global;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=t.Promise;if("undefined"!=typeof egret_native&&egret_native.capability&&!egret_native.capability("Promise")&&(n=void 0),n){var r=null;try{r=Object.prototype.toString.call(n.resolve())}catch(e){}if("[object Promise]"===r&&!n.cast)return}t.Promise=U}var z=void 0;z=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var B=z,G=0,H=void 0,I=void 0,J=function(t,e){$[G]=t,$[G+1]=e,G+=2,2===G&&(I?I(a):te())},Q="undefined"!=typeof window?window:void 0,R=Q||{},V=R.MutationObserver||R.WebKitMutationObserver,X="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),Z="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,$=new Array(1e3),te=void 0;te=X?o():V?s():Z?u():void 0===Q&&"function"==typeof require?f():c();var ee=Math.random().toString(36).substring(16),ne=void 0,re=1,oe=2,ie=new T,se=new T,ue=0;return Y.prototype._enumerate=function(){for(var t=this.length,e=this._input,n=0;this._state===ne&&t>n;n++)this._eachEntry(e[n],n)},Y.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===h){var o=_(t);if(o===l&&t._state!==ne)this._settledAt(t._state,e,t._result);else if("function"!=typeof o)this._remaining--,this._result[e]=t;else if(n===U){var i=new n(p);g(i,t,o),this._willSettleAt(i,e)}else this._willSettleAt(new n(function(e){return e(t)}),e)}else this._willSettleAt(r(t),e)},Y.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===ne&&(this._remaining--,t===oe?j(r,n):this._result[e]=n),0===this._remaining&&S(r,this._result)},Y.prototype._willSettleAt=function(t,e){var n=this;E(t,void 0,function(t){return n._settledAt(re,e,t)},function(t){return n._settledAt(oe,e,t)})},U.all=F,U.race=D,U.resolve=h,U.reject=K,U._setScheduler=n,U._setAsap=r,U._asap=J,U.prototype={constructor:U,then:l,"catch":function(t){return this.then(null,t)}},U.polyfill=W,U.Promise=U,U}),ES6Promise.polyfill();
\ No newline at end of file
declare namespace egret {
/**
* Easing function set. Different easing functions are used to make an animation proceed according to the corresponding equation
* @see http://edn.egret.com/cn/index.php/article/index/id/53 Easing effect Demo
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 缓动函数集合,使用不同的缓动函数使得动画按照对应的方程进行
* @see http://edn.egret.com/cn/index.php/article/index/id/53 缓动效果演示
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
class Ease {
/**
* @version Egret 2.4
* @platform Web,Native
*/
constructor();
/**
* get.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static get(amount: number): (t: number) => number;
/**
* get pow in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get pow in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static getPowIn(pow: number): (t: number) => number;
/**
* get pow out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get pow out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static getPowOut(pow: number): (t: number) => number;
/**
* get pow in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get pow in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static getPowInOut(pow: number): (t: number) => number;
/**
* quad in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* quad in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static quadIn: (t: number) => number;
/**
* quad out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* quad out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static quadOut: (t: number) => number;
/**
* quad in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* quad in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static quadInOut: (t: number) => number;
/**
* cubic in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* cubic in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static cubicIn: (t: number) => number;
/**
* cubic out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* cubic out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static cubicOut: (t: number) => number;
/**
* cubic in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* cubic in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static cubicInOut: (t: number) => number;
/**
* quart in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* quart in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static quartIn: (t: number) => number;
/**
* quart out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* quart out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static quartOut: (t: number) => number;
/**
* quart in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* quart in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static quartInOut: (t: number) => number;
/**
* quint in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* quint in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static quintIn: (t: number) => number;
/**
* quint out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* quint out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static quintOut: (t: number) => number;
/**
* quint in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* quint in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static quintInOut: (t: number) => number;
/**
* sine in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* sine in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static sineIn(t: number): number;
/**
* sine out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* sine out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static sineOut(t: number): number;
/**
* sine in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* sine in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static sineInOut(t: number): number;
/**
* get back in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get back in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static getBackIn(amount: number): (t: number) => number;
/**
* back in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* back in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static backIn: (t: number) => number;
/**
* get back out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get back out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static getBackOut(amount: number): (t: any) => number;
/**
* back out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* back out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static backOut: (t: any) => number;
/**
* get back in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get back in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static getBackInOut(amount: number): (t: number) => number;
/**
* back in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* back in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static backInOut: (t: number) => number;
/**
* circ in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* circ in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static circIn(t: number): number;
/**
* circ out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* circ out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static circOut(t: number): number;
/**
* circ in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* circ in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static circInOut(t: number): number;
/**
* bounce in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* bounce in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static bounceIn(t: number): number;
/**
* bounce out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* bounce out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static bounceOut(t: number): number;
/**
* bounce in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* bounce in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static bounceInOut(t: number): number;
/**
* get elastic in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get elastic in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static getElasticIn(amplitude: number, period: number): (t: number) => number;
/**
* elastic in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* elastic in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static elasticIn: (t: number) => number;
/**
* get elastic out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get elastic out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static getElasticOut(amplitude: number, period: number): (t: number) => number;
/**
* elastic out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* elastic out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static elasticOut: (t: number) => number;
/**
* get elastic in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get elastic in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static getElasticInOut(amplitude: number, period: number): (t: number) => number;
/**
* elastic in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* elastic in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static elasticInOut: (t: number) => number;
}
}
declare namespace egret {
/**
* Tween is the animation easing class of Egret
* @see http://edn.egret.com/cn/docs/page/576 Tween ease animation
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/tween/Tween.ts
* @language en_US
*/
/**
* Tween是Egret的动画缓动类
* @see http://edn.egret.com/cn/docs/page/576 Tween缓动动画
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/tween/Tween.ts
* @language zh_CN
*/
class Tween extends EventDispatcher {
/**
* 不做特殊处理
* @constant {number} egret.Tween.NONE
* @private
*/
private static NONE;
/**
* 循环
* @constant {number} egret.Tween.LOOP
* @private
*/
private static LOOP;
/**
* 倒序
* @constant {number} egret.Tween.REVERSE
* @private
*/
private static REVERSE;
/**
* @private
*/
private static _tweens;
/**
* @private
*/
private static IGNORE;
/**
* @private
*/
private static _plugins;
/**
* @private
*/
private static _inited;
/**
* @private
*/
private _target;
/**
* @private
*/
private _useTicks;
/**
* @private
*/
private ignoreGlobalPause;
/**
* @private
*/
private loop;
/**
* @private
*/
private pluginData;
/**
* @private
*/
private _curQueueProps;
/**
* @private
*/
private _initQueueProps;
/**
* @private
*/
private _steps;
/**
* @private
*/
private paused;
/**
* @private
*/
private duration;
/**
* @private
*/
private _prevPos;
/**
* @private
*/
private position;
/**
* @private
*/
private _prevPosition;
/**
* @private
*/
private _stepPosition;
/**
* @private
*/
private passive;
/**
* Activate an object and add a Tween animation to the object
* @param target {any} The object to be activated
* @param props {any} Parameters, support loop onChange onChangeObj
* @param pluginData {any} Write realized
* @param override {boolean} Whether to remove the object before adding a tween, the default value false
* Not recommended, you can use Tween.removeTweens(target) instead.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 激活一个对象,对其添加 Tween 动画
* @param target {any} 要激活 Tween 的对象
* @param props {any} 参数,支持loop(循环播放) onChange(变化函数) onChangeObj(变化函数作用域)
* @param pluginData {any} 暂未实现
* @param override {boolean} 是否移除对象之前添加的tween,默认值false。
* 不建议使用,可使用 Tween.removeTweens(target) 代替。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static get(target: any, props?: {
loop?: boolean;
onChange?: Function;
onChangeObj?: any;
}, pluginData?: any, override?: boolean): Tween;
/**
* Delete all Tween animations from an object
* @param target The object whose Tween to be deleted
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 删除一个对象上的全部 Tween 动画
* @param target 需要移除 Tween 的对象
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static removeTweens(target: any): void;
/**
* Pause all Tween animations of a certain object
* @param target The object whose Tween to be paused
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 暂停某个对象的所有 Tween
* @param target 要暂停 Tween 的对象
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static pauseTweens(target: any): void;
/**
* Resume playing all easing of a certain object
* @param target The object whose Tween to be resumed
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 继续播放某个对象的所有缓动
* @param target 要继续播放 Tween 的对象
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static resumeTweens(target: any): void;
/**
* @private
*
* @param delta
* @param paused
*/
private static tick(timeStamp, paused?);
private static _lastTime;
/**
* @private
*
* @param tween
* @param value
*/
private static _register(tween, value);
/**
* Delete all Tween
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 删除所有 Tween
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
static removeAllTweens(): void;
/**
* 创建一个 egret.Tween 对象
* @private
* @version Egret 2.4
* @platform Web,Native
*/
constructor(target: any, props: any, pluginData: any);
/**
* @private
*
* @param target
* @param props
* @param pluginData
*/
private initialize(target, props, pluginData);
/**
* @private
*
* @param value
* @param actionsMode
* @returns
*/
setPosition(value: number, actionsMode?: number): boolean;
/**
* @private
*
* @param startPos
* @param endPos
* @param includeStart
*/
private _runAction(action, startPos, endPos, includeStart?);
/**
* @private
*
* @param step
* @param ratio
*/
private _updateTargetProps(step, ratio);
/**
* Whether setting is paused
* @param value {boolean} Whether to pause
* @returns Tween object itself
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 设置是否暂停
* @param value {boolean} 是否暂停
* @returns Tween对象本身
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
setPaused(value: boolean): Tween;
/**
* @private
*
* @param props
* @returns
*/
private _cloneProps(props);
/**
* @private
*
* @param o
* @returns
*/
private _addStep(o);
/**
* @private
*
* @param o
* @returns
*/
private _appendQueueProps(o);
/**
* @private
*
* @param o
* @returns
*/
private _addAction(o);
/**
* @private
*
* @param props
* @param o
*/
private _set(props, o);
/**
* Wait the specified milliseconds before the execution of the next animation
* @param duration {number} Waiting time, in milliseconds
* @param passive {boolean} Whether properties are updated during the waiting time
* @returns Tween object itself
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 等待指定毫秒后执行下一个动画
* @param duration {number} 要等待的时间,以毫秒为单位
* @param passive {boolean} 等待期间属性是否会更新
* @returns Tween对象本身
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
wait(duration: number, passive?: boolean): Tween;
/**
* Modify the property of the specified object to a specified value
* @param props {Object} Property set of an object
* @param duration {number} Duration
* @param ease {egret.Ease} Easing algorithm
* @returns {egret.Tween} Tween object itself
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 将指定对象的属性修改为指定值
* @param props {Object} 对象的属性集合
* @param duration {number} 持续时间
* @param ease {egret.Ease} 缓动算法
* @returns {egret.Tween} Tween对象本身
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
to(props: any, duration?: number, ease?: Function): Tween;
/**
* Execute callback function
* @param callback {Function} Callback method
* @param thisObj {any} this action scope of the callback method
* @param params {any[]} Parameter of the callback method
* @returns {egret.Tween} Tween object itself
* @version Egret 2.4
* @platform Web,Native
* @example
* <pre>
* 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"]);
* </pre>
* @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
* <pre>
* egret.Tween.get(display).call(function (a:number, b:string) {
* console.log("a: " + a); //对应传入的第一个参数 233
* console.log("b: " + b); //对应传入的第二个参数 “hello”
* }, this, [233, "hello"]);
* </pre>
* @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 <code>Tween.to</code>
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 表示一个to动作,参见<code>Tween.to</code>
* @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 <code>Tween.wait</code>
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 表示一个wait动作,参见<code>Tween.wait</code>
* @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 <code>Tween.set</code>
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 表示一个set动作,参见<code>Tween.set</code>
* @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 <code>Tween.tick</code>
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 表示一个tick动作,参见<code>Tween.tick</code>
* @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:
* ```
* <tween:TweenItem target="{this.button}">
* <tween:props>
* <e:Object loop="{true}"/>
* </tween:props>
* <tween:paths>
* <e:Array>
* <tween:To duration="500">
* <tween:props>
* <e:Object x="{100}" y="{200}" />
* </tween:props>
* </tween:To>
* <tween:Wait duration="1000" />
* <tween:To duration="1000">
* <tween:props>
* <e:Object x="{200}" y="{100}" />
* </tween:props>
* </tween:To>
* </e:Array>
* </tween:paths>
* </tween:TweenItem>
* ```
*/
class TweenItem extends EventDispatcher {
private tween;
constructor();
/**
* @private
*/
private _props;
/**
* The Tween's props.
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* Tween的props参数。
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
props: any;
/**
* @private
*/
private _target;
/**
* The Tween's target.
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* Tween的target参数。
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
target: any;
/**
* @private
*/
private _paths;
/**
* The Actions in Tween.
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* TweenItem中添加的行为。
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
paths: BasePath[];
/**
* Play the Tween
* @position The starting position, the default is from the last position to play
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 播放Tween
* @position 播放的起始位置, 默认为从上次位置继续播放
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
play(position?: number): void;
/**
* Pause the Tween
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 暂停Tween
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
pause(): void;
private isStop;
/**
* Stop the Tween
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 停止Tween
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
stop(): void;
private createTween(position);
private applyPaths();
private applyPath(path);
private pathComplete(path);
}
/**
* TweenGroup is a collection of TweenItem that can be played in parallel with each Item
*
* @event itemComplete Dispatched when some TweenItem has complete.
* @event complete Dispatched when all TweenItems has complete.
*
* @version Egret 3.1.8
* @platform Web,Native
* @includeExample extension/tween/TweenWrapper.ts
* @language en_US
*/
/**
* TweenGroup是TweenItem的集合,可以并行播放每一个Item
* @version Egret 3.1.8
* @platform Web,Native
* @includeExample extension/tween/TweenWrapper.ts
* @language zh_CN
*/
class TweenGroup extends EventDispatcher {
private completeCount;
constructor();
/**
* @private
*/
private _items;
/**
* The Array that TweenItems in TweenGroup.
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* TweenGroup要控制的TweenItem集合。
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
items: TweenItem[];
private registerEvent(add);
/**
* Play the all TweenItems
* @time The starting position, the default is from the last position to play。If use 0, the group will play from the start position.
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 播放所有的TweenItem
* @time 播放的起始位置, 默认为从上次位置继续播放。如果为0,则从起始位置开始播放。
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
play(time?: number): void;
/**
* Pause the all TweenItems
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 暂停播放所有的TweenItem
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
pause(): void;
/**
* Stop the all TweenItems
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 停止所有的TweenItem
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
stop(): void;
private itemComplete(e);
}
}
var __reflect = (this && this.__reflect) || function (p, c, t) {
p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;
};
var __extends = this && this.__extends || function __extends(t, e) {
function r() {
this.constructor = t;
}
for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]);
r.prototype = e.prototype, t.prototype = new r();
};
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
var egret;
(function (egret) {
/**
* Easing function set. Different easing functions are used to make an animation proceed according to the corresponding equation
* @see http://edn.egret.com/cn/index.php/article/index/id/53 Easing effect Demo
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 缓动函数集合,使用不同的缓动函数使得动画按照对应的方程进行
* @see http://edn.egret.com/cn/index.php/article/index/id/53 缓动效果演示
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
var Ease = (function () {
/**
* @version Egret 2.4
* @platform Web,Native
*/
function Ease() {
egret.$error(1014);
}
/**
* get.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.get = function (amount) {
if (amount < -1) {
amount = -1;
}
if (amount > 1) {
amount = 1;
}
return function (t) {
if (amount == 0) {
return t;
}
if (amount < 0) {
return t * (t * -amount + 1 + amount);
}
return t * ((2 - t) * amount + (1 - amount));
};
};
/**
* get pow in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get pow in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.getPowIn = function (pow) {
return function (t) {
return Math.pow(t, pow);
};
};
/**
* get pow out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get pow out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.getPowOut = function (pow) {
return function (t) {
return 1 - Math.pow(1 - t, pow);
};
};
/**
* get pow in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get pow in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.getPowInOut = function (pow) {
return function (t) {
if ((t *= 2) < 1)
return 0.5 * Math.pow(t, pow);
return 1 - 0.5 * Math.abs(Math.pow(2 - t, pow));
};
};
/**
* sine in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* sine in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.sineIn = function (t) {
return 1 - Math.cos(t * Math.PI / 2);
};
/**
* sine out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* sine out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.sineOut = function (t) {
return Math.sin(t * Math.PI / 2);
};
/**
* sine in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* sine in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.sineInOut = function (t) {
return -0.5 * (Math.cos(Math.PI * t) - 1);
};
/**
* get back in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get back in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.getBackIn = function (amount) {
return function (t) {
return t * t * ((amount + 1) * t - amount);
};
};
/**
* get back out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get back out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.getBackOut = function (amount) {
return function (t) {
return (--t * t * ((amount + 1) * t + amount) + 1);
};
};
/**
* get back in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get back in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.getBackInOut = function (amount) {
amount *= 1.525;
return function (t) {
if ((t *= 2) < 1)
return 0.5 * (t * t * ((amount + 1) * t - amount));
return 0.5 * ((t -= 2) * t * ((amount + 1) * t + amount) + 2);
};
};
/**
* circ in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* circ in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.circIn = function (t) {
return -(Math.sqrt(1 - t * t) - 1);
};
/**
* circ out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* circ out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.circOut = function (t) {
return Math.sqrt(1 - (--t) * t);
};
/**
* circ in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* circ in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.circInOut = function (t) {
if ((t *= 2) < 1) {
return -0.5 * (Math.sqrt(1 - t * t) - 1);
}
return 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1);
};
/**
* bounce in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* bounce in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.bounceIn = function (t) {
return 1 - Ease.bounceOut(1 - t);
};
/**
* bounce out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* bounce out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.bounceOut = function (t) {
if (t < 1 / 2.75) {
return (7.5625 * t * t);
}
else if (t < 2 / 2.75) {
return (7.5625 * (t -= 1.5 / 2.75) * t + 0.75);
}
else if (t < 2.5 / 2.75) {
return (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375);
}
else {
return (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375);
}
};
/**
* bounce in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* bounce in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.bounceInOut = function (t) {
if (t < 0.5)
return Ease.bounceIn(t * 2) * .5;
return Ease.bounceOut(t * 2 - 1) * 0.5 + 0.5;
};
/**
* get elastic in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get elastic in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.getElasticIn = function (amplitude, period) {
var pi2 = Math.PI * 2;
return function (t) {
if (t == 0 || t == 1)
return t;
var s = period / pi2 * Math.asin(1 / amplitude);
return -(amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * pi2 / period));
};
};
/**
* get elastic out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get elastic out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.getElasticOut = function (amplitude, period) {
var pi2 = Math.PI * 2;
return function (t) {
if (t == 0 || t == 1)
return t;
var s = period / pi2 * Math.asin(1 / amplitude);
return (amplitude * Math.pow(2, -10 * t) * Math.sin((t - s) * pi2 / period) + 1);
};
};
/**
* get elastic in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* get elastic in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.getElasticInOut = function (amplitude, period) {
var pi2 = Math.PI * 2;
return function (t) {
var s = period / pi2 * Math.asin(1 / amplitude);
if ((t *= 2) < 1)
return -0.5 * (amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * pi2 / period));
return amplitude * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * pi2 / period) * 0.5 + 1;
};
};
/**
* quad in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* quad in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.quadIn = Ease.getPowIn(2);
/**
* quad out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* quad out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.quadOut = Ease.getPowOut(2);
/**
* quad in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* quad in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.quadInOut = Ease.getPowInOut(2);
/**
* cubic in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* cubic in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.cubicIn = Ease.getPowIn(3);
/**
* cubic out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* cubic out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.cubicOut = Ease.getPowOut(3);
/**
* cubic in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* cubic in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.cubicInOut = Ease.getPowInOut(3);
/**
* quart in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* quart in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.quartIn = Ease.getPowIn(4);
/**
* quart out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* quart out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.quartOut = Ease.getPowOut(4);
/**
* quart in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* quart in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.quartInOut = Ease.getPowInOut(4);
/**
* quint in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* quint in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.quintIn = Ease.getPowIn(5);
/**
* quint out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* quint out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.quintOut = Ease.getPowOut(5);
/**
* quint in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* quint in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.quintInOut = Ease.getPowInOut(5);
/**
* back in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* back in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.backIn = Ease.getBackIn(1.7);
/**
* back out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* back out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.backOut = Ease.getBackOut(1.7);
/**
* back in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* back in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.backInOut = Ease.getBackInOut(1.7);
/**
* elastic in.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* elastic in。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.elasticIn = Ease.getElasticIn(1, 0.3);
/**
* elastic out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* elastic out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.elasticOut = Ease.getElasticOut(1, 0.3);
/**
* elastic in out.See example.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* elastic in out。请查看示例
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Ease.elasticInOut = Ease.getElasticInOut(1, 0.3 * 1.5);
return Ease;
}());
egret.Ease = Ease;
__reflect(Ease.prototype, "egret.Ease");
})(egret || (egret = {}));
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
var egret;
(function (egret) {
/**
* Tween is the animation easing class of Egret
* @see http://edn.egret.com/cn/docs/page/576 Tween ease animation
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/tween/Tween.ts
* @language en_US
*/
/**
* Tween是Egret的动画缓动类
* @see http://edn.egret.com/cn/docs/page/576 Tween缓动动画
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/tween/Tween.ts
* @language zh_CN
*/
var Tween = (function (_super) {
__extends(Tween, _super);
/**
* 创建一个 egret.Tween 对象
* @private
* @version Egret 2.4
* @platform Web,Native
*/
function Tween(target, props, pluginData) {
var _this = _super.call(this) || this;
/**
* @private
*/
_this._target = null;
/**
* @private
*/
_this._useTicks = false;
/**
* @private
*/
_this.ignoreGlobalPause = false;
/**
* @private
*/
_this.loop = false;
/**
* @private
*/
_this.pluginData = null;
/**
* @private
*/
_this._steps = null;
/**
* @private
*/
_this.paused = false;
/**
* @private
*/
_this.duration = 0;
/**
* @private
*/
_this._prevPos = -1;
/**
* @private
*/
_this.position = null;
/**
* @private
*/
_this._prevPosition = 0;
/**
* @private
*/
_this._stepPosition = 0;
/**
* @private
*/
_this.passive = false;
_this.initialize(target, props, pluginData);
return _this;
}
/**
* Activate an object and add a Tween animation to the object
* @param target {any} The object to be activated
* @param props {any} Parameters, support loop onChange onChangeObj
* @param pluginData {any} Write realized
* @param override {boolean} Whether to remove the object before adding a tween, the default value false
* Not recommended, you can use Tween.removeTweens(target) instead.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 激活一个对象,对其添加 Tween 动画
* @param target {any} 要激活 Tween 的对象
* @param props {any} 参数,支持loop(循环播放) onChange(变化函数) onChangeObj(变化函数作用域)
* @param pluginData {any} 暂未实现
* @param override {boolean} 是否移除对象之前添加的tween,默认值false。
* 不建议使用,可使用 Tween.removeTweens(target) 代替。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Tween.get = function (target, props, pluginData, override) {
if (pluginData === void 0) { pluginData = null; }
if (override === void 0) { override = false; }
if (override) {
Tween.removeTweens(target);
}
return new Tween(target, props, pluginData);
};
/**
* Delete all Tween animations from an object
* @param target The object whose Tween to be deleted
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 删除一个对象上的全部 Tween 动画
* @param target 需要移除 Tween 的对象
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Tween.removeTweens = function (target) {
if (!target.tween_count) {
return;
}
var tweens = Tween._tweens;
for (var i = tweens.length - 1; i >= 0; i--) {
if (tweens[i]._target == target) {
tweens[i].paused = true;
tweens.splice(i, 1);
}
}
target.tween_count = 0;
};
/**
* Pause all Tween animations of a certain object
* @param target The object whose Tween to be paused
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 暂停某个对象的所有 Tween
* @param target 要暂停 Tween 的对象
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Tween.pauseTweens = function (target) {
if (!target.tween_count) {
return;
}
var tweens = egret.Tween._tweens;
for (var i = tweens.length - 1; i >= 0; i--) {
if (tweens[i]._target == target) {
tweens[i].paused = true;
}
}
};
/**
* Resume playing all easing of a certain object
* @param target The object whose Tween to be resumed
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 继续播放某个对象的所有缓动
* @param target 要继续播放 Tween 的对象
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Tween.resumeTweens = function (target) {
if (!target.tween_count) {
return;
}
var tweens = egret.Tween._tweens;
for (var i = tweens.length - 1; i >= 0; i--) {
if (tweens[i]._target == target) {
tweens[i].paused = false;
}
}
};
/**
* @private
*
* @param delta
* @param paused
*/
Tween.tick = function (timeStamp, paused) {
if (paused === void 0) { paused = false; }
var delta = timeStamp - Tween._lastTime;
Tween._lastTime = timeStamp;
var tweens = Tween._tweens.concat();
for (var i = tweens.length - 1; i >= 0; i--) {
var tween_1 = tweens[i];
if ((paused && !tween_1.ignoreGlobalPause) || tween_1.paused) {
continue;
}
tween_1.$tick(tween_1._useTicks ? 1 : delta);
}
return false;
};
/**
* @private
*
* @param tween
* @param value
*/
Tween._register = function (tween, value) {
var target = tween._target;
var tweens = Tween._tweens;
if (value) {
if (target) {
target.tween_count = target.tween_count > 0 ? target.tween_count + 1 : 1;
}
tweens.push(tween);
if (!Tween._inited) {
Tween._lastTime = egret.getTimer();
egret.ticker.$startTick(Tween.tick, null);
Tween._inited = true;
}
}
else {
if (target) {
target.tween_count--;
}
var i = tweens.length;
while (i--) {
if (tweens[i] == tween) {
tweens.splice(i, 1);
return;
}
}
}
};
/**
* Delete all Tween
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 删除所有 Tween
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Tween.removeAllTweens = function () {
var tweens = Tween._tweens;
for (var i = 0, l = tweens.length; i < l; i++) {
var tween_2 = tweens[i];
tween_2.paused = true;
tween_2._target.tween_count = 0;
}
tweens.length = 0;
};
/**
* @private
*
* @param target
* @param props
* @param pluginData
*/
Tween.prototype.initialize = function (target, props, pluginData) {
this._target = target;
if (props) {
this._useTicks = props.useTicks;
this.ignoreGlobalPause = props.ignoreGlobalPause;
this.loop = props.loop;
props.onChange && this.addEventListener("change", props.onChange, props.onChangeObj);
if (props.override) {
Tween.removeTweens(target);
}
}
this.pluginData = pluginData || {};
this._curQueueProps = {};
this._initQueueProps = {};
this._steps = [];
if (props && props.paused) {
this.paused = true;
}
else {
Tween._register(this, true);
}
if (props && props.position != null) {
this.setPosition(props.position, Tween.NONE);
}
};
/**
* @private
*
* @param value
* @param actionsMode
* @returns
*/
Tween.prototype.setPosition = function (value, actionsMode) {
if (actionsMode === void 0) { actionsMode = 1; }
if (value < 0) {
value = 0;
}
//正常化位置
var t = value;
var end = false;
if (t >= this.duration) {
if (this.loop) {
var newTime = t % this.duration;
if (t > 0 && newTime === 0) {
t = this.duration;
}
else {
t = newTime;
}
}
else {
t = this.duration;
end = true;
}
}
if (t == this._prevPos) {
return end;
}
if (end) {
this.setPaused(true);
}
var prevPos = this._prevPos;
this.position = this._prevPos = t;
this._prevPosition = value;
if (this._target) {
if (this._steps.length > 0) {
// 找到新的tween
var l = this._steps.length;
var stepIndex = -1;
for (var i = 0; i < l; i++) {
if (this._steps[i].type == "step") {
stepIndex = i;
if (this._steps[i].t <= t && this._steps[i].t + this._steps[i].d >= t) {
break;
}
}
}
for (var i = 0; i < l; i++) {
if (this._steps[i].type == "action") {
//执行actions
if (actionsMode != 0) {
if (this._useTicks) {
this._runAction(this._steps[i], t, t);
}
else if (actionsMode == 1 && t < prevPos) {
if (prevPos != this.duration) {
this._runAction(this._steps[i], prevPos, this.duration);
}
this._runAction(this._steps[i], 0, t, true);
}
else {
this._runAction(this._steps[i], prevPos, t);
}
}
}
else if (this._steps[i].type == "step") {
if (stepIndex == i) {
var step = this._steps[stepIndex];
this._updateTargetProps(step, Math.min((this._stepPosition = t - step.t) / step.d, 1));
}
}
}
}
}
this.dispatchEventWith("change");
return end;
};
/**
* @private
*
* @param startPos
* @param endPos
* @param includeStart
*/
Tween.prototype._runAction = function (action, startPos, endPos, includeStart) {
if (includeStart === void 0) { includeStart = false; }
var sPos = startPos;
var ePos = endPos;
if (startPos > endPos) {
//把所有的倒置
sPos = endPos;
ePos = startPos;
}
var pos = action.t;
if (pos == ePos || (pos > sPos && pos < ePos) || (includeStart && pos == startPos)) {
action.f.apply(action.o, action.p);
}
};
/**
* @private
*
* @param step
* @param ratio
*/
Tween.prototype._updateTargetProps = function (step, ratio) {
var p0, p1, v, v0, v1, arr;
if (!step && ratio == 1) {
this.passive = false;
p0 = p1 = this._curQueueProps;
}
else {
this.passive = !!step.v;
//不更新props.
if (this.passive) {
return;
}
//使用ease
if (step.e) {
ratio = step.e(ratio, 0, 1, 1);
}
p0 = step.p0;
p1 = step.p1;
}
for (var n in this._initQueueProps) {
if ((v0 = p0[n]) == null) {
p0[n] = v0 = this._initQueueProps[n];
}
if ((v1 = p1[n]) == null) {
p1[n] = v1 = v0;
}
if (v0 == v1 || ratio == 0 || ratio == 1 || (typeof (v0) != "number")) {
v = ratio == 1 ? v1 : v0;
}
else {
v = v0 + (v1 - v0) * ratio;
}
var ignore = false;
if (arr = Tween._plugins[n]) {
for (var i = 0, l = arr.length; i < l; i++) {
var v2 = arr[i].tween(this, n, v, p0, p1, ratio, !!step && p0 == p1, !step);
if (v2 == Tween.IGNORE) {
ignore = true;
}
else {
v = v2;
}
}
}
if (!ignore) {
this._target[n] = v;
}
}
};
/**
* Whether setting is paused
* @param value {boolean} Whether to pause
* @returns Tween object itself
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 设置是否暂停
* @param value {boolean} 是否暂停
* @returns Tween对象本身
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Tween.prototype.setPaused = function (value) {
if (this.paused == value) {
return this;
}
this.paused = value;
Tween._register(this, !value);
return this;
};
/**
* @private
*
* @param props
* @returns
*/
Tween.prototype._cloneProps = function (props) {
var o = {};
for (var n in props) {
o[n] = props[n];
}
return o;
};
/**
* @private
*
* @param o
* @returns
*/
Tween.prototype._addStep = function (o) {
if (o.d > 0) {
o.type = "step";
this._steps.push(o);
o.t = this.duration;
this.duration += o.d;
}
return this;
};
/**
* @private
*
* @param o
* @returns
*/
Tween.prototype._appendQueueProps = function (o) {
var arr, oldValue, i, l, injectProps;
for (var n in o) {
if (this._initQueueProps[n] === undefined) {
oldValue = this._target[n];
//设置plugins
if (arr = Tween._plugins[n]) {
for (i = 0, l = arr.length; i < l; i++) {
oldValue = arr[i].init(this, n, oldValue);
}
}
this._initQueueProps[n] = this._curQueueProps[n] = (oldValue === undefined) ? null : oldValue;
}
else {
oldValue = this._curQueueProps[n];
}
}
for (var n in o) {
oldValue = this._curQueueProps[n];
if (arr = Tween._plugins[n]) {
injectProps = injectProps || {};
for (i = 0, l = arr.length; i < l; i++) {
if (arr[i].step) {
arr[i].step(this, n, oldValue, o[n], injectProps);
}
}
}
this._curQueueProps[n] = o[n];
}
if (injectProps) {
this._appendQueueProps(injectProps);
}
return this._curQueueProps;
};
/**
* @private
*
* @param o
* @returns
*/
Tween.prototype._addAction = function (o) {
o.t = this.duration;
o.type = "action";
this._steps.push(o);
return this;
};
/**
* @private
*
* @param props
* @param o
*/
Tween.prototype._set = function (props, o) {
for (var n in props) {
o[n] = props[n];
}
};
/**
* Wait the specified milliseconds before the execution of the next animation
* @param duration {number} Waiting time, in milliseconds
* @param passive {boolean} Whether properties are updated during the waiting time
* @returns Tween object itself
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 等待指定毫秒后执行下一个动画
* @param duration {number} 要等待的时间,以毫秒为单位
* @param passive {boolean} 等待期间属性是否会更新
* @returns Tween对象本身
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Tween.prototype.wait = function (duration, passive) {
if (duration == null || duration <= 0) {
return this;
}
var o = this._cloneProps(this._curQueueProps);
return this._addStep({ d: duration, p0: o, p1: o, v: passive });
};
/**
* Modify the property of the specified object to a specified value
* @param props {Object} Property set of an object
* @param duration {number} Duration
* @param ease {egret.Ease} Easing algorithm
* @returns {egret.Tween} Tween object itself
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 将指定对象的属性修改为指定值
* @param props {Object} 对象的属性集合
* @param duration {number} 持续时间
* @param ease {egret.Ease} 缓动算法
* @returns {egret.Tween} Tween对象本身
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
Tween.prototype.to = function (props, duration, ease) {
if (ease === void 0) { ease = undefined; }
if (isNaN(duration) || duration < 0) {
duration = 0;
}
this._addStep({ d: duration || 0, p0: this._cloneProps(this._curQueueProps), e: ease, p1: this._cloneProps(this._appendQueueProps(props)) });
//加入一步set,防止游戏极其卡顿时候,to后面的call取到的属性值不对
return this.set(props);
};
/**
* Execute callback function
* @param callback {Function} Callback method
* @param thisObj {any} this action scope of the callback method
* @param params {any[]} Parameter of the callback method
* @returns {egret.Tween} Tween object itself
* @version Egret 2.4
* @platform Web,Native
* @example
* <pre>
* 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"]);
* </pre>
* @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
* <pre>
* egret.Tween.get(display).call(function (a:number, b:string) {
* console.log("a: " + a); //对应传入的第一个参数 233
* console.log("b: " + b); //对应传入的第二个参数 “hello”
* }, this, [233, "hello"]);
* </pre>
* @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 <code>Tween.to</code>
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 表示一个to动作,参见<code>Tween.to</code>
* @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 <code>Tween.wait</code>
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 表示一个wait动作,参见<code>Tween.wait</code>
* @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 <code>Tween.set</code>
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 表示一个set动作,参见<code>Tween.set</code>
* @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 <code>Tween.tick</code>
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 表示一个tick动作,参见<code>Tween.tick</code>
* @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:
* ```
* <tween:TweenItem target="{this.button}">
* <tween:props>
* <e:Object loop="{true}"/>
* </tween:props>
* <tween:paths>
* <e:Array>
* <tween:To duration="500">
* <tween:props>
* <e:Object x="{100}" y="{200}" />
* </tween:props>
* </tween:To>
* <tween:Wait duration="1000" />
* <tween:To duration="1000">
* <tween:props>
* <e:Object x="{200}" y="{100}" />
* </tween:props>
* </tween:To>
* </e:Array>
* </tween:paths>
* </tween:TweenItem>
* ```
*/
var TweenItem = (function (_super) {
__extends(TweenItem, _super);
function TweenItem() {
var _this = _super.call(this) || this;
_this.isStop = false;
return _this;
}
Object.defineProperty(TweenItem.prototype, "props", {
/**
* The Tween's props.
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* Tween的props参数。
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
get: function () {
return this._props;
},
set: function (value) {
this._props = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TweenItem.prototype, "target", {
/**
* The Tween's target.
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* Tween的target参数。
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
get: function () {
return this._target;
},
set: function (value) {
this._target = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TweenItem.prototype, "paths", {
/**
* The Actions in Tween.
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* TweenItem中添加的行为。
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
get: function () {
return this._paths;
},
set: function (value) {
this._paths = value || [];
},
enumerable: true,
configurable: true
});
/**
* Play the Tween
* @position The starting position, the default is from the last position to play
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 播放Tween
* @position 播放的起始位置, 默认为从上次位置继续播放
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
TweenItem.prototype.play = function (position) {
if (!this.tween) {
this.createTween(position);
}
else {
this.tween.setPaused(false);
if (this.isStop && position == undefined) {
position = 0;
this.isStop = false;
}
if (position !== undefined && position !== null) {
this.tween.setPosition(position);
}
}
};
/**
* Pause the Tween
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 暂停Tween
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
TweenItem.prototype.pause = function () {
if (this.tween) {
this.tween.setPaused(true);
}
};
/**
* Stop the Tween
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 停止Tween
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
TweenItem.prototype.stop = function () {
this.pause();
this.isStop = true;
};
TweenItem.prototype.createTween = function (position) {
this.tween = egret.Tween.get(this._target, this._props);
if (this._paths) {
this.applyPaths();
}
if (position !== undefined && position !== null) {
this.tween.setPosition(position);
}
};
TweenItem.prototype.applyPaths = function () {
for (var i = 0; i < this._paths.length; i++) {
var path = this._paths[i];
this.applyPath(path);
}
};
TweenItem.prototype.applyPath = function (path) {
var _this = this;
if (path instanceof To) {
this.tween.to(path.props, path.duration, convertEase(path.ease));
}
else if (path instanceof Wait) {
this.tween.wait(path.duration, path.passive);
}
else if (path instanceof Set) {
this.tween.set(path.props);
}
else if (path instanceof Tick) {
this.tween.$tick(path.delta);
}
this.tween.call(function () { return _this.pathComplete(path); });
};
TweenItem.prototype.pathComplete = function (path) {
path.dispatchEventWith('complete');
this.dispatchEventWith('pathComplete', false, path);
var index = this._paths.indexOf(path);
if (index >= 0 && index === this._paths.length - 1) {
this.dispatchEventWith('complete');
}
};
return TweenItem;
}(egret.EventDispatcher));
tween.TweenItem = TweenItem;
__reflect(TweenItem.prototype, "egret.tween.TweenItem");
registerProperty(TweenItem, 'paths', 'Array', true);
/**
* TweenGroup is a collection of TweenItem that can be played in parallel with each Item
*
* @event itemComplete Dispatched when some TweenItem has complete.
* @event complete Dispatched when all TweenItems has complete.
*
* @version Egret 3.1.8
* @platform Web,Native
* @includeExample extension/tween/TweenWrapper.ts
* @language en_US
*/
/**
* TweenGroup是TweenItem的集合,可以并行播放每一个Item
* @version Egret 3.1.8
* @platform Web,Native
* @includeExample extension/tween/TweenWrapper.ts
* @language zh_CN
*/
var TweenGroup = (function (_super) {
__extends(TweenGroup, _super);
function TweenGroup() {
var _this = _super.call(this) || this;
_this.completeCount = 0;
return _this;
}
Object.defineProperty(TweenGroup.prototype, "items", {
/**
* The Array that TweenItems in TweenGroup.
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* TweenGroup要控制的TweenItem集合。
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
get: function () {
return this._items;
},
set: function (value) {
this.completeCount = 0;
this.registerEvent(false);
this._items = value;
this.registerEvent(true);
},
enumerable: true,
configurable: true
});
TweenGroup.prototype.registerEvent = function (add) {
var _this = this;
this._items && this._items.forEach(function (item) {
if (add) {
item.addEventListener('complete', _this.itemComplete, _this);
}
else {
item.removeEventListener('complete', _this.itemComplete, _this);
}
});
};
/**
* Play the all TweenItems
* @time The starting position, the default is from the last position to play。If use 0, the group will play from the start position.
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 播放所有的TweenItem
* @time 播放的起始位置, 默认为从上次位置继续播放。如果为0,则从起始位置开始播放。
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
TweenGroup.prototype.play = function (time) {
if (!this._items) {
return;
}
for (var i = 0; i < this._items.length; i++) {
var item = this._items[i];
item.play(time);
}
};
/**
* Pause the all TweenItems
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 暂停播放所有的TweenItem
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
TweenGroup.prototype.pause = function () {
if (!this._items) {
return;
}
for (var i = 0; i < this._items.length; i++) {
var item = this._items[i];
item.pause();
}
};
/**
* Stop the all TweenItems
* @version Egret 3.1.8
* @platform Web,Native
* @language en_US
*/
/**
* 停止所有的TweenItem
* @version Egret 3.1.8
* @platform Web,Native
* @language zh_CN
*/
TweenGroup.prototype.stop = function () {
if (!this._items) {
return;
}
for (var i = 0; i < this._items.length; i++) {
var item = this._items[i];
item.stop();
}
};
TweenGroup.prototype.itemComplete = function (e) {
var item = e.currentTarget;
this.completeCount++;
this.dispatchEventWith('itemComplete', false, item);
if (this.completeCount === this.items.length) {
this.dispatchEventWith('complete');
this.completeCount = 0;
}
};
return TweenGroup;
}(egret.EventDispatcher));
tween.TweenGroup = TweenGroup;
__reflect(TweenGroup.prototype, "egret.tween.TweenGroup");
registerProperty(TweenGroup, 'items', 'Array', true);
function registerProperty(classDefinition, property, type, asDefault) {
var prototype = classDefinition.prototype;
prototype.__meta__ = prototype.__meta__ || {};
prototype.__meta__[property] = type;
if (asDefault) {
prototype.__defaultProperty__ = property;
}
}
})(tween = egret.tween || (egret.tween = {}));
})(egret || (egret = {}));
var __reflect=this&&this.__reflect||function(t,e,n){t.__class__=e,n?n.push(e):n=[e],t.__types__=t.__types__?n.concat(t.__types__):n},__extends=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);n.prototype=e.prototype,t.prototype=new n},egret;!function(t){var e=function(){function e(){t.$error(1014)}return e.get=function(t){return-1>t&&(t=-1),t>1&&(t=1),function(e){return 0==t?e:0>t?e*(e*-t+1+t):e*((2-e)*t+(1-t))}},e.getPowIn=function(t){return function(e){return Math.pow(e,t)}},e.getPowOut=function(t){return function(e){return 1-Math.pow(1-e,t)}},e.getPowInOut=function(t){return function(e){return(e*=2)<1?.5*Math.pow(e,t):1-.5*Math.abs(Math.pow(2-e,t))}},e.sineIn=function(t){return 1-Math.cos(t*Math.PI/2)},e.sineOut=function(t){return Math.sin(t*Math.PI/2)},e.sineInOut=function(t){return-.5*(Math.cos(Math.PI*t)-1)},e.getBackIn=function(t){return function(e){return e*e*((t+1)*e-t)}},e.getBackOut=function(t){return function(e){return--e*e*((t+1)*e+t)+1}},e.getBackInOut=function(t){return t*=1.525,function(e){return(e*=2)<1?.5*(e*e*((t+1)*e-t)):.5*((e-=2)*e*((t+1)*e+t)+2)}},e.circIn=function(t){return-(Math.sqrt(1-t*t)-1)},e.circOut=function(t){return Math.sqrt(1- --t*t)},e.circInOut=function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},e.bounceIn=function(t){return 1-e.bounceOut(1-t)},e.bounceOut=function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},e.bounceInOut=function(t){return.5>t?.5*e.bounceIn(2*t):.5*e.bounceOut(2*t-1)+.5},e.getElasticIn=function(t,e){var n=2*Math.PI;return function(i){if(0==i||1==i)return i;var s=e/n*Math.asin(1/t);return-(t*Math.pow(2,10*(i-=1))*Math.sin((i-s)*n/e))}},e.getElasticOut=function(t,e){var n=2*Math.PI;return function(i){if(0==i||1==i)return i;var s=e/n*Math.asin(1/t);return t*Math.pow(2,-10*i)*Math.sin((i-s)*n/e)+1}},e.getElasticInOut=function(t,e){var n=2*Math.PI;return function(i){var s=e/n*Math.asin(1/t);return(i*=2)<1?-.5*(t*Math.pow(2,10*(i-=1))*Math.sin((i-s)*n/e)):t*Math.pow(2,-10*(i-=1))*Math.sin((i-s)*n/e)*.5+1}},e.quadIn=e.getPowIn(2),e.quadOut=e.getPowOut(2),e.quadInOut=e.getPowInOut(2),e.cubicIn=e.getPowIn(3),e.cubicOut=e.getPowOut(3),e.cubicInOut=e.getPowInOut(3),e.quartIn=e.getPowIn(4),e.quartOut=e.getPowOut(4),e.quartInOut=e.getPowInOut(4),e.quintIn=e.getPowIn(5),e.quintOut=e.getPowOut(5),e.quintInOut=e.getPowInOut(5),e.backIn=e.getBackIn(1.7),e.backOut=e.getBackOut(1.7),e.backInOut=e.getBackInOut(1.7),e.elasticIn=e.getElasticIn(1,.3),e.elasticOut=e.getElasticOut(1,.3),e.elasticInOut=e.getElasticInOut(1,.3*1.5),e}();t.Ease=e,__reflect(e.prototype,"egret.Ease")}(egret||(egret={}));var egret;!function(t){var e=function(e){function n(t,n,i){var s=e.call(this)||this;return s._target=null,s._useTicks=!1,s.ignoreGlobalPause=!1,s.loop=!1,s.pluginData=null,s._steps=null,s.paused=!1,s.duration=0,s._prevPos=-1,s.position=null,s._prevPosition=0,s._stepPosition=0,s.passive=!1,s.initialize(t,n,i),s}return __extends(n,e),n.get=function(t,e,i,s){return void 0===i&&(i=null),void 0===s&&(s=!1),s&&n.removeTweens(t),new n(t,e,i)},n.removeTweens=function(t){if(t.tween_count){for(var e=n._tweens,i=e.length-1;i>=0;i--)e[i]._target==t&&(e[i].paused=!0,e.splice(i,1));t.tween_count=0}},n.pauseTweens=function(e){if(e.tween_count)for(var n=t.Tween._tweens,i=n.length-1;i>=0;i--)n[i]._target==e&&(n[i].paused=!0)},n.resumeTweens=function(e){if(e.tween_count)for(var n=t.Tween._tweens,i=n.length-1;i>=0;i--)n[i]._target==e&&(n[i].paused=!1)},n.tick=function(t,e){void 0===e&&(e=!1);var i=t-n._lastTime;n._lastTime=t;for(var s=n._tweens.concat(),r=s.length-1;r>=0;r--){var o=s[r];e&&!o.ignoreGlobalPause||o.paused||o.$tick(o._useTicks?1:i)}return!1},n._register=function(e,i){var s=e._target,r=n._tweens;if(i)s&&(s.tween_count=s.tween_count>0?s.tween_count+1:1),r.push(e),n._inited||(n._lastTime=t.getTimer(),t.ticker.$startTick(n.tick,null),n._inited=!0);else{s&&s.tween_count--;for(var o=r.length;o--;)if(r[o]==e)return void r.splice(o,1)}},n.removeAllTweens=function(){for(var t=n._tweens,e=0,i=t.length;i>e;e++){var s=t[e];s.paused=!0,s._target.tween_count=0}t.length=0},n.prototype.initialize=function(t,e,i){this._target=t,e&&(this._useTicks=e.useTicks,this.ignoreGlobalPause=e.ignoreGlobalPause,this.loop=e.loop,e.onChange&&this.addEventListener("change",e.onChange,e.onChangeObj),e.override&&n.removeTweens(t)),this.pluginData=i||{},this._curQueueProps={},this._initQueueProps={},this._steps=[],e&&e.paused?this.paused=!0:n._register(this,!0),e&&null!=e.position&&this.setPosition(e.position,n.NONE)},n.prototype.setPosition=function(t,e){void 0===e&&(e=1),0>t&&(t=0);var n=t,i=!1;if(n>=this.duration)if(this.loop){var s=n%this.duration;n=n>0&&0===s?this.duration:s}else n=this.duration,i=!0;if(n==this._prevPos)return i;i&&this.setPaused(!0);var r=this._prevPos;if(this.position=this._prevPos=n,this._prevPosition=t,this._target&&this._steps.length>0){for(var o=this._steps.length,u=-1,a=0;o>a&&!("step"==this._steps[a].type&&(u=a,this._steps[a].t<=n&&this._steps[a].t+this._steps[a].d>=n));a++);for(var a=0;o>a;a++)if("action"==this._steps[a].type)0!=e&&(this._useTicks?this._runAction(this._steps[a],n,n):1==e&&r>n?(r!=this.duration&&this._runAction(this._steps[a],r,this.duration),this._runAction(this._steps[a],0,n,!0)):this._runAction(this._steps[a],r,n));else if("step"==this._steps[a].type&&u==a){var p=this._steps[u];this._updateTargetProps(p,Math.min((this._stepPosition=n-p.t)/p.d,1))}}return this.dispatchEventWith("change"),i},n.prototype._runAction=function(t,e,n,i){void 0===i&&(i=!1);var s=e,r=n;e>n&&(s=n,r=e);var o=t.t;(o==r||o>s&&r>o||i&&o==e)&&t.f.apply(t.o,t.p)},n.prototype._updateTargetProps=function(t,e){var i,s,r,o,u,a;if(t||1!=e){if(this.passive=!!t.v,this.passive)return;t.e&&(e=t.e(e,0,1,1)),i=t.p0,s=t.p1}else this.passive=!1,i=s=this._curQueueProps;for(var p in this._initQueueProps){null==(o=i[p])&&(i[p]=o=this._initQueueProps[p]),null==(u=s[p])&&(s[p]=u=o),r=o==u||0==e||1==e||"number"!=typeof o?1==e?u:o:o+(u-o)*e;var h=!1;if(a=n._plugins[p])for(var c=0,_=a.length;_>c;c++){var f=a[c].tween(this,p,r,i,s,e,!!t&&i==s,!t);f==n.IGNORE?h=!0:r=f}h||(this._target[p]=r)}},n.prototype.setPaused=function(t){return this.paused==t?this:(this.paused=t,n._register(this,!t),this)},n.prototype._cloneProps=function(t){var e={};for(var n in t)e[n]=t[n];return e},n.prototype._addStep=function(t){return t.d>0&&(t.type="step",this._steps.push(t),t.t=this.duration,this.duration+=t.d),this},n.prototype._appendQueueProps=function(t){var e,i,s,r,o;for(var u in t)if(void 0===this._initQueueProps[u]){if(i=this._target[u],e=n._plugins[u])for(s=0,r=e.length;r>s;s++)i=e[s].init(this,u,i);this._initQueueProps[u]=this._curQueueProps[u]=void 0===i?null:i}else i=this._curQueueProps[u];for(var u in t){if(i=this._curQueueProps[u],e=n._plugins[u])for(o=o||{},s=0,r=e.length;r>s;s++)e[s].step&&e[s].step(this,u,i,t[u],o);this._curQueueProps[u]=t[u]}return o&&this._appendQueueProps(o),this._curQueueProps},n.prototype._addAction=function(t){return t.t=this.duration,t.type="action",this._steps.push(t),this},n.prototype._set=function(t,e){for(var n in t)e[n]=t[n]},n.prototype.wait=function(t,e){if(null==t||0>=t)return this;var n=this._cloneProps(this._curQueueProps);return this._addStep({d:t,p0:n,p1:n,v:e})},n.prototype.to=function(t,e,n){return void 0===n&&(n=void 0),(isNaN(e)||0>e)&&(e=0),this._addStep({d:e||0,p0:this._cloneProps(this._curQueueProps),e:n,p1:this._cloneProps(this._appendQueueProps(t))}),this.set(t)},n.prototype.call=function(t,e,n){return void 0===e&&(e=void 0),void 0===n&&(n=void 0),this._addAction({f:t,p:n?n:[],o:e?e:this._target})},n.prototype.set=function(t,e){return void 0===e&&(e=null),this._appendQueueProps(t),this._addAction({f:this._set,o:this,p:[t,e?e:this._target]})},n.prototype.play=function(t){return t||(t=this),this.call(t.setPaused,t,[!1])},n.prototype.pause=function(t){return t||(t=this),this.call(t.setPaused,t,[!0])},n.prototype.$tick=function(t){this.paused||this.setPosition(this._prevPosition+t)},n.NONE=0,n.LOOP=1,n.REVERSE=2,n._tweens=[],n.IGNORE={},n._plugins={},n._inited=!1,n._lastTime=0,n}(t.EventDispatcher);t.Tween=e,__reflect(e.prototype,"egret.Tween")}(egret||(egret={}));var egret;!function(t){var e;!function(e){function n(e){if("function"==typeof e)return e;var n=t.Ease[e];return"function"==typeof n?n:null}function i(t,e,n,i){var s=t.prototype;s.__meta__=s.__meta__||{},s.__meta__[e]=n,i&&(s.__defaultProperty__=e)}var s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="",e}return __extends(e,t),e}(t.EventDispatcher);e.BasePath=s,__reflect(s.prototype,"egret.tween.BasePath");var r=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.props=void 0,e.duration=500,e.ease=void 0,e}return __extends(e,t),e}(s);e.To=r,__reflect(r.prototype,"egret.tween.To");var o=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.duration=500,e.passive=void 0,e}return __extends(e,t),e}(s);e.Wait=o,__reflect(o.prototype,"egret.tween.Wait");var u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.props=void 0,e}return __extends(e,t),e}(s);e.Set=u,__reflect(u.prototype,"egret.tween.Set");var a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.delta=0,e}return __extends(e,t),e}(s);e.Tick=a,__reflect(a.prototype,"egret.tween.Tick");var p=function(e){function i(){var t=e.call(this)||this;return t.isStop=!1,t}return __extends(i,e),Object.defineProperty(i.prototype,"props",{get:function(){return this._props},set:function(t){this._props=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"target",{get:function(){return this._target},set:function(t){this._target=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"paths",{get:function(){return this._paths},set:function(t){this._paths=t||[]},enumerable:!0,configurable:!0}),i.prototype.play=function(t){this.tween?(this.tween.setPaused(!1),this.isStop&&void 0==t&&(t=0,this.isStop=!1),void 0!==t&&null!==t&&this.tween.setPosition(t)):this.createTween(t)},i.prototype.pause=function(){this.tween&&this.tween.setPaused(!0)},i.prototype.stop=function(){this.pause(),this.isStop=!0},i.prototype.createTween=function(e){this.tween=t.Tween.get(this._target,this._props),this._paths&&this.applyPaths(),void 0!==e&&null!==e&&this.tween.setPosition(e)},i.prototype.applyPaths=function(){for(var t=0;t<this._paths.length;t++){var e=this._paths[t];this.applyPath(e)}},i.prototype.applyPath=function(t){var e=this;t instanceof r?this.tween.to(t.props,t.duration,n(t.ease)):t instanceof o?this.tween.wait(t.duration,t.passive):t instanceof u?this.tween.set(t.props):t instanceof a&&this.tween.$tick(t.delta),this.tween.call(function(){return e.pathComplete(t)})},i.prototype.pathComplete=function(t){t.dispatchEventWith("complete"),this.dispatchEventWith("pathComplete",!1,t);var e=this._paths.indexOf(t);e>=0&&e===this._paths.length-1&&this.dispatchEventWith("complete")},i}(t.EventDispatcher);e.TweenItem=p,__reflect(p.prototype,"egret.tween.TweenItem"),i(p,"paths","Array",!0);var h=function(t){function e(){var e=t.call(this)||this;return e.completeCount=0,e}return __extends(e,t),Object.defineProperty(e.prototype,"items",{get:function(){return this._items},set:function(t){this.completeCount=0,this.registerEvent(!1),this._items=t,this.registerEvent(!0)},enumerable:!0,configurable:!0}),e.prototype.registerEvent=function(t){var e=this;this._items&&this._items.forEach(function(n){t?n.addEventListener("complete",e.itemComplete,e):n.removeEventListener("complete",e.itemComplete,e)})},e.prototype.play=function(t){if(this._items)for(var e=0;e<this._items.length;e++){var n=this._items[e];n.play(t)}},e.prototype.pause=function(){if(this._items)for(var t=0;t<this._items.length;t++){var e=this._items[t];e.pause()}},e.prototype.stop=function(){if(this._items)for(var t=0;t<this._items.length;t++){var e=this._items[t];e.stop()}},e.prototype.itemComplete=function(t){var e=t.currentTarget;this.completeCount++,this.dispatchEventWith("itemComplete",!1,e),this.completeCount===this.items.length&&(this.dispatchEventWith("complete"),this.completeCount=0)},e}(t.EventDispatcher);e.TweenGroup=h,__reflect(h.prototype,"egret.tween.TweenGroup"),i(h,"items","Array",!0)}(e=t.tween||(t.tween={}))}(egret||(egret={}));
\ No newline at end of file
{
"initial": [
"libs/modules/egret/egret.js",
"libs/modules/egret/egret.web.js",
"libs/modules/game/game.js",
"libs/modules/tween/tween.js",
"libs/modules/assetsmanager/assetsmanager.js",
"libs/modules/promise/promise.js"
],
"game": [
"bin-debug/LoadingUI.js",
"bin-debug/Main.js",
"bin-debug/Platform.js"
]
}
\ No newline at end of file
[
"<font color=0x00ff0c>Open-source</font>,<font color=0x00ff0c>Free</font>,<font color=0x00ff0c>Multi-platform</font>",
"Push <font color=0x00ff0c>Game </font>Forward",
"<font color=0x00ff0c>HTML5 </font>Game Engine"
]
\ No newline at end of file
{
"groups":[
{
"keys":"bg_jpg,egret_icon_png,description_json",
"name":"preload"
}],
"resources":[
{
"name":"bg_jpg",
"type":"image",
"url":"assets/bg.jpg"
},
{
"name":"egret_icon_png",
"type":"image",
"url":"assets/egret_icon.png"
},
{
"name":"description_json",
"type":"json",
"url":"config/description.json"
}]
}
\ No newline at end of file
/**
* ResourceManager 配置文件
*/
type ResourceManagerConfig = {
/**
* 构建与发布配置
*/
buildConfig: (param: BuildConfigParam) => UserConfig,
/**
* 设置资源类型
*/
typeSelector: (path: string) => (string | null | undefined)
/**
* 设置资源的合并策略
*/
mergeSelector?: (path: string) => (string | null | undefined),
/**
* 设置资源的命名策略
* beta 功能,请勿随意使用
*/
nameSelector?: (path: string) => (string | null | undefined)
}
/**
* 构建配置
*/
type UserConfig = {
/**
* 输出路径
*/
outputDir: string,
/**
* 插件
*/
commands: (string | plugins.Command)[]
}
type BuildConfigParam = {
/**
* 当前命令,build 或者 command
*/
readonly command: string;
/**
* 发布平台
*/
readonly target: string;
/**
* 开发者指定的版本号
*/
readonly version: string;
/**
* 项目名称
*/
readonly projectName: string;
/**
* 项目路径
*/
readonly projectRoot: string;
/**
* 项目配置
*/
readonly projectConfig: ProjectConfig;
}
type ProjectConfig = {
entryClassName: string;
orientation: string;
frameRate: number;
scaleMode: string;
contentWidth: number;
contentHeight: number;
showFPS: boolean;
fpsStyles: string;
showLog: boolean;
maxTouches: number;
}
/**
* 匹配机制,将满足 from 的文件输出为 to 格式的文件
* from 采用 glob 表达式 , to 包含 [path][name][hash][ext]四个变量
* 示例:{ from:"resource/**.*" , to:"[path][name]_[hash].[ext]" }
*/
type Matcher = {
from: string[],
to: string
}
declare namespace plugins {
interface CommandContext {
/**
* 可以用此接口进行文件创建
*/
createFile(relativeFilePath: string, contents: Buffer);
/**
* 构建配置
*/
buildConfig: BuildConfigParam;
/**
* 项目绝对路径
*/
projectRoot: string;
/**
* 项目输出绝对路径
*/
outputDir: string;
}
/**
* 构建管线命令
*/
interface Command {
/**
* 项目中的每个文件都会执行此函数,返回 file 表示保留此文件,返回 null 表示将此文件从构建管线中删除,即不会发布
*/
onFile?(file: File): Promise<File | null>
/**
* 项目中所有文件均执行完后,最终会执行此函数。
* 这个函数主要被用于创建新文件
*/
onFinish?(pluginContext?: CommandContext): Promise<void>
[options: string]: any;
}
interface File {
/**
* 文件内容的二进制流,如果开发者需要修改文件内容,请修改此属性
*/
contents: Buffer;
/**
* 文件绝对路径,如果开发者需要对文件进行重命名,请修改此属性
*/
path: string;
/**
* 文件所在的项目的项目路径
*/
readonly base: string;
/**
* 文件的相对于 base 属性的相对路径
*/
readonly relative: string;
/**
* 文件变更历史,history[0] 即 origin 属性
*/
readonly history: ReadonlyArray<string>;
/**
* 文件所在的文件夹的绝对路径
*/
readonly dirname: string;
/**
* 文件的文件名
*/
readonly basename: string;
/**
* 文件的扩展名
*/
readonly extname: string;
/**
* 文件的初始文件名
*/
readonly origin: string;
/**
* 其他自定义属性
*/
[customProperty: string]: any;
}
}
declare module 'built-in' {
/**
* 混淆插件参数,设置源代码和目标代码
*/
type UglifyPluginOption = { sources: string[], target: string };
type UglifyPluginOptions = UglifyPluginOption[];
/**
* 混淆插件
*/
export class UglifyPlugin implements plugins.Command {
constructor(mergeSelector: UglifyPluginOptions);
}
type LibraryType = "debug" | "release";
type CompilePluginOptions = { libraryType: LibraryType, defines?: any };
/**
* 编译命令
*/
export class CompilePlugin implements plugins.Command {
constructor(options: CompilePluginOptions);
}
/**
* EXML 插件,用于发布 EXML 文件
*/
export class ExmlPlugin implements plugins.Command {
constructor(publishPolicy: EXML_Publish_Policy);
}
/**
* 发布策略
* * default : 使用 egretProperties.json 中的 exmlPublishPolicy 中的策略
* * debug : 默认策略,用于开发环境
* * contents : 将 EXML 的内容写入到主题文件中
* * gjs : 将生成的JS文件写入到主题文件中
* * commonjs : 将EXML合并为一个 CommonJS 风格的文件
*/
type EXML_Publish_Policy = "default" | "debug" | "contents" | "gjs" | "commonjs"
/**
* 生成 manifest 文件,这个文件会被用于记录 JavaScript 文件的版本号
*/
export class ManifestPlugin implements plugins.Command {
constructor(options?: ManifestPluginOptions)
}
/**
* 生成文件的文件名
* 支持 json 与 js 两种格式
*/
type ManifestPluginOptions = {
output: string,
hash?: "crc32",
/**
* 是否输出转换过程
*/
verbose?: boolean
}
/**
* EmitResConfigFilePlugin 的参数
* * output: 生成路径,可以指定生成为 *.res.js 文件或者 *.res.json 文件
* * typeSelector: 根据文件路径决定文件类型
* * nameSelector: 根据文件路径决定文件的资源名
* * groupSelector: 根据文件路径决定资源所述的资源组
*/
type EmitResConfigFilePluginOptions = {
output: string,
typeSelector: (path: string) => string | null | undefined,
nameSelector: (path: string) => string | null | undefined,
groupSelector: (path: string) => string | null | undefined,
}
/**
* 生成 res.json 文件或者 res.js 文件
*/
export class EmitResConfigFilePlugin implements plugins.Command {
constructor(options: EmitResConfigFilePluginOptions)
}
/**
* 增量编译
* 这个插件生成的 JavaScript 代码不会被添加到构建管线中,后续其他插件无法获取生成的 js 文件
* 这个功能将会在未来被 watch 模式代替掉
*/
export class IncrementCompilePlugin implements plugins.Command {
}
/**
* 使用 TextureMerger 实现纹理自动合并,依赖 TextureMerger 1.7 以上的版本
*/
export class TextureMergerPlugin implements plugins.Command {
constructor();
}
type CleanPluginOptions = {
matchers: string[]
}
export class CleanPlugin implements plugins.Command {
constructor(options: CleanPluginOptions);
}
type RenamePluginOptions = {
/**
* 是否输出日志
*/
verbose?: boolean
/**
* 采用何种 hash 算法,目前暂时只支持 crc32
*/
hash?: "crc32"
/**
* 设置匹配规则,将指定文件进行改名
* 该参数是个数组,允许设置多个匹配规则
*/
matchers: Matcher[]
}
/**
* 修改文件名插件
*/
export class RenamePlugin implements plugins.Command {
constructor(options: RenamePluginOptions);
}
type ResSplitPluginOptions = {
/**
* 是否输出日志
*/
verbose?: boolean
/**
* 设置匹配规则,将指定文件拷贝至其他文件夹
* 该参数是个数组,允许设置多个匹配规则
*/
matchers: Matcher[]
}
export class ResSplitPlugin implements plugins.Command {
constructor(options: ResSplitPluginOptions);
}
type ZipPluginOptions = {
mergeSelector: (p: string) => string
}
export class ZipPlugin implements plugins.Command {
constructor(option: ZipPluginOptions);
}
}
\ No newline at end of file
import * as fs from 'fs';
import * as path from 'path';
type ManifestConfig = {
initial: string[],
game: string[]
}
export class BricksPlugin implements plugins.Command {
constructor() {
}
async onFile(file: plugins.File) {
const filename = file.origin;
if (filename == 'manifest.json') {
const contents = file.contents.toString();
const jsonData: ManifestConfig = JSON.parse(contents);
let content = '';
for (let item of jsonData.initial) {
if (item != 'js/promise.js' && item != 'js/promise.min.js') {
content += `BK.Script.loadlib("GameRes://${item}");\n`
}
if (item == "js/egret.js" || item == 'js/egret.min.js') {
content += `BK.Script.loadlib("GameRes://egret.bricks.js");\n`
}
}
for (let item of jsonData.game) {
content += `BK.Script.loadlib("GameRes://${item}");\n`
}
file.path = file.dirname + '/manifest.js'
file.contents = new Buffer(content);
} else if (filename == 'main.js') {
const content = file.contents.toString();
let result = content.replace(/RES\.loadConfig\("resource\/default\.res\.json", "resource\/"\)/gm, 'RES.loadConfig("GameRes://resource/default.res.json", "GameRes://resource/")');
result = result.replace(/eui\.Theme\("resource\/default\.thm\.json", _this\.stage\)/gm, 'eui.Theme("GameRes://resource/default.thm.json", _this.stage)');
file.path = file.dirname + '/main.js'
file.contents = new Buffer(result);
}
return file;
}
async onFinish(pluginContext) {
}
}
\ No newline at end of file
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import * as path from 'path';
import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin } from 'built-in';
import { BricksPlugin } from './bricks/bricks';
import { CustomPlugin } from './myplugin';
import * as defaultConfig from './config';
const config: ResourceManagerConfig = {
buildConfig: (params) => {
const { target, command, projectName, version } = params;
const outputDir = `../${projectName}_android/assets/game`;
return {
outputDir,
commands: [
// new CompilePlugin({ libraryType: "debug", defines: { DEBUG: false, RELEASE: true } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
new UglifyPlugin([{
sources: ["main.js"],
target: "main.min.js"
}]),
new ManifestPlugin({ output: 'manifest.json' })
]
}
},
mergeSelector: defaultConfig.mergeSelector,
typeSelector: defaultConfig.typeSelector
}
export = config;
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import * as path from 'path';
import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin } from 'built-in';
import { BricksPlugin } from './bricks/bricks';
import { CustomPlugin } from './myplugin';
import * as defaultConfig from './config';
const config: ResourceManagerConfig = {
buildConfig: (params) => {
const { target, command, projectName, version } = params;
const outputDir = `../${projectName}_bricks/PublicBrickEngineGame/Res`;
return {
outputDir,
commands: [
new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new ManifestPlugin({ output: 'manifest.json' }),
new BricksPlugin()
]
}
},
mergeSelector: defaultConfig.mergeSelector,
typeSelector: defaultConfig.typeSelector
}
export = config;
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import * as path from 'path';
import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin } from 'built-in';
import { BricksPlugin } from './bricks/bricks';
import { CustomPlugin } from './myplugin';
import * as defaultConfig from './config';
const config: ResourceManagerConfig = {
buildConfig: (params) => {
const { target, command, projectName, version } = params;
const outputDir = `../${projectName}_ios/assets/game`;
return {
outputDir,
commands: [
new CompilePlugin({ libraryType: "debug", defines: { DEBUG: false, RELEASE: true } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
new UglifyPlugin([{
sources: ["main.js"],
target: "main.min.js"
}]),
new ManifestPlugin({ output: 'manifest.json' })
]
}
},
mergeSelector: defaultConfig.mergeSelector,
typeSelector: defaultConfig.typeSelector
}
export = config;
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import * as path from 'path';
import { UglifyPlugin, IncrementCompilePlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin } from 'built-in';
import { WxgamePlugin } from './wxgame/wxgame';
import { BricksPlugin } from './bricks/bricks';
import { CustomPlugin } from './myplugin';
const config: ResourceManagerConfig = {
buildConfig: (params) => {
const { target, command, projectName, version } = params;
if (command == 'build') {
const outputDir = '.';
return {
outputDir,
commands: [
// new EmitResConfigFilePlugin({
// output: "resource/default.res.json",
// typeSelector: config.typeSelector,
// nameSelector: p => path.basename(p).replace(/\./gi, "_"),
// groupSelector: p => "preload"
// }),
new ExmlPlugin('debug'), // 非 EUI 项目关闭此设置
new IncrementCompilePlugin(),
]
}
}
else if (command == 'publish') {
const outputDir = `bin-release/web/${version}`;
return {
outputDir,
commands: [
new CustomPlugin(),
new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new UglifyPlugin([{
sources: ["main.js"],
target: "main.min.js"
}]),
new ManifestPlugin({ output: "manifest.json", hash: "crc32" })
]
}
}
else {
throw `unknown command : ${params.command}`
}
},
mergeSelector: (path) => {
if (path.indexOf("assets/bitmap/") >= 0) {
return "assets/bitmap/sheet.sheet"
}
else if (path.indexOf("armature") >= 0 && path.indexOf(".json") >= 0) {
return "assets/armature/1.zip";
}
},
typeSelector: (path) => {
const ext = path.substr(path.lastIndexOf(".") + 1);
const typeMap = {
"jpg": "image",
"png": "image",
"webp": "image",
"json": "json",
"fnt": "font",
"pvr": "pvr",
"mp3": "sound",
"zip": "zip",
"sheet": "sheet",
"exml": "text"
}
let type = typeMap[ext];
if (type == "json") {
if (path.indexOf("sheet") >= 0) {
type = "sheet";
} else if (path.indexOf("movieclip") >= 0) {
type = "movieclip";
};
}
return type;
}
}
export = config;
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>
import * as path from 'path';
import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in';
import { WxgamePlugin } from './wxgame/wxgame';
import { CustomPlugin } from './myplugin';
import * as defaultConfig from './config';
const config: ResourceManagerConfig = {
buildConfig: (params) => {
const { target, command, projectName, version } = params;
const outputDir = `../${projectName}_wxgame`;
if (command == 'build') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new WxgamePlugin(),
new ManifestPlugin({ output: 'manifest.js' })
]
}
}
else if (command == 'publish') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new WxgamePlugin(),
new UglifyPlugin([{
sources: ["main.js"],
target: "main.min.js"
}
]),
new ManifestPlugin({ output: 'manifest.js' })
]
}
}
else {
throw `unknown command : ${params.command}`;
}
},
mergeSelector: defaultConfig.mergeSelector,
typeSelector: defaultConfig.typeSelector
}
export = config;
/**
* 示例自定义插件,您可以查阅 http://developer.egret.com/cn/2d/projectConfig/cmdExtensionPluginin/
* 了解如何开发一个自定义插件
*/
export class CustomPlugin implements plugins.Command {
constructor() {
}
async onFile(file: plugins.File) {
return file;
}
async onFinish(commandContext: plugins.CommandContext) {
}
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"compilerOptions": {
/* Basic Options */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */
"lib": [
"es5",
"es2015.promise"
], /* Specify library files to be included in the compilation: */
"allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": false /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
/* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
/* Source Map Options */
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
}
}
\ No newline at end of file
import * as fs from 'fs';
import * as path from 'path';
export class WxgamePlugin implements plugins.Command {
constructor() {
}
async onFile(file: plugins.File) {
if (file.extname == '.js') {
const filename = file.origin;
if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') {
return null;
}
if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') {
let content = file.contents.toString();
content += `;window.egret = egret;`;
content = content.replace(/definition = __global/, "definition = window");
file.contents = new Buffer(content);
}
else {
let content = file.contents.toString();
if (
filename == "libs/modules/res/res.js" ||
filename == 'libs/modules/res/res.min.js' ||
filename == 'libs/modules/assetsmanager/assetsmanager.min.js' ||
filename == 'libs/modules/assetsmanager/assetsmanager.js'
) {
content += ";window.RES = RES;"
}
if (filename == "libs/modules/eui/eui.js" || filename == 'libs/modules/eui/eui.min.js') {
content += ";window.eui = eui;"
}
if (filename == 'libs/modules/dragonBones/dragonBones.js' || filename == 'libs/modules/dragonBones/dragonBones.min.js') {
content += ';window.dragonBones = dragonBones';
}
content = "var egret = window.egret;" + content;
if (filename == 'main.js') {
content += ";window.Main = Main;"
}
file.contents = new Buffer(content);
}
}
return file;
}
async onFinish(pluginContext: plugins.CommandContext) {
//同步 index.html 配置到 game.js
const gameJSPath = path.join(pluginContext.outputDir, "game.js");
let gameJSContent = fs.readFileSync(gameJSPath, { encoding: "utf8" });
const projectConfig = pluginContext.buildConfig.projectConfig;
const optionStr =
`entryClassName: ${projectConfig.entryClassName},\n\t\t` +
`orientation: ${projectConfig.orientation},\n\t\t` +
`frameRate: ${projectConfig.frameRate},\n\t\t` +
`scaleMode: ${projectConfig.scaleMode},\n\t\t` +
`contentWidth: ${projectConfig.contentWidth},\n\t\t` +
`contentHeight: ${projectConfig.contentHeight},\n\t\t` +
`showFPS: ${projectConfig.showFPS},\n\t\t` +
`fpsStyles: ${projectConfig.fpsStyles},\n\t\t` +
`showLog: ${projectConfig.showLog},\n\t\t` +
`maxTouches: ${projectConfig.maxTouches},`;
const reg = /\/\/----auto option start----[\s\S]*\/\/----auto option end----/;
const replaceStr = '\/\/----auto option start----\n\t\t' + optionStr + '\n\t\t\/\/----auto option end----';
gameJSContent = gameJSContent.replace(reg, replaceStr);
fs.writeFileSync(gameJSPath, gameJSContent);
//修改横竖屏
let orientation;
if (projectConfig.orientation == '"landscape"') {
orientation = "landscape";
}
else {
orientation = "portrait";
}
const gameJSONPath = path.join(pluginContext.outputDir, "game.json");
let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" }));
gameJSONContent.deviceOrientation = orientation;
fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t"));
}
}
\ No newline at end of file
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
class LoadingUI extends egret.Sprite implements RES.PromiseTaskReporter {
public constructor() {
super();
this.createView();
}
private textField: egret.TextField;
private createView(): void {
this.textField = new egret.TextField();
this.addChild(this.textField);
this.textField.y = 300;
this.textField.width = 480;
this.textField.height = 100;
this.textField.textAlign = "center";
}
public onProgress(current: number, total: number): void {
this.textField.text = `Loading...${current}/${total}`;
}
}
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
class Main extends egret.DisplayObjectContainer {
public constructor() {
super();
this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
}
private onAddToStage(event: egret.Event) {
egret.lifecycle.addLifecycleListener((context) => {
// custom lifecycle plugin
context.onUpdate = () => {
}
})
egret.lifecycle.onPause = () => {
egret.ticker.pause();
}
egret.lifecycle.onResume = () => {
egret.ticker.resume();
}
this.runGame().catch(e => {
console.log(e);
})
}
private async runGame() {
await this.loadResource()
this.createGameScene();
const result = await RES.getResAsync("description_json")
this.startAnimation(result);
await platform.login();
const userInfo = await platform.getUserInfo();
console.log(userInfo);
}
private async loadResource() {
try {
const loadingView = new LoadingUI();
this.stage.addChild(loadingView);
await RES.loadConfig("resource/default.res.json", "resource/");
await RES.loadGroup("preload", 0, loadingView);
this.stage.removeChild(loadingView);
}
catch (e) {
console.error(e);
}
}
private textfield: egret.TextField;
/**
* 创建游戏场景
* Create a game scene
*/
private createGameScene() {
let sky = this.createBitmapByName("bg_jpg");
this.addChild(sky);
let stageW = this.stage.stageWidth;
let stageH = this.stage.stageHeight;
sky.width = stageW;
sky.height = stageH;
let topMask = new egret.Shape();
topMask.graphics.beginFill(0x000000, 0.5);
topMask.graphics.drawRect(0, 0, stageW, 172);
topMask.graphics.endFill();
topMask.y = 33;
this.addChild(topMask);
let icon = this.createBitmapByName("egret_icon_png");
this.addChild(icon);
icon.x = 26;
icon.y = 33;
let line = new egret.Shape();
line.graphics.lineStyle(2, 0xffffff);
line.graphics.moveTo(0, 0);
line.graphics.lineTo(0, 117);
line.graphics.endFill();
line.x = 172;
line.y = 61;
this.addChild(line);
let colorLabel = new egret.TextField();
colorLabel.textColor = 0xffffff;
colorLabel.width = stageW - 172;
colorLabel.textAlign = "center";
colorLabel.text = "Hello Egret";
colorLabel.size = 24;
colorLabel.x = 172;
colorLabel.y = 80;
this.addChild(colorLabel);
let textfield = new egret.TextField();
this.addChild(textfield);
textfield.alpha = 0;
textfield.width = stageW - 172;
textfield.textAlign = egret.HorizontalAlign.CENTER;
textfield.size = 24;
textfield.textColor = 0xffffff;
textfield.x = 172;
textfield.y = 135;
this.textfield = textfield;
}
/**
* 根据name关键字创建一个Bitmap对象。name属性请参考resources/resource.json配置文件的内容。
* Create a Bitmap object according to name keyword.As for the property of name please refer to the configuration file of resources/resource.json.
*/
private createBitmapByName(name: string) {
let result = new egret.Bitmap();
let texture: egret.Texture = RES.getRes(name);
result.texture = texture;
return result;
}
/**
* 描述文件加载成功,开始播放动画
* Description file loading is successful, start to play the animation
*/
private startAnimation(result: string[]) {
let parser = new egret.HtmlTextParser();
let textflowArr = result.map(text => parser.parse(text));
let textfield = this.textfield;
let count = -1;
let change = () => {
count++;
if (count >= textflowArr.length) {
count = 0;
}
let textFlow = textflowArr[count];
// 切换描述内容
// Switch to described content
textfield.textFlow = textFlow;
let tw = egret.Tween.get(textfield);
tw.to({ "alpha": 1 }, 200);
tw.wait(2000);
tw.to({ "alpha": 0 }, 200);
tw.call(change, this);
};
change();
}
}
\ No newline at end of file
/**
* 平台数据接口。
* 由于每款游戏通常需要发布到多个平台上,所以提取出一个统一的接口用于开发者获取平台数据信息
* 推荐开发者通过这种方式封装平台逻辑,以保证整体结构的稳定
* 由于不同平台的接口形式各有不同,白鹭推荐开发者将所有接口封装为基于 Promise 的异步形式
*/
declare interface Platform {
getUserInfo(): Promise<any>;
login(): Promise<any>
}
class DebugPlatform implements Platform {
async getUserInfo() {
return { nickName: "username" }
}
async login() {
}
}
if (!window.platform) {
window.platform = new DebugPlatform();
}
declare let platform: Platform;
declare interface Window {
platform: Platform
}
require("launcher/native_require.js");
egret_native.egtMain = function () {
egret_native.nativeType = "native";
egret_native.egretInit();
egret_native.egretStart();
};
var manifest = JSON.parse(egret_native.readFileSync("manifest.json"));
var game_file_list = manifest.initial.concat(manifest.game);
var window = this;
egret_native.setSearchPaths([""]);
egret_native.requireFiles = function () {
for (var key in game_file_list) {
var src = game_file_list[key];
require(src);
}
};
egret_native.egretInit = function () {
if(egret_native.featureEnable) {
//控制一些优化方案是否开启
//Control whether some optimization options are open
var result = egret_native.featureEnable({
});
}
egret_native.requireFiles();
egret.dom = {};
egret.dom.drawAsCanvas = function () {
};
};
egret_native.egretStart = function () {
var option = {
//以下为自动修改,请勿修改
//The following is automatically modified, please do not modify
//----auto option start----
//----auto option end----
};
egret.native.NativePlayer.option = option;
egret.runEgret();
egret_native.Label.createLabel("/system/fonts/DroidSansFallback.ttf", 20, "", 0);
egret_native.EGTView.preSetOffScreenBufferEnable(true);
};
\ No newline at end of file
require("launcher/native_require.js");
egret_native.egtMain = function () {
egret_native.nativeType = "runtime";
egret_native.egretInit();
egret_native.egretStart();
};
\ No newline at end of file
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Egret</title>
<meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="full-screen" content="true" />
<meta name="screen-orientation" content="portrait" />
<meta name="x5-fullscreen" content="true" />
<meta name="360-fullscreen" content="true" />
<style>
html, body {
-ms-touch-action: none;
background: #888888;
padding: 0;
border: 0;
margin: 0;
height: 100%;
}
</style>
</head>
<body>
<div style="margin: auto;width: 100%;height: 100%;" class="egret-player"
data-entry-class="Main"
data-orientation="landscape"
data-scale-mode="fixedWidth"
data-frame-rate="30"
data-content-width="640"
data-content-height="1136"
data-show-paint-rect="false"
data-multi-fingered="2"
data-show-fps="false" data-show-log="false"
data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
</div>
<script>
var loadScript = function (list, callback) {
var loaded = 0;
var loadNext = function () {
loadSingleScript(list[loaded], function () {
loaded++;
if (loaded >= list.length) {
callback();
}
else {
loadNext();
}
})
};
loadNext();
};
var loadSingleScript = function (src, callback) {
var s = document.createElement('script');
s.async = false;
s.src = src;
s.addEventListener('load', function () {
s.parentNode.removeChild(s);
s.removeEventListener('load', arguments.callee, false);
callback();
}, false);
document.body.appendChild(s);
};
var xhr = new XMLHttpRequest();
xhr.open('GET', './manifest.json?v=' + Math.random(), true);
xhr.addEventListener("load", function () {
var manifest = JSON.parse(xhr.response);
var list = manifest.initial.concat(manifest.game);
loadScript(list, function () {
/**
* {
* "renderMode":, //Engine rendering mode, "canvas" or "webgl"
* "audioType": 0 //Use the audio type, 0: default, 2: web audio, 3: audio
* "antialias": //Whether the anti-aliasing is enabled in WebGL mode, true: on, false: off, defaults to false
* "calculateCanvasScaleFactor": //a function return canvas scale factor
* }
**/
egret.runEgret({ renderMode: "webgl", audioType: 0, calculateCanvasScaleFactor:function(context) {
var backingStore = context.backingStorePixelRatio ||
context.webkitBackingStorePixelRatio ||
context.mozBackingStorePixelRatio ||
context.msBackingStorePixelRatio ||
context.oBackingStorePixelRatio ||
context.backingStorePixelRatio || 1;
return (window.devicePixelRatio || 1) / backingStore;
}});
});
});
xhr.send(null);
</script>
</body>
</html>
\ No newline at end of file
{
"compilerOptions": {
"target": "es5",
"outDir": "bin-debug",
"experimentalDecorators": true,
"lib": [
"es5",
"dom",
"es2015.promise"
],
"types": []
},
"include": [
"src",
"libs"
]
}
\ No newline at end of file
{
"resourcePlugin":{
"configs":[{
"configPath":"resource/default.res.json",
"relativePath":"resource/"
}]
},
"theme":"resource/default.thm.json"
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment