CCTransition.js 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989
  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. * A tag constant for identifying fade scenes
  24. * @constant
  25. * @type Number
  26. */
  27. cc.SCENE_FADE = 4208917214;
  28. /**
  29. * horizontal orientation Type where the Left is nearer
  30. * @constant
  31. * @type Number
  32. */
  33. cc.TRANSITION_ORIENTATION_LEFT_OVER = 0;
  34. /**
  35. * horizontal orientation type where the Right is nearer
  36. * @constant
  37. * @type Number
  38. */
  39. cc.TRANSITION_ORIENTATION_RIGHT_OVER = 1;
  40. /**
  41. * vertical orientation type where the Up is nearer
  42. * @constant
  43. * @type Number
  44. */
  45. cc.TRANSITION_ORIENTATION_UP_OVER = 0;
  46. /**
  47. * vertical orientation type where the Bottom is nearer
  48. * @constant
  49. * @type Number
  50. */
  51. cc.TRANSITION_ORIENTATION_DOWN_OVER = 1;
  52. /**
  53. * @class
  54. * @extends cc.Scene
  55. * @param {Number} t time in seconds
  56. * @param {cc.Scene} scene the scene to transit with
  57. * @example
  58. * var trans = new TransitionScene(time,scene);
  59. */
  60. cc.TransitionScene = cc.Scene.extend(/** @lends cc.TransitionScene# */{
  61. _inScene:null,
  62. _outScene:null,
  63. _duration:null,
  64. _isInSceneOnTop:false,
  65. _isSendCleanupToScene:false,
  66. _className:"TransitionScene",
  67. /**
  68. * creates a base transition with duration and incoming scene
  69. * Constructor of cc.TransitionScene
  70. * @param {Number} t time in seconds
  71. * @param {cc.Scene} scene the scene to transit with
  72. */
  73. ctor:function (t, scene) {
  74. cc.Scene.prototype.ctor.call(this);
  75. if(t !== undefined && scene !== undefined)
  76. this.initWithDuration(t, scene);
  77. },
  78. //private
  79. _setNewScene:function (dt) {
  80. this.unschedule(this._setNewScene);
  81. // Before replacing, save the "send cleanup to scene"
  82. var director = cc.director;
  83. this._isSendCleanupToScene = director.isSendCleanupToScene();
  84. director.runScene(this._inScene);
  85. // enable events while transitions
  86. cc.eventManager.setEnabled(true);
  87. // issue #267
  88. this._outScene.visible = true;
  89. },
  90. //protected
  91. _sceneOrder:function () {
  92. this._isInSceneOnTop = true;
  93. },
  94. /**
  95. * stuff gets drawn here
  96. */
  97. draw:function () {
  98. if (this._isInSceneOnTop) {
  99. this._outScene.visit();
  100. this._inScene.visit();
  101. } else {
  102. this._inScene.visit();
  103. this._outScene.visit();
  104. }
  105. },
  106. /**
  107. * <p>
  108. * Event callback that is invoked every time when cc.TransitionScene enters the 'stage'. <br/>
  109. * If the TransitionScene enters the 'stage' with a transition, this event is called when the transition starts. <br/>
  110. * During onEnter you can't access a "sister/brother" node. <br/>
  111. * If you override onEnter, you must call its parent's onEnter function with this._super().
  112. * </p>
  113. */
  114. onEnter:function () {
  115. cc.Node.prototype.onEnter.call(this);
  116. // disable events while transitions
  117. cc.eventManager.setEnabled(false);
  118. // outScene should not receive the onEnter callback
  119. // only the onExitTransitionDidStart
  120. this._outScene.onExitTransitionDidStart();
  121. this._inScene.onEnter();
  122. },
  123. /**
  124. * <p>
  125. * callback that is called every time the cc.TransitionScene leaves the 'stage'. <br/>
  126. * If the cc.TransitionScene leaves the 'stage' with a transition, this callback is called when the transition finishes. <br/>
  127. * During onExit you can't access a sibling node. <br/>
  128. * If you override onExit, you shall call its parent's onExit with this._super().
  129. * </p>
  130. */
  131. onExit:function () {
  132. cc.Node.prototype.onExit.call(this);
  133. // enable events while transitions
  134. cc.eventManager.setEnabled(true);
  135. this._outScene.onExit();
  136. // _inScene should not receive the onEnter callback
  137. // only the onEnterTransitionDidFinish
  138. this._inScene.onEnterTransitionDidFinish();
  139. },
  140. /**
  141. * custom cleanup
  142. */
  143. cleanup:function () {
  144. cc.Node.prototype.cleanup.call(this);
  145. if (this._isSendCleanupToScene)
  146. this._outScene.cleanup();
  147. },
  148. /**
  149. * initializes a transition with duration and incoming scene
  150. * @param {Number} t time in seconds
  151. * @param {cc.Scene} scene a scene to transit to
  152. * @return {Boolean} return false if error
  153. */
  154. initWithDuration:function (t, scene) {
  155. if(!scene)
  156. throw "cc.TransitionScene.initWithDuration(): Argument scene must be non-nil";
  157. if (this.init()) {
  158. this._duration = t;
  159. this.attr({
  160. x: 0,
  161. y: 0,
  162. anchorX: 0,
  163. anchorY: 0
  164. });
  165. // retain
  166. this._inScene = scene;
  167. this._outScene = cc.director.getRunningScene();
  168. if (!this._outScene) {
  169. this._outScene = cc.Scene.create();
  170. this._outScene.init();
  171. }
  172. if(this._inScene == this._outScene)
  173. throw "cc.TransitionScene.initWithDuration(): Incoming scene must be different from the outgoing scene";
  174. this._sceneOrder();
  175. return true;
  176. } else {
  177. return false;
  178. }
  179. },
  180. /**
  181. * called after the transition finishes
  182. */
  183. finish:function () {
  184. // clean up
  185. this._inScene.attr({
  186. visible: true,
  187. x: 0,
  188. y: 0,
  189. scale: 1.0,
  190. rotation: 0.0
  191. });
  192. if(cc._renderType === cc._RENDER_TYPE_WEBGL)
  193. this._inScene.getCamera().restore();
  194. this._outScene.attr({
  195. visible: false,
  196. x: 0,
  197. y: 0,
  198. scale: 1.0,
  199. rotation: 0.0
  200. });
  201. if(cc._renderType === cc._RENDER_TYPE_WEBGL)
  202. this._outScene.getCamera().restore();
  203. //[self schedule:@selector(setNewScene:) interval:0];
  204. this.schedule(this._setNewScene, 0);
  205. },
  206. /**
  207. * set hide the out scene and show in scene
  208. */
  209. hideOutShowIn:function () {
  210. this._inScene.visible = true;
  211. this._outScene.visible = false;
  212. }
  213. });
  214. /**
  215. * creates a base transition with duration and incoming scene
  216. * @deprecated since v3.0, please use new cc.TransitionScene(t,scene) instead
  217. * @param {Number} t time in seconds
  218. * @param {cc.Scene} scene the scene to transit with
  219. * @return {cc.TransitionScene|Null}
  220. */
  221. cc.TransitionScene.create = function (t, scene) {
  222. return new cc.TransitionScene(t, scene);
  223. };
  224. /**
  225. * A cc.Transition that supports orientation like.<br/>
  226. * Possible orientation: LeftOver, RightOver, UpOver, DownOver<br/>
  227. * useful for when you want to make a transition happen between 2 orientations
  228. * @class
  229. * @extends cc.TransitionScene
  230. * @param {Number} t time in seconds
  231. * @param {cc.Scene} scene
  232. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} orientation
  233. * @example
  234. * var trans = new cc.TransitionSceneOriented(time,scene,orientation);
  235. */
  236. cc.TransitionSceneOriented = cc.TransitionScene.extend(/** @lends cc.TransitionSceneOriented# */{
  237. _orientation:0,
  238. /**
  239. * Constructor of TransitionSceneOriented
  240. * @param {Number} t time in seconds
  241. * @param {cc.Scene} scene
  242. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} orientation
  243. */
  244. ctor:function (t, scene, orientation) {
  245. cc.TransitionScene.prototype.ctor.call(this);
  246. orientation != undefined && this.initWithDuration(t, scene, orientation);
  247. },
  248. /**
  249. * initialize the transition
  250. * @param {Number} t time in seconds
  251. * @param {cc.Scene} scene
  252. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} orientation
  253. * @return {Boolean}
  254. */
  255. initWithDuration:function (t, scene, orientation) {
  256. if (cc.TransitionScene.prototype.initWithDuration.call(this, t, scene)) {
  257. this._orientation = orientation;
  258. }
  259. return true;
  260. }
  261. });
  262. /**
  263. * creates a base transition with duration and incoming scene
  264. * @deprecated since v3.0 ,please use new cc.TransitionSceneOriented(t, scene, orientation) instead.
  265. * @param {Number} t time in seconds
  266. * @param {cc.Scene} scene
  267. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} orientation
  268. * @return {cc.TransitionSceneOriented}
  269. * @example
  270. * // Example
  271. * var goHorizontal = cc.TransitionSceneOriented.create(0.5, thisScene, cc.TRANSITION_ORIENTATION_LEFT_OVER)
  272. */
  273. cc.TransitionSceneOriented.create = function (t, scene, orientation) {
  274. return new cc.TransitionSceneOriented(t, scene, orientation);
  275. };
  276. /**
  277. * Rotate and zoom out the outgoing scene, and then rotate and zoom in the incoming
  278. * @class
  279. * @extends cc.TransitionScene
  280. * @param {Number} t time in seconds
  281. * @param {cc.Scene} scene
  282. * @example
  283. * var trans = new cc.TransitionRotoZoom(t, scene);
  284. */
  285. cc.TransitionRotoZoom = cc.TransitionScene.extend(/** @lends cc.TransitionRotoZoom# */{
  286. /**
  287. * Constructor of TransitionRotoZoom
  288. * @function
  289. * @param {Number} t time in seconds
  290. * @param {cc.Scene} scene
  291. */
  292. ctor:function (t, scene) {
  293. cc.TransitionScene.prototype.ctor.call(this);
  294. scene && this.initWithDuration(t, scene);
  295. },
  296. /**
  297. * Custom On Enter callback
  298. * @override
  299. */
  300. onEnter:function () {
  301. cc.TransitionScene.prototype.onEnter.call(this);
  302. this._inScene.attr({
  303. scale: 0.001,
  304. anchorX: 0.5,
  305. anchorY: 0.5
  306. });
  307. this._outScene.attr({
  308. scale: 1.0,
  309. anchorX: 0.5,
  310. anchorY: 0.5
  311. });
  312. var rotoZoom = cc.sequence(
  313. cc.spawn(cc.scaleBy(this._duration / 2, 0.001),
  314. cc.rotateBy(this._duration / 2, 360 * 2)),
  315. cc.delayTime(this._duration / 2));
  316. this._outScene.runAction(rotoZoom);
  317. this._inScene.runAction(
  318. cc.sequence(rotoZoom.reverse(),
  319. cc.callFunc(this.finish, this)));
  320. }
  321. });
  322. /**
  323. * Creates a Transtion rotation and zoom
  324. * @deprecated since v3.0,please use new cc.TransitionRotoZoom(t, scene) instead
  325. * @param {Number} t time in seconds
  326. * @param {cc.Scene} scene the scene to work with
  327. * @return {cc.TransitionRotoZoom}
  328. * @example
  329. * var RotoZoomTrans = cc.TransitionRotoZoom.create(2, nextScene);
  330. */
  331. cc.TransitionRotoZoom.create = function (t, scene) {
  332. return new cc.TransitionRotoZoom(t, scene);
  333. };
  334. /**
  335. * Zoom out and jump the outgoing scene, and then jump and zoom in the incoming
  336. * @class
  337. * @extends cc.TransitionScene
  338. * @param {Number} t time in seconds
  339. * @param {cc.Scene} scene
  340. * @example
  341. * var trans = new cc.TransitionJumpZoom(t, scene);
  342. */
  343. cc.TransitionJumpZoom = cc.TransitionScene.extend(/** @lends cc.TransitionJumpZoom# */{
  344. /**
  345. * Constructor of TransitionJumpZoom
  346. * @param {Number} t time in seconds
  347. * @param {cc.Scene} scene
  348. */
  349. ctor:function (t, scene) {
  350. cc.TransitionScene.prototype.ctor.call(this);
  351. scene && this.initWithDuration(t, scene);
  352. },
  353. /**
  354. * Custom on enter
  355. */
  356. onEnter:function () {
  357. cc.TransitionScene.prototype.onEnter.call(this);
  358. var winSize = cc.director.getWinSize();
  359. this._inScene.attr({
  360. scale: 0.5,
  361. x: winSize.width,
  362. y: 0,
  363. anchorX: 0.5,
  364. anchorY: 0.5
  365. });
  366. this._outScene.anchorX = 0.5;
  367. this._outScene.anchorY = 0.5;
  368. var jump = cc.jumpBy(this._duration / 4, cc.p(-winSize.width, 0), winSize.width / 4, 2);
  369. var scaleIn = cc.scaleTo(this._duration / 4, 1.0);
  370. var scaleOut = cc.scaleTo(this._duration / 4, 0.5);
  371. var jumpZoomOut = cc.sequence(scaleOut, jump);
  372. var jumpZoomIn = cc.sequence(jump, scaleIn);
  373. var delay = cc.delayTime(this._duration / 2);
  374. this._outScene.runAction(jumpZoomOut);
  375. this._inScene.runAction(cc.sequence(delay, jumpZoomIn, cc.callFunc(this.finish, this)));
  376. }
  377. });
  378. /**
  379. * creates a scene transition that zooms then jump across the screen, the same for the incoming scene
  380. * @deprecated since v3.0,please use new cc.TransitionJumpZoom(t, scene);
  381. * @param {Number} t time in seconds
  382. * @param {cc.Scene} scene
  383. * @return {cc.TransitionJumpZoom}
  384. */
  385. cc.TransitionJumpZoom.create = function (t, scene) {
  386. return new cc.TransitionJumpZoom(t, scene);
  387. };
  388. /**
  389. * Move in from to the left the incoming scene.
  390. * @class
  391. * @extends cc.TransitionScene
  392. * @param {Number} t time in seconds
  393. * @param {cc.Scene} scene
  394. * @example
  395. * var trans = new cc.TransitionMoveInL(time,scene);
  396. */
  397. cc.TransitionMoveInL = cc.TransitionScene.extend(/** @lends cc.TransitionMoveInL# */{
  398. /**
  399. * Constructor of TransitionMoveInL
  400. * @param {Number} t time in seconds
  401. * @param {cc.Scene} scene
  402. */
  403. ctor:function (t, scene) {
  404. cc.TransitionScene.prototype.ctor.call(this);
  405. scene && this.initWithDuration(t, scene);
  406. },
  407. /**
  408. * Custom on enter
  409. */
  410. onEnter:function () {
  411. cc.TransitionScene.prototype.onEnter.call(this);
  412. this.initScenes();
  413. var action = this.action();
  414. this._inScene.runAction(
  415. cc.sequence(this.easeActionWithAction(action), cc.callFunc(this.finish, this))
  416. );
  417. },
  418. /**
  419. * initializes the scenes
  420. */
  421. initScenes:function () {
  422. this._inScene.setPosition(-cc.director.getWinSize().width, 0);
  423. },
  424. /**
  425. * returns the action that will be performed
  426. */
  427. action:function () {
  428. return cc.moveTo(this._duration, cc.p(0, 0));
  429. },
  430. /**
  431. * creates an ease action from action
  432. * @param {cc.ActionInterval} action
  433. * @return {cc.EaseOut}
  434. */
  435. easeActionWithAction:function (action) {
  436. return new cc.EaseOut(action, 2.0);
  437. }
  438. });
  439. /**
  440. * creates an action that Move in from to the left the incoming scene.
  441. * @deprecated since v3.0,please use new cc.TransitionMoveInL(t, scene) instead
  442. * @param {Number} t time in seconds
  443. * @param {cc.Scene} scene
  444. * @return {cc.TransitionMoveInL}
  445. * @example
  446. * var MoveInLeft = cc.TransitionMoveInL.create(1, nextScene)
  447. */
  448. cc.TransitionMoveInL.create = function (t, scene) {
  449. return new cc.TransitionMoveInL(t, scene);
  450. };
  451. /**
  452. * Move in from to the right the incoming scene.
  453. * @class
  454. * @extends cc.TransitionMoveInL
  455. * @param {Number} t time in seconds
  456. * @param {cc.Scene} scene
  457. * @example
  458. * var trans = new cc.TransitionMoveInR(time,scene);
  459. */
  460. cc.TransitionMoveInR = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveInR# */{
  461. /**
  462. * Constructor of TransitionMoveInR
  463. * @param {Number} t time in seconds
  464. * @param {cc.Scene} scene
  465. */
  466. ctor:function (t, scene) {
  467. cc.TransitionMoveInL.prototype.ctor.call(this);
  468. scene && this.initWithDuration(t, scene);
  469. },
  470. /**
  471. * Init function
  472. */
  473. initScenes:function () {
  474. this._inScene.setPosition(cc.director.getWinSize().width, 0);
  475. }
  476. });
  477. /**
  478. * create a scene transition that Move in from to the right the incoming scene.
  479. * @deprecated since v3.0,please use new cc.TransitionMoveInR(t, scene) instead
  480. * @param {Number} t time in seconds
  481. * @param {cc.Scene} scene
  482. * @return {cc.TransitionMoveInR}
  483. * @example
  484. * var MoveInRight = cc.TransitionMoveInR.create(1, nextScene)
  485. */
  486. cc.TransitionMoveInR.create = function (t, scene) {
  487. return new cc.TransitionMoveInR(t, scene);
  488. };
  489. /**
  490. * Move in from to the top the incoming scene.
  491. * @class
  492. * @extends cc.TransitionMoveInL
  493. * @param {Number} t time in seconds
  494. * @param {cc.Scene} scene
  495. * @example
  496. * var trans = new cc.TransitionMoveInT(time,scene);
  497. */
  498. cc.TransitionMoveInT = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveInT# */{
  499. /**
  500. * Constructor of TransitionMoveInT
  501. * @param {Number} t time in seconds
  502. * @param {cc.Scene} scene
  503. */
  504. ctor:function (t, scene) {
  505. cc.TransitionMoveInL.prototype.ctor.call(this);
  506. scene && this.initWithDuration(t, scene);
  507. },
  508. /**
  509. * init function
  510. */
  511. initScenes:function () {
  512. this._inScene.setPosition(0, cc.director.getWinSize().height);
  513. }
  514. });
  515. /**
  516. * Move in from to the top the incoming scene.
  517. * @deprecated since v3.0,please use new cc.TransitionMoveInT(t, scene) instead
  518. * @param {Number} t time in seconds
  519. * @param {cc.Scene} scene
  520. * @return {cc.TransitionMoveInT}
  521. * @example
  522. * var MoveInTop = cc.TransitionMoveInT.create(1, nextScene)
  523. */
  524. cc.TransitionMoveInT.create = function (t, scene) {
  525. return new cc.TransitionMoveInT(t, scene);
  526. };
  527. /**
  528. * Move in from to the bottom the incoming scene.
  529. * @class
  530. * @extends cc.TransitionMoveInL
  531. * @param {Number} t time in seconds
  532. * @param {cc.Scene} scene
  533. * @example
  534. * var trans = new cc.TransitionMoveInB(time,scene);
  535. */
  536. cc.TransitionMoveInB = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveInB# */{
  537. /**
  538. * Constructor of TransitionMoveInB
  539. * @param {Number} t time in seconds
  540. * @param {cc.Scene} scene
  541. */
  542. ctor:function (t, scene) {
  543. cc.TransitionMoveInL.prototype.ctor.call(this);
  544. scene && this.initWithDuration(t, scene);
  545. },
  546. /**
  547. * init function
  548. */
  549. initScenes:function () {
  550. this._inScene.setPosition(0, -cc.director.getWinSize().height);
  551. }
  552. });
  553. /**
  554. * create a scene transition that Move in from to the bottom the incoming scene.
  555. * @deprecated since v3.0,please use new cc.TransitionMoveInB(t, scene) instead
  556. * @param {Number} t time in seconds
  557. * @param {cc.Scene} scene
  558. * @return {cc.TransitionMoveInB}
  559. * @example
  560. * var MoveinB = cc.TransitionMoveInB.create(1, nextScene)
  561. */
  562. cc.TransitionMoveInB.create = function (t, scene) {
  563. return new cc.TransitionMoveInB(t, scene);
  564. };
  565. /**
  566. * The adjust factor is needed to prevent issue #442<br/>
  567. * One solution is to use DONT_RENDER_IN_SUBPIXELS images, but NO<br/>
  568. * The other issue is that in some transitions (and I don't know why)<br/>
  569. * the order should be reversed (In in top of Out or vice-versa).
  570. * @constant
  571. * @type Number
  572. */
  573. cc.ADJUST_FACTOR = 0.5;
  574. /**
  575. * a transition that a new scene is slided from left
  576. * @class
  577. * @extends cc.TransitionScene
  578. * @param {Number} t time in seconds
  579. * @param {cc.Scene} scene
  580. * @example
  581. * var trans = cc.TransitionSlideInL(time,scene);
  582. */
  583. cc.TransitionSlideInL = cc.TransitionScene.extend(/** @lends cc.TransitionSlideInL# */{
  584. /**
  585. * Constructor of TransitionSlideInL
  586. * @param {Number} t time in seconds
  587. * @param {cc.Scene} scene
  588. */
  589. ctor:function (t, scene) {
  590. cc.TransitionScene.prototype.ctor.call(this);
  591. scene && this.initWithDuration(t, scene);
  592. },
  593. _sceneOrder:function () {
  594. this._isInSceneOnTop = false;
  595. },
  596. /**
  597. * custom on enter
  598. */
  599. onEnter:function () {
  600. cc.TransitionScene.prototype.onEnter.call(this);
  601. this.initScenes();
  602. var inA = this.action();
  603. var outA = this.action();
  604. var inAction = this.easeActionWithAction(inA);
  605. var outAction = cc.sequence(this.easeActionWithAction(outA), cc.callFunc(this.finish, this));
  606. this._inScene.runAction(inAction);
  607. this._outScene.runAction(outAction);
  608. },
  609. /**
  610. * initializes the scenes
  611. */
  612. initScenes:function () {
  613. this._inScene.setPosition(-cc.director.getWinSize().width + cc.ADJUST_FACTOR, 0);
  614. },
  615. /**
  616. * returns the action that will be performed by the incomming and outgoing scene
  617. * @return {cc.MoveBy}
  618. */
  619. action:function () {
  620. return cc.moveBy(this._duration, cc.p(cc.director.getWinSize().width - cc.ADJUST_FACTOR, 0));
  621. },
  622. /**
  623. * @param {cc.ActionInterval} action
  624. * @return {*}
  625. */
  626. easeActionWithAction:function (action) {
  627. return new cc.EaseInOut(action, 2.0);
  628. }
  629. });
  630. /**
  631. * create a transition that a new scene is slided from left
  632. * @deprecated since v3.0,please use new cc.TransitionSlideInL(t, scene) instead
  633. * @param {Number} t time in seconds
  634. * @param {cc.Scene} scene
  635. * @return {cc.TransitionSlideInL}
  636. * @example
  637. * var myTransition = cc.TransitionSlideInL.create(1.5, nextScene)
  638. */
  639. cc.TransitionSlideInL.create = function (t, scene) {
  640. return new cc.TransitionSlideInL(t, scene);
  641. };
  642. /**
  643. * Slide in the incoming scene from the right border.
  644. * @class
  645. * @extends cc.TransitionSlideInL
  646. * @param {Number} t time in seconds
  647. * @param {cc.Scene} scene
  648. * @example
  649. * var trans = new cc.TransitionSlideInR(time,scene);
  650. */
  651. cc.TransitionSlideInR = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSlideInR# */{
  652. /**
  653. * Constructor of TransitionSlideInR
  654. * @param {Number} t time in seconds
  655. * @param {cc.Scene} scene
  656. */
  657. ctor:function (t, scene) {
  658. cc.TransitionSlideInL.prototype.ctor.call(this);
  659. scene && this.initWithDuration(t, scene);
  660. },
  661. _sceneOrder:function () {
  662. this._isInSceneOnTop = true;
  663. },
  664. /**
  665. * initializes the scenes
  666. */
  667. initScenes:function () {
  668. this._inScene.setPosition(cc.director.getWinSize().width - cc.ADJUST_FACTOR, 0);
  669. },
  670. /**
  671. * returns the action that will be performed by the incomming and outgoing scene
  672. * @return {cc.MoveBy}
  673. */
  674. action:function () {
  675. return cc.moveBy(this._duration, cc.p(-(cc.director.getWinSize().width - cc.ADJUST_FACTOR), 0));
  676. }
  677. });
  678. /**
  679. * create Slide in the incoming scene from the right border.
  680. * @deprecated since v3.0,please use new cc.TransitionSlideInR(t, scene) instead
  681. * @param {Number} t time in seconds
  682. * @param {cc.Scene} scene
  683. * @return {cc.TransitionSlideInR}
  684. * @example
  685. * var myTransition = cc.TransitionSlideInR.create(1.5, nextScene)
  686. */
  687. cc.TransitionSlideInR.create = function (t, scene) {
  688. return new cc.TransitionSlideInR(t, scene);
  689. };
  690. /**
  691. * Slide in the incoming scene from the bottom border.
  692. * @class
  693. * @extends cc.TransitionSlideInL
  694. * @param {Number} t time in seconds
  695. * @param {cc.Scene} scene
  696. * @example
  697. * var trans = new cc.TransitionSlideInB(time,scene);
  698. */
  699. cc.TransitionSlideInB = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSlideInB# */{
  700. /**
  701. * Constructor of TransitionSlideInB
  702. * @param {Number} t time in seconds
  703. * @param {cc.Scene} scene
  704. */
  705. ctor:function (t, scene) {
  706. cc.TransitionSlideInL.prototype.ctor.call(this);
  707. scene && this.initWithDuration(t, scene);
  708. },
  709. _sceneOrder:function () {
  710. this._isInSceneOnTop = false;
  711. },
  712. /**
  713. * initializes the scenes
  714. */
  715. initScenes:function () {
  716. this._inScene.setPosition(0, -(cc.director.getWinSize().height - cc.ADJUST_FACTOR));
  717. },
  718. /**
  719. * returns the action that will be performed by the incomming and outgoing scene
  720. * @return {cc.MoveBy}
  721. */
  722. action:function () {
  723. return cc.moveBy(this._duration, cc.p(0, cc.director.getWinSize().height - cc.ADJUST_FACTOR));
  724. }
  725. });
  726. /**
  727. * create a Slide in the incoming scene from the bottom border.
  728. * @deprecated since v3.0,please use new cc.TransitionSlideInB(t, scene) instead.
  729. * @param {Number} t time in seconds
  730. * @param {cc.Scene} scene
  731. * @return {cc.TransitionSlideInB}
  732. * @example
  733. * var myTransition = cc.TransitionSlideInB.create(1.5, nextScene)
  734. */
  735. cc.TransitionSlideInB.create = function (t, scene) {
  736. return new cc.TransitionSlideInB(t, scene);
  737. };
  738. /**
  739. * Slide in the incoming scene from the top border.
  740. * @class
  741. * @extends cc.TransitionSlideInL
  742. * @param {Number} t time in seconds
  743. * @param {cc.Scene} scene
  744. * @example
  745. * var trans = new cc.TransitionSlideInT(time,scene);
  746. */
  747. cc.TransitionSlideInT = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSlideInT# */{
  748. /**
  749. * Constructor of TransitionSlideInT
  750. * @param {Number} t time in seconds
  751. * @param {cc.Scene} scene
  752. */
  753. ctor:function (t, scene) {
  754. cc.TransitionSlideInL.prototype.ctor.call(this);
  755. scene && this.initWithDuration(t, scene);
  756. },
  757. _sceneOrder:function () {
  758. this._isInSceneOnTop = true;
  759. },
  760. /**
  761. * initializes the scenes
  762. */
  763. initScenes:function () {
  764. this._inScene.setPosition(0, cc.director.getWinSize().height - cc.ADJUST_FACTOR);
  765. },
  766. /**
  767. * returns the action that will be performed by the incomming and outgoing scene
  768. * @return {cc.MoveBy}
  769. */
  770. action:function () {
  771. return cc.moveBy(this._duration, cc.p(0, -(cc.director.getWinSize().height - cc.ADJUST_FACTOR)));
  772. }
  773. });
  774. /**
  775. * create a Slide in the incoming scene from the top border.
  776. * @deprecated since v3.0,please use new cc.TransitionSlideInT(t, scene) instead.
  777. * @param {Number} t time in seconds
  778. * @param {cc.Scene} scene
  779. * @return {cc.TransitionSlideInT}
  780. * @example
  781. * var myTransition = cc.TransitionSlideInT.create(1.5, nextScene)
  782. */
  783. cc.TransitionSlideInT.create = function (t, scene) {
  784. return new cc.TransitionSlideInT(t, scene);
  785. };
  786. /**
  787. * Shrink the outgoing scene while grow the incoming scene
  788. * @class
  789. * @extends cc.TransitionScene
  790. * @param {Number} t time in seconds
  791. * @param {cc.Scene} scene
  792. * @example
  793. * var trans = new cc.TransitionShrinkGrow(time,scene);
  794. */
  795. cc.TransitionShrinkGrow = cc.TransitionScene.extend(/** @lends cc.TransitionShrinkGrow# */{
  796. /**
  797. * Constructor of TransitionShrinkGrow
  798. * @param {Number} t time in seconds
  799. * @param {cc.Scene} scene
  800. */
  801. ctor:function (t, scene) {
  802. cc.TransitionScene.prototype.ctor.call(this);
  803. scene && this.initWithDuration(t, scene);
  804. },
  805. /**
  806. * Custom on enter
  807. */
  808. onEnter:function () {
  809. cc.TransitionScene.prototype.onEnter.call(this);
  810. this._inScene.attr({
  811. scale: 0.001,
  812. anchorX: 2 / 3.0,
  813. anchorY: 0.5
  814. });
  815. this._outScene.attr({
  816. scale: 1.0,
  817. anchorX: 1 / 3.0,
  818. anchorY: 0.5
  819. });
  820. var scaleOut = cc.scaleTo(this._duration, 0.01);
  821. var scaleIn = cc.scaleTo(this._duration, 1.0);
  822. this._inScene.runAction(this.easeActionWithAction(scaleIn));
  823. this._outScene.runAction(
  824. cc.sequence(this.easeActionWithAction(scaleOut), cc.callFunc(this.finish, this))
  825. );
  826. },
  827. /**
  828. * @param action
  829. * @return {cc.EaseOut}
  830. */
  831. easeActionWithAction:function (action) {
  832. return new cc.EaseOut(action, 2.0);
  833. }
  834. });
  835. /**
  836. * Shrink the outgoing scene while grow the incoming scene
  837. * @deprecated since v3.0,please use new cc.TransitionShrinkGrow(t, scene) instead.
  838. * @param {Number} t time in seconds
  839. * @param {cc.Scene} scene
  840. * @return {cc.TransitionShrinkGrow}
  841. * @example
  842. * var myTransition = cc.TransitionShrinkGrow.create(1.5, nextScene)
  843. */
  844. cc.TransitionShrinkGrow.create = function (t, scene) {
  845. return new cc.TransitionShrinkGrow(t, scene);
  846. };
  847. /**
  848. * Flips the screen horizontally.<br/>
  849. * The front face is the outgoing scene and the back face is the incoming scene.
  850. * @class
  851. * @extends cc.TransitionSceneOriented
  852. * @param {Number} t time in seconds
  853. * @param {cc.Scene} scene
  854. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  855. * @example
  856. * var trans = new cc.TransitionFlipX(t,scene,o);
  857. */
  858. cc.TransitionFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionFlipX# */{
  859. /**
  860. * Constructor of TransitionFlipX
  861. * @function
  862. * @param {Number} t time in seconds
  863. * @param {cc.Scene} scene
  864. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  865. */
  866. ctor:function (t, scene, o) {
  867. cc.TransitionSceneOriented.prototype.ctor.call(this);
  868. o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER;
  869. scene && this.initWithDuration(t, scene, o);
  870. },
  871. /**
  872. * custom on enter
  873. */
  874. onEnter:function () {
  875. cc.TransitionScene.prototype.onEnter.call(this);
  876. var inA, outA;
  877. this._inScene.visible = false;
  878. var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ;
  879. if (this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER) {
  880. inDeltaZ = 90;
  881. inAngleZ = 270;
  882. outDeltaZ = 90;
  883. outAngleZ = 0;
  884. } else {
  885. inDeltaZ = -90;
  886. inAngleZ = 90;
  887. outDeltaZ = -90;
  888. outAngleZ = 0;
  889. }
  890. inA = cc.sequence(
  891. cc.delayTime(this._duration / 2), cc.show(),
  892. cc.orbitCamera(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 0, 0),
  893. cc.callFunc(this.finish, this)
  894. );
  895. outA = cc.sequence(
  896. cc.orbitCamera(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 0, 0),
  897. cc.hide(), cc.delayTime(this._duration / 2)
  898. );
  899. this._inScene.runAction(inA);
  900. this._outScene.runAction(outA);
  901. }
  902. });
  903. /**
  904. * Flips the screen horizontally.<br/>
  905. * The front face is the outgoing scene and the back face is the incoming scene.
  906. * @deprecated since v3.0,please use new cc.TransitionFlipX(t, scene,o) instead.
  907. * @param {Number} t time in seconds
  908. * @param {cc.Scene} scene
  909. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  910. * @return {cc.TransitionFlipX}
  911. * @example
  912. * var myTransition = cc.TransitionFlipX.create(1.5, nextScene) //default is cc.TRANSITION_ORIENTATION_RIGHT_OVER
  913. * //OR
  914. * var myTransition = cc.TransitionFlipX.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_UP_OVER)
  915. */
  916. cc.TransitionFlipX.create = function (t, scene, o) {
  917. return new cc.TransitionFlipX(t, scene, o);
  918. };
  919. /**
  920. * Flips the screen vertically.<br/>
  921. * The front face is the outgoing scene and the back face is the incoming scene.
  922. * @class
  923. * @extends cc.TransitionSceneOriented
  924. * @param {Number} t time in seconds
  925. * @param {cc.Scene} scene
  926. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  927. * @example
  928. * var trans = new cc.TransitionFlipY(time,scene,0);
  929. */
  930. cc.TransitionFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionFlipY# */{
  931. /**
  932. * Constructor of TransitionFlipY
  933. * @param {Number} t time in seconds
  934. * @param {cc.Scene} scene
  935. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  936. */
  937. ctor:function (t, scene, o) {
  938. cc.TransitionSceneOriented.prototype.ctor.call(this);
  939. o = o || cc.TRANSITION_ORIENTATION_UP_OVER;
  940. scene && this.initWithDuration(t, scene, o);
  941. },
  942. /**
  943. * custom on enter
  944. */
  945. onEnter:function () {
  946. cc.TransitionScene.prototype.onEnter.call(this);
  947. var inA, outA;
  948. this._inScene.visible = false;
  949. var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ;
  950. if (this._orientation == cc.TRANSITION_ORIENTATION_UP_OVER) {
  951. inDeltaZ = 90;
  952. inAngleZ = 270;
  953. outDeltaZ = 90;
  954. outAngleZ = 0;
  955. } else {
  956. inDeltaZ = -90;
  957. inAngleZ = 90;
  958. outDeltaZ = -90;
  959. outAngleZ = 0;
  960. }
  961. inA = cc.Sequence.create(
  962. cc.DelayTime.create(this._duration / 2), cc.Show.create(),
  963. cc.OrbitCamera.create(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 90, 0),
  964. cc.CallFunc.create(this.finish, this)
  965. );
  966. outA = cc.Sequence.create(
  967. cc.OrbitCamera.create(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 90, 0),
  968. cc.Hide.create(), cc.DelayTime.create(this._duration / 2)
  969. );
  970. this._inScene.runAction(inA);
  971. this._outScene.runAction(outA);
  972. }
  973. });
  974. /**
  975. * Flips the screen vertically.<br/>
  976. * The front face is the outgoing scene and the back face is the incoming scene.
  977. * @deprecated since v3.0,please use new cc.TransitionFlipY(t, scene,o) instead.
  978. * @param {Number} t time in seconds
  979. * @param {cc.Scene} scene
  980. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  981. * @return {cc.TransitionFlipY}
  982. * @example
  983. * var myTransition = cc.TransitionFlipY.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_UP_OVER
  984. * //OR
  985. * var myTransition = cc.TransitionFlipY.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_RIGHT_OVER)
  986. */
  987. cc.TransitionFlipY.create = function (t, scene, o) {
  988. return new cc.TransitionFlipY(t, scene, o);
  989. };
  990. /**
  991. * Flips the screen half horizontally and half vertically.<br/>
  992. * The front face is the outgoing scene and the back face is the incoming scene.
  993. * @class
  994. * @extends cc.TransitionSceneOriented
  995. * @param {Number} t time in seconds
  996. * @param {cc.Scene} scene
  997. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  998. * @example
  999. * var trans = cc.TransitionFlipAngular(time,scene,o);
  1000. */
  1001. cc.TransitionFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionFlipAngular# */{
  1002. /**
  1003. * Constructor of TransitionFlipAngular
  1004. * @param {Number} t time in seconds
  1005. * @param {cc.Scene} scene
  1006. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  1007. */
  1008. ctor:function (t, scene, o) {
  1009. cc.TransitionSceneOriented.prototype.ctor.call(this);
  1010. o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER;
  1011. scene && this.initWithDuration(t, scene, o);
  1012. },
  1013. /**
  1014. * custom on enter
  1015. */
  1016. onEnter:function () {
  1017. cc.TransitionScene.prototype.onEnter.call(this);
  1018. var inA, outA;
  1019. this._inScene.visible = false;
  1020. var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ;
  1021. if (this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER) {
  1022. inDeltaZ = 90;
  1023. inAngleZ = 270;
  1024. outDeltaZ = 90;
  1025. outAngleZ = 0;
  1026. } else {
  1027. inDeltaZ = -90;
  1028. inAngleZ = 90;
  1029. outDeltaZ = -90;
  1030. outAngleZ = 0;
  1031. }
  1032. inA = cc.sequence(
  1033. cc.delayTime(this._duration / 2), cc.show(),
  1034. cc.orbitCamera(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, -45, 0),
  1035. cc.callFunc(this.finish, this)
  1036. );
  1037. outA = cc.sequence(
  1038. cc.orbitCamera(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 45, 0),
  1039. cc.hide(), cc.delayTime(this._duration / 2)
  1040. );
  1041. this._inScene.runAction(inA);
  1042. this._outScene.runAction(outA);
  1043. }
  1044. });
  1045. /**
  1046. * Flips the screen half horizontally and half vertically.<br/>
  1047. * The front face is the outgoing scene and the back face is the incoming scene.
  1048. * @deprecated since v3.0,please use new new cc.TransitionFlipAngular(t, scene, o) instead
  1049. * @param {Number} t time in seconds
  1050. * @param {cc.Scene} scene
  1051. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  1052. * @return {cc.TransitionFlipAngular}
  1053. * @example
  1054. * var myTransition = cc.TransitionFlipAngular.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_RIGHT_OVER
  1055. * //or
  1056. * var myTransition = cc.TransitionFlipAngular.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER)
  1057. */
  1058. cc.TransitionFlipAngular.create = function (t, scene, o) {
  1059. return new cc.TransitionFlipAngular(t, scene, o);
  1060. };
  1061. /**
  1062. * Flips the screen horizontally doing a zoom out/in<br/>
  1063. * The front face is the outgoing scene and the back face is the incoming scene.
  1064. * @class
  1065. * @extends cc.TransitionSceneOriented
  1066. * @param {Number} t time in seconds
  1067. * @param {cc.Scene} scene
  1068. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  1069. * @example
  1070. * var trans = new cc.TransitionZoomFlipX(time,scene,o);
  1071. */
  1072. cc.TransitionZoomFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionZoomFlipX# */{
  1073. /**
  1074. * Constructor of TransitionZoomFlipX
  1075. * @param {Number} t time in seconds
  1076. * @param {cc.Scene} scene
  1077. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  1078. */
  1079. ctor:function (t, scene, o) {
  1080. cc.TransitionSceneOriented.prototype.ctor.call(this);
  1081. o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER;
  1082. scene && this.initWithDuration(t, scene, o);
  1083. },
  1084. /**
  1085. * custom on enter
  1086. */
  1087. onEnter:function () {
  1088. cc.TransitionScene.prototype.onEnter.call(this);
  1089. var inA, outA;
  1090. this._inScene.visible = false;
  1091. var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ;
  1092. if (this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER) {
  1093. inDeltaZ = 90;
  1094. inAngleZ = 270;
  1095. outDeltaZ = 90;
  1096. outAngleZ = 0;
  1097. } else {
  1098. inDeltaZ = -90;
  1099. inAngleZ = 90;
  1100. outDeltaZ = -90;
  1101. outAngleZ = 0;
  1102. }
  1103. inA = cc.sequence(
  1104. cc.delayTime(this._duration / 2),
  1105. cc.spawn(
  1106. cc.orbitCamera(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 0, 0),
  1107. cc.scaleTo(this._duration / 2, 1), cc.show()),
  1108. cc.callFunc(this.finish, this)
  1109. );
  1110. outA = cc.sequence(
  1111. cc.spawn(
  1112. cc.orbitCamera(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 0, 0),
  1113. cc.scaleTo(this._duration / 2, 0.5)),
  1114. cc.hide(),
  1115. cc.delayTime(this._duration / 2)
  1116. );
  1117. this._inScene.scale = 0.5;
  1118. this._inScene.runAction(inA);
  1119. this._outScene.runAction(outA);
  1120. }
  1121. });
  1122. /**
  1123. * Flips the screen horizontally doing a zoom out/in<br/>
  1124. * The front face is the outgoing scene and the back face is the incoming scene.
  1125. * @deprecated since v3.0,please use new new cc.TransitionZoomFlipX(t, scene, o) instead
  1126. * @param {Number} t time in seconds
  1127. * @param {cc.Scene} scene
  1128. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  1129. * @return {cc.TransitionZoomFlipX}
  1130. * @example
  1131. * var myTransition = cc.TransitionZoomFlipX.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_RIGHT_OVER
  1132. * //OR
  1133. * var myTransition = cc.TransitionZoomFlipX.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER)
  1134. */
  1135. cc.TransitionZoomFlipX.create = function (t, scene, o) {
  1136. return new cc.TransitionZoomFlipX(t, scene, o);
  1137. };
  1138. /**
  1139. * Flips the screen vertically doing a little zooming out/in<br/>
  1140. * The front face is the outgoing scene and the back face is the incoming scene.
  1141. * @class
  1142. * @extends cc.TransitionSceneOriented
  1143. * @param {Number} t time in seconds
  1144. * @param {cc.Scene} scene
  1145. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  1146. * @example
  1147. * var trans = new cc.TransitionZoomFlipY(t,scene,o);
  1148. */
  1149. cc.TransitionZoomFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionZoomFlipY# */{
  1150. /**
  1151. * Constructor of TransitionZoomFlipY
  1152. * @param {Number} t time in seconds
  1153. * @param {cc.Scene} scene
  1154. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  1155. */
  1156. ctor:function (t, scene, o) {
  1157. cc.TransitionSceneOriented.prototype.ctor.call(this);
  1158. o = o || cc.TRANSITION_ORIENTATION_UP_OVER;
  1159. scene && this.initWithDuration(t, scene, o);
  1160. },
  1161. /**
  1162. * custom on enter
  1163. */
  1164. onEnter:function () {
  1165. cc.TransitionScene.prototype.onEnter.call(this);
  1166. var inA, outA;
  1167. this._inScene.visible = false;
  1168. var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ;
  1169. if (this._orientation === cc.TRANSITION_ORIENTATION_UP_OVER) {
  1170. inDeltaZ = 90;
  1171. inAngleZ = 270;
  1172. outDeltaZ = 90;
  1173. outAngleZ = 0;
  1174. } else {
  1175. inDeltaZ = -90;
  1176. inAngleZ = 90;
  1177. outDeltaZ = -90;
  1178. outAngleZ = 0;
  1179. }
  1180. inA = cc.sequence(
  1181. cc.delayTime(this._duration / 2),
  1182. cc.spawn(
  1183. cc.orbitCamera(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 90, 0),
  1184. cc.scaleTo(this._duration / 2, 1), cc.show()),
  1185. cc.callFunc(this.finish, this));
  1186. outA = cc.sequence(
  1187. cc.spawn(
  1188. cc.orbitCamera(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 90, 0),
  1189. cc.scaleTo(this._duration / 2, 0.5)),
  1190. cc.hide(), cc.delayTime(this._duration / 2));
  1191. this._inScene.scale = 0.5;
  1192. this._inScene.runAction(inA);
  1193. this._outScene.runAction(outA);
  1194. }
  1195. });
  1196. /**
  1197. * Flips the screen vertically doing a little zooming out/in<br/>
  1198. * The front face is the outgoing scene and the back face is the incoming scene.
  1199. * @deprecated since v3.0,please use new new cc.TransitionZoomFlipY(t, scene, o) instead
  1200. * @param {Number} t time in seconds
  1201. * @param {cc.Scene} scene
  1202. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  1203. * @return {cc.TransitionZoomFlipY}
  1204. * @example
  1205. * var myTransition = cc.TransitionZoomFlipY.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_UP_OVER
  1206. * //OR
  1207. * var myTransition = cc.TransitionZoomFlipY.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER)
  1208. */
  1209. cc.TransitionZoomFlipY.create = function (t, scene, o) {
  1210. return new cc.TransitionZoomFlipY(t, scene, o);
  1211. };
  1212. /**
  1213. * Flips the screen half horizontally and half vertically doing a little zooming out/in.<br/>
  1214. * The front face is the outgoing scene and the back face is the incoming scene.
  1215. * @class
  1216. * @extends cc.TransitionSceneOriented
  1217. * @param {Number} t time in seconds
  1218. * @param {cc.Scene} scene
  1219. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  1220. * @example
  1221. * var trans = new cc.TransitionZoomFlipAngular(time,scene,o);
  1222. */
  1223. cc.TransitionZoomFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionZoomFlipAngular# */{
  1224. /**
  1225. * Constructor of TransitionZoomFlipAngular
  1226. * @param {Number} t time in seconds
  1227. * @param {cc.Scene} scene
  1228. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  1229. */
  1230. ctor:function (t, scene, o) {
  1231. cc.TransitionSceneOriented.prototype.ctor.call(this);
  1232. o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER;
  1233. scene && this.initWithDuration(t, scene, o);
  1234. },
  1235. /**
  1236. * custom on enter
  1237. */
  1238. onEnter:function () {
  1239. cc.TransitionScene.prototype.onEnter.call(this);
  1240. var inA, outA;
  1241. this._inScene.visible = false;
  1242. var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ;
  1243. if (this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER) {
  1244. inDeltaZ = 90;
  1245. inAngleZ = 270;
  1246. outDeltaZ = 90;
  1247. outAngleZ = 0;
  1248. } else {
  1249. inDeltaZ = -90;
  1250. inAngleZ = 90;
  1251. outDeltaZ = -90;
  1252. outAngleZ = 0;
  1253. }
  1254. inA = cc.sequence(
  1255. cc.delayTime(this._duration / 2),
  1256. cc.spawn(
  1257. cc.orbitCamera(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, -45, 0),
  1258. cc.scaleTo(this._duration / 2, 1), cc.show()),
  1259. cc.show(),
  1260. cc.callFunc(this.finish, this));
  1261. outA = cc.sequence(
  1262. cc.spawn(
  1263. cc.orbitCamera(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 45, 0),
  1264. cc.scaleTo(this._duration / 2, 0.5)),
  1265. cc.hide(), cc.delayTime(this._duration / 2));
  1266. this._inScene.scale = 0.5;
  1267. this._inScene.runAction(inA);
  1268. this._outScene.runAction(outA);
  1269. }
  1270. });
  1271. /**
  1272. * Flips the screen half horizontally and half vertically doing a little zooming out/in.<br/>
  1273. * The front face is the outgoing scene and the back face is the incoming scene.
  1274. * @deprecated since v3.0,please use new new cc.TransitionZoomFlipAngular(t, scene, o) instead
  1275. * @param {Number} t time in seconds
  1276. * @param {cc.Scene} scene
  1277. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  1278. * @return {cc.TransitionZoomFlipAngular}
  1279. * @example
  1280. * var myTransition = cc.TransitionZoomFlipAngular.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_RIGHT_OVER
  1281. * //OR
  1282. * var myTransition = cc.TransitionZoomFlipAngular.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER)
  1283. */
  1284. cc.TransitionZoomFlipAngular.create = function (t, scene, o) {
  1285. return new cc.TransitionZoomFlipAngular(t, scene, o);
  1286. };
  1287. /**
  1288. * Fade out the outgoing scene and then fade in the incoming scene.
  1289. * @class
  1290. * @extends cc.TransitionScene
  1291. * @param {Number} t time in seconds
  1292. * @param {cc.Scene} scene
  1293. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  1294. * @example
  1295. * var trans = new cc.TransitionFade(time,scene,color)
  1296. */
  1297. cc.TransitionFade = cc.TransitionScene.extend(/** @lends cc.TransitionFade# */{
  1298. _color:null,
  1299. /**
  1300. * Constructor of TransitionFade
  1301. * @param {Number} t time in seconds
  1302. * @param {cc.Scene} scene
  1303. * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
  1304. */
  1305. ctor:function (t, scene, color) {
  1306. cc.TransitionScene.prototype.ctor.call(this);
  1307. this._color = cc.color();
  1308. scene && this.initWithDuration(t, scene, color);
  1309. },
  1310. /**
  1311. * custom on enter
  1312. */
  1313. onEnter:function () {
  1314. cc.TransitionScene.prototype.onEnter.call(this);
  1315. var l = new cc.LayerColor(this._color);
  1316. this._inScene.visible = false;
  1317. this.addChild(l, 2, cc.SCENE_FADE);
  1318. var f = this.getChildByTag(cc.SCENE_FADE);
  1319. var a = cc.sequence(
  1320. cc.fadeIn(this._duration / 2),
  1321. cc.callFunc(this.hideOutShowIn, this),
  1322. cc.fadeOut(this._duration / 2),
  1323. cc.callFunc(this.finish, this)
  1324. );
  1325. f.runAction(a);
  1326. },
  1327. /**
  1328. * custom on exit
  1329. */
  1330. onExit:function () {
  1331. cc.TransitionScene.prototype.onExit.call(this);
  1332. this.removeChildByTag(cc.SCENE_FADE, false);
  1333. },
  1334. /**
  1335. * initializes the transition with a duration and with an RGB color
  1336. * @param {Number} t time in seconds
  1337. * @param {cc.Scene} scene
  1338. * @param {cc.Color} color
  1339. * @return {Boolean}
  1340. */
  1341. initWithDuration:function (t, scene, color) {
  1342. color = color || cc.color.BLACK;
  1343. if (cc.TransitionScene.prototype.initWithDuration.call(this, t, scene)) {
  1344. this._color.r = color.r;
  1345. this._color.g = color.g;
  1346. this._color.b = color.b;
  1347. this._color.a = 0;
  1348. }
  1349. return true;
  1350. }
  1351. });
  1352. /**
  1353. * Fade out the outgoing scene and then fade in the incoming scene.
  1354. * @deprecated since v3.0,please use new cc.TransitionFade(time,scene,color) instead.
  1355. * @param {Number} t time in seconds
  1356. * @param {cc.Scene} scene
  1357. * @param {cc.Color} color
  1358. * @return {cc.TransitionFade}
  1359. * @example
  1360. * var myTransition = cc.TransitionFade.create(1.5, nextScene, cc.color(255,0,0))//fade to red
  1361. */
  1362. cc.TransitionFade.create = function (t, scene, color) {
  1363. return new cc.TransitionFade(t, scene, color);
  1364. };
  1365. /**
  1366. * Cross fades two scenes using the cc.RenderTexture object.
  1367. * @class
  1368. * @extends cc.TransitionScene
  1369. * @param {Number} t time in seconds
  1370. * @param {cc.Scene} scene
  1371. * @example
  1372. * var trans = new cc.TransitionCrossFade(time,scene);
  1373. */
  1374. cc.TransitionCrossFade = cc.TransitionScene.extend(/** @lends cc.TransitionCrossFade# */{
  1375. /**
  1376. * Constructor of TransitionCrossFade
  1377. * @param {Number} t time in seconds
  1378. * @param {cc.Scene} scene
  1379. */
  1380. ctor:function (t, scene) {
  1381. cc.TransitionScene.prototype.ctor.call(this);
  1382. scene && this.initWithDuration(t, scene);
  1383. },
  1384. /**
  1385. * custom on enter
  1386. */
  1387. onEnter:function () {
  1388. cc.TransitionScene.prototype.onEnter.call(this);
  1389. // create a transparent color layer
  1390. // in which we are going to add our rendertextures
  1391. var color = cc.color(0, 0, 0, 0);
  1392. var winSize = cc.director.getWinSize();
  1393. var layer = cc.LayerColor.create(color);
  1394. // create the first render texture for inScene
  1395. var inTexture = cc.RenderTexture.create(winSize.width, winSize.height);
  1396. if (null == inTexture)
  1397. return;
  1398. inTexture.sprite.anchorX = 0.5;
  1399. inTexture.sprite.anchorY = 0.5;
  1400. inTexture.attr({
  1401. x: winSize.width / 2,
  1402. y: winSize.height / 2,
  1403. anchorX: 0.5,
  1404. anchorY: 0.5
  1405. });
  1406. // render inScene to its texturebuffer
  1407. inTexture.begin();
  1408. this._inScene.visit();
  1409. inTexture.end();
  1410. // create the second render texture for outScene
  1411. var outTexture = cc.RenderTexture.create(winSize.width, winSize.height);
  1412. outTexture.setPosition(winSize.width / 2, winSize.height / 2);
  1413. outTexture.sprite.anchorX = outTexture.anchorX = 0.5;
  1414. outTexture.sprite.anchorY = outTexture.anchorY = 0.5;
  1415. // render outScene to its texturebuffer
  1416. outTexture.begin();
  1417. this._outScene.visit();
  1418. outTexture.end();
  1419. inTexture.sprite.setBlendFunc(cc.ONE, cc.ONE); // inScene will lay on background and will not be used with alpha
  1420. outTexture.sprite.setBlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA); // we are going to blend outScene via alpha
  1421. // add render textures to the layer
  1422. layer.addChild(inTexture);
  1423. layer.addChild(outTexture);
  1424. // initial opacity:
  1425. inTexture.sprite.opacity = 255;
  1426. outTexture.sprite.opacity = 255;
  1427. // create the blend action
  1428. var layerAction = cc.sequence(
  1429. cc.fadeTo(this._duration, 0), cc.callFunc(this.hideOutShowIn, this),
  1430. cc.callFunc(this.finish, this)
  1431. );
  1432. // run the blend action
  1433. outTexture.sprite.runAction(layerAction);
  1434. // add the layer (which contains our two rendertextures) to the scene
  1435. this.addChild(layer, 2, cc.SCENE_FADE);
  1436. },
  1437. /**
  1438. * custom on exit
  1439. */
  1440. onExit:function () {
  1441. this.removeChildByTag(cc.SCENE_FADE, false);
  1442. cc.TransitionScene.prototype.onExit.call(this);
  1443. },
  1444. /**
  1445. * overide draw
  1446. */
  1447. draw:function () {
  1448. // override draw since both scenes (textures) are rendered in 1 scene
  1449. }
  1450. });
  1451. /**
  1452. * Cross fades two scenes using the cc.RenderTexture object.
  1453. * @deprecated since v3.0,please use new cc.TransitionCrossFade(t, scene) instead.
  1454. * @param {Number} t time in seconds
  1455. * @param {cc.Scene} scene
  1456. * @return {cc.TransitionCrossFade}
  1457. * @example
  1458. * var myTransition = cc.TransitionCrossFade.create(1.5, nextScene)
  1459. */
  1460. cc.TransitionCrossFade.create = function (t, scene) {
  1461. return new cc.TransitionCrossFade(t, scene);
  1462. };
  1463. /**
  1464. * Turn off the tiles of the outgoing scene in random order
  1465. * @class
  1466. * @extends cc.TransitionScene
  1467. * @param {Number} t time in seconds
  1468. * @param {cc.Scene} scene
  1469. * @example
  1470. * var trans = new cc.TransitionTurnOffTiles(time,scene);
  1471. */
  1472. cc.TransitionTurnOffTiles = cc.TransitionScene.extend(/** @lends cc.TransitionTurnOffTiles# */{
  1473. /**
  1474. * Constructor of TransitionCrossFade
  1475. * @param {Number} t time in seconds
  1476. * @param {cc.Scene} scene
  1477. */
  1478. ctor:function (t, scene) {
  1479. cc.TransitionScene.prototype.ctor.call(this);
  1480. scene && this.initWithDuration(t, scene);
  1481. },
  1482. _sceneOrder:function () {
  1483. this._isInSceneOnTop = false;
  1484. },
  1485. /**
  1486. * custom on enter
  1487. */
  1488. onEnter:function () {
  1489. cc.TransitionScene.prototype.onEnter.call(this);
  1490. var winSize = cc.director.getWinSize();
  1491. var aspect = winSize.width / winSize.height;
  1492. var x = 0 | (12 * aspect);
  1493. var y = 12;
  1494. var toff = cc.turnOffTiles(this._duration, cc.size(x, y));
  1495. var action = this.easeActionWithAction(toff);
  1496. this._outScene.runAction(cc.sequence(action, cc.callFunc(this.finish, this), cc.stopGrid()));
  1497. },
  1498. /**
  1499. * @param {cc.ActionInterval} action
  1500. * @return {cc.ActionInterval}
  1501. */
  1502. easeActionWithAction:function (action) {
  1503. return action;
  1504. }
  1505. });
  1506. /**
  1507. * Turn off the tiles of the outgoing scene in random order
  1508. * @deprecated since v3.0,please use new cc.TransitionTurnOffTiles(t, scene) instead.
  1509. * @param {Number} t time in seconds
  1510. * @param {cc.Scene} scene
  1511. * @return {cc.TransitionTurnOffTiles}
  1512. * @example
  1513. * var myTransition = cc.TransitionTurnOffTiles.create(1.5, nextScene)
  1514. */
  1515. cc.TransitionTurnOffTiles.create = function (t, scene) {
  1516. return new cc.TransitionTurnOffTiles(t, scene);
  1517. };
  1518. /**
  1519. * The odd columns goes upwards while the even columns goes downwards.
  1520. * @class
  1521. * @extends cc.TransitionScene
  1522. * @param {Number} t time in seconds
  1523. * @param {cc.Scene} scene
  1524. * @example
  1525. * var trans = new cc.TransitionSplitCols(time,scene);
  1526. */
  1527. cc.TransitionSplitCols = cc.TransitionScene.extend(/** @lends cc.TransitionSplitCols# */{
  1528. /**
  1529. * Constructor of TransitionSplitCols
  1530. * @param {Number} t time in seconds
  1531. * @param {cc.Scene} scene
  1532. */
  1533. ctor:function (t, scene) {
  1534. cc.TransitionScene.prototype.ctor.call(this);
  1535. scene && this.initWithDuration(t, scene);
  1536. },
  1537. /**
  1538. * custom on enter
  1539. */
  1540. onEnter:function () {
  1541. cc.TransitionScene.prototype.onEnter.call(this);
  1542. this._inScene.visible = false;
  1543. var split = this.action();
  1544. var seq = cc.sequence(
  1545. split, cc.callFunc(this.hideOutShowIn, this), split.reverse());
  1546. this.runAction(
  1547. cc.sequence(this.easeActionWithAction(seq), cc.callFunc(this.finish, this), cc.stopGrid())
  1548. );
  1549. },
  1550. /**
  1551. * @param {cc.ActionInterval} action
  1552. * @return {cc.EaseInOut}
  1553. */
  1554. easeActionWithAction:function (action) {
  1555. return new cc.EaseInOut(action, 3.0);
  1556. },
  1557. /**
  1558. * @return {*}
  1559. */
  1560. action:function () {
  1561. return cc.splitCols(this._duration / 2.0, 3);
  1562. }
  1563. });
  1564. /**
  1565. * The odd columns goes upwards while the even columns goes downwards.
  1566. * @deprecated since v3.0,please use new cc.TransitionSplitCols(t, scene) instead.
  1567. * @param {Number} t time in seconds
  1568. * @param {cc.Scene} scene
  1569. * @return {cc.TransitionSplitCols}
  1570. * @example
  1571. * var myTransition = cc.TransitionSplitCols.create(1.5, nextScene)
  1572. */
  1573. cc.TransitionSplitCols.create = function (t, scene) {
  1574. return new cc.TransitionSplitCols(t, scene);
  1575. };
  1576. /**
  1577. * The odd rows goes to the left while the even rows goes to the right.
  1578. * @class
  1579. * @extends cc.TransitionSplitCols
  1580. * @param {Number} t time in seconds
  1581. * @param {cc.Scene} scene
  1582. * @example
  1583. * var trans = new cc.TransitionSplitRows(time,scene);
  1584. */
  1585. cc.TransitionSplitRows = cc.TransitionSplitCols.extend(/** @lends cc.TransitionSplitRows# */{
  1586. /**
  1587. * Constructor of TransitionSplitRows
  1588. * @param {Number} t time in seconds
  1589. * @param {cc.Scene} scene
  1590. */
  1591. ctor:function (t, scene) {
  1592. cc.TransitionSplitCols.prototype.ctor.call(this);
  1593. scene && this.initWithDuration(t, scene);
  1594. },
  1595. /**
  1596. * @return {*}
  1597. */
  1598. action:function () {
  1599. return cc.splitRows(this._duration / 2.0, 3);
  1600. }
  1601. });
  1602. /**
  1603. * The odd rows goes to the left while the even rows goes to the right.
  1604. * @deprecated since v3.0,please use new cc.TransitionSplitRows(t, scene) instead.
  1605. * @param {Number} t time in seconds
  1606. * @param {cc.Scene} scene
  1607. * @return {cc.TransitionSplitRows}
  1608. * @example
  1609. * var myTransition = cc.TransitionSplitRows.create(1.5, nextScene)
  1610. */
  1611. cc.TransitionSplitRows.create = function (t, scene) {
  1612. return new cc.TransitionSplitRows(t, scene);
  1613. };
  1614. /**
  1615. * Fade the tiles of the outgoing scene from the left-bottom corner the to top-right corner.
  1616. * @class
  1617. * @extends cc.TransitionScene
  1618. * @param {Number} t time in seconds
  1619. * @param {cc.Scene} scene
  1620. * @example
  1621. * var trans = new cc.TransitionFadeTR(time,scene);
  1622. */
  1623. cc.TransitionFadeTR = cc.TransitionScene.extend(/** @lends cc.TransitionFadeTR# */{
  1624. /**
  1625. * Constructor of TransitionFadeTR
  1626. * @param {Number} t time in seconds
  1627. * @param {cc.Scene} scene
  1628. */
  1629. ctor:function (t, scene) {
  1630. cc.TransitionScene.prototype.ctor.call(this);
  1631. scene && this.initWithDuration(t, scene);
  1632. },
  1633. _sceneOrder:function () {
  1634. this._isInSceneOnTop = false;
  1635. },
  1636. /**
  1637. * Custom on enter
  1638. */
  1639. onEnter:function () {
  1640. cc.TransitionScene.prototype.onEnter.call(this);
  1641. var winSize = cc.director.getWinSize();
  1642. var aspect = winSize.width / winSize.height;
  1643. var x = 0 | (12 * aspect);
  1644. var y = 12;
  1645. var action = this.actionWithSize(cc.size(x, y));
  1646. this._outScene.runAction(
  1647. cc.Sequence.create(this.easeActionWithAction(action), cc.CallFunc.create(this.finish, this),
  1648. cc.StopGrid.create())
  1649. );
  1650. },
  1651. /**
  1652. * @param {cc.ActionInterval} action
  1653. * @return {cc.ActionInterval}
  1654. */
  1655. easeActionWithAction:function (action) {
  1656. return action;
  1657. },
  1658. /**
  1659. * @param {cc.Size} size
  1660. * @return {*}
  1661. */
  1662. actionWithSize:function (size) {
  1663. return cc.fadeOutTRTiles(this._duration, size);
  1664. }
  1665. });
  1666. /**
  1667. * Fade the tiles of the outgoing scene from the left-bottom corner the to top-right corner.
  1668. * @deprecated since v3.0 please use new cc.TransitionFadeTR(t, scene) instead.
  1669. * @param {Number} t time in seconds
  1670. * @param {cc.Scene} scene
  1671. * @return {cc.TransitionFadeTR}
  1672. * @example
  1673. * var myTransition = cc.TransitionFadeTR.create(1.5, nextScene)
  1674. */
  1675. cc.TransitionFadeTR.create = function (t, scene) {
  1676. return new cc.TransitionFadeTR(t, scene);
  1677. };
  1678. /**
  1679. * Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner.
  1680. * @class
  1681. * @extends cc.TransitionFadeTR
  1682. * @param {Number} t time in seconds
  1683. * @param {cc.Scene} scene
  1684. * @example
  1685. * var trans = new cc.TransitionFadeBL(time,scene)
  1686. */
  1687. cc.TransitionFadeBL = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeBL# */{
  1688. /**
  1689. * Constructor of TransitionFadeBL
  1690. * @param {Number} t time in seconds
  1691. * @param {cc.Scene} scene
  1692. */
  1693. ctor:function (t, scene) {
  1694. cc.TransitionFadeTR.prototype.ctor.call(this);
  1695. scene && this.initWithDuration(t, scene);
  1696. },
  1697. /**
  1698. * @param {cc.Size} size
  1699. * @return {*}
  1700. */
  1701. actionWithSize:function (size) {
  1702. return cc.fadeOutBLTiles(this._duration, size);
  1703. }
  1704. });
  1705. /**
  1706. * Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner.
  1707. * @deprecated since v3.0,please use new cc.TransitionFadeBL(t, scene);
  1708. * @param {Number} t time in seconds
  1709. * @param {cc.Scene} scene
  1710. * @return {cc.TransitionFadeBL}
  1711. * @example
  1712. * // Example
  1713. * var myTransition = cc.TransitionFadeBL.create(1.5, nextScene)
  1714. */
  1715. cc.TransitionFadeBL.create = function (t, scene) {
  1716. return new cc.TransitionFadeBL(t, scene);
  1717. };
  1718. /**
  1719. * Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner.
  1720. * @class
  1721. * @extends cc.TransitionFadeTR
  1722. * @param {Number} t time in seconds
  1723. * @param {cc.Scene} scene
  1724. * @example
  1725. * var trans = new cc.TransitionFadeUp(time,scene);
  1726. */
  1727. cc.TransitionFadeUp = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeUp# */{
  1728. /**
  1729. * Constructor of TransitionFadeUp
  1730. * @function
  1731. * @param {Number} t time in seconds
  1732. * @param {cc.Scene} scene
  1733. */
  1734. ctor:function (t, scene) {
  1735. cc.TransitionFadeTR.prototype.ctor.call(this);
  1736. scene && this.initWithDuration(t, scene);
  1737. },
  1738. /**
  1739. * @param {cc.Size} size
  1740. * @return {cc.FadeOutUpTiles}
  1741. */
  1742. actionWithSize:function (size) {
  1743. return new cc.FadeOutUpTiles(this._duration, size);
  1744. }
  1745. });
  1746. /**
  1747. * Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner.
  1748. * @deprecated since v3.0,please use new cc.TransitionFadeUp(t, scene) instead.
  1749. * @param {Number} t time in seconds
  1750. * @param {cc.Scene} scene
  1751. * @return {cc.TransitionFadeUp}
  1752. * @example
  1753. * var myTransition = cc.TransitionFadeUp.create(1.5, nextScene)
  1754. */
  1755. cc.TransitionFadeUp.create = function (t, scene) {
  1756. return new cc.TransitionFadeUp(t, scene);
  1757. };
  1758. /**
  1759. * Fade the tiles of the outgoing scene from the top to the bottom.
  1760. * @class
  1761. * @extends cc.TransitionFadeTR
  1762. * @param {Number} t time in seconds
  1763. * @param {cc.Scene} scene
  1764. * @example
  1765. * var trans = new cc.TransitionFadeDown(time,scene);
  1766. */
  1767. cc.TransitionFadeDown = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeDown# */{
  1768. /**
  1769. * Constructor of TransitionFadeDown
  1770. * @param {Number} t time in seconds
  1771. * @param {cc.Scene} scene
  1772. */
  1773. ctor:function (t, scene) {
  1774. cc.TransitionFadeTR.prototype.ctor.call(this);
  1775. scene && this.initWithDuration(t, scene);
  1776. },
  1777. /**
  1778. * @param {cc.Size} size
  1779. * @return {*}
  1780. */
  1781. actionWithSize:function (size) {
  1782. return cc.fadeOutDownTiles( this._duration, size);
  1783. }
  1784. });
  1785. /**
  1786. * Fade the tiles of the outgoing scene from the top to the bottom.
  1787. * @deprecated since v3.0,please use new cc.TransitionFadeDown(t, scene) instead.
  1788. * @param {Number} t time in seconds
  1789. * @param {cc.Scene} scene
  1790. * @return {cc.TransitionFadeDown}
  1791. * @example
  1792. * var myTransition = cc.TransitionFadeDown.create(1.5, nextScene)
  1793. */
  1794. cc.TransitionFadeDown.create = function (t, scene) {
  1795. return new cc.TransitionFadeDown(t, scene);
  1796. };