CCActionEase.js 95 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682
  1. /****************************************************************************
  2. Copyright (c) 2008-2010 Ricardo Quesada
  3. Copyright (c) 2011-2012 cocos2d-x.org
  4. Copyright (c) 2013-2014 Chukong Technologies Inc.
  5. http://www.cocos2d-x.org
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. THE SOFTWARE.
  21. ****************************************************************************/
  22. /**
  23. * Base class for Easing actions
  24. * @class
  25. * @extends cc.ActionInterval
  26. * @param {cc.ActionInterval} action
  27. *
  28. * @deprecated since v3.0 Does not recommend the use of the base object.
  29. *
  30. * @example
  31. * var moveEase = new cc.ActionEase(action);
  32. */
  33. cc.ActionEase = cc.ActionInterval.extend(/** @lends cc.ActionEase# */{
  34. _inner:null,
  35. /**
  36. * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
  37. * creates the action of ActionEase.
  38. * @param {cc.ActionInterval} action
  39. */
  40. ctor: function (action) {
  41. cc.ActionInterval.prototype.ctor.call(this);
  42. action && this.initWithAction(action);
  43. },
  44. /**
  45. * initializes the action
  46. *
  47. * @param {cc.ActionInterval} action
  48. * @return {Boolean}
  49. */
  50. initWithAction:function (action) {
  51. if(!action)
  52. throw "cc.ActionEase.initWithAction(): action must be non nil";
  53. if (this.initWithDuration(action.getDuration())) {
  54. this._inner = action;
  55. return true;
  56. }
  57. return false;
  58. },
  59. /**
  60. * to copy object with deep copy.
  61. * returns a clone of action.
  62. *
  63. * @returns {cc.ActionEase}
  64. */
  65. clone:function(){
  66. var action = new cc.ActionEase();
  67. action.initWithAction(this._inner.clone());
  68. return action;
  69. },
  70. /**
  71. * called before the action start. It will also set the target.
  72. *
  73. * @param {cc.Node} target
  74. */
  75. startWithTarget:function (target) {
  76. cc.ActionInterval.prototype.startWithTarget.call(this, target);
  77. this._inner.startWithTarget(this.target);
  78. },
  79. /**
  80. * Stop the action.
  81. */
  82. stop:function () {
  83. this._inner.stop();
  84. cc.ActionInterval.prototype.stop.call(this);
  85. },
  86. /**
  87. * Called once per frame. Time is the number of seconds of a frame interval.
  88. *
  89. * @param {Number} dt
  90. */
  91. update:function (dt) {
  92. this._inner.update(dt);
  93. },
  94. /**
  95. * Create new action to original operation effect opposite. <br />
  96. * For example: <br />
  97. * - The action will be x coordinates of 0 move to 100. <br />
  98. * - The reversed action will be x of 100 move to 0.
  99. * - Will be rewritten
  100. * @return {cc.ActionEase}
  101. */
  102. reverse:function () {
  103. return new cc.ActionEase(this._inner.reverse());
  104. },
  105. /**
  106. * Get inner Action.
  107. *
  108. * @return {cc.ActionInterval}
  109. */
  110. getInnerAction:function(){
  111. return this._inner;
  112. }
  113. });
  114. /**
  115. * creates the action of ActionEase
  116. *
  117. * @param {cc.ActionInterval} action
  118. * @return {cc.ActionEase}
  119. * @example
  120. * // example
  121. * var moveEase = cc.actionEase(action);
  122. */
  123. cc.actionEase = function (action) {
  124. return new cc.ActionEase(action);
  125. };
  126. /**
  127. * Please use cc.actionEase instead
  128. * creates the action of ActionEase
  129. *
  130. * @param {cc.ActionInterval} action
  131. * @return {cc.ActionEase}
  132. * @static
  133. * @deprecated since v3.0 please use cc.actionEase(action) instead.
  134. */
  135. cc.ActionEase.create = cc.actionEase;
  136. /**
  137. * Base class for Easing actions with rate parameters
  138. *
  139. * @class
  140. * @extends cc.ActionEase
  141. * @param {cc.ActionInterval} action
  142. * @param {Number} rate
  143. *
  144. * @deprecated since v3.0 please cc.easeRateAction(action, 3.0);
  145. *
  146. * @example
  147. * //The old usage
  148. * cc.EaseRateAction.create(action, 3.0);
  149. * //The new usage
  150. * var moveEaseRateAction = cc.easeRateAction(action, 3.0);
  151. */
  152. cc.EaseRateAction = cc.ActionEase.extend(/** @lends cc.EaseRateAction# */{
  153. _rate:0,
  154. /**
  155. * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
  156. * Creates the action with the inner action and the rate parameter.
  157. * @param {cc.ActionInterval} action
  158. * @param {Number} rate
  159. */
  160. ctor: function(action, rate){
  161. cc.ActionEase.prototype.ctor.call(this);
  162. rate !== undefined && this.initWithAction(action, rate);
  163. },
  164. /**
  165. * set rate value for the actions
  166. * @param {Number} rate
  167. */
  168. setRate:function (rate) {
  169. this._rate = rate;
  170. },
  171. /** get rate value for the actions
  172. * @return {Number}
  173. */
  174. getRate:function () {
  175. return this._rate;
  176. },
  177. /**
  178. * Initializes the action with the inner action and the rate parameter
  179. * @param {cc.ActionInterval} action
  180. * @param {Number} rate
  181. * @return {Boolean}
  182. */
  183. initWithAction:function (action, rate) {
  184. if (cc.ActionEase.prototype.initWithAction.call(this, action)) {
  185. this._rate = rate;
  186. return true;
  187. }
  188. return false;
  189. },
  190. /**
  191. * to copy object with deep copy.
  192. * returns a clone of action.
  193. *
  194. * @returns {cc.EaseRateAction}
  195. */
  196. clone:function(){
  197. var action = new cc.EaseRateAction();
  198. action.initWithAction(this._inner.clone(), this._rate);
  199. return action;
  200. },
  201. /**
  202. * Create new action to original operation effect opposite. <br />
  203. * For example: <br />
  204. * - The action will be x coordinates of 0 move to 100. <br />
  205. * - The reversed action will be x of 100 move to 0.
  206. * - Will be rewritten
  207. * @return {cc.EaseRateAction}
  208. */
  209. reverse:function () {
  210. return new cc.EaseRateAction(this._inner.reverse(), 1 / this._rate);
  211. }
  212. });
  213. /**
  214. * Creates the action with the inner action and the rate parameter.
  215. *
  216. * @param {cc.ActionInterval} action
  217. * @param {Number} rate
  218. * @return {cc.EaseRateAction}
  219. * @example
  220. * // example
  221. * var moveEaseRateAction = cc.easeRateAction(action, 3.0);
  222. */
  223. cc.easeRateAction = function (action, rate) {
  224. return new cc.EaseRateAction(action, rate);
  225. };
  226. /**
  227. * Please use cc.easeRateAction instead. <br />
  228. * Creates the action with the inner action and the rate parameter.
  229. *
  230. * @param {cc.ActionInterval} action
  231. * @param {Number} rate
  232. * @return {cc.EaseRateAction}
  233. * @static
  234. * @deprecated since v3.0 please use cc.easeRateAction(action, rate)
  235. * @example
  236. * //The old usage
  237. * cc.EaseRateAction.create(action, 3.0);
  238. * //The new usage
  239. * var moveEaseRateAction = cc.easeRateAction(action, 3.0);
  240. */
  241. cc.EaseRateAction.create = cc.easeRateAction;
  242. /**
  243. * cc.EaseIn action with a rate. From slow to fast.
  244. *
  245. * @class
  246. * @extends cc.EaseRateAction
  247. *
  248. * @deprecated since v3.0 please use action.easing(cc.easeIn(3));
  249. *
  250. * @example
  251. * //The old usage
  252. * cc.EaseIn.create(action, 3);
  253. * //The new usage
  254. * action.easing(cc.easeIn(3.0));
  255. */
  256. cc.EaseIn = cc.EaseRateAction.extend(/** @lends cc.EaseIn# */{
  257. /**
  258. * Called once per frame. Time is the number of seconds of a frame interval.
  259. *
  260. * @param {Number} dt
  261. */
  262. update:function (dt) {
  263. this._inner.update(Math.pow(dt, this._rate));
  264. },
  265. /**
  266. * Create a cc.easeIn action. Opposite with the original motion trajectory.
  267. * @return {cc.EaseIn}
  268. */
  269. reverse:function () {
  270. return new cc.EaseIn(this._inner.reverse(), 1 / this._rate);
  271. },
  272. /**
  273. * to copy object with deep copy.
  274. * returns a clone of action.
  275. *
  276. * @returns {cc.EaseIn}
  277. */
  278. clone:function(){
  279. var action = new cc.EaseIn();
  280. action.initWithAction(this._inner.clone(), this._rate);
  281. return action;
  282. }
  283. });
  284. /**
  285. * Creates the action with the inner action and the rate parameter. <br />
  286. * From slow to fast.
  287. *
  288. * @static
  289. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeIn(3))
  290. *
  291. * @example
  292. * //The old usage
  293. * cc.EaseIn.create(action, 3);
  294. * //The new usage
  295. * action.easing(cc.easeIn(3.0));
  296. *
  297. * @param {cc.ActionInterval} action
  298. * @param {Number} rate
  299. * @return {cc.EaseIn}
  300. */
  301. cc.EaseIn.create = function (action, rate) {
  302. return new cc.EaseIn(action, rate);
  303. };
  304. /**
  305. * Creates the action easing object with the rate parameter. <br />
  306. * From slow to fast.
  307. *
  308. * @function
  309. * @param {Number} rate
  310. * @return {Object}
  311. * @example
  312. * // example
  313. * action.easing(cc.easeIn(3.0));
  314. */
  315. cc.easeIn = function (rate) {
  316. return {
  317. _rate: rate,
  318. easing: function (dt) {
  319. return Math.pow(dt, this._rate);
  320. },
  321. reverse: function(){
  322. return cc.easeIn(1 / this._rate);
  323. }
  324. };
  325. };
  326. /**
  327. * cc.EaseOut action with a rate. From fast to slow.
  328. *
  329. * @class
  330. * @extends cc.EaseRateAction
  331. *
  332. * @deprecated since v3.0 please use action.easing(cc.easeOut(3))
  333. *
  334. * @example
  335. * //The old usage
  336. * cc.EaseOut.create(action, 3);
  337. * //The new usage
  338. * action.easing(cc.easeOut(3.0));
  339. */
  340. cc.EaseOut = cc.EaseRateAction.extend(/** @lends cc.EaseOut# */{
  341. /**
  342. * Called once per frame. Time is the number of seconds of a frame interval.
  343. *
  344. * @param {Number} dt
  345. */
  346. update:function (dt) {
  347. this._inner.update(Math.pow(dt, 1 / this._rate));
  348. },
  349. /**
  350. * Create a cc.easeIn action. Opposite with the original motion trajectory.
  351. * @return {cc.EaseOut}
  352. */
  353. reverse:function () {
  354. return new cc.EaseOut(this._inner.reverse(), 1 / this._rate);
  355. },
  356. /**
  357. * to copy object with deep copy.
  358. * returns a clone of action.
  359. *
  360. * @returns {cc.EaseOut}
  361. */
  362. clone:function(){
  363. var action = new cc.EaseOut();
  364. action.initWithAction(this._inner.clone(),this._rate);
  365. return action;
  366. }
  367. });
  368. /**
  369. * Creates the action with the inner action and the rate parameter. <br />
  370. * From fast to slow.
  371. *
  372. * @static
  373. * @deprecated since v3.0 <br /> Please use cc.easeOut instead.
  374. *
  375. * @example
  376. * //The old usage
  377. * cc.EaseOut.create(action, 3);
  378. * //The new usage
  379. * action.easing(cc.easeOut(3.0));
  380. *
  381. * @param {cc.ActionInterval} action
  382. * @param {Number} rate
  383. * @return {cc.EaseOut}
  384. */
  385. cc.EaseOut.create = function (action, rate) {
  386. return new cc.EaseOut(action, rate);
  387. };
  388. /**
  389. * Creates the action easing object with the rate parameter. <br />
  390. * From fast to slow.
  391. *
  392. * @function
  393. * @param {Number} rate
  394. * @return {Object}
  395. * @example
  396. * // example
  397. * action.easing(cc.easeOut(3.0));
  398. */
  399. cc.easeOut = function (rate) {
  400. return {
  401. _rate: rate,
  402. easing: function (dt) {
  403. return Math.pow(dt, 1 / this._rate);
  404. },
  405. reverse: function(){
  406. return cc.easeOut(1 / this._rate)
  407. }
  408. };
  409. };
  410. /**
  411. * cc.EaseInOut action with a rate. <br />
  412. * Slow to fast then to slow.
  413. * @class
  414. * @extends cc.EaseRateAction
  415. *
  416. * @deprecated since v3.0 please use action.easing(cc.easeInOut(3.0))
  417. *
  418. * @example
  419. * //The old usage
  420. * cc.EaseInOut.create(action, 3);
  421. * //The new usage
  422. * action.easing(cc.easeInOut(3.0));
  423. */
  424. cc.EaseInOut = cc.EaseRateAction.extend(/** @lends cc.EaseInOut# */{
  425. /**
  426. * Called once per frame. Time is the number of seconds of a frame interval.
  427. *
  428. * @param {Number} dt
  429. */
  430. update:function (dt) {
  431. dt *= 2;
  432. if (dt < 1)
  433. this._inner.update(0.5 * Math.pow(dt, this._rate));
  434. else
  435. this._inner.update(1.0 - 0.5 * Math.pow(2 - dt, this._rate));
  436. },
  437. /**
  438. * to copy object with deep copy.
  439. * returns a clone of action.
  440. *
  441. * @returns {cc.EaseInOut}
  442. */
  443. clone:function(){
  444. var action = new cc.EaseInOut();
  445. action.initWithAction(this._inner.clone(), this._rate);
  446. return action;
  447. },
  448. /**
  449. * Create a cc.EaseInOut action. Opposite with the original motion trajectory.
  450. * @return {cc.EaseInOut}
  451. */
  452. reverse:function () {
  453. return new cc.EaseInOut(this._inner.reverse(), this._rate);
  454. }
  455. });
  456. /**
  457. * Creates the action with the inner action and the rate parameter.
  458. * Slow to fast then to slow.
  459. * @static
  460. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeInOut(3.0))
  461. *
  462. * @example
  463. * //The old usage
  464. * cc.EaseInOut.create(action, 3);
  465. * //The new usage
  466. * action.easing(cc.easeInOut(3.0));
  467. *
  468. * @param {cc.ActionInterval} action
  469. * @param {Number} rate
  470. * @return {cc.EaseInOut}
  471. */
  472. cc.EaseInOut.create = function (action, rate) {
  473. return new cc.EaseInOut(action, rate);
  474. };
  475. /**
  476. * Creates the action easing object with the rate parameter. <br />
  477. * Slow to fast then to slow.
  478. * @function
  479. * @param {Number} rate
  480. * @return {Object}
  481. *
  482. * @example
  483. * //The new usage
  484. * action.easing(cc.easeInOut(3.0));
  485. */
  486. cc.easeInOut = function (rate) {
  487. return {
  488. _rate: rate,
  489. easing: function (dt) {
  490. dt *= 2;
  491. if (dt < 1)
  492. return 0.5 * Math.pow(dt, this._rate);
  493. else
  494. return 1.0 - 0.5 * Math.pow(2 - dt, this._rate);
  495. },
  496. reverse: function(){
  497. return cc.easeInOut(this._rate);
  498. }
  499. };
  500. };
  501. /**
  502. * cc.Ease Exponential In. Slow to Fast. <br />
  503. * Reference easeInExpo: <br />
  504. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  505. * @class
  506. * @extends cc.ActionEase
  507. *
  508. * @deprecated since v3.0 please action.easing(cc.easeExponentialIn())
  509. *
  510. * @example
  511. * //The old usage
  512. * cc.EaseExponentialIn.create(action);
  513. * //The new usage
  514. * action.easing(cc.easeExponentialIn());
  515. */
  516. cc.EaseExponentialIn = cc.ActionEase.extend(/** @lends cc.EaseExponentialIn# */{
  517. /**
  518. * Called once per frame. Time is the number of seconds of a frame interval.
  519. *
  520. * @param {Number} dt
  521. */
  522. update:function (dt) {
  523. this._inner.update(dt === 0 ? 0 : Math.pow(2, 10 * (dt - 1)));
  524. },
  525. /**
  526. * Create a cc.EaseExponentialOut action. Opposite with the original motion trajectory.
  527. * @return {cc.EaseExponentialOut}
  528. */
  529. reverse:function () {
  530. return new cc.EaseExponentialOut(this._inner.reverse());
  531. },
  532. /**
  533. * to copy object with deep copy.
  534. * returns a clone of action.
  535. *
  536. * @returns {cc.EaseExponentialIn}
  537. */
  538. clone:function(){
  539. var action = new cc.EaseExponentialIn();
  540. action.initWithAction(this._inner.clone());
  541. return action;
  542. }
  543. });
  544. /**
  545. * Creates the action easing object with the rate parameter. <br />
  546. * Reference easeInExpo: <br />
  547. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  548. * @static
  549. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeExponentialIn())
  550. * @param {cc.ActionInterval} action
  551. * @return {cc.EaseExponentialIn}
  552. *
  553. * @example
  554. * //The old usage
  555. * cc.EaseExponentialIn.create(action);
  556. * //The new usage
  557. * action.easing(cc.easeExponentialIn());
  558. */
  559. cc.EaseExponentialIn.create = function (action) {
  560. return new cc.EaseExponentialIn(action);
  561. };
  562. cc._easeExponentialInObj = {
  563. easing: function(dt){
  564. return dt === 0 ? 0 : Math.pow(2, 10 * (dt - 1));
  565. },
  566. reverse: function(){
  567. return cc._easeExponentialOutObj;
  568. }
  569. };
  570. /**
  571. * Creates the action easing object with the rate parameter. <br />
  572. * Reference easeInExpo: <br />
  573. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  574. * @function
  575. * @return {Object}
  576. * @example
  577. * // example
  578. * action.easing(cc.easeExponentialIn());
  579. */
  580. cc.easeExponentialIn = function(){
  581. return cc._easeExponentialInObj;
  582. };
  583. /**
  584. * Ease Exponential Out. <br />
  585. * Reference easeOutExpo: <br />
  586. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  587. * @class
  588. * @extends cc.ActionEase
  589. *
  590. * @deprecated since v3.0 please use action.easing(cc.easeExponentialOut())
  591. *
  592. * @example
  593. * //The old usage
  594. * cc.EaseExponentialOut.create(action);
  595. * //The new usage
  596. * action.easing(cc.easeExponentialOut());
  597. */
  598. cc.EaseExponentialOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialOut# */{
  599. /**
  600. * Called once per frame. Time is the number of seconds of a frame interval.
  601. *
  602. * @param {Number} dt
  603. */
  604. update:function (dt) {
  605. this._inner.update(dt == 1 ? 1 : (-(Math.pow(2, -10 * dt)) + 1));
  606. },
  607. /**
  608. * Create a cc.EaseExponentialIn action. Opposite with the original motion trajectory.
  609. * @return {cc.EaseExponentialIn}
  610. */
  611. reverse:function () {
  612. return new cc.EaseExponentialIn(this._inner.reverse());
  613. },
  614. /**
  615. * to copy object with deep copy.
  616. * returns a clone of action.
  617. *
  618. * @returns {cc.EaseExponentialOut}
  619. */
  620. clone:function(){
  621. var action = new cc.EaseExponentialOut();
  622. action.initWithAction(this._inner.clone());
  623. return action;
  624. }
  625. });
  626. /**
  627. * Creates the action easing object with the rate parameter. <br />
  628. * Reference easeOutExpo: <br />
  629. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  630. * @static
  631. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeExponentialOut())
  632. * @param {cc.ActionInterval} action
  633. * @return {Object}
  634. *
  635. * @example
  636. * //The old usage
  637. * cc.EaseExponentialOut.create(action);
  638. * //The new usage
  639. * action.easing(cc.easeExponentialOut());
  640. */
  641. cc.EaseExponentialOut.create = function (action) {
  642. return new cc.EaseExponentialOut(action);
  643. };
  644. cc._easeExponentialOutObj = {
  645. easing: function(dt){
  646. return dt == 1 ? 1 : (-(Math.pow(2, -10 * dt)) + 1);
  647. },
  648. reverse: function(){
  649. return cc._easeExponentialInObj;
  650. }
  651. };
  652. /**
  653. * creates the action easing object. <br />
  654. * Reference easeOutExpo: <br />
  655. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  656. *
  657. * @return {Object}
  658. * @example
  659. * // example
  660. * action.easing(cc.easeExponentialOut());
  661. */
  662. cc.easeExponentialOut = function(){
  663. return cc._easeExponentialOutObj;
  664. };
  665. /**
  666. * Ease Exponential InOut. <br />
  667. * Reference easeInOutExpo: <br />
  668. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  669. *
  670. * @class
  671. * @extends cc.ActionEase
  672. *
  673. * @deprecated since v3.0 please use action.easing(cc.easeExponentialInOut)
  674. *
  675. * @example
  676. * //The old usage
  677. * cc.EaseExponentialInOut.create(action);
  678. * //The new usage
  679. * action.easing(cc.easeExponentialInOut());
  680. */
  681. cc.EaseExponentialInOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialInOut# */{
  682. /**
  683. * Called once per frame. Time is the number of seconds of a frame interval.
  684. *
  685. * @param {Number} dt
  686. */
  687. update:function (dt) {
  688. if( dt != 1 && dt !== 0) {
  689. dt *= 2;
  690. if (dt < 1)
  691. dt = 0.5 * Math.pow(2, 10 * (dt - 1));
  692. else
  693. dt = 0.5 * (-Math.pow(2, -10 * (dt - 1)) + 2);
  694. }
  695. this._inner.update(dt);
  696. },
  697. /**
  698. * Create a cc.EaseExponentialInOut action. Opposite with the original motion trajectory.
  699. * @return {cc.EaseExponentialInOut}
  700. */
  701. reverse:function () {
  702. return new cc.EaseExponentialInOut(this._inner.reverse());
  703. },
  704. /**
  705. * to copy object with deep copy.
  706. * returns a clone of action.
  707. *
  708. * @returns {cc.EaseExponentialInOut}
  709. */
  710. clone:function(){
  711. var action = new cc.EaseExponentialInOut();
  712. action.initWithAction(this._inner.clone());
  713. return action;
  714. }
  715. });
  716. /**
  717. * creates an EaseExponentialInOut action. <br />
  718. * Reference easeInOutExpo: <br />
  719. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  720. * @static
  721. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeExponentialInOut)
  722. * @param {cc.ActionInterval} action
  723. * @return {cc.EaseExponentialInOut}
  724. *
  725. * @example
  726. * //The old usage
  727. * cc.EaseExponentialInOut.create(action);
  728. * //The new usage
  729. * action.easing(cc.easeExponentialInOut());
  730. */
  731. cc.EaseExponentialInOut.create = function (action) {
  732. return new cc.EaseExponentialInOut(action);
  733. };
  734. cc._easeExponentialInOutObj = {
  735. easing: function(dt){
  736. if( dt !== 1 && dt !== 0) {
  737. dt *= 2;
  738. if (dt < 1)
  739. return 0.5 * Math.pow(2, 10 * (dt - 1));
  740. else
  741. return 0.5 * (-Math.pow(2, -10 * (dt - 1)) + 2);
  742. }
  743. return dt;
  744. },
  745. reverse: function(){
  746. return cc._easeExponentialInOutObj;
  747. }
  748. };
  749. /**
  750. * creates an EaseExponentialInOut action easing object. <br />
  751. * Reference easeInOutExpo: <br />
  752. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  753. * @function
  754. * @return {Object}
  755. * @example
  756. * // example
  757. * action.easing(cc.easeExponentialInOut());
  758. */
  759. cc.easeExponentialInOut = function(){
  760. return cc._easeExponentialInOutObj;
  761. };
  762. /**
  763. * Ease Sine In. <br />
  764. * Reference easeInSine: <br />
  765. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  766. * @class
  767. * @extends cc.ActionEase
  768. *
  769. * @deprecated since v3.0 please use action.easing(cc.easeSineIn())
  770. *
  771. * @example
  772. * //The old usage
  773. * cc.EaseSineIn.create(action);
  774. * //The new usage
  775. * action.easing(cc.easeSineIn());
  776. */
  777. cc.EaseSineIn = cc.ActionEase.extend(/** @lends cc.EaseSineIn# */{
  778. /**
  779. * Called once per frame. Time is the number of seconds of a frame interval.
  780. *
  781. * @param {Number} dt
  782. */
  783. update:function (dt) {
  784. dt = dt===0 || dt===1 ? dt : -1 * Math.cos(dt * Math.PI / 2) + 1;
  785. this._inner.update(dt);
  786. },
  787. /**
  788. * Create a cc.EaseSineOut action. Opposite with the original motion trajectory.
  789. * @return {cc.EaseSineOut}
  790. */
  791. reverse:function () {
  792. return new cc.EaseSineOut(this._inner.reverse());
  793. },
  794. /**
  795. * to copy object with deep copy.
  796. * returns a clone of action.
  797. *
  798. * @returns {cc.EaseSineIn}
  799. */
  800. clone:function(){
  801. var action = new cc.EaseSineIn();
  802. action.initWithAction(this._inner.clone());
  803. return action;
  804. }
  805. });
  806. /**
  807. * creates an EaseSineIn action. <br />
  808. * Reference easeInSine: <br />
  809. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  810. * @static
  811. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeSineIn())
  812. * @param {cc.ActionInterval} action
  813. * @return {cc.EaseSineIn}
  814. *
  815. * @example
  816. * //The old usage
  817. * cc.EaseSineIn.create(action);
  818. * //The new usage
  819. * action.easing(cc.easeSineIn());
  820. */
  821. cc.EaseSineIn.create = function (action) {
  822. return new cc.EaseSineIn(action);
  823. };
  824. cc._easeSineInObj = {
  825. easing: function(dt){
  826. return (dt===0 || dt===1) ? dt : -1 * Math.cos(dt * Math.PI / 2) + 1;
  827. },
  828. reverse: function(){
  829. return cc._easeSineOutObj;
  830. }
  831. };
  832. /**
  833. * creates an EaseSineIn action. <br />
  834. * Reference easeInSine: <br />
  835. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  836. * @function
  837. * @return {Object}
  838. * @example
  839. * // example
  840. * action.easing(cc.easeSineIn());
  841. */
  842. cc.easeSineIn = function(){
  843. return cc._easeSineInObj;
  844. };
  845. /**
  846. * Ease Sine Out. <br />
  847. * Reference easeOutSine: <br />
  848. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  849. * @class
  850. * @extends cc.ActionEase
  851. *
  852. * @deprecated since v3.0 please use action.easing(cc.easeSineOut())
  853. *
  854. * @example
  855. * //The old usage
  856. * cc.EaseSineOut.create(action);
  857. * //The new usage
  858. * action.easing(cc.easeSineOut());
  859. */
  860. cc.EaseSineOut = cc.ActionEase.extend(/** @lends cc.EaseSineOut# */{
  861. /**
  862. * Called once per frame. Time is the number of seconds of a frame interval.
  863. *
  864. * @param {Number} dt
  865. */
  866. update:function (dt) {
  867. dt = dt===0 || dt===1 ? dt : Math.sin(dt * Math.PI / 2);
  868. this._inner.update(dt);
  869. },
  870. /**
  871. * Create a cc.EaseSineIn action. Opposite with the original motion trajectory.
  872. * @return {cc.EaseSineIn}
  873. */
  874. reverse:function () {
  875. return new cc.EaseSineIn(this._inner.reverse());
  876. },
  877. /**
  878. * to copy object with deep copy.
  879. * returns a clone of action.
  880. *
  881. * @returns {cc.EaseSineOut}
  882. */
  883. clone:function(){
  884. var action = new cc.EaseSineOut();
  885. action.initWithAction(this._inner.clone());
  886. return action;
  887. }
  888. });
  889. /**
  890. * Creates an EaseSineOut action. <br />
  891. * Reference easeOutSine: <br />
  892. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  893. * @static
  894. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeSineOut())
  895. * @param {cc.ActionInterval} action
  896. * @return {cc.EaseSineOut}
  897. *
  898. * @example
  899. * //The old usage
  900. * cc.EaseSineOut.create(action);
  901. * //The new usage
  902. * action.easing(cc.easeSineOut());
  903. */
  904. cc.EaseSineOut.create = function (action) {
  905. return new cc.EaseSineOut(action);
  906. };
  907. cc._easeSineOutObj = {
  908. easing: function(dt){
  909. return (dt===0 || dt==1) ? dt : Math.sin(dt * Math.PI / 2);
  910. },
  911. reverse: function(){
  912. return cc._easeSineInObj;
  913. }
  914. };
  915. /**
  916. * Creates an EaseSineOut action easing object. <br />
  917. * Reference easeOutSine: <br />
  918. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  919. * @function
  920. * @return {Object}
  921. * @example
  922. * // example
  923. * action.easing(cc.easeSineOut());
  924. */
  925. cc.easeSineOut = function(){
  926. return cc._easeSineOutObj;
  927. };
  928. /**
  929. * Ease Sine InOut. <br />
  930. * Reference easeInOutSine: <br />
  931. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  932. * @class
  933. * @extends cc.ActionEase
  934. *
  935. * @deprecated since v3.0 please use action.easing(cc.easeSineInOut())
  936. *
  937. * @example
  938. * //The old usage
  939. * cc.EaseSineInOut.create(action);
  940. * //The new usage
  941. * action.easing(cc.easeSineInOut());
  942. */
  943. cc.EaseSineInOut = cc.ActionEase.extend(/** @lends cc.EaseSineInOut# */{
  944. /**
  945. * Called once per frame. Time is the number of seconds of a frame interval.
  946. *
  947. * @param {Number} dt
  948. */
  949. update:function (dt) {
  950. dt = dt===0 || dt===1 ? dt : -0.5 * (Math.cos(Math.PI * dt) - 1);
  951. this._inner.update(dt);
  952. },
  953. /**
  954. * to copy object with deep copy.
  955. * returns a clone of action.
  956. *
  957. * @returns {cc.EaseSineInOut}
  958. */
  959. clone:function(){
  960. var action = new cc.EaseSineInOut();
  961. action.initWithAction(this._inner.clone());
  962. return action;
  963. },
  964. /**
  965. * Create a cc.EaseSineInOut action. Opposite with the original motion trajectory.
  966. * @return {cc.EaseSineInOut}
  967. */
  968. reverse:function () {
  969. return new cc.EaseSineInOut(this._inner.reverse());
  970. }
  971. });
  972. /**
  973. * Creates the action. <br />
  974. * Reference easeInOutSine: <br />
  975. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  976. * @static
  977. * @param {cc.ActionInterval} action
  978. * @return {cc.EaseSineInOut}
  979. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeSineInOut())
  980. *
  981. * @example
  982. * //The old usage
  983. * cc.EaseSineInOut.create(action);
  984. * //The new usage
  985. * action.easing(cc.easeSineInOut());
  986. */
  987. cc.EaseSineInOut.create = function (action) {
  988. return new cc.EaseSineInOut(action);
  989. };
  990. cc._easeSineInOutObj = {
  991. easing: function(dt){
  992. return (dt === 0 || dt === 1) ? dt : -0.5 * (Math.cos(Math.PI * dt) - 1);
  993. },
  994. reverse: function(){
  995. return cc._easeSineInOutObj;
  996. }
  997. };
  998. /**
  999. * creates the action easing object. <br />
  1000. * Reference easeInOutSine: <br />
  1001. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  1002. * @return {Object}
  1003. * @example
  1004. * // example
  1005. * action.easing(cc.easeSineInOut());
  1006. */
  1007. cc.easeSineInOut = function(){
  1008. return cc._easeSineInOutObj;
  1009. };
  1010. /**
  1011. * Ease Elastic abstract class.
  1012. * @class
  1013. * @extends cc.ActionEase
  1014. * @param {cc.ActionInterval} action
  1015. * @param {Number} [period=0.3]
  1016. *
  1017. * @deprecated since v3.0 Does not recommend the use of the base object.
  1018. */
  1019. cc.EaseElastic = cc.ActionEase.extend(/** @lends cc.EaseElastic# */{
  1020. _period: 0.3,
  1021. /**
  1022. * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
  1023. * Creates the action with the inner action and the period in radians (default is 0.3).
  1024. * @param {cc.ActionInterval} action
  1025. * @param {Number} [period=0.3]
  1026. */
  1027. ctor:function(action, period){
  1028. cc.ActionEase.prototype.ctor.call(this);
  1029. action && this.initWithAction(action, period);
  1030. },
  1031. /**
  1032. * get period of the wave in radians. default is 0.3
  1033. * @return {Number}
  1034. */
  1035. getPeriod:function () {
  1036. return this._period;
  1037. },
  1038. /**
  1039. * set period of the wave in radians.
  1040. * @param {Number} period
  1041. */
  1042. setPeriod:function (period) {
  1043. this._period = period;
  1044. },
  1045. /**
  1046. * Initializes the action with the inner action and the period in radians (default is 0.3)
  1047. * @param {cc.ActionInterval} action
  1048. * @param {Number} [period=0.3]
  1049. * @return {Boolean}
  1050. */
  1051. initWithAction:function (action, period) {
  1052. cc.ActionEase.prototype.initWithAction.call(this, action);
  1053. this._period = (period == null) ? 0.3 : period;
  1054. return true;
  1055. },
  1056. /**
  1057. * Create a action. Opposite with the original motion trajectory. <br />
  1058. * Will be overwrite.
  1059. * @return {null}
  1060. */
  1061. reverse:function () {
  1062. cc.log("cc.EaseElastic.reverse(): it should be overridden in subclass.");
  1063. return null;
  1064. },
  1065. /**
  1066. * to copy object with deep copy.
  1067. * returns a clone of action.
  1068. *
  1069. * @returns {cc.EaseElastic}
  1070. */
  1071. clone:function(){
  1072. var action = new cc.EaseElastic();
  1073. action.initWithAction(this._inner.clone(), this._period);
  1074. return action;
  1075. }
  1076. });
  1077. /**
  1078. * Creates the action with the inner action and the period in radians (default is 0.3).
  1079. * @static
  1080. * @deprecated since v3.0 Does not recommend the use of the base object.
  1081. * @param {cc.ActionInterval} action
  1082. * @param {Number} [period=0.3]
  1083. * @return {cc.EaseElastic}
  1084. */
  1085. cc.EaseElastic.create = function (action, period) {
  1086. return new cc.EaseElastic(action, period);
  1087. };
  1088. /**
  1089. * Ease Elastic In action. <br />
  1090. * Reference easeInElastic: <br />
  1091. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  1092. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
  1093. * @class
  1094. * @extends cc.EaseElastic
  1095. *
  1096. * @deprecated since v3.0 please use action.easing(cc.easeElasticIn())
  1097. *
  1098. * @example
  1099. * //The old usage
  1100. * cc.EaseElasticIn.create(action, period);
  1101. * //The new usage
  1102. * action.easing(cc.easeElasticIn(period));
  1103. */
  1104. cc.EaseElasticIn = cc.EaseElastic.extend(/** @lends cc.EaseElasticIn# */{
  1105. /**
  1106. * Called once per frame. Time is the number of seconds of a frame interval.
  1107. *
  1108. * @param {Number} dt
  1109. */
  1110. update:function (dt) {
  1111. var newT = 0;
  1112. if (dt === 0 || dt === 1) {
  1113. newT = dt;
  1114. } else {
  1115. var s = this._period / 4;
  1116. dt = dt - 1;
  1117. newT = -Math.pow(2, 10 * dt) * Math.sin((dt - s) * Math.PI * 2 / this._period);
  1118. }
  1119. this._inner.update(newT);
  1120. },
  1121. /**
  1122. * Create a action. Opposite with the original motion trajectory.
  1123. * @return {cc.EaseElasticOut}
  1124. */
  1125. reverse:function () {
  1126. return new cc.EaseElasticOut(this._inner.reverse(), this._period);
  1127. },
  1128. /**
  1129. * to copy object with deep copy.
  1130. * returns a clone of action.
  1131. *
  1132. * @returns {cc.EaseElasticIn}
  1133. */
  1134. clone:function(){
  1135. var action = new cc.EaseElasticIn();
  1136. action.initWithAction(this._inner.clone(), this._period);
  1137. return action;
  1138. }
  1139. });
  1140. /**
  1141. * Creates the action with the inner action and the period in radians (default is 0.3). <br />
  1142. * Reference easeInElastic: <br />
  1143. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  1144. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeElasticIn(period))
  1145. *
  1146. * @example
  1147. * //The old usage
  1148. * cc.EaseElasticIn.create(action, period);
  1149. * //The new usage
  1150. * action.easing(cc.easeElasticIn(period));
  1151. *
  1152. * @param {cc.ActionInterval} action
  1153. * @param {Number} [period=0.3]
  1154. * @return {cc.EaseElasticIn}
  1155. */
  1156. cc.EaseElasticIn.create = function (action, period) {
  1157. return new cc.EaseElasticIn(action, period);
  1158. };
  1159. //default ease elastic in object (period = 0.3)
  1160. cc._easeElasticInObj = {
  1161. easing:function(dt){
  1162. if (dt === 0 || dt === 1)
  1163. return dt;
  1164. dt = dt - 1;
  1165. return -Math.pow(2, 10 * dt) * Math.sin((dt - (0.3 / 4)) * Math.PI * 2 / 0.3);
  1166. },
  1167. reverse:function(){
  1168. return cc._easeElasticOutObj;
  1169. }
  1170. };
  1171. /**
  1172. * Creates the action easing obejct with the period in radians (default is 0.3). <br />
  1173. * Reference easeInElastic: <br />
  1174. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  1175. * @function
  1176. * @param {Number} [period=0.3]
  1177. * @return {Object}
  1178. * @example
  1179. * // example
  1180. * action.easing(cc.easeElasticIn(3.0));
  1181. */
  1182. cc.easeElasticIn = function (period) {
  1183. if(period && period !== 0.3){
  1184. return {
  1185. _period: period,
  1186. easing: function (dt) {
  1187. if (dt === 0 || dt === 1)
  1188. return dt;
  1189. dt = dt - 1;
  1190. return -Math.pow(2, 10 * dt) * Math.sin((dt - (this._period / 4)) * Math.PI * 2 / this._period);
  1191. },
  1192. reverse:function () {
  1193. return cc.easeElasticOut(this._period);
  1194. }
  1195. };
  1196. }
  1197. return cc._easeElasticInObj;
  1198. };
  1199. /**
  1200. * Ease Elastic Out action. <br />
  1201. * Reference easeOutElastic: <br />
  1202. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  1203. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
  1204. * @class
  1205. * @extends cc.EaseElastic
  1206. *
  1207. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeElasticOut(period))
  1208. *
  1209. * @example
  1210. * //The old usage
  1211. * cc.EaseElasticOut.create(action, period);
  1212. * //The new usage
  1213. * action.easing(cc.easeElasticOut(period));
  1214. */
  1215. cc.EaseElasticOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticOut# */{
  1216. /**
  1217. * Called once per frame. Time is the number of seconds of a frame interval.
  1218. *
  1219. * @param {Number} dt
  1220. */
  1221. update:function (dt) {
  1222. var newT = 0;
  1223. if (dt === 0 || dt == 1) {
  1224. newT = dt;
  1225. } else {
  1226. var s = this._period / 4;
  1227. newT = Math.pow(2, -10 * dt) * Math.sin((dt - s) * Math.PI * 2 / this._period) + 1;
  1228. }
  1229. this._inner.update(newT);
  1230. },
  1231. /**
  1232. * Create a action. Opposite with the original motion trajectory.
  1233. * @return {cc.EaseElasticIn}
  1234. */
  1235. reverse:function () {
  1236. return new cc.EaseElasticIn(this._inner.reverse(), this._period);
  1237. },
  1238. /**
  1239. * to copy object with deep copy.
  1240. * returns a clone of action.
  1241. *
  1242. * @returns {cc.EaseElasticOut}
  1243. */
  1244. clone:function(){
  1245. var action = new cc.EaseElasticOut();
  1246. action.initWithAction(this._inner.clone(), this._period);
  1247. return action;
  1248. }
  1249. });
  1250. /**
  1251. * Creates the action with the inner action and the period in radians (default is 0.3). <br />
  1252. * Reference easeOutElastic: <br />
  1253. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  1254. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeElasticOut(period))
  1255. * @param {cc.ActionInterval} action
  1256. * @param {Number} [period=0.3]
  1257. * @return {cc.EaseElasticOut}
  1258. *
  1259. * @example
  1260. * //The old usage
  1261. * cc.EaseElasticOut.create(action, period);
  1262. * //The new usage
  1263. * action.easing(cc.easeElasticOut(period));
  1264. */
  1265. cc.EaseElasticOut.create = function (action, period) {
  1266. return new cc.EaseElasticOut(action, period);
  1267. };
  1268. //default ease elastic out object (period = 0.3)
  1269. cc._easeElasticOutObj = {
  1270. easing: function (dt) {
  1271. return (dt === 0 || dt === 1) ? dt : Math.pow(2, -10 * dt) * Math.sin((dt - (0.3 / 4)) * Math.PI * 2 / 0.3) + 1;
  1272. },
  1273. reverse:function(){
  1274. return cc._easeElasticInObj;
  1275. }
  1276. };
  1277. /**
  1278. * Creates the action easing object with the period in radians (default is 0.3). <br />
  1279. * Reference easeOutElastic: <br />
  1280. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  1281. * @function
  1282. * @param {Number} [period=0.3]
  1283. * @return {Object}
  1284. * @example
  1285. * // example
  1286. * action.easing(cc.easeElasticOut(3.0));
  1287. */
  1288. cc.easeElasticOut = function (period) {
  1289. if(period && period !== 0.3){
  1290. return {
  1291. _period: period,
  1292. easing: function (dt) {
  1293. return (dt === 0 || dt === 1) ? dt : Math.pow(2, -10 * dt) * Math.sin((dt - (this._period / 4)) * Math.PI * 2 / this._period) + 1;
  1294. },
  1295. reverse:function(){
  1296. return cc.easeElasticIn(this._period);
  1297. }
  1298. };
  1299. }
  1300. return cc._easeElasticOutObj;
  1301. };
  1302. /**
  1303. * Ease Elastic InOut action. <br />
  1304. * Reference easeInOutElastic: <br />
  1305. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  1306. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
  1307. * @class
  1308. * @extends cc.EaseElastic
  1309. *
  1310. * @deprecated since v3.0 please use action.easing(cc.easeElasticInOut())
  1311. *
  1312. * @example
  1313. * //The old usage
  1314. * cc.EaseElasticInOut.create(action, period);
  1315. * //The new usage
  1316. * action.easing(cc.easeElasticInOut(period));
  1317. */
  1318. cc.EaseElasticInOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticInOut# */{
  1319. /**
  1320. * Called once per frame. Time is the number of seconds of a frame interval.
  1321. *
  1322. * @param {Number} dt
  1323. */
  1324. update:function (dt) {
  1325. var newT = 0;
  1326. var locPeriod = this._period;
  1327. if (dt === 0 || dt == 1) {
  1328. newT = dt;
  1329. } else {
  1330. dt = dt * 2;
  1331. if (!locPeriod)
  1332. locPeriod = this._period = 0.3 * 1.5;
  1333. var s = locPeriod / 4;
  1334. dt = dt - 1;
  1335. if (dt < 0)
  1336. newT = -0.5 * Math.pow(2, 10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod);
  1337. else
  1338. newT = Math.pow(2, -10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod) * 0.5 + 1;
  1339. }
  1340. this._inner.update(newT);
  1341. },
  1342. /**
  1343. * Create a action. Opposite with the original motion trajectory.
  1344. * @return {cc.EaseElasticInOut}
  1345. */
  1346. reverse:function () {
  1347. return new cc.EaseElasticInOut(this._inner.reverse(), this._period);
  1348. },
  1349. /**
  1350. * to copy object with deep copy.
  1351. * returns a clone of action.
  1352. *
  1353. * @returns {cc.EaseElasticInOut}
  1354. */
  1355. clone:function(){
  1356. var action = new cc.EaseElasticInOut();
  1357. action.initWithAction(this._inner.clone(), this._period);
  1358. return action;
  1359. }
  1360. });
  1361. /**
  1362. * Creates the action with the inner action and the period in radians (default is 0.3). <br />
  1363. * Reference easeInOutElastic: <br />
  1364. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  1365. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeElasticInOut(period))
  1366. * @param {cc.ActionInterval} action
  1367. * @param {Number} [period=0.3]
  1368. * @return {cc.EaseElasticInOut}
  1369. *
  1370. * @example
  1371. * //The old usage
  1372. * cc.EaseElasticInOut.create(action, period);
  1373. * //The new usage
  1374. * action.easing(cc.easeElasticInOut(period));
  1375. */
  1376. cc.EaseElasticInOut.create = function (action, period) {
  1377. return new cc.EaseElasticInOut(action, period);
  1378. };
  1379. /**
  1380. * Creates the action easing object with the period in radians (default is 0.3). <br />
  1381. * Reference easeInOutElastic: <br />
  1382. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  1383. * @function
  1384. * @param {Number} [period=0.3]
  1385. * @return {Object}
  1386. * @example
  1387. * // example
  1388. * action.easing(cc.easeElasticInOut(3.0));
  1389. */
  1390. cc.easeElasticInOut = function (period) {
  1391. period = period || 0.3;
  1392. return {
  1393. _period: period,
  1394. easing: function (dt) {
  1395. var newT = 0;
  1396. var locPeriod = this._period;
  1397. if (dt === 0 || dt === 1) {
  1398. newT = dt;
  1399. } else {
  1400. dt = dt * 2;
  1401. if (!locPeriod)
  1402. locPeriod = this._period = 0.3 * 1.5;
  1403. var s = locPeriod / 4;
  1404. dt = dt - 1;
  1405. if (dt < 0)
  1406. newT = -0.5 * Math.pow(2, 10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod);
  1407. else
  1408. newT = Math.pow(2, -10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod) * 0.5 + 1;
  1409. }
  1410. return newT;
  1411. },
  1412. reverse: function(){
  1413. return cc.easeElasticInOut(this._period);
  1414. }
  1415. };
  1416. };
  1417. /**
  1418. * cc.EaseBounce abstract class.
  1419. *
  1420. * @deprecated since v3.0 Does not recommend the use of the base object.
  1421. *
  1422. * @class
  1423. * @extends cc.ActionEase
  1424. */
  1425. cc.EaseBounce = cc.ActionEase.extend(/** @lends cc.EaseBounce# */{
  1426. /**
  1427. * @param {Number} time1
  1428. * @return {Number}
  1429. */
  1430. bounceTime:function (time1) {
  1431. if (time1 < 1 / 2.75) {
  1432. return 7.5625 * time1 * time1;
  1433. } else if (time1 < 2 / 2.75) {
  1434. time1 -= 1.5 / 2.75;
  1435. return 7.5625 * time1 * time1 + 0.75;
  1436. } else if (time1 < 2.5 / 2.75) {
  1437. time1 -= 2.25 / 2.75;
  1438. return 7.5625 * time1 * time1 + 0.9375;
  1439. }
  1440. time1 -= 2.625 / 2.75;
  1441. return 7.5625 * time1 * time1 + 0.984375;
  1442. },
  1443. /**
  1444. * to copy object with deep copy.
  1445. * returns a clone of action.
  1446. *
  1447. * @returns {cc.EaseBounce}
  1448. */
  1449. clone:function(){
  1450. var action = new cc.EaseBounce();
  1451. action.initWithAction(this._inner.clone());
  1452. return action;
  1453. },
  1454. /**
  1455. * Create a action. Opposite with the original motion trajectory.
  1456. * @return {cc.EaseBounce}
  1457. */
  1458. reverse:function () {
  1459. return new cc.EaseBounce(this._inner.reverse());
  1460. }
  1461. });
  1462. /**
  1463. * Creates an ease bounce action.
  1464. * @static
  1465. * @deprecated since v3.0 Does not recommend the use of the base object.
  1466. * @param {cc.ActionInterval} action
  1467. * @return {cc.EaseBounce}
  1468. */
  1469. cc.EaseBounce.create = function (action) {
  1470. return new cc.EaseBounce(action);
  1471. };
  1472. /**
  1473. * cc.EaseBounceIn action. <br />
  1474. * Eased bounce effect at the beginning.
  1475. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
  1476. * @class
  1477. * @extends cc.EaseBounce
  1478. *
  1479. * @deprecated since v3.0 please use action.easing(cc.easeBounceIn())
  1480. *
  1481. * @example
  1482. * //The old usage
  1483. * cc.EaseBounceIn.create(action);
  1484. * //The new usage
  1485. * action.easing(cc.easeBounceIn());
  1486. */
  1487. cc.EaseBounceIn = cc.EaseBounce.extend(/** @lends cc.EaseBounceIn# */{
  1488. /**
  1489. * Called once per frame. Time is the number of seconds of a frame interval.
  1490. *
  1491. * @param {Number} dt
  1492. */
  1493. update:function (dt) {
  1494. var newT = 1 - this.bounceTime(1 - dt);
  1495. this._inner.update(newT);
  1496. },
  1497. /**
  1498. * Create a action. Opposite with the original motion trajectory.
  1499. * @return {cc.EaseBounceOut}
  1500. */
  1501. reverse:function () {
  1502. return new cc.EaseBounceOut(this._inner.reverse());
  1503. },
  1504. /**
  1505. * to copy object with deep copy.
  1506. * returns a clone of action.
  1507. *
  1508. * @returns {cc.EaseBounceIn}
  1509. */
  1510. clone:function(){
  1511. var action = new cc.EaseBounceIn();
  1512. action.initWithAction(this._inner.clone());
  1513. return action;
  1514. }
  1515. });
  1516. /**
  1517. * Creates the action. <br />
  1518. * Eased bounce effect at the beginning.
  1519. * @static
  1520. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeBounceIn())
  1521. * @param {cc.ActionInterval} action
  1522. * @return {cc.EaseBounceIn}
  1523. *
  1524. * @example
  1525. * //The old usage
  1526. * cc.EaseBounceIn.create(action);
  1527. * //The new usage
  1528. * action.easing(cc.easeBounceIn());
  1529. */
  1530. cc.EaseBounceIn.create = function (action) {
  1531. return new cc.EaseBounceIn(action);
  1532. };
  1533. cc._bounceTime = function (time1) {
  1534. if (time1 < 1 / 2.75) {
  1535. return 7.5625 * time1 * time1;
  1536. } else if (time1 < 2 / 2.75) {
  1537. time1 -= 1.5 / 2.75;
  1538. return 7.5625 * time1 * time1 + 0.75;
  1539. } else if (time1 < 2.5 / 2.75) {
  1540. time1 -= 2.25 / 2.75;
  1541. return 7.5625 * time1 * time1 + 0.9375;
  1542. }
  1543. time1 -= 2.625 / 2.75;
  1544. return 7.5625 * time1 * time1 + 0.984375;
  1545. };
  1546. cc._easeBounceInObj = {
  1547. easing: function(dt){
  1548. return 1 - cc._bounceTime(1 - dt);
  1549. },
  1550. reverse: function(){
  1551. return cc._easeBounceOutObj;
  1552. }
  1553. };
  1554. /**
  1555. * Creates the action easing object. <br />
  1556. * Eased bounce effect at the beginning.
  1557. * @function
  1558. * @return {Object}
  1559. * @example
  1560. * // example
  1561. * action.easing(cc.easeBounceIn());
  1562. */
  1563. cc.easeBounceIn = function(){
  1564. return cc._easeBounceInObj;
  1565. };
  1566. /**
  1567. * cc.EaseBounceOut action. <br />
  1568. * Eased bounce effect at the ending.
  1569. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
  1570. * @class
  1571. * @extends cc.EaseBounce
  1572. *
  1573. * @deprecated since v3.0 please use action.easing(cc.easeBounceOut())
  1574. *
  1575. * @example
  1576. * //The old usage
  1577. * cc.EaseBounceOut.create(action);
  1578. * //The new usage
  1579. * action.easing(cc.easeBounceOut());
  1580. */
  1581. cc.EaseBounceOut = cc.EaseBounce.extend(/** @lends cc.EaseBounceOut# */{
  1582. /**
  1583. * Called once per frame. Time is the number of seconds of a frame interval.
  1584. *
  1585. * @param {Number} dt
  1586. */
  1587. update:function (dt) {
  1588. var newT = this.bounceTime(dt);
  1589. this._inner.update(newT);
  1590. },
  1591. /**
  1592. * Create a action. Opposite with the original motion trajectory.
  1593. * @return {cc.EaseBounceIn}
  1594. */
  1595. reverse:function () {
  1596. return new cc.EaseBounceIn(this._inner.reverse());
  1597. },
  1598. /**
  1599. * to copy object with deep copy.
  1600. * returns a clone of action.
  1601. *
  1602. * @returns {cc.EaseBounceOut}
  1603. */
  1604. clone:function(){
  1605. var action = new cc.EaseBounceOut();
  1606. action.initWithAction(this._inner.clone());
  1607. return action;
  1608. }
  1609. });
  1610. /**
  1611. * Creates the action. <br />
  1612. * Eased bounce effect at the ending.
  1613. * @static
  1614. * @deprecated since v3.0 please use action.easing(cc.easeBounceOut())
  1615. * @param {cc.ActionInterval} action
  1616. * @return {cc.EaseBounceOut}
  1617. *
  1618. * @example
  1619. * //The old usage
  1620. * cc.EaseBounceOut.create(action);
  1621. * //The new usage
  1622. * action.easing(cc.easeBounceOut());
  1623. */
  1624. cc.EaseBounceOut.create = function (action) {
  1625. return new cc.EaseBounceOut(action);
  1626. };
  1627. cc._easeBounceOutObj = {
  1628. easing: function(dt){
  1629. return cc._bounceTime(dt);
  1630. },
  1631. reverse:function () {
  1632. return cc._easeBounceInObj;
  1633. }
  1634. };
  1635. /**
  1636. * Creates the action easing object. <br />
  1637. * Eased bounce effect at the ending.
  1638. * @function
  1639. * @return {Object}
  1640. * @example
  1641. * // example
  1642. * action.easing(cc.easeBounceOut());
  1643. */
  1644. cc.easeBounceOut = function(){
  1645. return cc._easeBounceOutObj;
  1646. };
  1647. /**
  1648. * cc.EaseBounceInOut action. <br />
  1649. * Eased bounce effect at the begining and ending.
  1650. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
  1651. * @class
  1652. * @extends cc.EaseBounce
  1653. *
  1654. * @deprecated since v3.0 <br /> Please use acton.easing(cc.easeBounceInOut())
  1655. *
  1656. * @example
  1657. * //The old usage
  1658. * cc.EaseBounceInOut.create(action);
  1659. * //The new usage
  1660. * action.easing(cc.easeBounceInOut());
  1661. */
  1662. cc.EaseBounceInOut = cc.EaseBounce.extend(/** @lends cc.EaseBounceInOut# */{
  1663. /**
  1664. * Called once per frame. Time is the number of seconds of a frame interval.
  1665. *
  1666. * @param {Number} dt
  1667. */
  1668. update:function (dt) {
  1669. var newT = 0;
  1670. if (dt < 0.5) {
  1671. dt = dt * 2;
  1672. newT = (1 - this.bounceTime(1 - dt)) * 0.5;
  1673. } else {
  1674. newT = this.bounceTime(dt * 2 - 1) * 0.5 + 0.5;
  1675. }
  1676. this._inner.update(newT);
  1677. },
  1678. /**
  1679. * to copy object with deep copy.
  1680. * returns a clone of action.
  1681. *
  1682. * @returns {cc.EaseBounceInOut}
  1683. */
  1684. clone:function(){
  1685. var action = new cc.EaseBounceInOut();
  1686. action.initWithAction(this._inner.clone());
  1687. return action;
  1688. },
  1689. /**
  1690. * Create a action. Opposite with the original motion trajectory.
  1691. * @return {cc.EaseBounceInOut}
  1692. */
  1693. reverse:function () {
  1694. return new cc.EaseBounceInOut(this._inner.reverse());
  1695. }
  1696. });
  1697. /**
  1698. * Creates the action. <br />
  1699. * Eased bounce effect at the begining and ending.
  1700. * @static
  1701. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeBounceInOut())
  1702. * @param {cc.ActionInterval} action
  1703. * @return {cc.EaseBounceInOut}
  1704. *
  1705. * @example
  1706. * //The old usage
  1707. * cc.EaseBounceInOut.create(action);
  1708. * //The new usage
  1709. * action.easing(cc.easeBounceInOut());
  1710. */
  1711. cc.EaseBounceInOut.create = function (action) {
  1712. return new cc.EaseBounceInOut(action);
  1713. };
  1714. cc._easeBounceInOutObj = {
  1715. easing: function (time1) {
  1716. var newT;
  1717. if (time1 < 0.5) {
  1718. time1 = time1 * 2;
  1719. newT = (1 - cc._bounceTime(1 - time1)) * 0.5;
  1720. } else {
  1721. newT = cc._bounceTime(time1 * 2 - 1) * 0.5 + 0.5;
  1722. }
  1723. return newT;
  1724. },
  1725. reverse: function(){
  1726. return cc._easeBounceInOutObj;
  1727. }
  1728. };
  1729. /**
  1730. * Creates the action easing object. <br />
  1731. * Eased bounce effect at the begining and ending.
  1732. * @function
  1733. * @return {Object}
  1734. * @example
  1735. * // example
  1736. * action.easing(cc.easeBounceInOut());
  1737. */
  1738. cc.easeBounceInOut = function(){
  1739. return cc._easeBounceInOutObj;
  1740. };
  1741. /**
  1742. * cc.EaseBackIn action. <br />
  1743. * In the opposite direction to move slowly, and then accelerated to the right direction.
  1744. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
  1745. * @class
  1746. * @extends cc.ActionEase
  1747. *
  1748. * @deprecated since v3.0 please use action.easing(cc.easeBackIn())
  1749. *
  1750. * @example
  1751. * //The old usage
  1752. * cc.EaseBackIn.create(action);
  1753. * //The new usage
  1754. * action.easing(cc.easeBackIn());
  1755. */
  1756. cc.EaseBackIn = cc.ActionEase.extend(/** @lends cc.EaseBackIn# */{
  1757. /**
  1758. * Called once per frame. Time is the number of seconds of a frame interval.
  1759. *
  1760. * @param {Number} dt
  1761. */
  1762. update:function (dt) {
  1763. var overshoot = 1.70158;
  1764. dt = dt===0 || dt==1 ? dt : dt * dt * ((overshoot + 1) * dt - overshoot);
  1765. this._inner.update(dt);
  1766. },
  1767. /**
  1768. * Create a action. Opposite with the original motion trajectory.
  1769. * @return {cc.EaseBackOut}
  1770. */
  1771. reverse:function () {
  1772. return new cc.EaseBackOut(this._inner.reverse());
  1773. },
  1774. /**
  1775. * to copy object with deep copy.
  1776. * returns a clone of action.
  1777. *
  1778. * @returns {cc.EaseBackIn}
  1779. */
  1780. clone:function(){
  1781. var action = new cc.EaseBackIn();
  1782. action.initWithAction(this._inner.clone());
  1783. return action;
  1784. }
  1785. });
  1786. /**
  1787. * Creates the cc.EaseBackIn. <br />
  1788. * In the opposite direction to move slowly, and then accelerated to the right direction.
  1789. * @static
  1790. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeBackIn())
  1791. * @param {cc.ActionInterval} action
  1792. * @return {cc.EaseBackIn}
  1793. *
  1794. * @example
  1795. * //The old usage
  1796. * cc.EaseBackIn.create(action);
  1797. * //The new usage
  1798. * action.easing(cc.easeBackIn());
  1799. */
  1800. cc.EaseBackIn.create = function (action) {
  1801. return new cc.EaseBackIn(action);
  1802. };
  1803. cc._easeBackInObj = {
  1804. easing: function (time1) {
  1805. var overshoot = 1.70158;
  1806. return (time1===0 || time1===1) ? time1 : time1 * time1 * ((overshoot + 1) * time1 - overshoot);
  1807. },
  1808. reverse: function(){
  1809. return cc._easeBackOutObj;
  1810. }
  1811. };
  1812. /**
  1813. * Creates the action easing object. <br />
  1814. * In the opposite direction to move slowly, and then accelerated to the right direction.
  1815. * @function
  1816. * @return {Object}
  1817. * @example
  1818. * // example
  1819. * action.easing(cc.easeBackIn());
  1820. */
  1821. cc.easeBackIn = function(){
  1822. return cc._easeBackInObj;
  1823. };
  1824. /**
  1825. * cc.EaseBackOut action. <br />
  1826. * Fast moving more than the finish, and then slowly back to the finish.
  1827. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
  1828. * @class
  1829. * @extends cc.ActionEase
  1830. *
  1831. * @deprecated since v3.0 please use action.easing(cc.easeBackOut());
  1832. *
  1833. * @example
  1834. * //The old usage
  1835. * cc.EaseBackOut.create(action);
  1836. * //The new usage
  1837. * action.easing(cc.easeBackOut());
  1838. */
  1839. cc.EaseBackOut = cc.ActionEase.extend(/** @lends cc.EaseBackOut# */{
  1840. /**
  1841. * Called once per frame. Time is the number of seconds of a frame interval.
  1842. *
  1843. * @param {Number} dt
  1844. */
  1845. update:function (dt) {
  1846. var overshoot = 1.70158;
  1847. dt = dt - 1;
  1848. this._inner.update(dt * dt * ((overshoot + 1) * dt + overshoot) + 1);
  1849. },
  1850. /**
  1851. * Create a action. Opposite with the original motion trajectory.
  1852. * @return {cc.EaseBackIn}
  1853. */
  1854. reverse:function () {
  1855. return new cc.EaseBackIn(this._inner.reverse());
  1856. },
  1857. /**
  1858. * to copy object with deep copy.
  1859. * returns a clone of action.
  1860. *
  1861. * @returns {cc.EaseBackOut}
  1862. */
  1863. clone:function(){
  1864. var action = new cc.EaseBackOut();
  1865. action.initWithAction(this._inner.clone());
  1866. return action;
  1867. }
  1868. });
  1869. /**
  1870. * Creates the action. <br />
  1871. * Fast moving more than the finish, and then slowly back to the finish.
  1872. * @static
  1873. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeBackOut());
  1874. * @param {cc.ActionInterval} action
  1875. * @return {cc.EaseBackOut}
  1876. *
  1877. * @example
  1878. * //The old usage
  1879. * cc.EaseBackOut.create(action);
  1880. * //The new usage
  1881. * action.easing(cc.easeBackOut());
  1882. */
  1883. cc.EaseBackOut.create = function (action) {
  1884. return new cc.EaseBackOut(action);
  1885. };
  1886. cc._easeBackOutObj = {
  1887. easing: function (time1) {
  1888. var overshoot = 1.70158;
  1889. time1 = time1 - 1;
  1890. return time1 * time1 * ((overshoot + 1) * time1 + overshoot) + 1;
  1891. },
  1892. reverse: function(){
  1893. return cc._easeBackInObj;
  1894. }
  1895. };
  1896. /**
  1897. * Creates the action easing object. <br />
  1898. * Fast moving more than the finish, and then slowly back to the finish.
  1899. * @function
  1900. * @return {Object}
  1901. * @example
  1902. * // example
  1903. * action.easing(cc.easeBackOut());
  1904. */
  1905. cc.easeBackOut = function(){
  1906. return cc._easeBackOutObj;
  1907. };
  1908. /**
  1909. * cc.EaseBackInOut action. <br />
  1910. * Begining of cc.EaseBackIn. Ending of cc.EaseBackOut.
  1911. * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
  1912. * @class
  1913. * @extends cc.ActionEase
  1914. *
  1915. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeBackInOut())
  1916. *
  1917. * @example
  1918. * //The old usage
  1919. * cc.EaseBackInOut.create(action);
  1920. * //The new usage
  1921. * action.easing(cc.easeBackInOut());
  1922. */
  1923. cc.EaseBackInOut = cc.ActionEase.extend(/** @lends cc.EaseBackInOut# */{
  1924. /**
  1925. * Called once per frame. Time is the number of seconds of a frame interval.
  1926. *
  1927. * @param {Number} dt
  1928. */
  1929. update:function (dt) {
  1930. var overshoot = 1.70158 * 1.525;
  1931. dt = dt * 2;
  1932. if (dt < 1) {
  1933. this._inner.update((dt * dt * ((overshoot + 1) * dt - overshoot)) / 2);
  1934. } else {
  1935. dt = dt - 2;
  1936. this._inner.update((dt * dt * ((overshoot + 1) * dt + overshoot)) / 2 + 1);
  1937. }
  1938. },
  1939. /**
  1940. * to copy object with deep copy.
  1941. * returns a clone of action.
  1942. *
  1943. * @returns {cc.EaseBackInOut}
  1944. */
  1945. clone:function(){
  1946. var action = new cc.EaseBackInOut();
  1947. action.initWithAction(this._inner.clone());
  1948. return action;
  1949. },
  1950. /**
  1951. * Create a action. Opposite with the original motion trajectory.
  1952. * @return {cc.EaseBackInOut}
  1953. */
  1954. reverse:function () {
  1955. return new cc.EaseBackInOut(this._inner.reverse());
  1956. }
  1957. });
  1958. /**
  1959. * Creates the action. <br />
  1960. * Begining of cc.EaseBackIn. Ending of cc.EaseBackOut.
  1961. * @static
  1962. * @param {cc.ActionInterval} action
  1963. * @return {cc.EaseBackInOut}
  1964. *
  1965. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeBackInOut())
  1966. *
  1967. * @example
  1968. * //The old usage
  1969. * cc.EaseBackInOut.create(action);
  1970. * //The new usage
  1971. * action.easing(cc.easeBackInOut());
  1972. */
  1973. cc.EaseBackInOut.create = function (action) {
  1974. return new cc.EaseBackInOut(action);
  1975. };
  1976. cc._easeBackInOutObj = {
  1977. easing: function (time1) {
  1978. var overshoot = 1.70158 * 1.525;
  1979. time1 = time1 * 2;
  1980. if (time1 < 1) {
  1981. return (time1 * time1 * ((overshoot + 1) * time1 - overshoot)) / 2;
  1982. } else {
  1983. time1 = time1 - 2;
  1984. return (time1 * time1 * ((overshoot + 1) * time1 + overshoot)) / 2 + 1;
  1985. }
  1986. },
  1987. reverse: function(){
  1988. return cc._easeBackInOutObj;
  1989. }
  1990. };
  1991. /**
  1992. * Creates the action easing object. <br />
  1993. * Begining of cc.EaseBackIn. Ending of cc.EaseBackOut.
  1994. * @function
  1995. * @return {Object}
  1996. * @example
  1997. * // example
  1998. * action.easing(cc.easeBackInOut());
  1999. */
  2000. cc.easeBackInOut = function(){
  2001. return cc._easeBackInOutObj;
  2002. };
  2003. /**
  2004. * cc.EaseBezierAction action. <br />
  2005. * Manually set a 4 order Bessel curve. <br />
  2006. * According to the set point, calculate the trajectory.
  2007. * @class
  2008. * @extends cc.ActionEase
  2009. * @param {cc.Action} action
  2010. *
  2011. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeBezierAction())
  2012. *
  2013. * @example
  2014. * //The old usage
  2015. * var action = cc.EaseBezierAction.create(action);
  2016. * action.setBezierParamer(0.5, 0.5, 1.0, 1.0);
  2017. * //The new usage
  2018. * action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0));
  2019. */
  2020. cc.EaseBezierAction = cc.ActionEase.extend(/** @lends cc.EaseBezierAction# */{
  2021. _p0: null,
  2022. _p1: null,
  2023. _p2: null,
  2024. _p3: null,
  2025. /**
  2026. * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
  2027. * Initialization requires the application of Bessel curve of action.
  2028. * @param {cc.Action} action
  2029. */
  2030. ctor: function(action){
  2031. cc.ActionEase.prototype.ctor.call(this, action);
  2032. },
  2033. _updateTime: function(a, b, c, d, t){
  2034. return (Math.pow(1-t,3) * a + 3*t*(Math.pow(1-t,2))*b + 3*Math.pow(t,2)*(1-t)*c + Math.pow(t,3)*d );
  2035. },
  2036. /**
  2037. * Called once per frame. Time is the number of seconds of a frame interval.
  2038. *
  2039. * @param {Number} dt
  2040. */
  2041. update: function(dt){
  2042. var t = this._updateTime(this._p0, this._p1, this._p2, this._p3, dt);
  2043. this._inner.update(t);
  2044. },
  2045. /**
  2046. * to copy object with deep copy.
  2047. * returns a clone of action.
  2048. *
  2049. * @returns {cc.EaseBezierAction}
  2050. */
  2051. clone: function(){
  2052. var action = new cc.EaseBezierAction();
  2053. action.initWithAction(this._inner.clone());
  2054. action.setBezierParamer(this._p0, this._p1, this._p2, this._p3);
  2055. return action;
  2056. },
  2057. /**
  2058. * Create a action. Opposite with the original motion trajectory.
  2059. * @return {cc.EaseBezierAction}
  2060. */
  2061. reverse: function(){
  2062. var action = new cc.EaseBezierAction(this._inner.reverse());
  2063. action.setBezierParamer(this._p3, this._p2, this._p1, this._p0);
  2064. return action;
  2065. },
  2066. /**
  2067. * Set of 4 reference point
  2068. * @param p0
  2069. * @param p1
  2070. * @param p2
  2071. * @param p3
  2072. */
  2073. setBezierParamer: function(p0, p1, p2, p3){
  2074. this._p0 = p0 || 0;
  2075. this._p1 = p1 || 0;
  2076. this._p2 = p2 || 0;
  2077. this._p3 = p3 || 0;
  2078. }
  2079. });
  2080. /**
  2081. * Creates the action. <br />
  2082. * After creating the cc.EaseBezierAction, also need to manually call setBezierParamer. <br />
  2083. * According to the set point, calculate the trajectory.
  2084. * @static
  2085. * @param action
  2086. * @returns {cc.EaseBezierAction}
  2087. *
  2088. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeBezierAction())
  2089. *
  2090. * @example
  2091. * //The old usage
  2092. * var action = cc.EaseBezierAction.create(action);
  2093. * action.setBezierParamer(0.5, 0.5, 1.0, 1.0);
  2094. * //The new usage
  2095. * action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0));
  2096. */
  2097. cc.EaseBezierAction.create = function(action){
  2098. return new cc.EaseBezierAction(action);
  2099. };
  2100. /**
  2101. * Creates the action easing object. <br />
  2102. * Into the 4 reference point. <br />
  2103. * To calculate the motion curve.
  2104. * @param {Number} p0 The first bezier parameter
  2105. * @param {Number} p1 The second bezier parameter
  2106. * @param {Number} p2 The third bezier parameter
  2107. * @param {Number} p3 The fourth bezier parameter
  2108. * @returns {Object}
  2109. * @example
  2110. * // example
  2111. * action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0));
  2112. */
  2113. cc.easeBezierAction = function(p0, p1, p2, p3){
  2114. return {
  2115. easing: function(time){
  2116. return cc.EaseBezierAction.prototype._updateTime(p0, p1, p2, p3, time);
  2117. },
  2118. reverse: function(){
  2119. return cc.easeBezierAction(p3, p2, p1, p0);
  2120. }
  2121. };
  2122. };
  2123. /**
  2124. * cc.EaseQuadraticActionIn action. <br />
  2125. * Reference easeInQuad: <br />
  2126. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2127. * @class
  2128. * @extends cc.ActionEase
  2129. *
  2130. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuadraticAction())
  2131. *
  2132. * @example
  2133. * //The old usage
  2134. * cc.EaseQuadraticActionIn.create(action);
  2135. * //The new usage
  2136. * action.easing(cc.easeQuadraticActionIn());
  2137. */
  2138. cc.EaseQuadraticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActionIn# */{
  2139. _updateTime: function(time){
  2140. return Math.pow(time, 2);
  2141. },
  2142. /**
  2143. * Called once per frame. Time is the number of seconds of a frame interval.
  2144. *
  2145. * @param {Number} dt
  2146. */
  2147. update: function(dt){
  2148. this._inner.update(this._updateTime(dt));
  2149. },
  2150. /**
  2151. * to copy object with deep copy.
  2152. * returns a clone of action.
  2153. *
  2154. * @returns {cc.EaseQuadraticActionIn}
  2155. */
  2156. clone: function(){
  2157. var action = new cc.EaseQuadraticActionIn();
  2158. action.initWithAction(this._inner.clone());
  2159. return action;
  2160. },
  2161. /**
  2162. * Create a action. Opposite with the original motion trajectory.
  2163. * @return {cc.EaseQuadraticActionIn}
  2164. */
  2165. reverse: function(){
  2166. return new cc.EaseQuadraticActionIn(this._inner.reverse());
  2167. }
  2168. });
  2169. /**
  2170. * Creates the cc.EaseQuadRaticActionIn. <br />
  2171. * Reference easeInQuad: <br />
  2172. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2173. * @static
  2174. * @param action
  2175. * @returns {cc.EaseQuadraticActionIn}
  2176. *
  2177. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuadraticAction())
  2178. *
  2179. * @example
  2180. * //The old usage
  2181. * cc.EaseQuadraticActionIn.create(action);
  2182. * //The new usage
  2183. * action.easing(cc.easeQuadraticActionIn());
  2184. */
  2185. cc.EaseQuadraticActionIn.create = function(action){
  2186. return new cc.EaseQuadraticActionIn(action);
  2187. };
  2188. cc._easeQuadraticActionIn = {
  2189. easing: cc.EaseQuadraticActionIn.prototype._updateTime,
  2190. reverse: function(){
  2191. return cc._easeQuadraticActionIn;
  2192. }
  2193. };
  2194. /**
  2195. * Creates the action easing object. <br />
  2196. * Reference easeInQuad: <br />
  2197. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2198. * @returns {Object}
  2199. * @example
  2200. * //example
  2201. * action.easing(cc.easeQuadraticActionIn());
  2202. */
  2203. cc.easeQuadraticActionIn = function(){
  2204. return cc._easeQuadraticActionIn;
  2205. };
  2206. /**
  2207. * cc.EaseQuadraticActionIn action. <br />
  2208. * Reference easeOutQuad: <br />
  2209. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2210. * @class
  2211. * @extends cc.ActionEase
  2212. *
  2213. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuadraticActionOut())
  2214. *
  2215. * @example
  2216. * //The old usage
  2217. * cc.EaseQuadraticActionOut.create(action);
  2218. * //The new usage
  2219. * action.easing(cc.easeQuadraticActionOut());
  2220. */
  2221. cc.EaseQuadraticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActionOut# */{
  2222. _updateTime: function(time){
  2223. return -time*(time-2);
  2224. },
  2225. /**
  2226. * Called once per frame. Time is the number of seconds of a frame interval.
  2227. *
  2228. * @param {Number} dt
  2229. */
  2230. update: function(dt){
  2231. this._inner.update(this._updateTime(dt));
  2232. },
  2233. /**
  2234. * to copy object with deep copy.
  2235. * returns a clone of action.
  2236. *
  2237. * @returns {cc.EaseQuadraticActionOut}
  2238. */
  2239. clone: function(){
  2240. var action = new cc.EaseQuadraticActionOut();
  2241. action.initWithAction();
  2242. return action;
  2243. },
  2244. /**
  2245. * Create a action. Opposite with the original motion trajectory.
  2246. * @return {cc.EaseQuadraticActionOut}
  2247. */
  2248. reverse: function(){
  2249. return new cc.EaseQuadraticActionOut(this._inner.reverse());
  2250. }
  2251. });
  2252. /**
  2253. * Creates the action. <br />
  2254. * Reference easeOutQuad: <br />
  2255. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2256. * @static
  2257. * @param action
  2258. * @returns {cc.EaseQuadraticActionOut}
  2259. *
  2260. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuadraticActionOut())
  2261. *
  2262. * @example
  2263. * //The old usage
  2264. * cc.EaseQuadraticActionOut.create(action);
  2265. * //The new usage
  2266. * action.easing(cc.easeQuadraticActionOut());
  2267. */
  2268. cc.EaseQuadraticActionOut.create = function(action){
  2269. return new cc.EaseQuadraticActionOut(action);
  2270. };
  2271. cc._easeQuadraticActionOut = {
  2272. easing: cc.EaseQuadraticActionOut.prototype._updateTime,
  2273. reverse: function(){
  2274. return cc._easeQuadraticActionOut;
  2275. }
  2276. };
  2277. /**
  2278. * Creates the action easing object. <br />
  2279. * Reference easeOutQuad: <br />
  2280. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2281. * @function
  2282. * @returns {Object}
  2283. * @example
  2284. * //example
  2285. * action.easing(cc.easeQuadraticActionOut());
  2286. */
  2287. cc.easeQuadraticActionOut = function(){
  2288. return cc._easeQuadraticActionOut;
  2289. };
  2290. /**
  2291. * cc.EaseQuadraticActionInOut action. <br />
  2292. * Reference easeInOutQuad: <br />
  2293. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2294. * @class
  2295. * @extends cc.ActionEase
  2296. *
  2297. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuadraticActionInOut())
  2298. *
  2299. * @example
  2300. * //The old usage
  2301. * cc.EaseQuadraticActionInOut.create(action);
  2302. * //The new usage
  2303. * action.easing(cc.easeQuadraticActionInOut());
  2304. */
  2305. cc.EaseQuadraticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActionInOut# */{
  2306. _updateTime: function(time){
  2307. var resultTime = time;
  2308. time *= 2;
  2309. if(time < 1){
  2310. resultTime = time * time * 0.5;
  2311. }else{
  2312. --time;
  2313. resultTime = -0.5 * ( time * ( time - 2 ) - 1)
  2314. }
  2315. return resultTime;
  2316. },
  2317. /**
  2318. * Called once per frame. Time is the number of seconds of a frame interval.
  2319. *
  2320. * @param {Number} dt
  2321. */
  2322. update: function(dt){
  2323. this._inner.update(this._updateTime(dt));
  2324. },
  2325. /**
  2326. * to copy object with deep copy.
  2327. * returns a clone of action.
  2328. *
  2329. * @returns {cc.EaseQuadraticActionInOut}
  2330. */
  2331. clone: function(){
  2332. var action = new cc.EaseQuadraticActionInOut();
  2333. action.initWithAction(this._inner.clone());
  2334. return action;
  2335. },
  2336. /**
  2337. * Create a action. Opposite with the original motion trajectory.
  2338. * @return {cc.EaseQuadraticActionInOut}
  2339. */
  2340. reverse: function(){
  2341. return new cc.EaseQuadraticActionInOut(this._inner.reverse());
  2342. }
  2343. });
  2344. /**
  2345. * Creates the action. <br />
  2346. * Reference easeInOutQuad: <br />
  2347. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2348. * @static
  2349. *
  2350. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuadraticActionInOut())
  2351. *
  2352. * @example
  2353. * //The old usage
  2354. * cc.EaseQuadraticActionInOut.create(action);
  2355. * //The new usage
  2356. * action.easing(cc.easeQuadraticActionInOut());
  2357. *
  2358. * @param action
  2359. * @returns {cc.EaseQuadraticActionInOut}
  2360. */
  2361. cc.EaseQuadraticActionInOut.create = function(action){
  2362. return new cc.EaseQuadraticActionInOut(action);
  2363. };
  2364. cc._easeQuadraticActionInOut = {
  2365. easing: cc.EaseQuadraticActionInOut.prototype._updateTime,
  2366. reverse: function(){
  2367. return cc._easeQuadraticActionInOut;
  2368. }
  2369. };
  2370. /**
  2371. * Creates the action easing object. <br />
  2372. * Reference easeInOutQuad: <br />
  2373. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2374. * @function
  2375. * @returns {Object}
  2376. * @example
  2377. * //example
  2378. * action.easing(cc.easeQuadraticActionInOut());
  2379. */
  2380. cc.easeQuadraticActionInOut = function(){
  2381. return cc._easeQuadraticActionInOut;
  2382. };
  2383. /**
  2384. * cc.EaseQuarticActionIn action. <br />
  2385. * Reference easeInQuart: <br />
  2386. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2387. * @class
  2388. * @extends cc.ActionEase
  2389. *
  2390. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuarticActionIn());
  2391. *
  2392. * @example
  2393. * //The old usage
  2394. * cc.EaseQuarticActionIn.create(action);
  2395. * //The new usage
  2396. * action.easing(cc.easeQuarticActionIn());
  2397. */
  2398. cc.EaseQuarticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionIn# */{
  2399. _updateTime: function(time){
  2400. return time * time * time * time;
  2401. },
  2402. /**
  2403. * Called once per frame. Time is the number of seconds of a frame interval.
  2404. *
  2405. * @param {Number} dt
  2406. */
  2407. update: function(dt){
  2408. this._inner.update(this._updateTime(dt));
  2409. },
  2410. /**
  2411. * to copy object with deep copy.
  2412. * returns a clone of action.
  2413. *
  2414. * @returns {cc.EaseQuarticActionIn}
  2415. */
  2416. clone: function(){
  2417. var action = new cc.EaseQuarticActionIn();
  2418. action.initWithAction(this._inner.clone());
  2419. return action;
  2420. },
  2421. /**
  2422. * Create a action. Opposite with the original motion trajectory.
  2423. * @return {cc.EaseQuarticActionIn}
  2424. */
  2425. reverse: function(){
  2426. return new cc.EaseQuarticActionIn(this._inner.reverse());
  2427. }
  2428. });
  2429. /**
  2430. * Creates the action. <br />
  2431. * Reference easeInQuart: <br />
  2432. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2433. * @static
  2434. *
  2435. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuarticActionIn());
  2436. *
  2437. * @example
  2438. * //The old usage
  2439. * cc.EaseQuarticActionIn.create(action);
  2440. * //The new usage
  2441. * action.easing(cc.easeQuarticActionIn());
  2442. *
  2443. * @param action
  2444. * @returns {cc.EaseQuarticActionIn}
  2445. */
  2446. cc.EaseQuarticActionIn.create = function(action){
  2447. return new cc.EaseQuarticActionIn(action);
  2448. };
  2449. cc._easeQuarticActionIn = {
  2450. easing: cc.EaseQuarticActionIn.prototype._updateTime,
  2451. reverse: function(){
  2452. return cc._easeQuarticActionIn;
  2453. }
  2454. };
  2455. /**
  2456. * Creates the action easing object. <br />
  2457. * Reference easeIntQuart: <br />
  2458. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2459. * @function
  2460. * @returns {Object}
  2461. * @example
  2462. * //example
  2463. * action.easing(cc.easeQuarticActionIn());
  2464. */
  2465. cc.easeQuarticActionIn = function(){
  2466. return cc._easeQuarticActionIn;
  2467. };
  2468. /**
  2469. * cc.EaseQuarticActionOut action. <br />
  2470. * Reference easeOutQuart: <br />
  2471. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2472. * @class
  2473. * @extends cc.ActionEase
  2474. *
  2475. * @deprecated since v3.0 <br /> Please use action.easing(cc.QuarticActionOut());
  2476. *
  2477. * @example
  2478. * //The old usage
  2479. * cc.EaseQuarticActionOut.create(action);
  2480. * //The new usage
  2481. * action.easing(cc.EaseQuarticActionOut());
  2482. */
  2483. cc.EaseQuarticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionOut# */{
  2484. _updateTime: function(time){
  2485. time -= 1;
  2486. return -(time * time * time * time - 1);
  2487. },
  2488. /**
  2489. * Called once per frame. Time is the number of seconds of a frame interval.
  2490. *
  2491. * @param {Number} dt
  2492. */
  2493. update: function(dt){
  2494. this._inner.update(this._updateTime(dt));
  2495. },
  2496. /**
  2497. * to copy object with deep copy.
  2498. * returns a clone of action.
  2499. *
  2500. * @returns {cc.EaseQuarticActionOut}
  2501. */
  2502. clone: function(){
  2503. var action = new cc.EaseQuarticActionOut();
  2504. action.initWithAction(this._inner.clone());
  2505. return action;
  2506. },
  2507. /**
  2508. * Create a action. Opposite with the original motion trajectory.
  2509. * @return {cc.EaseQuarticActionOut}
  2510. */
  2511. reverse: function(){
  2512. return new cc.EaseQuarticActionOut(this._inner.reverse());
  2513. }
  2514. });
  2515. /**
  2516. * Creates the action. <br />
  2517. * Reference easeOutQuart: <br />
  2518. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2519. * @static
  2520. *
  2521. * @deprecated since v3.0 <br /> Please use action.easing(cc.QuarticActionOut());
  2522. *
  2523. * @example
  2524. * //The old usage
  2525. * cc.EaseQuarticActionOut.create(action);
  2526. * //The new usage
  2527. * action.easing(cc.EaseQuarticActionOut());
  2528. *
  2529. * @param action
  2530. * @returns {cc.EaseQuarticActionOut}
  2531. */
  2532. cc.EaseQuarticActionOut.create = function(action){
  2533. return new cc.EaseQuarticActionOut(action);
  2534. };
  2535. cc._easeQuarticActionOut = {
  2536. easing: cc.EaseQuarticActionOut.prototype._updateTime,
  2537. reverse: function(){
  2538. return cc._easeQuarticActionOut;
  2539. }
  2540. };
  2541. /**
  2542. * Creates the action easing object. <br />
  2543. * Reference easeOutQuart: <br />
  2544. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2545. * @function
  2546. * @returns {Object}
  2547. * @example
  2548. * //example
  2549. * action.easing(cc.QuarticActionOut());
  2550. */
  2551. cc.easeQuarticActionOut = function(){
  2552. return cc._easeQuarticActionOut;
  2553. };
  2554. /**
  2555. * cc.EaseQuarticActionInOut action. <br />
  2556. * Reference easeInOutQuart: <br />
  2557. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2558. * @class
  2559. * @extends cc.ActionEase
  2560. *
  2561. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuarticActionInOut());
  2562. *
  2563. * @example
  2564. * //The old usage
  2565. * cc.EaseQuarticActionInOut.create(action);
  2566. * //The new usage
  2567. * action.easing(cc.easeQuarticActionInOut());
  2568. */
  2569. cc.EaseQuarticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionInOut# */{
  2570. _updateTime: function(time){
  2571. time = time*2;
  2572. if (time < 1)
  2573. return 0.5 * time * time * time * time;
  2574. time -= 2;
  2575. return -0.5 * (time * time * time * time - 2);
  2576. },
  2577. /**
  2578. * Called once per frame. Time is the number of seconds of a frame interval.
  2579. *
  2580. * @param {Number} dt
  2581. */
  2582. update: function(dt){
  2583. this._inner.update(this._updateTime(dt));
  2584. },
  2585. /**
  2586. * to copy object with deep copy.
  2587. * returns a clone of action.
  2588. *
  2589. * @returns {cc.EaseQuarticActionInOut}
  2590. */
  2591. clone: function(){
  2592. var action = new cc.EaseQuarticActionInOut();
  2593. action.initWithAction(this._inner.clone());
  2594. return action;
  2595. },
  2596. /**
  2597. * Create a action. Opposite with the original motion trajectory.
  2598. * @return {cc.EaseQuarticActionInOut}
  2599. */
  2600. reverse: function(){
  2601. return new cc.EaseQuarticActionInOut(this._inner.reverse());
  2602. }
  2603. });
  2604. /**
  2605. * Creates the action. <br />
  2606. * Reference easeInOutQuart: <br />
  2607. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2608. * @static
  2609. *
  2610. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuarticActionInOut());
  2611. *
  2612. * @example
  2613. * //The old usage
  2614. * cc.EaseQuarticActionInOut.create(action);
  2615. * //The new usage
  2616. * action.easing(cc.easeQuarticActionInOut());
  2617. *
  2618. * @param action
  2619. * @returns {cc.EaseQuarticActionInOut}
  2620. */
  2621. cc.EaseQuarticActionInOut.create = function(action){
  2622. return new cc.EaseQuarticActionInOut(action);
  2623. };
  2624. cc._easeQuarticActionInOut = {
  2625. easing: cc.EaseQuarticActionInOut.prototype._updateTime,
  2626. reverse: function(){
  2627. return cc._easeQuarticActionInOut;
  2628. }
  2629. };
  2630. /**
  2631. * Creates the action easing object. <br />
  2632. * Reference easeInOutQuart: <br />
  2633. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2634. * @function
  2635. * @returns {Object}
  2636. */
  2637. cc.easeQuarticActionInOut = function(){
  2638. return cc._easeQuarticActionInOut;
  2639. };
  2640. /**
  2641. * cc.EaseQuinticActionIn action. <br />
  2642. * Reference easeInQuint: <br />
  2643. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2644. * @class
  2645. * @extends cc.ActionEase
  2646. *
  2647. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuinticActionIn());
  2648. *
  2649. * @example
  2650. * //The old usage
  2651. * cc.EaseQuinticActionIn.create(action);
  2652. * //The new usage
  2653. * action.easing(cc.easeQuinticActionIn());
  2654. */
  2655. cc.EaseQuinticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionIn# */{
  2656. _updateTime: function(time){
  2657. return time * time * time * time * time;
  2658. },
  2659. /**
  2660. * Called once per frame. Time is the number of seconds of a frame interval.
  2661. *
  2662. * @param {Number} dt
  2663. */
  2664. update: function(dt){
  2665. this._inner.update(this._updateTime(dt));
  2666. },
  2667. /**
  2668. * to copy object with deep copy.
  2669. * returns a clone of action.
  2670. *
  2671. * @returns {cc.EaseQuinticActionIn}
  2672. */
  2673. clone: function(){
  2674. var action = new cc.EaseQuinticActionIn();
  2675. action.initWithAction(this._inner.clone());
  2676. return action;
  2677. },
  2678. /**
  2679. * Create a action. Opposite with the original motion trajectory.
  2680. * @return {cc.EaseQuinticActionIn}
  2681. */
  2682. reverse: function(){
  2683. return new cc.EaseQuinticActionIn(this._inner.reverse());
  2684. }
  2685. });
  2686. /**
  2687. * Creates the action. <br />
  2688. * Reference easeInQuint: <br />
  2689. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2690. * @static
  2691. *
  2692. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuinticActionIn());
  2693. *
  2694. * @example
  2695. * //The old usage
  2696. * cc.EaseQuinticActionIn.create(action);
  2697. * //The new usage
  2698. * action.easing(cc.easeQuinticActionIn());
  2699. *
  2700. * @param action
  2701. * @returns {cc.EaseQuinticActionIn}
  2702. */
  2703. cc.EaseQuinticActionIn.create = function(action){
  2704. return new cc.EaseQuinticActionIn(action);
  2705. };
  2706. cc._easeQuinticActionIn = {
  2707. easing: cc.EaseQuinticActionIn.prototype._updateTime,
  2708. reverse: function(){
  2709. return cc._easeQuinticActionIn;
  2710. }
  2711. };
  2712. /**
  2713. * Creates the action easing object. <br />
  2714. * Reference easeInQuint: <br />
  2715. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2716. * @function
  2717. * @returns {Object}
  2718. * @example
  2719. * //example
  2720. * action.easing(cc.easeQuinticActionIn());
  2721. */
  2722. cc.easeQuinticActionIn = function(){
  2723. return cc._easeQuinticActionIn;
  2724. };
  2725. /**
  2726. * cc.EaseQuinticActionOut action. <br />
  2727. * Reference easeQuint: <br />
  2728. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2729. * @class
  2730. * @extends cc.ActionEase
  2731. *
  2732. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuadraticActionOut());
  2733. *
  2734. * @example
  2735. * //The old usage
  2736. * cc.EaseQuinticActionOut.create(action);
  2737. * //The new usage
  2738. * action.easing(cc.easeQuadraticActionOut());
  2739. */
  2740. cc.EaseQuinticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionOut# */{
  2741. _updateTime: function(time){
  2742. time -=1;
  2743. return (time * time * time * time * time + 1);
  2744. },
  2745. /**
  2746. * Called once per frame. Time is the number of seconds of a frame interval.
  2747. *
  2748. * @param {Number} dt
  2749. */
  2750. update: function(dt){
  2751. this._inner.update(this._updateTime(dt));
  2752. },
  2753. /**
  2754. * to copy object with deep copy.
  2755. * returns a clone of action.
  2756. *
  2757. * @returns {cc.EaseQuinticActionOut}
  2758. */
  2759. clone: function(){
  2760. var action = new cc.EaseQuinticActionOut();
  2761. action.initWithAction(this._inner.clone());
  2762. return action;
  2763. },
  2764. /**
  2765. * Create a action. Opposite with the original motion trajectory.
  2766. * @return {cc.EaseQuinticActionOut}
  2767. */
  2768. reverse: function(){
  2769. return new cc.EaseQuinticActionOut(this._inner.reverse());
  2770. }
  2771. });
  2772. /**
  2773. * Creates the action. <br />
  2774. * Reference easeOutQuint: <br />
  2775. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2776. * @static
  2777. *
  2778. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuadraticActionOut());
  2779. *
  2780. * @example
  2781. * //The old usage
  2782. * cc.EaseQuinticActionOut.create(action);
  2783. * //The new usage
  2784. * action.easing(cc.easeQuadraticActionOut());
  2785. *
  2786. * @param action
  2787. * @returns {cc.EaseQuinticActionOut}
  2788. */
  2789. cc.EaseQuinticActionOut.create = function(action){
  2790. return new cc.EaseQuinticActionOut(action);
  2791. };
  2792. cc._easeQuinticActionOut = {
  2793. easing: cc.EaseQuinticActionOut.prototype._updateTime,
  2794. reverse: function(){
  2795. return cc._easeQuinticActionOut;
  2796. }
  2797. };
  2798. /**
  2799. * Creates the action easing object. <br />
  2800. * Reference easeOutQuint: <br />
  2801. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2802. * @function
  2803. * @returns {Object}
  2804. * @example
  2805. * //example
  2806. * action.easing(cc.easeQuadraticActionOut());
  2807. */
  2808. cc.easeQuinticActionOut = function(){
  2809. return cc._easeQuinticActionOut;
  2810. };
  2811. /**
  2812. * cc.EaseQuinticActionInOut action. <br />
  2813. * Reference easeInOutQuint: <br />
  2814. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2815. * @class
  2816. * @extends cc.ActionEase
  2817. *
  2818. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuinticActionInOut());
  2819. *
  2820. * @example
  2821. * //The old usage
  2822. * cc.EaseQuinticActionInOut.create(action);
  2823. * //The new usage
  2824. * action.easing(cc.easeQuinticActionInOut());
  2825. */
  2826. cc.EaseQuinticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionInOut# */{
  2827. _updateTime: function(time){
  2828. time = time*2;
  2829. if (time < 1)
  2830. return 0.5 * time * time * time * time * time;
  2831. time -= 2;
  2832. return 0.5 * (time * time * time * time * time + 2);
  2833. },
  2834. /**
  2835. * Called once per frame. Time is the number of seconds of a frame interval.
  2836. *
  2837. * @param {Number} dt
  2838. */
  2839. update: function(dt){
  2840. this._inner.update(this._updateTime(dt));
  2841. },
  2842. /**
  2843. * to copy object with deep copy.
  2844. * returns a clone of action.
  2845. *
  2846. * @returns {cc.EaseQuinticActionInOut}
  2847. */
  2848. clone: function(){
  2849. var action = new cc.EaseQuinticActionInOut();
  2850. action.initWithAction(this._inner.clone());
  2851. return action;
  2852. },
  2853. /**
  2854. * Create a action. Opposite with the original motion trajectory.
  2855. * @return {cc.EaseQuinticActionInOut}
  2856. */
  2857. reverse: function(){
  2858. return new cc.EaseQuinticActionInOut(this._inner.reverse());
  2859. }
  2860. });
  2861. /**
  2862. * Creates the action. <br />
  2863. * Reference easeInOutQuint: <br />
  2864. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2865. * @static
  2866. *
  2867. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuinticActionInOut());
  2868. *
  2869. * @example
  2870. * //The old usage
  2871. * cc.EaseQuinticActionInOut.create(action);
  2872. * //The new usage
  2873. * action.easing(cc.easeQuinticActionInOut());
  2874. *
  2875. * @param action
  2876. * @returns {cc.EaseQuinticActionInOut}
  2877. */
  2878. cc.EaseQuinticActionInOut.create = function(action){
  2879. return new cc.EaseQuinticActionInOut(action);
  2880. };
  2881. cc._easeQuinticActionInOut = {
  2882. easing: cc.EaseQuinticActionInOut.prototype._updateTime,
  2883. reverse: function(){
  2884. return cc._easeQuinticActionInOut;
  2885. }
  2886. };
  2887. /**
  2888. * Creates the action easing object. <br />
  2889. * Reference easeInOutQuint: <br />
  2890. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2891. * @function
  2892. * @returns {Object}
  2893. * @example
  2894. * //example
  2895. * action.easing(cc.easeQuinticActionInOut());
  2896. */
  2897. cc.easeQuinticActionInOut = function(){
  2898. return cc._easeQuinticActionInOut;
  2899. };
  2900. /**
  2901. * cc.EaseCircleActionIn action. <br />
  2902. * Reference easeInCirc: <br />
  2903. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2904. * @class
  2905. * @extends cc.ActionEase
  2906. *
  2907. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCircleActionIn());
  2908. *
  2909. * @example
  2910. * //The old usage
  2911. * cc.EaseCircleActionIn.create(action);
  2912. * //The new usage
  2913. * action.easing(cc.easeCircleActionIn());
  2914. */
  2915. cc.EaseCircleActionIn = cc.ActionEase.extend(/** @lends cc.EaseCircleActionIn# */{
  2916. _updateTime: function(time){
  2917. return -1 * (Math.sqrt(1 - time * time) - 1);
  2918. },
  2919. /**
  2920. * Called once per frame. Time is the number of seconds of a frame interval.
  2921. *
  2922. * @param {Number} dt
  2923. */
  2924. update: function(dt){
  2925. this._inner.update(this._updateTime(dt));
  2926. },
  2927. /**
  2928. * to copy object with deep copy.
  2929. * returns a clone of action.
  2930. *
  2931. * @returns {cc.EaseCircleActionIn}
  2932. */
  2933. clone: function(){
  2934. var action = new cc.EaseCircleActionIn();
  2935. action.initWithAction(this._inner.clone());
  2936. return action;
  2937. },
  2938. /**
  2939. * Create a action. Opposite with the original motion trajectory.
  2940. * @return {cc.EaseCircleActionIn}
  2941. */
  2942. reverse: function(){
  2943. return new cc.EaseCircleActionIn(this._inner.reverse());
  2944. }
  2945. });
  2946. /**
  2947. * Creates the action. <br />
  2948. * Reference easeInCirc: <br />
  2949. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2950. * @static
  2951. *
  2952. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCircleActionIn());
  2953. *
  2954. * @example
  2955. * //The old usage
  2956. * cc.EaseCircleActionIn.create(action);
  2957. * //The new usage
  2958. * action.easing(cc.easeCircleActionIn());
  2959. *
  2960. * @param action
  2961. * @returns {cc.EaseCircleActionIn}
  2962. */
  2963. cc.EaseCircleActionIn.create = function(action){
  2964. return new cc.EaseCircleActionIn(action);
  2965. };
  2966. cc._easeCircleActionIn = {
  2967. easing: cc.EaseCircleActionIn.prototype._updateTime,
  2968. reverse: function(){
  2969. return cc._easeCircleActionIn;
  2970. }
  2971. };
  2972. /**
  2973. * Creates the action easing object. <br />
  2974. * Reference easeInCirc: <br />
  2975. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2976. * @function
  2977. * @returns {Object}
  2978. * @example
  2979. * //example
  2980. * action.easing(cc.easeCircleActionIn());
  2981. */
  2982. cc.easeCircleActionIn = function(){
  2983. return cc._easeCircleActionIn;
  2984. };
  2985. /**
  2986. * cc.EaseCircleActionOut action. <br />
  2987. * Reference easeOutCirc: <br />
  2988. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  2989. * @class
  2990. * @extends cc.ActionEase
  2991. *
  2992. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCircleActionOut());
  2993. *
  2994. * @example
  2995. * //The old usage
  2996. * cc.EaseCircleActionOut.create(action);
  2997. * //The new usage
  2998. * action.easing(cc.easeCircleActionOut());
  2999. */
  3000. cc.EaseCircleActionOut = cc.ActionEase.extend(/** @lends cc.EaseCircleActionOut# */{
  3001. _updateTime: function(time){
  3002. time = time - 1;
  3003. return Math.sqrt(1 - time * time);
  3004. },
  3005. /**
  3006. * Called once per frame. Time is the number of seconds of a frame interval.
  3007. *
  3008. * @param {Number} dt
  3009. */
  3010. update: function(dt){
  3011. this._inner.update(this._updateTime(dt));
  3012. },
  3013. /**
  3014. * to copy object with deep copy.
  3015. * returns a clone of action.
  3016. *
  3017. * @returns {cc.EaseCircleActionOut}
  3018. */
  3019. clone: function(){
  3020. var action = new cc.EaseCircleActionOut();
  3021. action.initWithAction(this._inner.clone());
  3022. return action;
  3023. },
  3024. /**
  3025. * Create a action. Opposite with the original motion trajectory.
  3026. * @return {cc.EaseCircleActionOut}
  3027. */
  3028. reverse: function(){
  3029. return new cc.EaseCircleActionOut(this._inner.reverse());
  3030. }
  3031. });
  3032. /**
  3033. * Creates the action. <br />
  3034. * Reference easeOutCirc: <br />
  3035. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  3036. * @static
  3037. *
  3038. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCircleActionOut());
  3039. *
  3040. * @example
  3041. * //The old usage
  3042. * cc.EaseCircleActionOut.create(action);
  3043. * //The new usage
  3044. * action.easing(cc.easeCircleActionOut());
  3045. *
  3046. * @param action
  3047. * @returns {cc.EaseCircleActionOut}
  3048. */
  3049. cc.EaseCircleActionOut.create = function(action){
  3050. return new cc.EaseCircleActionOut(action);
  3051. };
  3052. cc._easeCircleActionOut = {
  3053. easing: cc.EaseCircleActionOut.prototype._updateTime,
  3054. reverse: function(){
  3055. return cc._easeCircleActionOut;
  3056. }
  3057. };
  3058. /**
  3059. * Creates the action easing object. <br />
  3060. * Reference easeOutCirc: <br />
  3061. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  3062. * @function
  3063. * @returns {Object}
  3064. * @exampple
  3065. * //example
  3066. * actioneasing(cc.easeCircleActionOut());
  3067. */
  3068. cc.easeCircleActionOut = function(){
  3069. return cc._easeCircleActionOut;
  3070. };
  3071. /**
  3072. * cc.EaseCircleActionInOut action. <br />
  3073. * Reference easeInOutCirc: <br />
  3074. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  3075. * @class
  3076. * @extends cc.ActionEase
  3077. *
  3078. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCircleActionInOut());
  3079. *
  3080. * @example
  3081. * //The old usage
  3082. * cc.EaseCircleActionInOut.create(action);
  3083. * //The new usage
  3084. * action.easing(cc.easeCircleActionInOut());
  3085. */
  3086. cc.EaseCircleActionInOut = cc.ActionEase.extend(/** @lends cc.EaseCircleActionInOut# */{
  3087. _updateTime: function(time){
  3088. time = time * 2;
  3089. if (time < 1)
  3090. return -0.5 * (Math.sqrt(1 - time * time) - 1);
  3091. time -= 2;
  3092. return 0.5 * (Math.sqrt(1 - time * time) + 1);
  3093. },
  3094. /**
  3095. * Called once per frame. Time is the number of seconds of a frame interval.
  3096. *
  3097. * @param {Number} dt
  3098. */
  3099. update: function(dt){
  3100. this._inner.update(this._updateTime(dt));
  3101. },
  3102. /**
  3103. * to copy object with deep copy.
  3104. * returns a clone of action.
  3105. *
  3106. * @returns {cc.EaseCircleActionInOut}
  3107. */
  3108. clone: function(){
  3109. var action = new cc.EaseCircleActionInOut();
  3110. action.initWithAction(this._inner.clone());
  3111. return action;
  3112. },
  3113. /**
  3114. * Create a action. Opposite with the original motion trajectory.
  3115. * @return {cc.EaseCircleActionInOut}
  3116. */
  3117. reverse: function(){
  3118. return new cc.EaseCircleActionInOut(this._inner.reverse());
  3119. }
  3120. });
  3121. /**
  3122. * Creates the action. <br />
  3123. * Reference easeInOutCirc: <br />
  3124. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  3125. * @static
  3126. *
  3127. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCircleActionInOut());
  3128. *
  3129. * @example
  3130. * //The old usage
  3131. * cc.EaseCircleActionInOut.create(action);
  3132. * //The new usage
  3133. * action.easing(cc.easeCircleActionInOut());
  3134. *
  3135. * @param action
  3136. * @returns {cc.EaseCircleActionInOut}
  3137. */
  3138. cc.EaseCircleActionInOut.create = function(action){
  3139. return new cc.EaseCircleActionInOut(action);
  3140. };
  3141. cc._easeCircleActionInOut = {
  3142. easing: cc.EaseCircleActionInOut.prototype._updateTime,
  3143. reverse: function(){
  3144. return cc._easeCircleActionInOut;
  3145. }
  3146. };
  3147. /**
  3148. * Creates the action easing object. <br />
  3149. * Reference easeInOutCirc: <br />
  3150. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  3151. * @function
  3152. * @returns {Object}
  3153. * @example
  3154. * //example
  3155. * action.easing(cc.easeCircleActionInOut());
  3156. */
  3157. cc.easeCircleActionInOut = function(){
  3158. return cc._easeCircleActionInOut;
  3159. };
  3160. /**
  3161. * cc.EaseCubicActionIn action. <br />
  3162. * Reference easeInCubic: <br />
  3163. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  3164. * @class
  3165. * @extends cc.ActionEase
  3166. *
  3167. * @deprecated since v3.0 <br /> action.easing(cc.easeCubicActionIn());
  3168. *
  3169. * @example
  3170. * //The old usage
  3171. * cc.EaseCubicActionIn.create(action);
  3172. * //The new usage
  3173. * action.easing(cc.easeCubicActionIn());
  3174. */
  3175. cc.EaseCubicActionIn = cc.ActionEase.extend(/** @lends cc.EaseCubicActionIn# */{
  3176. _updateTime: function(time){
  3177. return time * time * time;
  3178. },
  3179. /**
  3180. * Called once per frame. Time is the number of seconds of a frame interval.
  3181. *
  3182. * @param {Number} dt
  3183. */
  3184. update: function(dt){
  3185. this._inner.update(this._updateTime(dt));
  3186. },
  3187. /**
  3188. * to copy object with deep copy.
  3189. * returns a clone of action.
  3190. *
  3191. * @returns {cc.EaseCubicActionIn}
  3192. */
  3193. clone: function(){
  3194. var action = new cc.EaseCubicActionIn();
  3195. action.initWithAction(this._inner.clone());
  3196. return action;
  3197. },
  3198. /**
  3199. * Create a action. Opposite with the original motion trajectory.
  3200. * @return {cc.EaseCubicActionIn}
  3201. */
  3202. reverse: function(){
  3203. return new cc.EaseCubicActionIn(this._inner.reverse());
  3204. }
  3205. });
  3206. /**
  3207. * Creates the action. <br />
  3208. * Reference easeInCubic: <br />
  3209. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  3210. * @static
  3211. *
  3212. * @deprecated since v3.0 <br /> action.easing(cc.easeCubicActionIn());
  3213. *
  3214. * @example
  3215. * //The old usage
  3216. * cc.EaseCubicActionIn.create(action);
  3217. * //The new usage
  3218. * action.easing(cc.easeCubicActionIn());
  3219. *
  3220. * @param action
  3221. * @returns {cc.EaseCubicActionIn}
  3222. */
  3223. cc.EaseCubicActionIn.create = function(action){
  3224. return new cc.EaseCubicActionIn(action);
  3225. };
  3226. cc._easeCubicActionIn = {
  3227. easing: cc.EaseCubicActionIn.prototype._updateTime,
  3228. reverse: function(){
  3229. return cc._easeCubicActionIn;
  3230. }
  3231. };
  3232. /**
  3233. * Creates the action easing object. <br />
  3234. * Reference easeInCubic: <br />
  3235. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  3236. * @function
  3237. * @returns {Object}
  3238. * @example
  3239. * //example
  3240. * action.easing(cc.easeCubicActionIn());
  3241. */
  3242. cc.easeCubicActionIn = function(){
  3243. return cc._easeCubicActionIn;
  3244. };
  3245. /**
  3246. * cc.EaseCubicActionOut action. <br />
  3247. * Reference easeOutCubic: <br />
  3248. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  3249. * @class
  3250. * @extends cc.ActionEase
  3251. *
  3252. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCubicActionOut());
  3253. *
  3254. * @example
  3255. * //The old usage
  3256. * cc.EaseCubicActionOut.create(action);
  3257. * //The new usage
  3258. * action.easing(cc.easeCubicActionOut());
  3259. */
  3260. cc.EaseCubicActionOut = cc.ActionEase.extend(/** @lends cc.EaseCubicActionOut# */{
  3261. _updateTime: function(time){
  3262. time -= 1;
  3263. return (time * time * time + 1);
  3264. },
  3265. /**
  3266. * Called once per frame. Time is the number of seconds of a frame interval.
  3267. *
  3268. * @param {Number} dt
  3269. */
  3270. update: function(dt){
  3271. this._inner.update(this._updateTime(dt));
  3272. },
  3273. /**
  3274. * to copy object with deep copy.
  3275. * returns a clone of action.
  3276. *
  3277. * @returns {cc.EaseCubicActionOut}
  3278. */
  3279. clone: function(){
  3280. var action = new cc.EaseCubicActionOut();
  3281. action.initWithAction(this._inner.clone());
  3282. return action;
  3283. },
  3284. /**
  3285. * Create a action. Opposite with the original motion trajectory.
  3286. * @return {cc.EaseCubicActionOut}
  3287. */
  3288. reverse: function(){
  3289. return new cc.EaseCubicActionOut(this._inner.reverse());
  3290. }
  3291. });
  3292. /**
  3293. * Creates the action. <br />
  3294. * Reference easeOutCubic: <br />
  3295. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  3296. * @static
  3297. *
  3298. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCubicActionOut());
  3299. *
  3300. * @example
  3301. * //The old usage
  3302. * cc.EaseCubicActionOut.create(action);
  3303. * //The new usage
  3304. * action.easing(cc.easeCubicActionOut());
  3305. *
  3306. * @param action
  3307. * @returns {cc.EaseCubicActionOut}
  3308. */
  3309. cc.EaseCubicActionOut.create = function(action){
  3310. return new cc.EaseCubicActionOut(action);
  3311. };
  3312. cc._easeCubicActionOut = {
  3313. easing: cc.EaseCubicActionOut.prototype._updateTime,
  3314. reverse: function(){
  3315. return cc._easeCubicActionOut;
  3316. }
  3317. };
  3318. /**
  3319. * Creates the action easing object. <br />
  3320. * Reference easeOutCubic: <br />
  3321. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  3322. * @function
  3323. * @returns {Object}
  3324. * @example
  3325. * //example
  3326. * action.easing(cc.easeCubicActionOut());
  3327. */
  3328. cc.easeCubicActionOut = function(){
  3329. return cc._easeCubicActionOut;
  3330. };
  3331. /**
  3332. * cc.EaseCubicActionInOut action. <br />
  3333. * Reference easeInOutCubic: <br />
  3334. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  3335. * @class
  3336. * @extends cc.ActionEase
  3337. *
  3338. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCubicActionInOut());
  3339. *
  3340. * @example
  3341. * //The old usage
  3342. * cc.EaseCubicActionInOut.create(action);
  3343. * //The new usage
  3344. * action.easing(cc.easeCubicActionInOut());
  3345. */
  3346. cc.EaseCubicActionInOut = cc.ActionEase.extend(/** @lends cc.EaseCubicActionInOut# */{
  3347. _updateTime: function(time){
  3348. time = time*2;
  3349. if (time < 1)
  3350. return 0.5 * time * time * time;
  3351. time -= 2;
  3352. return 0.5 * (time * time * time + 2);
  3353. },
  3354. /**
  3355. * Called once per frame. Time is the number of seconds of a frame interval.
  3356. *
  3357. * @param {Number} dt
  3358. */
  3359. update: function(dt){
  3360. this._inner.update(this._updateTime(dt));
  3361. },
  3362. /**
  3363. * to copy object with deep copy.
  3364. * returns a clone of action.
  3365. *
  3366. * @returns {cc.EaseCubicActionInOut}
  3367. */
  3368. clone: function(){
  3369. var action = new cc.EaseCubicActionInOut();
  3370. action.initWithAction(this._inner.clone());
  3371. return action;
  3372. },
  3373. /**
  3374. * Create a action. Opposite with the original motion trajectory.
  3375. * @return {cc.EaseCubicActionInOut}
  3376. */
  3377. reverse: function(){
  3378. return new cc.EaseCubicActionInOut(this._inner.reverse());
  3379. }
  3380. });
  3381. /**
  3382. * Creates the action. <br />
  3383. * Reference easeInOutCubic: <br />
  3384. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  3385. * @static
  3386. *
  3387. * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCubicActionInOut());
  3388. *
  3389. * @example
  3390. * //The old usage
  3391. * cc.EaseCubicActionInOut.create(action);
  3392. * //The new usage
  3393. * action.easing(cc.easeCubicActionInOut());
  3394. *
  3395. * @param action
  3396. * @returns {cc.EaseCubicActionInOut}
  3397. */
  3398. cc.EaseCubicActionInOut.create = function(action){
  3399. return new cc.EaseCubicActionInOut(action);
  3400. };
  3401. cc._easeCubicActionInOut = {
  3402. easing: cc.EaseCubicActionInOut.prototype._updateTime,
  3403. reverse: function(){
  3404. return cc._easeCubicActionInOut;
  3405. }
  3406. };
  3407. /**
  3408. * Creates the action easing object. <br />
  3409. * Reference easeInOutCubic: <br />
  3410. * {@link http://www.zhihu.com/question/21981571/answer/19925418}
  3411. * @function
  3412. * @returns {Object}
  3413. */
  3414. cc.easeCubicActionInOut = function(){
  3415. return cc._easeCubicActionInOut;
  3416. };