CCTransition.h 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093
  1. /****************************************************************************
  2. Copyright (c) 2009-2010 Ricardo Quesada
  3. Copyright (c) 2010-2012 cocos2d-x.org
  4. Copyright (c) 2011 Zynga Inc.
  5. Copyright (c) 2013-2016 Chukong Technologies Inc.
  6. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  7. http://www.cocos2d-x.org
  8. Permission is hereby granted, free of charge, to any person obtaining a copy
  9. of this software and associated documentation files (the "Software"), to deal
  10. in the Software without restriction, including without limitation the rights
  11. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. copies of the Software, and to permit persons to whom the Software is
  13. furnished to do so, subject to the following conditions:
  14. The above copyright notice and this permission notice shall be included in
  15. all copies or substantial portions of the Software.
  16. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. THE SOFTWARE.
  23. ****************************************************************************/
  24. #ifndef __CCTRANSITION_H__
  25. #define __CCTRANSITION_H__
  26. #include "2d/CCScene.h"
  27. NS_CC_BEGIN
  28. /**
  29. * @addtogroup _2d
  30. * @{
  31. */
  32. //static creation function macro
  33. //c/c++ don't support object creation of using class name
  34. //so, all classes need creation method.
  35. class ActionInterval;
  36. class Node;
  37. class NodeGrid;
  38. /** @class TransitionEaseScene
  39. * @brief TransitionEaseScene can ease the actions of the scene protocol.
  40. @since v0.8.2
  41. @js NA
  42. */
  43. class CC_DLL TransitionEaseScene// : public Ref
  44. {
  45. public:
  46. /** Constructor.
  47. */
  48. virtual ~TransitionEaseScene() {}
  49. /** Returns the Ease action that will be performed on a linear action.
  50. @since v0.8.2
  51. *
  52. * @param action A given interval action.
  53. * @return The Ease action that will be performed on a linear action.
  54. */
  55. virtual ActionInterval * easeActionWithAction(ActionInterval * action) = 0;
  56. };
  57. /** @class TransitionScene
  58. * @brief Base class for Transition scenes.
  59. */
  60. class CC_DLL TransitionScene : public Scene
  61. {
  62. public:
  63. /** Orientation Type used by some transitions.
  64. */
  65. enum class Orientation
  66. {
  67. /// An horizontal orientation where the Left is nearer
  68. LEFT_OVER = 0,
  69. /// An horizontal orientation where the Right is nearer
  70. RIGHT_OVER = 1,
  71. /// A vertical orientation where the Up is nearer
  72. UP_OVER = 0,
  73. /// A vertical orientation where the Bottom is nearer
  74. DOWN_OVER = 1,
  75. };
  76. /** Creates a base transition with duration and incoming scene.
  77. *
  78. * @param t Duration time, in seconds.
  79. * @param scene A given scene.
  80. * @return A autoreleased TransitionScene object.
  81. */
  82. static TransitionScene * create(float t, Scene *scene);
  83. /** Called after the transition finishes.
  84. */
  85. void finish(void);
  86. /** Used by some transitions to hide the outer scene.
  87. */
  88. void hideOutShowIn(void);
  89. Scene* getInScene() const{ return _inScene; }
  90. float getDuration() const { return _duration; }
  91. //
  92. // Overrides
  93. //
  94. virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
  95. virtual void onEnter() override;
  96. virtual void onExit() override;
  97. virtual void cleanup() override;
  98. CC_CONSTRUCTOR_ACCESS:
  99. TransitionScene();
  100. virtual ~TransitionScene();
  101. /** initializes a transition with duration and incoming scene */
  102. bool initWithDuration(float t,Scene* scene);
  103. protected:
  104. virtual void sceneOrder();
  105. void setNewScene(float dt);
  106. Scene *_inScene;
  107. Scene *_outScene;
  108. float _duration;
  109. bool _isInSceneOnTop;
  110. bool _isSendCleanupToScene;
  111. private:
  112. CC_DISALLOW_COPY_AND_ASSIGN(TransitionScene);
  113. };
  114. /** @class TransitionSceneOriented
  115. * @brief A Transition that supports orientation like.
  116. * Possible orientation: LeftOver, RightOver, UpOver, DownOver
  117. */
  118. class CC_DLL TransitionSceneOriented : public TransitionScene
  119. {
  120. public:
  121. /** Creates a transition with duration, incoming scene and orientation.
  122. *
  123. * @param t Duration time, in seconds.
  124. * @param scene A given scene.
  125. * @param orientation A given orientation: LeftOver, RightOver, UpOver, DownOver.
  126. * @return A autoreleased TransitionSceneOriented object.
  127. */
  128. static TransitionSceneOriented * create(float t,Scene* scene, Orientation orientation);
  129. CC_CONSTRUCTOR_ACCESS:
  130. TransitionSceneOriented();
  131. virtual ~TransitionSceneOriented();
  132. /** initializes a transition with duration and incoming scene */
  133. bool initWithDuration(float t,Scene* scene,Orientation orientation);
  134. protected:
  135. Orientation _orientation;
  136. private:
  137. CC_DISALLOW_COPY_AND_ASSIGN(TransitionSceneOriented);
  138. };
  139. /** @class TransitionRotoZoom
  140. * @brief TransitionRotoZoom:
  141. Rotate and zoom out the outgoing scene, and then rotate and zoom in the incoming
  142. */
  143. class CC_DLL TransitionRotoZoom : public TransitionScene
  144. {
  145. public:
  146. /** Creates a transition with duration and incoming scene.
  147. *
  148. * @param t Duration time, in seconds.
  149. * @param scene A given scene.
  150. * @return A autoreleased TransitionRotoZoom object.
  151. */
  152. static TransitionRotoZoom* create(float t, Scene* scene);
  153. //
  154. // Overrides
  155. //
  156. virtual void onEnter() override;
  157. CC_CONSTRUCTOR_ACCESS:
  158. TransitionRotoZoom();
  159. virtual ~TransitionRotoZoom();
  160. private:
  161. CC_DISALLOW_COPY_AND_ASSIGN(TransitionRotoZoom);
  162. };
  163. /** @class TransitionJumpZoom
  164. * @brief TransitionJumpZoom:
  165. Zoom out and jump the outgoing scene, and then jump and zoom in the incoming
  166. */
  167. class CC_DLL TransitionJumpZoom : public TransitionScene
  168. {
  169. public:
  170. /** Creates a transition with duration and incoming scene.
  171. *
  172. * @param t Duration time, in seconds.
  173. * @param scene A given scene.
  174. * @return A autoreleased TransitionJumpZoom object.
  175. */
  176. static TransitionJumpZoom* create(float t, Scene* scene);
  177. //
  178. // Overrides
  179. //
  180. virtual void onEnter() override;
  181. CC_CONSTRUCTOR_ACCESS:
  182. TransitionJumpZoom();
  183. virtual ~TransitionJumpZoom();
  184. private:
  185. CC_DISALLOW_COPY_AND_ASSIGN(TransitionJumpZoom);
  186. };
  187. /** @class TransitionMoveInL
  188. * @brief TransitionMoveInL:
  189. Move in from to the left the incoming scene.
  190. */
  191. class CC_DLL TransitionMoveInL : public TransitionScene, public TransitionEaseScene
  192. {
  193. public:
  194. /** Creates a transition with duration and incoming scene.
  195. *
  196. * @param t Duration time, in seconds.
  197. * @param scene A given scene.
  198. * @return A autoreleased TransitionMoveInL object.
  199. */
  200. static TransitionMoveInL* create(float t, Scene* scene);
  201. /** Returns the action that will be performed.
  202. *
  203. * @return The action that will be performed.
  204. */
  205. virtual ActionInterval* action(void);
  206. virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
  207. //
  208. // Overrides
  209. //
  210. virtual void onEnter() override;
  211. CC_CONSTRUCTOR_ACCESS:
  212. TransitionMoveInL();
  213. virtual ~TransitionMoveInL();
  214. protected:
  215. /** initializes the scenes */
  216. virtual void initScenes();
  217. private:
  218. CC_DISALLOW_COPY_AND_ASSIGN(TransitionMoveInL);
  219. };
  220. /** @class TransitionMoveInR
  221. * @brief TransitionMoveInR:
  222. Move in from to the right the incoming scene.
  223. */
  224. class CC_DLL TransitionMoveInR : public TransitionMoveInL
  225. {
  226. public:
  227. /** Creates a transition with duration and incoming scene.
  228. *
  229. * @param t Duration time, in seconds.
  230. * @param scene A given scene.
  231. * @return A autoreleased TransitionMoveInR object.
  232. */
  233. static TransitionMoveInR* create(float t, Scene* scene);
  234. CC_CONSTRUCTOR_ACCESS:
  235. TransitionMoveInR();
  236. virtual ~TransitionMoveInR();
  237. protected:
  238. virtual void initScenes();
  239. private:
  240. CC_DISALLOW_COPY_AND_ASSIGN(TransitionMoveInR);
  241. };
  242. /** @class TransitionMoveInT
  243. * @brief TransitionMoveInT:
  244. Move in from to the top the incoming scene.
  245. */
  246. class CC_DLL TransitionMoveInT : public TransitionMoveInL
  247. {
  248. public:
  249. /** Creates a transition with duration and incoming scene.
  250. *
  251. * @param t Duration time, in seconds.
  252. * @param scene A given scene.
  253. * @return A autoreleased TransitionMoveInT object.
  254. */
  255. static TransitionMoveInT* create(float t, Scene* scene);
  256. CC_CONSTRUCTOR_ACCESS:
  257. TransitionMoveInT();
  258. virtual ~TransitionMoveInT();
  259. protected:
  260. virtual void initScenes();
  261. private:
  262. CC_DISALLOW_COPY_AND_ASSIGN(TransitionMoveInT);
  263. };
  264. /** @class TransitionMoveInB
  265. * @brief TransitionMoveInB:
  266. Move in from to the bottom the incoming scene.
  267. */
  268. class CC_DLL TransitionMoveInB : public TransitionMoveInL
  269. {
  270. public:
  271. /** Creates a transition with duration and incoming scene.
  272. *
  273. * @param t Duration time, in seconds.
  274. * @param scene A given scene.
  275. * @return A autoreleased TransitionMoveInB object.
  276. */
  277. static TransitionMoveInB* create(float t, Scene* scene);
  278. CC_CONSTRUCTOR_ACCESS:
  279. TransitionMoveInB();
  280. virtual ~TransitionMoveInB();
  281. protected:
  282. virtual void initScenes();
  283. private:
  284. CC_DISALLOW_COPY_AND_ASSIGN(TransitionMoveInB);
  285. };
  286. /** @class TransitionSlideInL
  287. * @brief TransitionSlideInL:
  288. Slide in the incoming scene from the left border.
  289. */
  290. class CC_DLL TransitionSlideInL : public TransitionScene, public TransitionEaseScene
  291. {
  292. public:
  293. /** Creates a transition with duration and incoming scene.
  294. *
  295. * @param t Duration time, in seconds.
  296. * @param scene A given scene.
  297. * @return A autoreleased TransitionSlideInL object.
  298. */
  299. static TransitionSlideInL* create(float t, Scene* scene);
  300. virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
  301. /** Returns the action that will be performed by the incoming and outgoing scene.
  302. *
  303. * @return The action that will be performed by the incoming and outgoing scene.
  304. */
  305. virtual ActionInterval* action(void);
  306. //
  307. // Overrides
  308. //
  309. virtual void onEnter() override;
  310. CC_CONSTRUCTOR_ACCESS:
  311. TransitionSlideInL();
  312. virtual ~TransitionSlideInL();
  313. protected:
  314. /** initializes the scenes */
  315. virtual void initScenes(void);
  316. virtual void sceneOrder() override;
  317. private:
  318. CC_DISALLOW_COPY_AND_ASSIGN(TransitionSlideInL);
  319. };
  320. /** @class TransitionSlideInR
  321. *@brief TransitionSlideInR:
  322. Slide in the incoming scene from the right border.
  323. */
  324. class CC_DLL TransitionSlideInR : public TransitionSlideInL
  325. {
  326. public:
  327. /** Creates a transition with duration and incoming scene.
  328. *
  329. * @param t Duration time, in seconds.
  330. * @param scene A given scene.
  331. * @return A autoreleased TransitionSlideInR object.
  332. */
  333. static TransitionSlideInR* create(float t, Scene* scene);
  334. /** Returns the action that will be performed by the incoming and outgoing scene. */
  335. virtual ActionInterval* action(void) override;
  336. CC_CONSTRUCTOR_ACCESS:
  337. TransitionSlideInR();
  338. virtual ~TransitionSlideInR();
  339. protected:
  340. /** initializes the scenes */
  341. virtual void initScenes(void) override;
  342. virtual void sceneOrder() override;
  343. private:
  344. CC_DISALLOW_COPY_AND_ASSIGN(TransitionSlideInR);
  345. };
  346. /** @class TransitionSlideInB
  347. * @brief TransitionSlideInB:
  348. Slide in the incoming scene from the bottom border.
  349. */
  350. class CC_DLL TransitionSlideInB : public TransitionSlideInL
  351. {
  352. public:
  353. /** Creates a transition with duration and incoming scene.
  354. *
  355. * @param t Duration time, in seconds.
  356. * @param scene A given scene.
  357. * @return A autoreleased TransitionSlideInB object.
  358. */
  359. static TransitionSlideInB* create(float t, Scene* scene);
  360. /** returns the action that will be performed by the incoming and outgoing scene */
  361. virtual ActionInterval* action(void) override;
  362. CC_CONSTRUCTOR_ACCESS:
  363. TransitionSlideInB();
  364. virtual ~TransitionSlideInB();
  365. protected:
  366. /** initializes the scenes */
  367. virtual void initScenes() override;
  368. virtual void sceneOrder() override;
  369. private:
  370. CC_DISALLOW_COPY_AND_ASSIGN(TransitionSlideInB);
  371. };
  372. /** @class TransitionSlideInT
  373. * @brief TransitionSlideInT:
  374. Slide in the incoming scene from the top border.
  375. */
  376. class CC_DLL TransitionSlideInT : public TransitionSlideInL
  377. {
  378. public:
  379. /** Creates a transition with duration and incoming scene.
  380. *
  381. * @param t Duration time, in seconds.
  382. * @param scene A given scene.
  383. * @return A autoreleased TransitionSlideInT object.
  384. */
  385. static TransitionSlideInT* create(float t, Scene* scene);
  386. /** returns the action that will be performed by the incoming and outgoing scene */
  387. virtual ActionInterval* action(void) override;
  388. CC_CONSTRUCTOR_ACCESS:
  389. TransitionSlideInT();
  390. virtual ~TransitionSlideInT();
  391. protected:
  392. /** initializes the scenes */
  393. virtual void initScenes(void) override;
  394. virtual void sceneOrder() override;
  395. private:
  396. CC_DISALLOW_COPY_AND_ASSIGN(TransitionSlideInT);
  397. };
  398. /** @class TransitionShrinkGrow
  399. * @brief Shrink the outgoing scene while grow the incoming scene
  400. */
  401. class CC_DLL TransitionShrinkGrow : public TransitionScene , public TransitionEaseScene
  402. {
  403. public:
  404. /** Creates a transition with duration and incoming scene.
  405. *
  406. * @param t Duration time, in seconds.
  407. * @param scene A given scene.
  408. * @return A autoreleased TransitionShrinkGrow object.
  409. */
  410. static TransitionShrinkGrow* create(float t, Scene* scene);
  411. //
  412. // Overrides
  413. //
  414. /**
  415. * @lua NA
  416. */
  417. virtual void onEnter() override;
  418. virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
  419. CC_CONSTRUCTOR_ACCESS:
  420. TransitionShrinkGrow();
  421. virtual ~TransitionShrinkGrow();
  422. private:
  423. CC_DISALLOW_COPY_AND_ASSIGN(TransitionShrinkGrow);
  424. };
  425. /** @class TransitionFlipX
  426. * @brief TransitionFlipX:
  427. Flips the screen horizontally.
  428. The front face is the outgoing scene and the back face is the incoming scene.
  429. */
  430. class CC_DLL TransitionFlipX : public TransitionSceneOriented
  431. {
  432. public:
  433. /** Creates a transition with duration, incoming scene and orientation.
  434. *
  435. * @param t Duration time, in seconds.
  436. * @param s A given scene.
  437. * @param o A given orientation.
  438. * @return A autoreleased TransitionFlipX object.
  439. */
  440. static TransitionFlipX* create(float t, Scene* s, Orientation o);
  441. /** Creates a transition with duration and incoming scene.
  442. *
  443. * @param t Duration time, in seconds.
  444. * @param s A given scene.
  445. * @return A autoreleased TransitionFlipX object.
  446. */
  447. static TransitionFlipX* create(float t, Scene* s);
  448. //
  449. // Overrides
  450. //
  451. /**
  452. * @lua NA
  453. */
  454. virtual void onEnter() override;
  455. CC_CONSTRUCTOR_ACCESS:
  456. TransitionFlipX();
  457. virtual ~TransitionFlipX();
  458. private:
  459. CC_DISALLOW_COPY_AND_ASSIGN(TransitionFlipX);
  460. };
  461. /** @class TransitionFlipY
  462. * @brief TransitionFlipY:
  463. Flips the screen vertically.
  464. The front face is the outgoing scene and the back face is the incoming scene.
  465. */
  466. class CC_DLL TransitionFlipY : public TransitionSceneOriented
  467. {
  468. public:
  469. /** Creates a transition with duration, incoming scene and orientation.
  470. *
  471. * @param t Duration time, in seconds.
  472. * @param s A given scene.
  473. * @param o A given orientation.
  474. * @return A autoreleased TransitionFlipY object.
  475. */
  476. static TransitionFlipY* create(float t, Scene* s, Orientation o);
  477. /** Creates a transition with duration and incoming scene.
  478. *
  479. * @param t Duration time, in seconds.
  480. * @param s A given scene.
  481. * @return A autoreleased TransitionFlipY object.
  482. */
  483. static TransitionFlipY* create(float t, Scene* s);
  484. //
  485. // Overrides
  486. //
  487. /**
  488. * @lua NA
  489. */
  490. virtual void onEnter() override;
  491. CC_CONSTRUCTOR_ACCESS:
  492. TransitionFlipY();
  493. virtual ~TransitionFlipY();
  494. private:
  495. CC_DISALLOW_COPY_AND_ASSIGN(TransitionFlipY);
  496. };
  497. /** @class TransitionFlipAngular
  498. * @brief TransitionFlipAngular:
  499. Flips the screen half horizontally and half vertically.
  500. The front face is the outgoing scene and the back face is the incoming scene.
  501. */
  502. class CC_DLL TransitionFlipAngular : public TransitionSceneOriented
  503. {
  504. public:
  505. /** Creates a transition with duration, incoming scene and orientation.
  506. *
  507. * @param t Duration time, in seconds.
  508. * @param s A given scene.
  509. * @param o A given orientation.
  510. * @return A autoreleased TransitionFlipAngular object.
  511. */
  512. static TransitionFlipAngular* create(float t, Scene* s, Orientation o);
  513. /** Creates a transition with duration and incoming scene.
  514. *
  515. * @param t Duration time, in seconds.
  516. * @param s A given scene.
  517. * @return A autoreleased TransitionFlipAngular object.
  518. */
  519. static TransitionFlipAngular* create(float t, Scene* s);
  520. //
  521. // Overrides
  522. //
  523. /**
  524. * @lua NA
  525. */
  526. virtual void onEnter() override;
  527. CC_CONSTRUCTOR_ACCESS:
  528. TransitionFlipAngular();
  529. virtual ~TransitionFlipAngular();
  530. private:
  531. CC_DISALLOW_COPY_AND_ASSIGN(TransitionFlipAngular);
  532. };
  533. /** @class TransitionZoomFlipX
  534. * @brief TransitionZoomFlipX:
  535. Flips the screen horizontally doing a zoom out/in
  536. The front face is the outgoing scene and the back face is the incoming scene.
  537. */
  538. class CC_DLL TransitionZoomFlipX : public TransitionSceneOriented
  539. {
  540. public:
  541. /** Creates a transition with duration, incoming scene and orientation.
  542. *
  543. * @param t Duration time, in seconds.
  544. * @param s A given scene.
  545. * @param o A given orientation.
  546. * @return A autoreleased TransitionZoomFlipX object.
  547. */
  548. static TransitionZoomFlipX* create(float t, Scene* s, Orientation o);
  549. /** Creates a transition with duration and incoming scene.
  550. *
  551. * @param t Duration time, in seconds.
  552. * @param s A given scene.
  553. * @return A autoreleased TransitionZoomFlipX object.
  554. */
  555. static TransitionZoomFlipX* create(float t, Scene* s);
  556. //
  557. // Overrides
  558. //
  559. /**
  560. * @lua NA
  561. */
  562. virtual void onEnter() override;
  563. CC_CONSTRUCTOR_ACCESS:
  564. TransitionZoomFlipX();
  565. virtual ~TransitionZoomFlipX();
  566. private:
  567. CC_DISALLOW_COPY_AND_ASSIGN(TransitionZoomFlipX);
  568. };
  569. /** @class TransitionZoomFlipY
  570. * @brief TransitionZoomFlipY:
  571. Flips the screen vertically doing a little zooming out/in
  572. The front face is the outgoing scene and the back face is the incoming scene.
  573. */
  574. class CC_DLL TransitionZoomFlipY : public TransitionSceneOriented
  575. {
  576. public:
  577. /** Creates a transition with duration, incoming scene and orientation.
  578. *
  579. * @param t Duration time, in seconds.
  580. * @param s A given scene.
  581. * @param o A given orientation.
  582. * @return A autoreleased TransitionZoomFlipY object.
  583. */
  584. static TransitionZoomFlipY* create(float t, Scene* s, Orientation o);
  585. /** Creates a transition with duration and incoming scene.
  586. *
  587. * @param t Duration time, in seconds.
  588. * @param s A given scene.
  589. * @return A autoreleased TransitionZoomFlipY object.
  590. */
  591. static TransitionZoomFlipY* create(float t, Scene* s);
  592. //
  593. // Overrides
  594. //
  595. /**
  596. * @lua NA
  597. */
  598. virtual void onEnter() override;
  599. CC_CONSTRUCTOR_ACCESS:
  600. TransitionZoomFlipY();
  601. virtual ~TransitionZoomFlipY();
  602. private:
  603. CC_DISALLOW_COPY_AND_ASSIGN(TransitionZoomFlipY);
  604. };
  605. /** @class TransitionZoomFlipAngular
  606. * @brief TransitionZoomFlipAngular:
  607. Flips the screen half horizontally and half vertically doing a little zooming out/in.
  608. The front face is the outgoing scene and the back face is the incoming scene.
  609. */
  610. class CC_DLL TransitionZoomFlipAngular : public TransitionSceneOriented
  611. {
  612. public:
  613. /** Creates a transition with duration, incoming scene and orientation.
  614. *
  615. * @param t Duration time, in seconds.
  616. * @param s A given scene.
  617. * @param o A given orientation.
  618. * @return A autoreleased TransitionZoomFlipAngular object.
  619. */
  620. static TransitionZoomFlipAngular* create(float t, Scene* s, Orientation o);
  621. /** Creates a transition with duration and incoming scene.
  622. *
  623. * @param t Duration time, in seconds.
  624. * @param s A given scene.
  625. * @return A autoreleased TransitionZoomFlipAngular object.
  626. */
  627. static TransitionZoomFlipAngular* create(float t, Scene* s);
  628. //
  629. // Overrides
  630. //
  631. /**
  632. * @lua NA
  633. */
  634. virtual void onEnter() override;
  635. CC_CONSTRUCTOR_ACCESS:
  636. TransitionZoomFlipAngular();
  637. virtual ~TransitionZoomFlipAngular();
  638. private:
  639. CC_DISALLOW_COPY_AND_ASSIGN(TransitionZoomFlipAngular);
  640. };
  641. /** @class TransitionFade
  642. * @brief TransitionFade:
  643. Fade out the outgoing scene and then fade in the incoming scene.'''
  644. */
  645. class CC_DLL TransitionFade : public TransitionScene
  646. {
  647. public:
  648. /** Creates the transition with a duration and with an RGB color
  649. * Example: FadeTransition::create(2, scene, Color3B(255,0,0); // red color
  650. *
  651. * @param duration Duration time, in seconds.
  652. * @param scene A given scene.
  653. * @param color A given transition color.
  654. * @return A autoreleased TransitionFade object.
  655. */
  656. static TransitionFade* create(float duration, Scene* scene, const Color3B& color);
  657. /** Creates the transition with a duration.
  658. *
  659. * @param duration Duration time, in seconds.
  660. * @param scene A given scene.
  661. * @return A autoreleased TransitionFade object.
  662. */
  663. static TransitionFade* create(float duration, Scene* scene);
  664. /**
  665. * @lua NA
  666. */
  667. virtual void onEnter() override;
  668. /**
  669. * @lua NA
  670. */
  671. virtual void onExit() override;
  672. CC_CONSTRUCTOR_ACCESS:
  673. TransitionFade();
  674. virtual ~TransitionFade();
  675. /** initializes the transition with a duration and with an RGB color */
  676. bool initWithDuration(float t, Scene*scene, const Color3B& color);
  677. bool initWithDuration(float t, Scene* scene);
  678. protected:
  679. Color4B _color;
  680. private:
  681. CC_DISALLOW_COPY_AND_ASSIGN(TransitionFade);
  682. };
  683. class RenderTexture;
  684. /** @class TransitionCrossFade
  685. @brief TransitionCrossFade:
  686. Cross fades two scenes using the RenderTexture object.
  687. */
  688. class CC_DLL TransitionCrossFade : public TransitionScene
  689. {
  690. public :
  691. /** Creates a transition with duration and incoming scene.
  692. *
  693. * @param t Duration time, in seconds.
  694. * @param scene A given scene.
  695. * @return A autoreleased TransitionCrossFade object.
  696. */
  697. static TransitionCrossFade* create(float t, Scene* scene);
  698. //
  699. // Overrides
  700. //
  701. /**
  702. * @lua NA
  703. */
  704. virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
  705. /**
  706. * @lua NA
  707. */
  708. virtual void onEnter() override;
  709. /**
  710. * @lua NA
  711. */
  712. virtual void onExit() override;
  713. CC_CONSTRUCTOR_ACCESS:
  714. TransitionCrossFade();
  715. virtual ~TransitionCrossFade();
  716. private:
  717. CC_DISALLOW_COPY_AND_ASSIGN(TransitionCrossFade);
  718. };
  719. /** @class TransitionTurnOffTiles
  720. * @brief TransitionTurnOffTiles:
  721. Turn off the tiles of the outgoing scene in random order
  722. */
  723. class CC_DLL TransitionTurnOffTiles : public TransitionScene ,public TransitionEaseScene
  724. {
  725. public :
  726. /** Creates a transition with duration and incoming scene.
  727. *
  728. * @param t Duration time, in seconds.
  729. * @param scene A given scene.
  730. * @return A autoreleased TransitionTurnOffTiles object.
  731. */
  732. static TransitionTurnOffTiles* create(float t, Scene* scene);
  733. //
  734. // Overrides
  735. //
  736. /**
  737. * @lua NA
  738. */
  739. virtual void onEnter() override;
  740. /**
  741. * @js NA
  742. */
  743. virtual void onExit() override;
  744. virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
  745. /**
  746. * @js NA
  747. */
  748. virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
  749. CC_CONSTRUCTOR_ACCESS:
  750. TransitionTurnOffTiles();
  751. virtual ~TransitionTurnOffTiles();
  752. protected:
  753. virtual void sceneOrder() override;
  754. NodeGrid* _outSceneProxy;
  755. private:
  756. CC_DISALLOW_COPY_AND_ASSIGN(TransitionTurnOffTiles);
  757. };
  758. /** @class TransitionSplitCols
  759. * @brief TransitionSplitCols:
  760. The odd columns goes upwards while the even columns goes downwards.
  761. */
  762. class CC_DLL TransitionSplitCols : public TransitionScene , public TransitionEaseScene
  763. {
  764. public:
  765. /** Creates a transition with duration and incoming scene.
  766. *
  767. * @param t Duration time, in seconds.
  768. * @param scene A given scene.
  769. * @return A autoreleased TransitionSplitCols object.
  770. */
  771. static TransitionSplitCols* create(float t, Scene* scene);
  772. /** Returns the action that will be performed.
  773. *
  774. * @return The action that will be performed.
  775. */
  776. virtual ActionInterval* action();
  777. //
  778. // Overrides
  779. //
  780. /**
  781. * @lua NA
  782. */
  783. virtual void onEnter() override;
  784. virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
  785. virtual void onExit() override;
  786. virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
  787. CC_CONSTRUCTOR_ACCESS:
  788. TransitionSplitCols();
  789. virtual ~TransitionSplitCols();
  790. protected:
  791. void switchTargetToInscene();
  792. NodeGrid* _gridProxy;
  793. private:
  794. CC_DISALLOW_COPY_AND_ASSIGN(TransitionSplitCols);
  795. };
  796. /** @class TransitionSplitRows
  797. * @brief TransitionSplitRows:
  798. The odd rows goes to the left while the even rows goes to the right.
  799. */
  800. class CC_DLL TransitionSplitRows : public TransitionSplitCols
  801. {
  802. public:
  803. /** Creates a transition with duration and incoming scene.
  804. *
  805. * @param t Duration time, in seconds.
  806. * @param scene A given scene.
  807. * @return A autoreleased TransitionSplitRows object.
  808. */
  809. static TransitionSplitRows* create(float t, Scene* scene);
  810. //
  811. // Overrides
  812. //
  813. virtual ActionInterval* action(void) override;
  814. CC_CONSTRUCTOR_ACCESS:
  815. TransitionSplitRows();
  816. virtual ~TransitionSplitRows();
  817. private:
  818. CC_DISALLOW_COPY_AND_ASSIGN(TransitionSplitRows);
  819. };
  820. /** @class TransitionFadeTR
  821. * @brief TransitionFadeTR:
  822. Fade the tiles of the outgoing scene from the left-bottom corner the to top-right corner.
  823. */
  824. class CC_DLL TransitionFadeTR : public TransitionScene , public TransitionEaseScene
  825. {
  826. public:
  827. /** Creates a transition with duration and incoming scene.
  828. *
  829. * @param t Duration time, in seconds.
  830. * @param scene A given scene.
  831. * @return A autoreleased TransitionFadeTR object.
  832. */
  833. static TransitionFadeTR* create(float t, Scene* scene);
  834. /** Returns the action that will be performed with size.
  835. *
  836. * @param size A given size.
  837. * @return The action that will be performed.
  838. */
  839. virtual ActionInterval* actionWithSize(const Size& size);
  840. //
  841. // Overrides
  842. //
  843. /**
  844. * @js NA
  845. * @lua NA
  846. */
  847. virtual void onEnter() override;
  848. virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
  849. virtual void onExit() override;
  850. virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
  851. CC_CONSTRUCTOR_ACCESS:
  852. TransitionFadeTR();
  853. virtual ~TransitionFadeTR();
  854. protected:
  855. virtual void sceneOrder() override;
  856. NodeGrid* _outSceneProxy;
  857. private:
  858. CC_DISALLOW_COPY_AND_ASSIGN(TransitionFadeTR);
  859. };
  860. /** @class TransitionFadeBL
  861. * @brief TransitionFadeBL:
  862. Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner.
  863. */
  864. class CC_DLL TransitionFadeBL : public TransitionFadeTR
  865. {
  866. public:
  867. /** Creates a transition with duration and incoming scene.
  868. *
  869. * @param t Duration time, in seconds.
  870. * @param scene A given scene.
  871. * @return A autoreleased TransitionFadeBL object.
  872. */
  873. static TransitionFadeBL* create(float t, Scene* scene);
  874. //
  875. // Overrides
  876. //
  877. virtual ActionInterval* actionWithSize(const Size& size) override;
  878. CC_CONSTRUCTOR_ACCESS:
  879. TransitionFadeBL();
  880. virtual ~TransitionFadeBL();
  881. private:
  882. CC_DISALLOW_COPY_AND_ASSIGN(TransitionFadeBL);
  883. };
  884. /** @class TransitionFadeUp
  885. * @brief TransitionFadeUp:
  886. * Fade the tiles of the outgoing scene from the bottom to the top.
  887. */
  888. class CC_DLL TransitionFadeUp : public TransitionFadeTR
  889. {
  890. public:
  891. /** Creates a transition with duration and incoming scene.
  892. *
  893. * @param t Duration time, in seconds.
  894. * @param scene A given scene.
  895. * @return A autoreleased TransitionFadeUp object.
  896. */
  897. static TransitionFadeUp* create(float t, Scene* scene);
  898. //
  899. // Overrides
  900. //
  901. virtual ActionInterval* actionWithSize(const Size& size) override;
  902. CC_CONSTRUCTOR_ACCESS:
  903. TransitionFadeUp();
  904. virtual ~TransitionFadeUp();
  905. private:
  906. CC_DISALLOW_COPY_AND_ASSIGN(TransitionFadeUp);
  907. };
  908. /** @class TransitionFadeDown
  909. * @brief TransitionFadeDown:
  910. * Fade the tiles of the outgoing scene from the top to the bottom.
  911. */
  912. class CC_DLL TransitionFadeDown : public TransitionFadeTR
  913. {
  914. public:
  915. /** Creates a transition with duration and incoming scene.
  916. *
  917. * @param t Duration time, in seconds.
  918. * @param scene A given scene.
  919. * @return A autoreleased TransitionFadeDown object.
  920. */
  921. static TransitionFadeDown* create(float t, Scene* scene);
  922. //
  923. // Overrides
  924. //
  925. virtual ActionInterval* actionWithSize(const Size& size) override;
  926. CC_CONSTRUCTOR_ACCESS:
  927. TransitionFadeDown();
  928. virtual ~TransitionFadeDown();
  929. private:
  930. CC_DISALLOW_COPY_AND_ASSIGN(TransitionFadeDown);
  931. };
  932. // end of _2d group
  933. /// @}
  934. NS_CC_END
  935. #endif // __CCTRANSITION_H__