olympus-r-17plugins
Version:
A plugin of Olympus for 17zuoye.
1,344 lines • 195 kB
JavaScript
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 () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
var egret;
(function (egret) {
/**
* The URLLoaderDataFormat class provides values that specify how downloaded data is received.
* @see http://edn.egret.com/cn/docs/page/600 Read different data format
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/net/URLLoaderDataFormat.ts
* @language en_US
*/
/**
* URLLoaderDataFormat 类提供了一些用于指定如何接收已下载数据的值。
* @see http://edn.egret.com/cn/docs/page/600 读取不同数据格式
* @version Egret 2.4
* @platform Web,Native
* @includeExample extension/game/net/URLLoaderDataFormat.ts
* @language zh_CN
*/
var URLLoaderDataFormat = (function () {
function URLLoaderDataFormat() {
}
/**
* Specify that downloaded data is received as raw binary data.
* @version Egret 2.4
* @platform Web
* @language en_US
*/
/**
* 指定以原始二进制数据形式接收下载的数据。
* @version Egret 2.4
* @platform Web
* @language zh_CN
*/
URLLoaderDataFormat.BINARY = "binary";
/**
* Specify that downloaded data is received as text.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 指定以文本形式接收已下载的数据。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
URLLoaderDataFormat.TEXT = "text";
/**
* Specify that downloaded data is received as URL-encoded variables.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 指定以 URL 编码变量形式接收下载的数据。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
URLLoaderDataFormat.VARIABLES = "variables";
/**
* Specify that downloaded data is received as bitmap texture.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 指定以位图纹理形式接收已下载的数据。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
URLLoaderDataFormat.TEXTURE = "texture";
/**
* Specify that downloaded data is received as sound.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 指定以声音形式接收已下载的数据。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
URLLoaderDataFormat.SOUND = "sound";
return URLLoaderDataFormat;
}());
egret.URLLoaderDataFormat = URLLoaderDataFormat;
__reflect(URLLoaderDataFormat.prototype, "egret.URLLoaderDataFormat");
})(egret || (egret = {}));
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
var egret;
(function (egret) {
/**
* @version Egret 2.4
* @platform Web,Native
* @private
*/
var FrameLabel = (function (_super) {
__extends(FrameLabel, _super);
/**
* @version Egret 2.4
* @platform Web,Native
*/
function FrameLabel(name, frame /*int*/, end /*int*/) {
var _this = _super.call(this) || this;
_this._name = name;
_this._frame = frame | 0;
if (end)
_this._end = end | 0;
return _this;
}
Object.defineProperty(FrameLabel.prototype, "name", {
/**
* Frame number
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 标签名
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
get: function () {
return this._name;
},
enumerable: true,
configurable: true
});
Object.defineProperty(FrameLabel.prototype, "frame", {
/**
* Frame serial number of the label
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 标签所在帧序号
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
get: function () {
return this._frame;
},
enumerable: true,
configurable: true
});
Object.defineProperty(FrameLabel.prototype, "end", {
/**
* Frame serial number, the end of the label
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 标签对应的结束帧序号
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
get: function () {
return this._end;
},
enumerable: true,
configurable: true
});
/**
* Duplicate the current frame label object
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 复制当前帧标签对象
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
FrameLabel.prototype.clone = function () {
return new FrameLabel(this._name, this._frame, this._end);
};
return FrameLabel;
}(egret.EventDispatcher));
egret.FrameLabel = FrameLabel;
__reflect(FrameLabel.prototype, "egret.FrameLabel");
})(egret || (egret = {}));
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
var egret;
(function (egret) {
/**
* @classdesc 使用 MovieClipData 类,您可以创建 MovieClip 对象和处理 MovieClip 对象的数据。MovieClipData 一般由MovieClipDataFactory生成
* @see http://edn.egret.com/cn/docs/page/596 MovieClip序列帧动画
* @version Egret 2.4
* @platform Web,Native
*/
var MovieClipData = (function (_super) {
__extends(MovieClipData, _super);
/**
* 创建一个 egret.MovieClipData 对象
* @version Egret 2.4
* @platform Web,Native
*/
function MovieClipData() {
var _this = _super.call(this) || this;
/**
* @private
* MovieClip数据
*/
_this.$mcData = null;
/**
* 总帧数
* @version Egret 2.4
* @platform Web,Native
*/
_this.numFrames = 1;
/**
* 帧数据列表
* @version Egret 2.4
* @platform Web,Native
*/
_this.frames = [];
/**
* 帧标签列表
* @version Egret 2.4
* @platform Web,Native
*/
_this.labels = null;
/**
* 帧事件列表
* @version Egret 2.4
* @platform Web,Native
*/
_this.events = [];
/**
* 帧率
* @version Egret 2.4
* @platform Web,Native
*/
_this.frameRate = 0;
/**
* 纹理数据
* @version Egret 2.4
* @platform Web,Native
*/
_this.textureData = null;
/**
* 纹理集
* @version Egret 2.4
* @platform Web,Native
*/
_this.spriteSheet = null;
return _this;
}
/**
* @private
*
* @param mcData
* @param textureData
* @param spriteSheet
*/
MovieClipData.prototype.$init = function (mcData, textureData, spriteSheet) {
this.textureData = textureData;
this.spriteSheet = spriteSheet;
this.setMCData(mcData);
};
/**
* 根据指定帧序号获取该帧对应的关键帧数据
* @param frame {number} 帧序号
* @returns {any} 帧数据对象
* @version Egret 2.4
* @platform Web,Native
*/
MovieClipData.prototype.getKeyFrameData = function (frame) {
var outputFrameData = this.frames[frame - 1];
if (outputFrameData.frame) {
outputFrameData = this.frames[outputFrameData.frame - 1];
}
return outputFrameData;
};
/**
* 根据指定帧序号获取该帧对应的Texture对象
* @param frame {number} 帧序号
* @returns {egret.Texture} Texture对象
* @version Egret 2.4
* @platform Web,Native
*/
MovieClipData.prototype.getTextureByFrame = function (frame) {
var frameData = this.getKeyFrameData(frame);
if (frameData.res) {
var outputTexture = this.getTextureByResName(frameData.res);
return outputTexture;
}
return null;
};
MovieClipData.prototype.$getOffsetByFrame = function (frame, point) {
var frameData = this.getKeyFrameData(frame);
if (frameData.res) {
point.setTo(frameData.x | 0, frameData.y | 0);
}
};
/**
* @private
*
* @param resName
* @returns
*/
MovieClipData.prototype.getTextureByResName = function (resName) {
if (this.spriteSheet == null) {
return null;
}
var texture = this.spriteSheet.getTexture(resName);
if (!texture) {
var textureData = this.textureData[resName];
texture = this.spriteSheet.createTexture(resName, textureData.x, textureData.y, textureData.w, textureData.h);
}
return texture;
};
/**
* @private
*
* @returns
*/
MovieClipData.prototype.$isDataValid = function () {
return this.frames.length > 0;
};
/**
* @private
*
* @returns
*/
MovieClipData.prototype.$isTextureValid = function () {
return this.textureData != null && this.spriteSheet != null;
};
/**
* @private
*
* @param mcData
*/
MovieClipData.prototype.$fillMCData = function (mcData) {
this.frameRate = mcData["frameRate"] || 24;
this.fillFramesData(mcData.frames);
this.fillFrameLabelsData(mcData.labels);
this.fillFrameEventsData(mcData.events);
};
/**
* @private
*
* @param framesData
*/
MovieClipData.prototype.fillFramesData = function (framesData) {
var frames = this.frames;
var length = framesData ? framesData.length : 0;
var keyFramePosition;
for (var i = 0; i < length; i++) {
var frameData = framesData[i];
frames.push(frameData);
if (frameData.duration) {
var duration = parseInt(frameData.duration);
if (duration > 1) {
keyFramePosition = frames.length;
for (var j = 1; j < duration; j++) {
frames.push({ "frame": keyFramePosition });
}
}
}
}
this.numFrames = frames.length;
};
/**
* @private
*
* @param frameLabelsData
*/
MovieClipData.prototype.fillFrameLabelsData = function (frameLabelsData) {
if (frameLabelsData) {
var length_1 = frameLabelsData.length;
if (length_1 > 0) {
this.labels = [];
for (var i = 0; i < length_1; i++) {
var label = frameLabelsData[i];
this.labels.push(new egret.FrameLabel(label.name, label.frame, label.end));
}
}
}
};
/**
* @private
*
* @param frameEventsData
*/
MovieClipData.prototype.fillFrameEventsData = function (frameEventsData) {
if (frameEventsData) {
var length_2 = frameEventsData.length;
if (length_2 > 0) {
this.events = [];
for (var i = 0; i < length_2; i++) {
var events = frameEventsData[i];
this.events[events.frame] = events.name;
}
}
}
};
Object.defineProperty(MovieClipData.prototype, "mcData", {
/**
* @version Egret 2.4
* @platform Web,Native
*/
get: function () {
return this.$mcData;
},
/**
* MovieClip数据源
*/
set: function (value) {
this.setMCData(value);
},
enumerable: true,
configurable: true
});
/**
* @private
*
* @param value
*/
MovieClipData.prototype.setMCData = function (value) {
if (this.$mcData == value) {
return;
}
this.$mcData = value;
if (value) {
this.$fillMCData(value);
}
};
return MovieClipData;
}(egret.HashObject));
egret.MovieClipData = MovieClipData;
__reflect(MovieClipData.prototype, "egret.MovieClipData");
})(egret || (egret = {}));
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
var egret;
(function (egret) {
/**
* @classdesc 使用 MovieClipDataFactory 类,可以生成 MovieClipData 对象用于创建MovieClip
* @see http://edn.egret.com/cn/docs/page/596 MovieClip序列帧动画
* @version Egret 2.4
* @platform Web,Native
*/
var MovieClipDataFactory = (function (_super) {
__extends(MovieClipDataFactory, _super);
/**
* 创建一个 egret.MovieClipDataFactory 对象
* @param movieClipDataSet {any} MovieClip数据集,该数据集必须由Egret官方工具生成
* @param texture {Texture} 纹理
* @version Egret 2.4
* @platform Web,Native
*/
function MovieClipDataFactory(movieClipDataSet, texture) {
var _this = _super.call(this) || this;
/**
* 是否开启缓存
* @version Egret 2.4
* @platform Web,Native
*/
_this.enableCache = true;
/**
* @private
*/
_this.$mcDataCache = {};
_this.$mcDataSet = movieClipDataSet;
_this.setTexture(texture);
return _this;
}
/**
* 清空缓存
* @version Egret 2.4
* @platform Web,Native
*/
MovieClipDataFactory.prototype.clearCache = function () {
this.$mcDataCache = {};
};
/**
* 根据名字生成一个MovieClipData实例。可以用于创建MovieClip。
* @param movieClipName {string} MovieClip名字. 可选参数,默认为"", 相当于取第一个MovieClip数据
* @returns {MovieClipData} 生成的MovieClipData对象
* @version Egret 2.4
* @platform Web,Native
*/
MovieClipDataFactory.prototype.generateMovieClipData = function (movieClipName) {
if (movieClipName === void 0) { movieClipName = ""; }
if (movieClipName == "") {
if (this.$mcDataSet) {
for (movieClipName in this.$mcDataSet.mc) {
break;
}
}
}
if (movieClipName == "") {
return null;
}
var output = this.findFromCache(movieClipName, this.$mcDataCache);
if (!output) {
output = new egret.MovieClipData();
this.fillData(movieClipName, output, this.$mcDataCache);
}
return output;
};
/**
* @private
*
* @param movieClipName
* @param cache
* @returns
*/
MovieClipDataFactory.prototype.findFromCache = function (movieClipName, cache) {
if (this.enableCache && cache[movieClipName]) {
return cache[movieClipName];
}
return null;
};
/**
* @private
*
* @param movieClipName
* @param movieClip
* @param cache
*/
MovieClipDataFactory.prototype.fillData = function (movieClipName, movieClip, cache) {
if (this.$mcDataSet) {
var mcData = this.$mcDataSet.mc[movieClipName];
if (mcData) {
movieClip.$init(mcData, this.$mcDataSet.res, this.$spriteSheet);
if (this.enableCache) {
cache[movieClipName] = movieClip;
}
}
}
};
Object.defineProperty(MovieClipDataFactory.prototype, "mcDataSet", {
/**
* MovieClip数据集
* @version Egret 2.4
* @platform Web,Native
*/
get: function () {
return this.$mcDataSet;
},
set: function (value) {
this.$mcDataSet = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MovieClipDataFactory.prototype, "texture", {
/**
* MovieClip需要使用的纹理图
*/
set: function (value) {
this.setTexture(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MovieClipDataFactory.prototype, "spriteSheet", {
/**
* 由纹理图生成的精灵表
* @version Egret 2.4
* @platform Web,Native
*/
get: function () {
return this.$spriteSheet;
},
enumerable: true,
configurable: true
});
/**
* @private
*
* @param value
*/
MovieClipDataFactory.prototype.setTexture = function (value) {
this.$spriteSheet = value ? new egret.SpriteSheet(value) : null;
};
return MovieClipDataFactory;
}(egret.EventDispatcher));
egret.MovieClipDataFactory = MovieClipDataFactory;
__reflect(MovieClipDataFactory.prototype, "egret.MovieClipDataFactory");
})(egret || (egret = {}));
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
var egret;
(function (egret) {
/**
* When the movieClip's current frame have a frameLabel, dispatches MovieClipEvent object. FrameLabel Event type: MovieClipEvent.FRAME_LABEL
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 当动画的当前帧有事件,将调度 MovieClipEvent 对象。帧事件类型 MovieClipEvent.FRAME_LABEL.
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
var MovieClipEvent = (function (_super) {
__extends(MovieClipEvent, _super);
/**
* TextEvent create an object that contains information about movieClip events.
* @param type Type of event, you can access the MovieClipEvent.type.
* @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false.
* @param cancelable Determine whether the Event object can be canceled. The default value is false.
* @param frameLabel When the current frame have a frameLabel, the event listeners can access this information through the frameLabel property.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 创建一个 MovieClipEvent 对象,其中包含有关帧事件的信息。
* @param type 事件的类型,可以作为 MovieClipEvent.type 访问。
* @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。
* @param cancelable 确定是否可以取消 Event 对象。默认值为 false。
* @param frameLabel 动画上的帧事件。事件侦听器可以通过 frameLabel 属性访问此信息。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
function MovieClipEvent(type, bubbles, cancelable, frameLabel) {
if (bubbles === void 0) { bubbles = false; }
if (cancelable === void 0) { cancelable = false; }
if (frameLabel === void 0) { frameLabel = null; }
var _this = _super.call(this, type, bubbles, cancelable) || this;
/**
* In MovieClipEvent.FRAME_LABEL event, event corresponding string.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 在 MovieClipEvent.FRAME_LABEL 事件中,event对应的字符串。
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
_this.frameLabel = null;
_this.frameLabel = frameLabel;
return _this;
}
/**
* EventDispatcher object using the specified event object thrown MovieClipEvent. The objects will be thrown in the object cache pool for the next round robin.
* @param type The type of the event, accessible as Event.type.
* @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false.
* @param frameLabel MovieClipEvent object frameLabel
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 使用指定的EventDispatcher对象来抛出 MovieClipEvent 事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。
* @param target 派发事件目标
* @param type 事件类型
* @param frameLabel MovieClipEvent 对象的 frameLabel 赋值
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
MovieClipEvent.dispatchMovieClipEvent = function (target, type, frameLabel) {
if (frameLabel === void 0) { frameLabel = null; }
var event = egret.Event.create(MovieClipEvent, type);
event.frameLabel = frameLabel;
var result = target.dispatchEvent(event);
egret.Event.release(event);
return result;
};
/**
* Dispatched whenever the current frame have a frameLabel.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 动画的当前帧上有事件时调度
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
MovieClipEvent.FRAME_LABEL = "frame_label";
return MovieClipEvent;
}(egret.Event));
egret.MovieClipEvent = MovieClipEvent;
__reflect(MovieClipEvent.prototype, "egret.MovieClipEvent");
})(egret || (egret = {}));
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
var egret;
(function (egret) {
/**
* @private
*/
var ScrollEase = (function () {
/**
* @version Egret 2.4
* @platform Web,Native
*/
function ScrollEase() {
egret.$error(1014);
}
/**
*
* @param amount
* @returns
* @version Egret 2.4
* @platform Web,Native
*/
ScrollEase.get = function (amount) {
if (amount < -1) {
amount = -1;
}
if (amount > 1) {
amount = 1;
}
return function (t) {
if (amount == 0) {
return t;
}
if (amount < 0) {
return t * (t * -amount + 1 + amount);
}
return t * ((2 - t) * amount + (1 - amount));
};
};
/**
*
* @param pow
* @returns
* @version Egret 2.4
* @platform Web,Native
*/
ScrollEase.getPowOut = function (pow) {
return function (t) {
return 1 - Math.pow(1 - t, pow);
};
};
/**
* @version Egret 2.4
* @platform Web,Native
*/
ScrollEase.quintOut = ScrollEase.getPowOut(5);
/**
* @version Egret 2.4
* @platform Web,Native
*/
ScrollEase.quartOut = ScrollEase.getPowOut(4);
return ScrollEase;
}());
egret.ScrollEase = ScrollEase;
__reflect(ScrollEase.prototype, "egret.ScrollEase");
/**
* @private
*/
var ScrollTween = (function (_super) {
__extends(ScrollTween, _super);
/**
* 创建一个 egret.ScrollTween 对象
* @private
* @version Egret 2.4
* @platform Web,Native
*/
function ScrollTween(target, props, pluginData) {
var _this = _super.call(this) || this;
/**
* @private
*/
_this._target = null;
/**
* @private
*/
_this._useTicks = false;
/**
* @private
*/
_this.ignoreGlobalPause = false;
/**
* @private
*/
_this.loop = false;
/**
* @private
*/
_this.pluginData = null;
/**
* @private
*/
_this._steps = null;
/**
* @private
*/
_this._actions = null;
/**
* @private
*/
_this.paused = false;
/**
* @private
*/
_this.duration = 0;
/**
* @private
*/
_this._prevPos = -1;
/**
* @private
*/
_this.position = null;
/**
* @private
*/
_this._prevPosition = 0;
/**
* @private
*/
_this._stepPosition = 0;
/**
* @private
*/
_this.passive = false;
_this.initialize(target, props, pluginData);
return _this;
}
/**
* Activate an object and add a ScrollTween animation to the object
* @param target {any} The object to be activated
* @param props {any} Parameters, support loop onChange onChangeObj
* @param pluginData {any} Write realized
* @param override {boolean} Whether to remove the object before adding a tween, the default value false
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 激活一个对象,对其添加 ScrollTween 动画
* @param target {any} 要激活 ScrollTween 的对象
* @param props {any} 参数,支持loop(循环播放) onChange(变化函数) onChangeObj(变化函数作用域)
* @param pluginData {any} 暂未实现
* @param override {boolean} 是否移除对象之前添加的tween,默认值false
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
ScrollTween.get = function (target, props, pluginData, override) {
if (props === void 0) { props = null; }
if (pluginData === void 0) { pluginData = null; }
if (override === void 0) { override = false; }
if (override) {
ScrollTween.removeTweens(target);
}
return new ScrollTween(target, props, pluginData);
};
/**
* Delete all ScrollTween animations from an object
* @param target The object whose ScrollTween to be deleted
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 删除一个对象上的全部 ScrollTween 动画
* @param target 需要移除 ScrollTween 的对象
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
ScrollTween.removeTweens = function (target) {
if (!target.tween_count) {
return;
}
var tweens = ScrollTween._tweens;
for (var i = tweens.length - 1; i >= 0; i--) {
if (tweens[i]._target == target) {
tweens[i].paused = true;
tweens.splice(i, 1);
}
}
target.tween_count = 0;
};
/**
* @private
*
* @param delta
* @param paused
*/
ScrollTween.tick = function (timeStamp, paused) {
if (paused === void 0) { paused = false; }
var delta = timeStamp - ScrollTween._lastTime;
ScrollTween._lastTime = timeStamp;
var tweens = ScrollTween._tweens.concat();
for (var i = tweens.length - 1; i >= 0; i--) {
var tween = tweens[i];
if ((paused && !tween.ignoreGlobalPause) || tween.paused) {
continue;
}
tween.tick(tween._useTicks ? 1 : delta);
}
return false;
};
/**
* @private
*
* @param tween
* @param value
*/
ScrollTween._register = function (tween, value) {
var target = tween._target;
var tweens = ScrollTween._tweens;
if (value) {
if (target) {
target.tween_count = target.tween_count > 0 ? target.tween_count + 1 : 1;
}
tweens.push(tween);
if (!ScrollTween._inited) {
ScrollTween._lastTime = egret.getTimer();
egret.ticker.$startTick(ScrollTween.tick, null);
ScrollTween._inited = true;
}
}
else {
if (target) {
target.tween_count--;
}
var i = tweens.length;
while (i--) {
if (tweens[i] == tween) {
tweens.splice(i, 1);
return;
}
}
}
};
/**
* @private
*
* @param target
* @param props
* @param pluginData
*/
ScrollTween.prototype.initialize = function (target, props, pluginData) {
this._target = target;
if (props) {
this._useTicks = props.useTicks;
this.ignoreGlobalPause = props.ignoreGlobalPause;
this.loop = props.loop;
props.onChange && this.addEventListener("change", props.onChange, props.onChangeObj);
if (props.override) {
ScrollTween.removeTweens(target);
}
}
this.pluginData = pluginData || {};
this._curQueueProps = {};
this._initQueueProps = {};
this._steps = [];
this._actions = [];
if (props && props.paused) {
this.paused = true;
}
else {
ScrollTween._register(this, true);
}
if (props && props.position != null) {
this.setPosition(props.position);
}
};
/**
* @private
*
* @param value
* @param actionsMode
* @returns
*/
ScrollTween.prototype.setPosition = function (value, actionsMode) {
if (actionsMode === void 0) { actionsMode = 1; }
if (value < 0) {
value = 0;
}
//正常化位置
var t = value;
var end = false;
if (t >= this.duration) {
if (this.loop) {
t = t % this.duration;
}
else {
t = this.duration;
end = true;
}
}
if (t == this._prevPos) {
return end;
}
var prevPos = this._prevPos;
this.position = this._prevPos = t;
this._prevPosition = value;
if (this._target) {
if (end) {
//结束
this._updateTargetProps(null, 1);
}
else if (this._steps.length > 0) {
// 找到新的tween
var i = void 0;
var l = this._steps.length;
for (i = 0; i < l; i++) {
if (this._steps[i].t > t) {
break;
}
}
var step = this._steps[i - 1];
this._updateTargetProps(step, (this._stepPosition = t - step.t) / step.d);
}
}
if (end) {
this.setPaused(true);
}
//执行actions
if (actionsMode != 0 && this._actions.length > 0) {
if (this._useTicks) {
this._runActions(t, t);
}
else if (actionsMode == 1 && t < prevPos) {
if (prevPos != this.duration) {
this._runActions(prevPos, this.duration);
}
this._runActions(0, t, true);
}
else {
this._runActions(prevPos, t);
}
}
this.dispatchEventWith("change");
return end;
};
/**
* @private
*
* @param startPos
* @param endPos
* @param includeStart
*/
ScrollTween.prototype._runActions = function (startPos, endPos, includeStart) {
if (includeStart === void 0) { includeStart = false; }
var sPos = startPos;
var ePos = endPos;
var i = -1;
var j = this._actions.length;
var k = 1;
if (startPos > endPos) {
//把所有的倒置
sPos = endPos;
ePos = startPos;
i = j;
j = k = -1;
}
while ((i += k) != j) {
var action = this._actions[i];
var pos = action.t;
if (pos == ePos || (pos > sPos && pos < ePos) || (includeStart && pos == startPos)) {
action.f.apply(action.o, action.p);
}
}
};
/**
* @private
*
* @param step
* @param ratio
*/
ScrollTween.prototype._updateTargetProps = function (step, ratio) {
var p0, p1, v, v0, v1, arr;
if (!step && ratio == 1) {
this.passive = false;
p0 = p1 = this._curQueueProps;
}
else {
this.passive = !!step.v;
//不更新props.
if (this.passive) {
return;
}
//使用ease
if (step.e) {
ratio = step.e(ratio, 0, 1, 1);
}
p0 = step.p0;
p1 = step.p1;
}
for (var n in this._initQueueProps) {
if ((v0 = p0[n]) == null) {
p0[n] = v0 = this._initQueueProps[n];
}
if ((v1 = p1[n]) == null) {
p1[n] = v1 = v0;
}
if (v0 == v1 || ratio == 0 || ratio == 1 || (typeof (v0) != "number")) {
v = ratio == 1 ? v1 : v0;
}
else {
v = v0 + (v1 - v0) * ratio;
}
var ignore = false;
if (arr = ScrollTween._plugins[n]) {
for (var i = 0, l = arr.length; i < l; i++) {
var v2 = arr[i].tween(this, n, v, p0, p1, ratio, !!step && p0 == p1, !step);
if (v2 == ScrollTween.IGNORE) {
ignore = true;
}
else {
v = v2;
}
}
}
if (!ignore) {
this._target[n] = v;
}
}
};
/**
* Whether setting is paused
* @param value {boolean} Whether to pause
* @returns ScrollTween object itself
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
/**
* 设置是否暂停
* @param value {boolean} 是否暂停
* @returns Tween对象本身
* @version Egret 2.4
* @platform Web,Native
* @language zh_CN
*/
ScrollTween.prototype.setPaused = function (value) {
this.paused = value;
ScrollTween._register(this, !value);
return this;
};
/**
* @private
*
* @param props
* @returns
*/
ScrollTween.prototype._cloneProps = function (props) {
var o = {};
for (var n in props) {
o[n] = props[n];
}
return o;
};
/**
* @private
*
* @param o
* @returns
*/
ScrollTween.prototype._addStep = function (o) {
if (o.d > 0) {
this._steps.push(o);
o.t = this.dur