1
0

CCTransition.h 29 KB

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