tween.js 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095
  1. var __reflect = (this && this.__reflect) || function (p, c, t) {
  2. p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;
  3. };
  4. var __extends = this && this.__extends || function __extends(t, e) {
  5. function r() {
  6. this.constructor = t;
  7. }
  8. for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]);
  9. r.prototype = e.prototype, t.prototype = new r();
  10. };
  11. //////////////////////////////////////////////////////////////////////////////////////
  12. //
  13. // Copyright (c) 2014-present, Egret Technology.
  14. // All rights reserved.
  15. // Redistribution and use in source and binary forms, with or without
  16. // modification, are permitted provided that the following conditions are met:
  17. //
  18. // * Redistributions of source code must retain the above copyright
  19. // notice, this list of conditions and the following disclaimer.
  20. // * Redistributions in binary form must reproduce the above copyright
  21. // notice, this list of conditions and the following disclaimer in the
  22. // documentation and/or other materials provided with the distribution.
  23. // * Neither the name of the Egret nor the
  24. // names of its contributors may be used to endorse or promote products
  25. // derived from this software without specific prior written permission.
  26. //
  27. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  28. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  29. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  30. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  31. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  32. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  33. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  34. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  35. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  36. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37. //
  38. //////////////////////////////////////////////////////////////////////////////////////
  39. var egret;
  40. (function (egret) {
  41. /**
  42. * Easing function set. Different easing functions are used to make an animation proceed according to the corresponding equation
  43. * @see http://edn.egret.com/cn/index.php/article/index/id/53 Easing effect Demo
  44. * @version Egret 2.4
  45. * @platform Web,Native
  46. * @language en_US
  47. */
  48. /**
  49. * 缓动函数集合,使用不同的缓动函数使得动画按照对应的方程进行
  50. * @see http://edn.egret.com/cn/index.php/article/index/id/53 缓动效果演示
  51. * @version Egret 2.4
  52. * @platform Web,Native
  53. * @language zh_CN
  54. */
  55. var Ease = (function () {
  56. /**
  57. * @version Egret 2.4
  58. * @platform Web,Native
  59. */
  60. function Ease() {
  61. egret.$error(1014);
  62. }
  63. /**
  64. * get.See example.
  65. * @version Egret 2.4
  66. * @platform Web,Native
  67. * @language en_US
  68. */
  69. /**
  70. * get。请查看示例
  71. * @version Egret 2.4
  72. * @platform Web,Native
  73. * @language zh_CN
  74. */
  75. Ease.get = function (amount) {
  76. if (amount < -1) {
  77. amount = -1;
  78. }
  79. if (amount > 1) {
  80. amount = 1;
  81. }
  82. return function (t) {
  83. if (amount == 0) {
  84. return t;
  85. }
  86. if (amount < 0) {
  87. return t * (t * -amount + 1 + amount);
  88. }
  89. return t * ((2 - t) * amount + (1 - amount));
  90. };
  91. };
  92. /**
  93. * get pow in.See example.
  94. * @version Egret 2.4
  95. * @platform Web,Native
  96. * @language en_US
  97. */
  98. /**
  99. * get pow in。请查看示例
  100. * @version Egret 2.4
  101. * @platform Web,Native
  102. * @language zh_CN
  103. */
  104. Ease.getPowIn = function (pow) {
  105. return function (t) {
  106. return Math.pow(t, pow);
  107. };
  108. };
  109. /**
  110. * get pow out.See example.
  111. * @version Egret 2.4
  112. * @platform Web,Native
  113. * @language en_US
  114. */
  115. /**
  116. * get pow out。请查看示例
  117. * @version Egret 2.4
  118. * @platform Web,Native
  119. * @language zh_CN
  120. */
  121. Ease.getPowOut = function (pow) {
  122. return function (t) {
  123. return 1 - Math.pow(1 - t, pow);
  124. };
  125. };
  126. /**
  127. * get pow in out.See example.
  128. * @version Egret 2.4
  129. * @platform Web,Native
  130. * @language en_US
  131. */
  132. /**
  133. * get pow in out。请查看示例
  134. * @version Egret 2.4
  135. * @platform Web,Native
  136. * @language zh_CN
  137. */
  138. Ease.getPowInOut = function (pow) {
  139. return function (t) {
  140. if ((t *= 2) < 1)
  141. return 0.5 * Math.pow(t, pow);
  142. return 1 - 0.5 * Math.abs(Math.pow(2 - t, pow));
  143. };
  144. };
  145. /**
  146. * sine in.See example.
  147. * @version Egret 2.4
  148. * @platform Web,Native
  149. * @language en_US
  150. */
  151. /**
  152. * sine in。请查看示例
  153. * @version Egret 2.4
  154. * @platform Web,Native
  155. * @language zh_CN
  156. */
  157. Ease.sineIn = function (t) {
  158. return 1 - Math.cos(t * Math.PI / 2);
  159. };
  160. /**
  161. * sine out.See example.
  162. * @version Egret 2.4
  163. * @platform Web,Native
  164. * @language en_US
  165. */
  166. /**
  167. * sine out。请查看示例
  168. * @version Egret 2.4
  169. * @platform Web,Native
  170. * @language zh_CN
  171. */
  172. Ease.sineOut = function (t) {
  173. return Math.sin(t * Math.PI / 2);
  174. };
  175. /**
  176. * sine in out.See example.
  177. * @version Egret 2.4
  178. * @platform Web,Native
  179. * @language en_US
  180. */
  181. /**
  182. * sine in out。请查看示例
  183. * @version Egret 2.4
  184. * @platform Web,Native
  185. * @language zh_CN
  186. */
  187. Ease.sineInOut = function (t) {
  188. return -0.5 * (Math.cos(Math.PI * t) - 1);
  189. };
  190. /**
  191. * get back in.See example.
  192. * @version Egret 2.4
  193. * @platform Web,Native
  194. * @language en_US
  195. */
  196. /**
  197. * get back in。请查看示例
  198. * @version Egret 2.4
  199. * @platform Web,Native
  200. * @language zh_CN
  201. */
  202. Ease.getBackIn = function (amount) {
  203. return function (t) {
  204. return t * t * ((amount + 1) * t - amount);
  205. };
  206. };
  207. /**
  208. * get back out.See example.
  209. * @version Egret 2.4
  210. * @platform Web,Native
  211. * @language en_US
  212. */
  213. /**
  214. * get back out。请查看示例
  215. * @version Egret 2.4
  216. * @platform Web,Native
  217. * @language zh_CN
  218. */
  219. Ease.getBackOut = function (amount) {
  220. return function (t) {
  221. return (--t * t * ((amount + 1) * t + amount) + 1);
  222. };
  223. };
  224. /**
  225. * get back in out.See example.
  226. * @version Egret 2.4
  227. * @platform Web,Native
  228. * @language en_US
  229. */
  230. /**
  231. * get back in out。请查看示例
  232. * @version Egret 2.4
  233. * @platform Web,Native
  234. * @language zh_CN
  235. */
  236. Ease.getBackInOut = function (amount) {
  237. amount *= 1.525;
  238. return function (t) {
  239. if ((t *= 2) < 1)
  240. return 0.5 * (t * t * ((amount + 1) * t - amount));
  241. return 0.5 * ((t -= 2) * t * ((amount + 1) * t + amount) + 2);
  242. };
  243. };
  244. /**
  245. * circ in.See example.
  246. * @version Egret 2.4
  247. * @platform Web,Native
  248. * @language en_US
  249. */
  250. /**
  251. * circ in。请查看示例
  252. * @version Egret 2.4
  253. * @platform Web,Native
  254. * @language zh_CN
  255. */
  256. Ease.circIn = function (t) {
  257. return -(Math.sqrt(1 - t * t) - 1);
  258. };
  259. /**
  260. * circ out.See example.
  261. * @version Egret 2.4
  262. * @platform Web,Native
  263. * @language en_US
  264. */
  265. /**
  266. * circ out。请查看示例
  267. * @version Egret 2.4
  268. * @platform Web,Native
  269. * @language zh_CN
  270. */
  271. Ease.circOut = function (t) {
  272. return Math.sqrt(1 - (--t) * t);
  273. };
  274. /**
  275. * circ in out.See example.
  276. * @version Egret 2.4
  277. * @platform Web,Native
  278. * @language en_US
  279. */
  280. /**
  281. * circ in out。请查看示例
  282. * @version Egret 2.4
  283. * @platform Web,Native
  284. * @language zh_CN
  285. */
  286. Ease.circInOut = function (t) {
  287. if ((t *= 2) < 1) {
  288. return -0.5 * (Math.sqrt(1 - t * t) - 1);
  289. }
  290. return 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1);
  291. };
  292. /**
  293. * bounce in.See example.
  294. * @version Egret 2.4
  295. * @platform Web,Native
  296. * @language en_US
  297. */
  298. /**
  299. * bounce in。请查看示例
  300. * @version Egret 2.4
  301. * @platform Web,Native
  302. * @language zh_CN
  303. */
  304. Ease.bounceIn = function (t) {
  305. return 1 - Ease.bounceOut(1 - t);
  306. };
  307. /**
  308. * bounce out.See example.
  309. * @version Egret 2.4
  310. * @platform Web,Native
  311. * @language en_US
  312. */
  313. /**
  314. * bounce out。请查看示例
  315. * @version Egret 2.4
  316. * @platform Web,Native
  317. * @language zh_CN
  318. */
  319. Ease.bounceOut = function (t) {
  320. if (t < 1 / 2.75) {
  321. return (7.5625 * t * t);
  322. }
  323. else if (t < 2 / 2.75) {
  324. return (7.5625 * (t -= 1.5 / 2.75) * t + 0.75);
  325. }
  326. else if (t < 2.5 / 2.75) {
  327. return (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375);
  328. }
  329. else {
  330. return (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375);
  331. }
  332. };
  333. /**
  334. * bounce in out.See example.
  335. * @version Egret 2.4
  336. * @platform Web,Native
  337. * @language en_US
  338. */
  339. /**
  340. * bounce in out。请查看示例
  341. * @version Egret 2.4
  342. * @platform Web,Native
  343. * @language zh_CN
  344. */
  345. Ease.bounceInOut = function (t) {
  346. if (t < 0.5)
  347. return Ease.bounceIn(t * 2) * .5;
  348. return Ease.bounceOut(t * 2 - 1) * 0.5 + 0.5;
  349. };
  350. /**
  351. * get elastic in.See example.
  352. * @version Egret 2.4
  353. * @platform Web,Native
  354. * @language en_US
  355. */
  356. /**
  357. * get elastic in。请查看示例
  358. * @version Egret 2.4
  359. * @platform Web,Native
  360. * @language zh_CN
  361. */
  362. Ease.getElasticIn = function (amplitude, period) {
  363. var pi2 = Math.PI * 2;
  364. return function (t) {
  365. if (t == 0 || t == 1)
  366. return t;
  367. var s = period / pi2 * Math.asin(1 / amplitude);
  368. return -(amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * pi2 / period));
  369. };
  370. };
  371. /**
  372. * get elastic out.See example.
  373. * @version Egret 2.4
  374. * @platform Web,Native
  375. * @language en_US
  376. */
  377. /**
  378. * get elastic out。请查看示例
  379. * @version Egret 2.4
  380. * @platform Web,Native
  381. * @language zh_CN
  382. */
  383. Ease.getElasticOut = function (amplitude, period) {
  384. var pi2 = Math.PI * 2;
  385. return function (t) {
  386. if (t == 0 || t == 1)
  387. return t;
  388. var s = period / pi2 * Math.asin(1 / amplitude);
  389. return (amplitude * Math.pow(2, -10 * t) * Math.sin((t - s) * pi2 / period) + 1);
  390. };
  391. };
  392. /**
  393. * get elastic in out.See example.
  394. * @version Egret 2.4
  395. * @platform Web,Native
  396. * @language en_US
  397. */
  398. /**
  399. * get elastic in out。请查看示例
  400. * @version Egret 2.4
  401. * @platform Web,Native
  402. * @language zh_CN
  403. */
  404. Ease.getElasticInOut = function (amplitude, period) {
  405. var pi2 = Math.PI * 2;
  406. return function (t) {
  407. var s = period / pi2 * Math.asin(1 / amplitude);
  408. if ((t *= 2) < 1)
  409. return -0.5 * (amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * pi2 / period));
  410. return amplitude * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * pi2 / period) * 0.5 + 1;
  411. };
  412. };
  413. /**
  414. * quad in.See example.
  415. * @version Egret 2.4
  416. * @platform Web,Native
  417. * @language en_US
  418. */
  419. /**
  420. * quad in。请查看示例
  421. * @version Egret 2.4
  422. * @platform Web,Native
  423. * @language zh_CN
  424. */
  425. Ease.quadIn = Ease.getPowIn(2);
  426. /**
  427. * quad out.See example.
  428. * @version Egret 2.4
  429. * @platform Web,Native
  430. * @language en_US
  431. */
  432. /**
  433. * quad out。请查看示例
  434. * @version Egret 2.4
  435. * @platform Web,Native
  436. * @language zh_CN
  437. */
  438. Ease.quadOut = Ease.getPowOut(2);
  439. /**
  440. * quad in out.See example.
  441. * @version Egret 2.4
  442. * @platform Web,Native
  443. * @language en_US
  444. */
  445. /**
  446. * quad in out。请查看示例
  447. * @version Egret 2.4
  448. * @platform Web,Native
  449. * @language zh_CN
  450. */
  451. Ease.quadInOut = Ease.getPowInOut(2);
  452. /**
  453. * cubic in.See example.
  454. * @version Egret 2.4
  455. * @platform Web,Native
  456. * @language en_US
  457. */
  458. /**
  459. * cubic in。请查看示例
  460. * @version Egret 2.4
  461. * @platform Web,Native
  462. * @language zh_CN
  463. */
  464. Ease.cubicIn = Ease.getPowIn(3);
  465. /**
  466. * cubic out.See example.
  467. * @version Egret 2.4
  468. * @platform Web,Native
  469. * @language en_US
  470. */
  471. /**
  472. * cubic out。请查看示例
  473. * @version Egret 2.4
  474. * @platform Web,Native
  475. * @language zh_CN
  476. */
  477. Ease.cubicOut = Ease.getPowOut(3);
  478. /**
  479. * cubic in out.See example.
  480. * @version Egret 2.4
  481. * @platform Web,Native
  482. * @language en_US
  483. */
  484. /**
  485. * cubic in out。请查看示例
  486. * @version Egret 2.4
  487. * @platform Web,Native
  488. * @language zh_CN
  489. */
  490. Ease.cubicInOut = Ease.getPowInOut(3);
  491. /**
  492. * quart in.See example.
  493. * @version Egret 2.4
  494. * @platform Web,Native
  495. * @language en_US
  496. */
  497. /**
  498. * quart in。请查看示例
  499. * @version Egret 2.4
  500. * @platform Web,Native
  501. * @language zh_CN
  502. */
  503. Ease.quartIn = Ease.getPowIn(4);
  504. /**
  505. * quart out.See example.
  506. * @version Egret 2.4
  507. * @platform Web,Native
  508. * @language en_US
  509. */
  510. /**
  511. * quart out。请查看示例
  512. * @version Egret 2.4
  513. * @platform Web,Native
  514. * @language zh_CN
  515. */
  516. Ease.quartOut = Ease.getPowOut(4);
  517. /**
  518. * quart in out.See example.
  519. * @version Egret 2.4
  520. * @platform Web,Native
  521. * @language en_US
  522. */
  523. /**
  524. * quart in out。请查看示例
  525. * @version Egret 2.4
  526. * @platform Web,Native
  527. * @language zh_CN
  528. */
  529. Ease.quartInOut = Ease.getPowInOut(4);
  530. /**
  531. * quint in.See example.
  532. * @version Egret 2.4
  533. * @platform Web,Native
  534. * @language en_US
  535. */
  536. /**
  537. * quint in。请查看示例
  538. * @version Egret 2.4
  539. * @platform Web,Native
  540. * @language zh_CN
  541. */
  542. Ease.quintIn = Ease.getPowIn(5);
  543. /**
  544. * quint out.See example.
  545. * @version Egret 2.4
  546. * @platform Web,Native
  547. * @language en_US
  548. */
  549. /**
  550. * quint out。请查看示例
  551. * @version Egret 2.4
  552. * @platform Web,Native
  553. * @language zh_CN
  554. */
  555. Ease.quintOut = Ease.getPowOut(5);
  556. /**
  557. * quint in out.See example.
  558. * @version Egret 2.4
  559. * @platform Web,Native
  560. * @language en_US
  561. */
  562. /**
  563. * quint in out。请查看示例
  564. * @version Egret 2.4
  565. * @platform Web,Native
  566. * @language zh_CN
  567. */
  568. Ease.quintInOut = Ease.getPowInOut(5);
  569. /**
  570. * back in.See example.
  571. * @version Egret 2.4
  572. * @platform Web,Native
  573. * @language en_US
  574. */
  575. /**
  576. * back in。请查看示例
  577. * @version Egret 2.4
  578. * @platform Web,Native
  579. * @language zh_CN
  580. */
  581. Ease.backIn = Ease.getBackIn(1.7);
  582. /**
  583. * back out.See example.
  584. * @version Egret 2.4
  585. * @platform Web,Native
  586. * @language en_US
  587. */
  588. /**
  589. * back out。请查看示例
  590. * @version Egret 2.4
  591. * @platform Web,Native
  592. * @language zh_CN
  593. */
  594. Ease.backOut = Ease.getBackOut(1.7);
  595. /**
  596. * back in out.See example.
  597. * @version Egret 2.4
  598. * @platform Web,Native
  599. * @language en_US
  600. */
  601. /**
  602. * back in out。请查看示例
  603. * @version Egret 2.4
  604. * @platform Web,Native
  605. * @language zh_CN
  606. */
  607. Ease.backInOut = Ease.getBackInOut(1.7);
  608. /**
  609. * elastic in.See example.
  610. * @version Egret 2.4
  611. * @platform Web,Native
  612. * @language en_US
  613. */
  614. /**
  615. * elastic in。请查看示例
  616. * @version Egret 2.4
  617. * @platform Web,Native
  618. * @language zh_CN
  619. */
  620. Ease.elasticIn = Ease.getElasticIn(1, 0.3);
  621. /**
  622. * elastic out.See example.
  623. * @version Egret 2.4
  624. * @platform Web,Native
  625. * @language en_US
  626. */
  627. /**
  628. * elastic out。请查看示例
  629. * @version Egret 2.4
  630. * @platform Web,Native
  631. * @language zh_CN
  632. */
  633. Ease.elasticOut = Ease.getElasticOut(1, 0.3);
  634. /**
  635. * elastic in out.See example.
  636. * @version Egret 2.4
  637. * @platform Web,Native
  638. * @language en_US
  639. */
  640. /**
  641. * elastic in out。请查看示例
  642. * @version Egret 2.4
  643. * @platform Web,Native
  644. * @language zh_CN
  645. */
  646. Ease.elasticInOut = Ease.getElasticInOut(1, 0.3 * 1.5);
  647. return Ease;
  648. }());
  649. egret.Ease = Ease;
  650. __reflect(Ease.prototype, "egret.Ease");
  651. })(egret || (egret = {}));
  652. //////////////////////////////////////////////////////////////////////////////////////
  653. //
  654. // Copyright (c) 2014-present, Egret Technology.
  655. // All rights reserved.
  656. // Redistribution and use in source and binary forms, with or without
  657. // modification, are permitted provided that the following conditions are met:
  658. //
  659. // * Redistributions of source code must retain the above copyright
  660. // notice, this list of conditions and the following disclaimer.
  661. // * Redistributions in binary form must reproduce the above copyright
  662. // notice, this list of conditions and the following disclaimer in the
  663. // documentation and/or other materials provided with the distribution.
  664. // * Neither the name of the Egret nor the
  665. // names of its contributors may be used to endorse or promote products
  666. // derived from this software without specific prior written permission.
  667. //
  668. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  669. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  670. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  671. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  672. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  673. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  674. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  675. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  676. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  677. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  678. //
  679. //////////////////////////////////////////////////////////////////////////////////////
  680. var egret;
  681. (function (egret) {
  682. /**
  683. * Tween is the animation easing class of Egret
  684. * @see http://edn.egret.com/cn/docs/page/576 Tween ease animation
  685. * @version Egret 2.4
  686. * @platform Web,Native
  687. * @includeExample extension/tween/Tween.ts
  688. * @language en_US
  689. */
  690. /**
  691. * Tween是Egret的动画缓动类
  692. * @see http://edn.egret.com/cn/docs/page/576 Tween缓动动画
  693. * @version Egret 2.4
  694. * @platform Web,Native
  695. * @includeExample extension/tween/Tween.ts
  696. * @language zh_CN
  697. */
  698. var Tween = (function (_super) {
  699. __extends(Tween, _super);
  700. /**
  701. * 创建一个 egret.Tween 对象
  702. * @private
  703. * @version Egret 2.4
  704. * @platform Web,Native
  705. */
  706. function Tween(target, props, pluginData) {
  707. var _this = _super.call(this) || this;
  708. /**
  709. * @private
  710. */
  711. _this._target = null;
  712. /**
  713. * @private
  714. */
  715. _this._useTicks = false;
  716. /**
  717. * @private
  718. */
  719. _this.ignoreGlobalPause = false;
  720. /**
  721. * @private
  722. */
  723. _this.loop = false;
  724. /**
  725. * @private
  726. */
  727. _this.pluginData = null;
  728. /**
  729. * @private
  730. */
  731. _this._steps = null;
  732. /**
  733. * @private
  734. */
  735. _this.paused = false;
  736. /**
  737. * @private
  738. */
  739. _this.duration = 0;
  740. /**
  741. * @private
  742. */
  743. _this._prevPos = -1;
  744. /**
  745. * @private
  746. */
  747. _this.position = null;
  748. /**
  749. * @private
  750. */
  751. _this._prevPosition = 0;
  752. /**
  753. * @private
  754. */
  755. _this._stepPosition = 0;
  756. /**
  757. * @private
  758. */
  759. _this.passive = false;
  760. _this.initialize(target, props, pluginData);
  761. return _this;
  762. }
  763. /**
  764. * Activate an object and add a Tween animation to the object
  765. * @param target {any} The object to be activated
  766. * @param props {any} Parameters, support loop onChange onChangeObj
  767. * @param pluginData {any} Write realized
  768. * @param override {boolean} Whether to remove the object before adding a tween, the default value false
  769. * Not recommended, you can use Tween.removeTweens(target) instead.
  770. * @version Egret 2.4
  771. * @platform Web,Native
  772. * @language en_US
  773. */
  774. /**
  775. * 激活一个对象,对其添加 Tween 动画
  776. * @param target {any} 要激活 Tween 的对象
  777. * @param props {any} 参数,支持loop(循环播放) onChange(变化函数) onChangeObj(变化函数作用域)
  778. * @param pluginData {any} 暂未实现
  779. * @param override {boolean} 是否移除对象之前添加的tween,默认值false。
  780. * 不建议使用,可使用 Tween.removeTweens(target) 代替。
  781. * @version Egret 2.4
  782. * @platform Web,Native
  783. * @language zh_CN
  784. */
  785. Tween.get = function (target, props, pluginData, override) {
  786. if (pluginData === void 0) { pluginData = null; }
  787. if (override === void 0) { override = false; }
  788. if (override) {
  789. Tween.removeTweens(target);
  790. }
  791. return new Tween(target, props, pluginData);
  792. };
  793. /**
  794. * Delete all Tween animations from an object
  795. * @param target The object whose Tween to be deleted
  796. * @version Egret 2.4
  797. * @platform Web,Native
  798. * @language en_US
  799. */
  800. /**
  801. * 删除一个对象上的全部 Tween 动画
  802. * @param target 需要移除 Tween 的对象
  803. * @version Egret 2.4
  804. * @platform Web,Native
  805. * @language zh_CN
  806. */
  807. Tween.removeTweens = function (target) {
  808. if (!target.tween_count) {
  809. return;
  810. }
  811. var tweens = Tween._tweens;
  812. for (var i = tweens.length - 1; i >= 0; i--) {
  813. if (tweens[i]._target == target) {
  814. tweens[i].paused = true;
  815. tweens.splice(i, 1);
  816. }
  817. }
  818. target.tween_count = 0;
  819. };
  820. /**
  821. * Pause all Tween animations of a certain object
  822. * @param target The object whose Tween to be paused
  823. * @version Egret 2.4
  824. * @platform Web,Native
  825. * @language en_US
  826. */
  827. /**
  828. * 暂停某个对象的所有 Tween
  829. * @param target 要暂停 Tween 的对象
  830. * @version Egret 2.4
  831. * @platform Web,Native
  832. * @language zh_CN
  833. */
  834. Tween.pauseTweens = function (target) {
  835. if (!target.tween_count) {
  836. return;
  837. }
  838. var tweens = egret.Tween._tweens;
  839. for (var i = tweens.length - 1; i >= 0; i--) {
  840. if (tweens[i]._target == target) {
  841. tweens[i].paused = true;
  842. }
  843. }
  844. };
  845. /**
  846. * Resume playing all easing of a certain object
  847. * @param target The object whose Tween to be resumed
  848. * @version Egret 2.4
  849. * @platform Web,Native
  850. * @language en_US
  851. */
  852. /**
  853. * 继续播放某个对象的所有缓动
  854. * @param target 要继续播放 Tween 的对象
  855. * @version Egret 2.4
  856. * @platform Web,Native
  857. * @language zh_CN
  858. */
  859. Tween.resumeTweens = function (target) {
  860. if (!target.tween_count) {
  861. return;
  862. }
  863. var tweens = egret.Tween._tweens;
  864. for (var i = tweens.length - 1; i >= 0; i--) {
  865. if (tweens[i]._target == target) {
  866. tweens[i].paused = false;
  867. }
  868. }
  869. };
  870. /**
  871. * @private
  872. *
  873. * @param delta
  874. * @param paused
  875. */
  876. Tween.tick = function (timeStamp, paused) {
  877. if (paused === void 0) { paused = false; }
  878. var delta = timeStamp - Tween._lastTime;
  879. Tween._lastTime = timeStamp;
  880. var tweens = Tween._tweens.concat();
  881. for (var i = tweens.length - 1; i >= 0; i--) {
  882. var tween_1 = tweens[i];
  883. if ((paused && !tween_1.ignoreGlobalPause) || tween_1.paused) {
  884. continue;
  885. }
  886. tween_1.$tick(tween_1._useTicks ? 1 : delta);
  887. }
  888. return false;
  889. };
  890. /**
  891. * @private
  892. *
  893. * @param tween
  894. * @param value
  895. */
  896. Tween._register = function (tween, value) {
  897. var target = tween._target;
  898. var tweens = Tween._tweens;
  899. if (value) {
  900. if (target) {
  901. target.tween_count = target.tween_count > 0 ? target.tween_count + 1 : 1;
  902. }
  903. tweens.push(tween);
  904. if (!Tween._inited) {
  905. Tween._lastTime = egret.getTimer();
  906. egret.ticker.$startTick(Tween.tick, null);
  907. Tween._inited = true;
  908. }
  909. }
  910. else {
  911. if (target) {
  912. target.tween_count--;
  913. }
  914. var i = tweens.length;
  915. while (i--) {
  916. if (tweens[i] == tween) {
  917. tweens.splice(i, 1);
  918. return;
  919. }
  920. }
  921. }
  922. };
  923. /**
  924. * Delete all Tween
  925. * @version Egret 2.4
  926. * @platform Web,Native
  927. * @language en_US
  928. */
  929. /**
  930. * 删除所有 Tween
  931. * @version Egret 2.4
  932. * @platform Web,Native
  933. * @language zh_CN
  934. */
  935. Tween.removeAllTweens = function () {
  936. var tweens = Tween._tweens;
  937. for (var i = 0, l = tweens.length; i < l; i++) {
  938. var tween_2 = tweens[i];
  939. tween_2.paused = true;
  940. tween_2._target.tween_count = 0;
  941. }
  942. tweens.length = 0;
  943. };
  944. /**
  945. * @private
  946. *
  947. * @param target
  948. * @param props
  949. * @param pluginData
  950. */
  951. Tween.prototype.initialize = function (target, props, pluginData) {
  952. this._target = target;
  953. if (props) {
  954. this._useTicks = props.useTicks;
  955. this.ignoreGlobalPause = props.ignoreGlobalPause;
  956. this.loop = props.loop;
  957. props.onChange && this.addEventListener("change", props.onChange, props.onChangeObj);
  958. if (props.override) {
  959. Tween.removeTweens(target);
  960. }
  961. }
  962. this.pluginData = pluginData || {};
  963. this._curQueueProps = {};
  964. this._initQueueProps = {};
  965. this._steps = [];
  966. if (props && props.paused) {
  967. this.paused = true;
  968. }
  969. else {
  970. Tween._register(this, true);
  971. }
  972. if (props && props.position != null) {
  973. this.setPosition(props.position, Tween.NONE);
  974. }
  975. };
  976. /**
  977. * @private
  978. *
  979. * @param value
  980. * @param actionsMode
  981. * @returns
  982. */
  983. Tween.prototype.setPosition = function (value, actionsMode) {
  984. if (actionsMode === void 0) { actionsMode = 1; }
  985. if (value < 0) {
  986. value = 0;
  987. }
  988. //正常化位置
  989. var t = value;
  990. var end = false;
  991. if (t >= this.duration) {
  992. if (this.loop) {
  993. var newTime = t % this.duration;
  994. if (t > 0 && newTime === 0) {
  995. t = this.duration;
  996. }
  997. else {
  998. t = newTime;
  999. }
  1000. }
  1001. else {
  1002. t = this.duration;
  1003. end = true;
  1004. }
  1005. }
  1006. if (t == this._prevPos) {
  1007. return end;
  1008. }
  1009. if (end) {
  1010. this.setPaused(true);
  1011. }
  1012. var prevPos = this._prevPos;
  1013. this.position = this._prevPos = t;
  1014. this._prevPosition = value;
  1015. if (this._target) {
  1016. if (this._steps.length > 0) {
  1017. // 找到新的tween
  1018. var l = this._steps.length;
  1019. var stepIndex = -1;
  1020. for (var i = 0; i < l; i++) {
  1021. if (this._steps[i].type == "step") {
  1022. stepIndex = i;
  1023. if (this._steps[i].t <= t && this._steps[i].t + this._steps[i].d >= t) {
  1024. break;
  1025. }
  1026. }
  1027. }
  1028. for (var i = 0; i < l; i++) {
  1029. if (this._steps[i].type == "action") {
  1030. //执行actions
  1031. if (actionsMode != 0) {
  1032. if (this._useTicks) {
  1033. this._runAction(this._steps[i], t, t);
  1034. }
  1035. else if (actionsMode == 1 && t < prevPos) {
  1036. if (prevPos != this.duration) {
  1037. this._runAction(this._steps[i], prevPos, this.duration);
  1038. }
  1039. this._runAction(this._steps[i], 0, t, true);
  1040. }
  1041. else {
  1042. this._runAction(this._steps[i], prevPos, t);
  1043. }
  1044. }
  1045. }
  1046. else if (this._steps[i].type == "step") {
  1047. if (stepIndex == i) {
  1048. var step = this._steps[stepIndex];
  1049. this._updateTargetProps(step, Math.min((this._stepPosition = t - step.t) / step.d, 1));
  1050. }
  1051. }
  1052. }
  1053. }
  1054. }
  1055. this.dispatchEventWith("change");
  1056. return end;
  1057. };
  1058. /**
  1059. * @private
  1060. *
  1061. * @param startPos
  1062. * @param endPos
  1063. * @param includeStart
  1064. */
  1065. Tween.prototype._runAction = function (action, startPos, endPos, includeStart) {
  1066. if (includeStart === void 0) { includeStart = false; }
  1067. var sPos = startPos;
  1068. var ePos = endPos;
  1069. if (startPos > endPos) {
  1070. //把所有的倒置
  1071. sPos = endPos;
  1072. ePos = startPos;
  1073. }
  1074. var pos = action.t;
  1075. if (pos == ePos || (pos > sPos && pos < ePos) || (includeStart && pos == startPos)) {
  1076. action.f.apply(action.o, action.p);
  1077. }
  1078. };
  1079. /**
  1080. * @private
  1081. *
  1082. * @param step
  1083. * @param ratio
  1084. */
  1085. Tween.prototype._updateTargetProps = function (step, ratio) {
  1086. var p0, p1, v, v0, v1, arr;
  1087. if (!step && ratio == 1) {
  1088. this.passive = false;
  1089. p0 = p1 = this._curQueueProps;
  1090. }
  1091. else {
  1092. this.passive = !!step.v;
  1093. //不更新props.
  1094. if (this.passive) {
  1095. return;
  1096. }
  1097. //使用ease
  1098. if (step.e) {
  1099. ratio = step.e(ratio, 0, 1, 1);
  1100. }
  1101. p0 = step.p0;
  1102. p1 = step.p1;
  1103. }
  1104. for (var n in this._initQueueProps) {
  1105. if ((v0 = p0[n]) == null) {
  1106. p0[n] = v0 = this._initQueueProps[n];
  1107. }
  1108. if ((v1 = p1[n]) == null) {
  1109. p1[n] = v1 = v0;
  1110. }
  1111. if (v0 == v1 || ratio == 0 || ratio == 1 || (typeof (v0) != "number")) {
  1112. v = ratio == 1 ? v1 : v0;
  1113. }
  1114. else {
  1115. v = v0 + (v1 - v0) * ratio;
  1116. }
  1117. var ignore = false;
  1118. if (arr = Tween._plugins[n]) {
  1119. for (var i = 0, l = arr.length; i < l; i++) {
  1120. var v2 = arr[i].tween(this, n, v, p0, p1, ratio, !!step && p0 == p1, !step);
  1121. if (v2 == Tween.IGNORE) {
  1122. ignore = true;
  1123. }
  1124. else {
  1125. v = v2;
  1126. }
  1127. }
  1128. }
  1129. if (!ignore) {
  1130. this._target[n] = v;
  1131. }
  1132. }
  1133. };
  1134. /**
  1135. * Whether setting is paused
  1136. * @param value {boolean} Whether to pause
  1137. * @returns Tween object itself
  1138. * @version Egret 2.4
  1139. * @platform Web,Native
  1140. * @language en_US
  1141. */
  1142. /**
  1143. * 设置是否暂停
  1144. * @param value {boolean} 是否暂停
  1145. * @returns Tween对象本身
  1146. * @version Egret 2.4
  1147. * @platform Web,Native
  1148. * @language zh_CN
  1149. */
  1150. Tween.prototype.setPaused = function (value) {
  1151. if (this.paused == value) {
  1152. return this;
  1153. }
  1154. this.paused = value;
  1155. Tween._register(this, !value);
  1156. return this;
  1157. };
  1158. /**
  1159. * @private
  1160. *
  1161. * @param props
  1162. * @returns
  1163. */
  1164. Tween.prototype._cloneProps = function (props) {
  1165. var o = {};
  1166. for (var n in props) {
  1167. o[n] = props[n];
  1168. }
  1169. return o;
  1170. };
  1171. /**
  1172. * @private
  1173. *
  1174. * @param o
  1175. * @returns
  1176. */
  1177. Tween.prototype._addStep = function (o) {
  1178. if (o.d > 0) {
  1179. o.type = "step";
  1180. this._steps.push(o);
  1181. o.t = this.duration;
  1182. this.duration += o.d;
  1183. }
  1184. return this;
  1185. };
  1186. /**
  1187. * @private
  1188. *
  1189. * @param o
  1190. * @returns
  1191. */
  1192. Tween.prototype._appendQueueProps = function (o) {
  1193. var arr, oldValue, i, l, injectProps;
  1194. for (var n in o) {
  1195. if (this._initQueueProps[n] === undefined) {
  1196. oldValue = this._target[n];
  1197. //设置plugins
  1198. if (arr = Tween._plugins[n]) {
  1199. for (i = 0, l = arr.length; i < l; i++) {
  1200. oldValue = arr[i].init(this, n, oldValue);
  1201. }
  1202. }
  1203. this._initQueueProps[n] = this._curQueueProps[n] = (oldValue === undefined) ? null : oldValue;
  1204. }
  1205. else {
  1206. oldValue = this._curQueueProps[n];
  1207. }
  1208. }
  1209. for (var n in o) {
  1210. oldValue = this._curQueueProps[n];
  1211. if (arr = Tween._plugins[n]) {
  1212. injectProps = injectProps || {};
  1213. for (i = 0, l = arr.length; i < l; i++) {
  1214. if (arr[i].step) {
  1215. arr[i].step(this, n, oldValue, o[n], injectProps);
  1216. }
  1217. }
  1218. }
  1219. this._curQueueProps[n] = o[n];
  1220. }
  1221. if (injectProps) {
  1222. this._appendQueueProps(injectProps);
  1223. }
  1224. return this._curQueueProps;
  1225. };
  1226. /**
  1227. * @private
  1228. *
  1229. * @param o
  1230. * @returns
  1231. */
  1232. Tween.prototype._addAction = function (o) {
  1233. o.t = this.duration;
  1234. o.type = "action";
  1235. this._steps.push(o);
  1236. return this;
  1237. };
  1238. /**
  1239. * @private
  1240. *
  1241. * @param props
  1242. * @param o
  1243. */
  1244. Tween.prototype._set = function (props, o) {
  1245. for (var n in props) {
  1246. o[n] = props[n];
  1247. }
  1248. };
  1249. /**
  1250. * Wait the specified milliseconds before the execution of the next animation
  1251. * @param duration {number} Waiting time, in milliseconds
  1252. * @param passive {boolean} Whether properties are updated during the waiting time
  1253. * @returns Tween object itself
  1254. * @version Egret 2.4
  1255. * @platform Web,Native
  1256. * @language en_US
  1257. */
  1258. /**
  1259. * 等待指定毫秒后执行下一个动画
  1260. * @param duration {number} 要等待的时间,以毫秒为单位
  1261. * @param passive {boolean} 等待期间属性是否会更新
  1262. * @returns Tween对象本身
  1263. * @version Egret 2.4
  1264. * @platform Web,Native
  1265. * @language zh_CN
  1266. */
  1267. Tween.prototype.wait = function (duration, passive) {
  1268. if (duration == null || duration <= 0) {
  1269. return this;
  1270. }
  1271. var o = this._cloneProps(this._curQueueProps);
  1272. return this._addStep({ d: duration, p0: o, p1: o, v: passive });
  1273. };
  1274. /**
  1275. * Modify the property of the specified object to a specified value
  1276. * @param props {Object} Property set of an object
  1277. * @param duration {number} Duration
  1278. * @param ease {egret.Ease} Easing algorithm
  1279. * @returns {egret.Tween} Tween object itself
  1280. * @version Egret 2.4
  1281. * @platform Web,Native
  1282. * @language en_US
  1283. */
  1284. /**
  1285. * 将指定对象的属性修改为指定值
  1286. * @param props {Object} 对象的属性集合
  1287. * @param duration {number} 持续时间
  1288. * @param ease {egret.Ease} 缓动算法
  1289. * @returns {egret.Tween} Tween对象本身
  1290. * @version Egret 2.4
  1291. * @platform Web,Native
  1292. * @language zh_CN
  1293. */
  1294. Tween.prototype.to = function (props, duration, ease) {
  1295. if (ease === void 0) { ease = undefined; }
  1296. if (isNaN(duration) || duration < 0) {
  1297. duration = 0;
  1298. }
  1299. this._addStep({ d: duration || 0, p0: this._cloneProps(this._curQueueProps), e: ease, p1: this._cloneProps(this._appendQueueProps(props)) });
  1300. //加入一步set,防止游戏极其卡顿时候,to后面的call取到的属性值不对
  1301. return this.set(props);
  1302. };
  1303. /**
  1304. * Execute callback function
  1305. * @param callback {Function} Callback method
  1306. * @param thisObj {any} this action scope of the callback method
  1307. * @param params {any[]} Parameter of the callback method
  1308. * @returns {egret.Tween} Tween object itself
  1309. * @version Egret 2.4
  1310. * @platform Web,Native
  1311. * @example
  1312. * <pre>
  1313. * egret.Tween.get(display).call(function (a:number, b:string) {
  1314. * console.log("a: " + a); // the first parameter passed 233
  1315. * console.log("b: " + b); // the second parameter passed “hello”
  1316. * }, this, [233, "hello"]);
  1317. * </pre>
  1318. * @language en_US
  1319. */
  1320. /**
  1321. * 执行回调函数
  1322. * @param callback {Function} 回调方法
  1323. * @param thisObj {any} 回调方法this作用域
  1324. * @param params {any[]} 回调方法参数
  1325. * @returns {egret.Tween} Tween对象本身
  1326. * @version Egret 2.4
  1327. * @platform Web,Native
  1328. * @example
  1329. * <pre>
  1330. * egret.Tween.get(display).call(function (a:number, b:string) {
  1331. * console.log("a: " + a); //对应传入的第一个参数 233
  1332. * console.log("b: " + b); //对应传入的第二个参数 “hello”
  1333. * }, this, [233, "hello"]);
  1334. * </pre>
  1335. * @language zh_CN
  1336. */
  1337. Tween.prototype.call = function (callback, thisObj, params) {
  1338. if (thisObj === void 0) { thisObj = undefined; }
  1339. if (params === void 0) { params = undefined; }
  1340. return this._addAction({ f: callback, p: params ? params : [], o: thisObj ? thisObj : this._target });
  1341. };
  1342. /**
  1343. * Now modify the properties of the specified object to the specified value
  1344. * @param props {Object} Property set of an object
  1345. * @param target The object whose Tween to be resumed
  1346. * @returns {egret.Tween} Tween object itself
  1347. * @version Egret 2.4
  1348. * @platform Web,Native
  1349. */
  1350. /**
  1351. * 立即将指定对象的属性修改为指定值
  1352. * @param props {Object} 对象的属性集合
  1353. * @param target 要继续播放 Tween 的对象
  1354. * @returns {egret.Tween} Tween对象本身
  1355. * @version Egret 2.4
  1356. * @platform Web,Native
  1357. */
  1358. Tween.prototype.set = function (props, target) {
  1359. if (target === void 0) { target = null; }
  1360. //更新当前数据,保证缓动流畅性
  1361. this._appendQueueProps(props);
  1362. return this._addAction({ f: this._set, o: this, p: [props, target ? target : this._target] });
  1363. };
  1364. /**
  1365. * Execute
  1366. * @param tween {egret.Tween} The Tween object to be operated. Default: this
  1367. * @returns {egret.Tween} Tween object itself
  1368. * @version Egret 2.4
  1369. * @platform Web,Native
  1370. * @language en_US
  1371. */
  1372. /**
  1373. * 执行
  1374. * @param tween {egret.Tween} 需要操作的 Tween 对象,默认this
  1375. * @returns {egret.Tween} Tween对象本身
  1376. * @version Egret 2.4
  1377. * @platform Web,Native
  1378. * @language zh_CN
  1379. */
  1380. Tween.prototype.play = function (tween) {
  1381. if (!tween) {
  1382. tween = this;
  1383. }
  1384. return this.call(tween.setPaused, tween, [false]);
  1385. };
  1386. /**
  1387. * Pause
  1388. * @param tween {egret.Tween} The Tween object to be operated. Default: this
  1389. * @returns {egret.Tween} Tween object itself
  1390. * @version Egret 2.4
  1391. * @platform Web,Native
  1392. * @language en_US
  1393. */
  1394. /**
  1395. * 暂停
  1396. * @param tween {egret.Tween} 需要操作的 Tween 对象,默认this
  1397. * @returns {egret.Tween} Tween对象本身
  1398. * @version Egret 2.4
  1399. * @platform Web,Native
  1400. * @language zh_CN
  1401. */
  1402. Tween.prototype.pause = function (tween) {
  1403. if (!tween) {
  1404. tween = this;
  1405. }
  1406. return this.call(tween.setPaused, tween, [true]);
  1407. };
  1408. /**
  1409. * @method egret.Tween#tick
  1410. * @param delta {number}
  1411. * @private
  1412. * @version Egret 2.4
  1413. * @platform Web,Native
  1414. */
  1415. Tween.prototype.$tick = function (delta) {
  1416. if (this.paused) {
  1417. return;
  1418. }
  1419. this.setPosition(this._prevPosition + delta);
  1420. };
  1421. /**
  1422. * 不做特殊处理
  1423. * @constant {number} egret.Tween.NONE
  1424. * @private
  1425. */
  1426. Tween.NONE = 0;
  1427. /**
  1428. * 循环
  1429. * @constant {number} egret.Tween.LOOP
  1430. * @private
  1431. */
  1432. Tween.LOOP = 1;
  1433. /**
  1434. * 倒序
  1435. * @constant {number} egret.Tween.REVERSE
  1436. * @private
  1437. */
  1438. Tween.REVERSE = 2;
  1439. /**
  1440. * @private
  1441. */
  1442. Tween._tweens = [];
  1443. /**
  1444. * @private
  1445. */
  1446. Tween.IGNORE = {};
  1447. /**
  1448. * @private
  1449. */
  1450. Tween._plugins = {};
  1451. /**
  1452. * @private
  1453. */
  1454. Tween._inited = false;
  1455. Tween._lastTime = 0;
  1456. return Tween;
  1457. }(egret.EventDispatcher));
  1458. egret.Tween = Tween;
  1459. __reflect(Tween.prototype, "egret.Tween");
  1460. })(egret || (egret = {}));
  1461. //////////////////////////////////////////////////////////////////////////////////////
  1462. //
  1463. // Copyright (c) 2014-present, Egret Technology.
  1464. // All rights reserved.
  1465. // Redistribution and use in source and binary forms, with or without
  1466. // modification, are permitted provided that the following conditions are met:
  1467. //
  1468. // * Redistributions of source code must retain the above copyright
  1469. // notice, this list of conditions and the following disclaimer.
  1470. // * Redistributions in binary form must reproduce the above copyright
  1471. // notice, this list of conditions and the following disclaimer in the
  1472. // documentation and/or other materials provided with the distribution.
  1473. // * Neither the name of the Egret nor the
  1474. // names of its contributors may be used to endorse or promote products
  1475. // derived from this software without specific prior written permission.
  1476. //
  1477. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  1478. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  1479. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  1480. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  1481. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  1482. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  1483. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  1484. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  1485. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  1486. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1487. //
  1488. //////////////////////////////////////////////////////////////////////////////////////
  1489. var egret;
  1490. (function (egret) {
  1491. var tween;
  1492. (function (tween) {
  1493. /**
  1494. * Abstract class, Indicate the base action.
  1495. * @version Egret 3.1.8
  1496. * @platform Web,Native
  1497. * @language en_US
  1498. */
  1499. /**
  1500. * 抽象类,表示一个基本动作
  1501. * @version Egret 3.1.8
  1502. * @platform Web,Native
  1503. * @language zh_CN
  1504. */
  1505. var BasePath = (function (_super) {
  1506. __extends(BasePath, _super);
  1507. function BasePath() {
  1508. var _this = _super !== null && _super.apply(this, arguments) || this;
  1509. /**
  1510. * the name of this action.
  1511. * @version Egret 3.1.8
  1512. * @platform Web,Native
  1513. * @language en_US
  1514. */
  1515. /**
  1516. * 动作的名称
  1517. * @version Egret 3.1.8
  1518. * @platform Web,Native
  1519. * @language zh_CN
  1520. */
  1521. _this.name = "";
  1522. return _this;
  1523. }
  1524. return BasePath;
  1525. }(egret.EventDispatcher));
  1526. tween.BasePath = BasePath;
  1527. __reflect(BasePath.prototype, "egret.tween.BasePath");
  1528. /**
  1529. * Indicate the to action. See <code>Tween.to</code>
  1530. * @version Egret 3.1.8
  1531. * @platform Web,Native
  1532. * @language en_US
  1533. */
  1534. /**
  1535. * 表示一个to动作,参见<code>Tween.to</code>
  1536. * @version Egret 3.1.8
  1537. * @platform Web,Native
  1538. * @language zh_CN
  1539. */
  1540. var To = (function (_super) {
  1541. __extends(To, _super);
  1542. function To() {
  1543. var _this = _super !== null && _super.apply(this, arguments) || this;
  1544. /**
  1545. * Property set of an object
  1546. * @version Egret 3.1.8
  1547. * @platform Web,Native
  1548. * @language en_US
  1549. */
  1550. /**
  1551. * 对象的属性集合
  1552. * @version Egret 3.1.8
  1553. * @platform Web,Native
  1554. * @language zh_CN
  1555. */
  1556. _this.props = undefined;
  1557. /**
  1558. * Duration
  1559. * @version Egret 3.1.8
  1560. * @platform Web,Native
  1561. * @language en_US
  1562. */
  1563. /**
  1564. * 持续时间
  1565. * @version Egret 3.1.8
  1566. * @platform Web,Native
  1567. * @language zh_CN
  1568. */
  1569. _this.duration = 500;
  1570. /**
  1571. * Easing algorithm
  1572. * @version Egret 3.1.8
  1573. * @platform Web,Native
  1574. * @language en_US
  1575. */
  1576. /**
  1577. * 缓动算法
  1578. * @version Egret 3.1.8
  1579. * @platform Web,Native
  1580. * @language zh_CN
  1581. */
  1582. _this.ease = undefined;
  1583. return _this;
  1584. }
  1585. return To;
  1586. }(BasePath));
  1587. tween.To = To;
  1588. __reflect(To.prototype, "egret.tween.To");
  1589. /**
  1590. * Indicate the wait action. See <code>Tween.wait</code>
  1591. * @version Egret 3.1.8
  1592. * @platform Web,Native
  1593. * @language en_US
  1594. */
  1595. /**
  1596. * 表示一个wait动作,参见<code>Tween.wait</code>
  1597. * @version Egret 3.1.8
  1598. * @platform Web,Native
  1599. * @language zh_CN
  1600. */
  1601. var Wait = (function (_super) {
  1602. __extends(Wait, _super);
  1603. function Wait() {
  1604. var _this = _super !== null && _super.apply(this, arguments) || this;
  1605. /**
  1606. * Duration
  1607. * @version Egret 3.1.8
  1608. * @platform Web,Native
  1609. * @language en_US
  1610. */
  1611. /**
  1612. * 持续时间
  1613. * @version Egret 3.1.8
  1614. * @platform Web,Native
  1615. * @language zh_CN
  1616. */
  1617. _this.duration = 500;
  1618. /**
  1619. * Whether properties are updated during the waiting time
  1620. * @version Egret 3.1.8
  1621. * @platform Web,Native
  1622. * @language en_US
  1623. */
  1624. /**
  1625. * 等待期间属性是否会更新
  1626. * @version Egret 3.1.8
  1627. * @platform Web,Native
  1628. * @language zh_CN
  1629. */
  1630. _this.passive = undefined;
  1631. return _this;
  1632. }
  1633. return Wait;
  1634. }(BasePath));
  1635. tween.Wait = Wait;
  1636. __reflect(Wait.prototype, "egret.tween.Wait");
  1637. /**
  1638. * Indicate the set action. See <code>Tween.set</code>
  1639. * @version Egret 3.1.8
  1640. * @platform Web,Native
  1641. * @language en_US
  1642. */
  1643. /**
  1644. * 表示一个set动作,参见<code>Tween.set</code>
  1645. * @version Egret 3.1.8
  1646. * @platform Web,Native
  1647. * @language zh_CN
  1648. */
  1649. var Set = (function (_super) {
  1650. __extends(Set, _super);
  1651. function Set() {
  1652. var _this = _super !== null && _super.apply(this, arguments) || this;
  1653. /**
  1654. * Property set of an object
  1655. * @version Egret 3.1.8
  1656. * @platform Web,Native
  1657. * @language en_US
  1658. */
  1659. /**
  1660. * 对象的属性集合
  1661. * @version Egret 3.1.8
  1662. * @platform Web,Native
  1663. * @language zh_CN
  1664. */
  1665. _this.props = undefined;
  1666. return _this;
  1667. }
  1668. return Set;
  1669. }(BasePath));
  1670. tween.Set = Set;
  1671. __reflect(Set.prototype, "egret.tween.Set");
  1672. /**
  1673. * Indicate the tick action. See <code>Tween.tick</code>
  1674. * @version Egret 3.1.8
  1675. * @platform Web,Native
  1676. * @language en_US
  1677. */
  1678. /**
  1679. * 表示一个tick动作,参见<code>Tween.tick</code>
  1680. * @version Egret 3.1.8
  1681. * @platform Web,Native
  1682. * @language zh_CN
  1683. */
  1684. var Tick = (function (_super) {
  1685. __extends(Tick, _super);
  1686. function Tick() {
  1687. var _this = _super !== null && _super.apply(this, arguments) || this;
  1688. /**
  1689. * Delta time
  1690. * @version Egret 3.1.8
  1691. * @platform Web,Native
  1692. * @language en_US
  1693. */
  1694. /**
  1695. * 增加的时间
  1696. * @version Egret 3.1.8
  1697. * @platform Web,Native
  1698. * @language zh_CN
  1699. */
  1700. _this.delta = 0;
  1701. return _this;
  1702. }
  1703. return Tick;
  1704. }(BasePath));
  1705. tween.Tick = Tick;
  1706. __reflect(Tick.prototype, "egret.tween.Tick");
  1707. function convertEase(ease) {
  1708. if (typeof ease === 'function') {
  1709. return ease;
  1710. }
  1711. else {
  1712. var func = egret.Ease[ease];
  1713. if (typeof func === 'function') {
  1714. return func;
  1715. }
  1716. }
  1717. return null;
  1718. }
  1719. /**
  1720. * TweenItem is a wrapper for Tween, which can set the behavior of Tween by setting attributes and adding Path.
  1721. *
  1722. * @event pathComplete Dispatched when some Path has complete.
  1723. * @event complete Dispatched when all Paths has complete.
  1724. *
  1725. * @defaultProperty props
  1726. * @version Egret 3.1.8
  1727. * @platform Web,Native
  1728. * @language en_US
  1729. */
  1730. /**
  1731. * TweenItem是对Tween的包装器,能通过设置属性和添加Path的方式设置Tween的行为。
  1732. * 通常用于使用在EXML中定义组件的动画。
  1733. *
  1734. * @event pathComplete 当某个Path执行完毕时会派发此事件。
  1735. * @event complete 当所有Path执行完毕时会派发此事件。
  1736. *
  1737. * @defaultProperty props
  1738. * @version Egret 3.1.8
  1739. * @platform Web,Native
  1740. * @language zh_CN
  1741. */
  1742. /**
  1743. * Use in exml:
  1744. * ```
  1745. * <tween:TweenItem target="{this.button}">
  1746. * <tween:props>
  1747. * <e:Object loop="{true}"/>
  1748. * </tween:props>
  1749. * <tween:paths>
  1750. * <e:Array>
  1751. * <tween:To duration="500">
  1752. * <tween:props>
  1753. * <e:Object x="{100}" y="{200}" />
  1754. * </tween:props>
  1755. * </tween:To>
  1756. * <tween:Wait duration="1000" />
  1757. * <tween:To duration="1000">
  1758. * <tween:props>
  1759. * <e:Object x="{200}" y="{100}" />
  1760. * </tween:props>
  1761. * </tween:To>
  1762. * </e:Array>
  1763. * </tween:paths>
  1764. * </tween:TweenItem>
  1765. * ```
  1766. */
  1767. var TweenItem = (function (_super) {
  1768. __extends(TweenItem, _super);
  1769. function TweenItem() {
  1770. var _this = _super.call(this) || this;
  1771. _this.isStop = false;
  1772. return _this;
  1773. }
  1774. Object.defineProperty(TweenItem.prototype, "props", {
  1775. /**
  1776. * The Tween's props.
  1777. * @version Egret 3.1.8
  1778. * @platform Web,Native
  1779. * @language en_US
  1780. */
  1781. /**
  1782. * Tween的props参数。
  1783. * @version Egret 3.1.8
  1784. * @platform Web,Native
  1785. * @language zh_CN
  1786. */
  1787. get: function () {
  1788. return this._props;
  1789. },
  1790. set: function (value) {
  1791. this._props = value;
  1792. },
  1793. enumerable: true,
  1794. configurable: true
  1795. });
  1796. Object.defineProperty(TweenItem.prototype, "target", {
  1797. /**
  1798. * The Tween's target.
  1799. * @version Egret 3.1.8
  1800. * @platform Web,Native
  1801. * @language en_US
  1802. */
  1803. /**
  1804. * Tween的target参数。
  1805. * @version Egret 3.1.8
  1806. * @platform Web,Native
  1807. * @language zh_CN
  1808. */
  1809. get: function () {
  1810. return this._target;
  1811. },
  1812. set: function (value) {
  1813. this._target = value;
  1814. },
  1815. enumerable: true,
  1816. configurable: true
  1817. });
  1818. Object.defineProperty(TweenItem.prototype, "paths", {
  1819. /**
  1820. * The Actions in Tween.
  1821. * @version Egret 3.1.8
  1822. * @platform Web,Native
  1823. * @language en_US
  1824. */
  1825. /**
  1826. * TweenItem中添加的行为。
  1827. * @version Egret 3.1.8
  1828. * @platform Web,Native
  1829. * @language zh_CN
  1830. */
  1831. get: function () {
  1832. return this._paths;
  1833. },
  1834. set: function (value) {
  1835. this._paths = value || [];
  1836. },
  1837. enumerable: true,
  1838. configurable: true
  1839. });
  1840. /**
  1841. * Play the Tween
  1842. * @position The starting position, the default is from the last position to play
  1843. * @version Egret 3.1.8
  1844. * @platform Web,Native
  1845. * @language en_US
  1846. */
  1847. /**
  1848. * 播放Tween
  1849. * @position 播放的起始位置, 默认为从上次位置继续播放
  1850. * @version Egret 3.1.8
  1851. * @platform Web,Native
  1852. * @language zh_CN
  1853. */
  1854. TweenItem.prototype.play = function (position) {
  1855. if (!this.tween) {
  1856. this.createTween(position);
  1857. }
  1858. else {
  1859. this.tween.setPaused(false);
  1860. if (this.isStop && position == undefined) {
  1861. position = 0;
  1862. this.isStop = false;
  1863. }
  1864. if (position !== undefined && position !== null) {
  1865. this.tween.setPosition(position);
  1866. }
  1867. }
  1868. };
  1869. /**
  1870. * Pause the Tween
  1871. * @version Egret 3.1.8
  1872. * @platform Web,Native
  1873. * @language en_US
  1874. */
  1875. /**
  1876. * 暂停Tween
  1877. * @version Egret 3.1.8
  1878. * @platform Web,Native
  1879. * @language zh_CN
  1880. */
  1881. TweenItem.prototype.pause = function () {
  1882. if (this.tween) {
  1883. this.tween.setPaused(true);
  1884. }
  1885. };
  1886. /**
  1887. * Stop the Tween
  1888. * @version Egret 3.1.8
  1889. * @platform Web,Native
  1890. * @language en_US
  1891. */
  1892. /**
  1893. * 停止Tween
  1894. * @version Egret 3.1.8
  1895. * @platform Web,Native
  1896. * @language zh_CN
  1897. */
  1898. TweenItem.prototype.stop = function () {
  1899. this.pause();
  1900. this.isStop = true;
  1901. };
  1902. TweenItem.prototype.createTween = function (position) {
  1903. this.tween = egret.Tween.get(this._target, this._props);
  1904. if (this._paths) {
  1905. this.applyPaths();
  1906. }
  1907. if (position !== undefined && position !== null) {
  1908. this.tween.setPosition(position);
  1909. }
  1910. };
  1911. TweenItem.prototype.applyPaths = function () {
  1912. for (var i = 0; i < this._paths.length; i++) {
  1913. var path = this._paths[i];
  1914. this.applyPath(path);
  1915. }
  1916. };
  1917. TweenItem.prototype.applyPath = function (path) {
  1918. var _this = this;
  1919. if (path instanceof To) {
  1920. this.tween.to(path.props, path.duration, convertEase(path.ease));
  1921. }
  1922. else if (path instanceof Wait) {
  1923. this.tween.wait(path.duration, path.passive);
  1924. }
  1925. else if (path instanceof Set) {
  1926. this.tween.set(path.props);
  1927. }
  1928. else if (path instanceof Tick) {
  1929. this.tween.$tick(path.delta);
  1930. }
  1931. this.tween.call(function () { return _this.pathComplete(path); });
  1932. };
  1933. TweenItem.prototype.pathComplete = function (path) {
  1934. path.dispatchEventWith('complete');
  1935. this.dispatchEventWith('pathComplete', false, path);
  1936. var index = this._paths.indexOf(path);
  1937. if (index >= 0 && index === this._paths.length - 1) {
  1938. this.dispatchEventWith('complete');
  1939. }
  1940. };
  1941. return TweenItem;
  1942. }(egret.EventDispatcher));
  1943. tween.TweenItem = TweenItem;
  1944. __reflect(TweenItem.prototype, "egret.tween.TweenItem");
  1945. registerProperty(TweenItem, 'paths', 'Array', true);
  1946. /**
  1947. * TweenGroup is a collection of TweenItem that can be played in parallel with each Item
  1948. *
  1949. * @event itemComplete Dispatched when some TweenItem has complete.
  1950. * @event complete Dispatched when all TweenItems has complete.
  1951. *
  1952. * @version Egret 3.1.8
  1953. * @platform Web,Native
  1954. * @includeExample extension/tween/TweenWrapper.ts
  1955. * @language en_US
  1956. */
  1957. /**
  1958. * TweenGroup是TweenItem的集合,可以并行播放每一个Item
  1959. * @version Egret 3.1.8
  1960. * @platform Web,Native
  1961. * @includeExample extension/tween/TweenWrapper.ts
  1962. * @language zh_CN
  1963. */
  1964. var TweenGroup = (function (_super) {
  1965. __extends(TweenGroup, _super);
  1966. function TweenGroup() {
  1967. var _this = _super.call(this) || this;
  1968. _this.completeCount = 0;
  1969. return _this;
  1970. }
  1971. Object.defineProperty(TweenGroup.prototype, "items", {
  1972. /**
  1973. * The Array that TweenItems in TweenGroup.
  1974. * @version Egret 3.1.8
  1975. * @platform Web,Native
  1976. * @language en_US
  1977. */
  1978. /**
  1979. * TweenGroup要控制的TweenItem集合。
  1980. * @version Egret 3.1.8
  1981. * @platform Web,Native
  1982. * @language zh_CN
  1983. */
  1984. get: function () {
  1985. return this._items;
  1986. },
  1987. set: function (value) {
  1988. this.completeCount = 0;
  1989. this.registerEvent(false);
  1990. this._items = value;
  1991. this.registerEvent(true);
  1992. },
  1993. enumerable: true,
  1994. configurable: true
  1995. });
  1996. TweenGroup.prototype.registerEvent = function (add) {
  1997. var _this = this;
  1998. this._items && this._items.forEach(function (item) {
  1999. if (add) {
  2000. item.addEventListener('complete', _this.itemComplete, _this);
  2001. }
  2002. else {
  2003. item.removeEventListener('complete', _this.itemComplete, _this);
  2004. }
  2005. });
  2006. };
  2007. /**
  2008. * Play the all TweenItems
  2009. * @time The starting position, the default is from the last position to play。If use 0, the group will play from the start position.
  2010. * @version Egret 3.1.8
  2011. * @platform Web,Native
  2012. * @language en_US
  2013. */
  2014. /**
  2015. * 播放所有的TweenItem
  2016. * @time 播放的起始位置, 默认为从上次位置继续播放。如果为0,则从起始位置开始播放。
  2017. * @version Egret 3.1.8
  2018. * @platform Web,Native
  2019. * @language zh_CN
  2020. */
  2021. TweenGroup.prototype.play = function (time) {
  2022. if (!this._items) {
  2023. return;
  2024. }
  2025. for (var i = 0; i < this._items.length; i++) {
  2026. var item = this._items[i];
  2027. item.play(time);
  2028. }
  2029. };
  2030. /**
  2031. * Pause the all TweenItems
  2032. * @version Egret 3.1.8
  2033. * @platform Web,Native
  2034. * @language en_US
  2035. */
  2036. /**
  2037. * 暂停播放所有的TweenItem
  2038. * @version Egret 3.1.8
  2039. * @platform Web,Native
  2040. * @language zh_CN
  2041. */
  2042. TweenGroup.prototype.pause = function () {
  2043. if (!this._items) {
  2044. return;
  2045. }
  2046. for (var i = 0; i < this._items.length; i++) {
  2047. var item = this._items[i];
  2048. item.pause();
  2049. }
  2050. };
  2051. /**
  2052. * Stop the all TweenItems
  2053. * @version Egret 3.1.8
  2054. * @platform Web,Native
  2055. * @language en_US
  2056. */
  2057. /**
  2058. * 停止所有的TweenItem
  2059. * @version Egret 3.1.8
  2060. * @platform Web,Native
  2061. * @language zh_CN
  2062. */
  2063. TweenGroup.prototype.stop = function () {
  2064. if (!this._items) {
  2065. return;
  2066. }
  2067. for (var i = 0; i < this._items.length; i++) {
  2068. var item = this._items[i];
  2069. item.stop();
  2070. }
  2071. };
  2072. TweenGroup.prototype.itemComplete = function (e) {
  2073. var item = e.currentTarget;
  2074. this.completeCount++;
  2075. this.dispatchEventWith('itemComplete', false, item);
  2076. if (this.completeCount === this.items.length) {
  2077. this.dispatchEventWith('complete');
  2078. this.completeCount = 0;
  2079. }
  2080. };
  2081. return TweenGroup;
  2082. }(egret.EventDispatcher));
  2083. tween.TweenGroup = TweenGroup;
  2084. __reflect(TweenGroup.prototype, "egret.tween.TweenGroup");
  2085. registerProperty(TweenGroup, 'items', 'Array', true);
  2086. function registerProperty(classDefinition, property, type, asDefault) {
  2087. var prototype = classDefinition.prototype;
  2088. prototype.__meta__ = prototype.__meta__ || {};
  2089. prototype.__meta__[property] = type;
  2090. if (asDefault) {
  2091. prototype.__defaultProperty__ = property;
  2092. }
  2093. }
  2094. })(tween = egret.tween || (egret.tween = {}));
  2095. })(egret || (egret = {}));