美素佳儿 litter wizard小游戏
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

tween.js 67KB

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