1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095 |
- 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 = {}));
|