CCTransitionPageTurn.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /****************************************************************************
  2. Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/
  3. Copyright (c) 2010-2012 cocos2d-x.org
  4. Copyright (c) 2013-2016 Chukong Technologies Inc.
  5. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  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 __CCPAGE_TURN_TRANSITION_H__
  24. #define __CCPAGE_TURN_TRANSITION_H__
  25. #include "2d/CCTransition.h"
  26. #include "renderer/CCCustomCommand.h"
  27. NS_CC_BEGIN
  28. class NodeGrid;
  29. /**
  30. * @addtogroup _2d
  31. * @{
  32. */
  33. /** @class TransitionPageTurn
  34. * @brief A transition which peels back the bottom right hand corner of a scene
  35. to transition to the scene beneath it simulating a page turn.
  36. This uses a 3DAction so it's strongly recommended that depth buffering
  37. is turned on in Director using:
  38. Director::getInstance()->setDepthBufferFormat(kDepthBuffer16);
  39. @since v0.8.2
  40. */
  41. class CC_DLL TransitionPageTurn : public TransitionScene
  42. {
  43. public:
  44. /**
  45. * Creates a base transition with duration and incoming scene.
  46. * If back is true then the effect is reversed to appear as if the incoming
  47. * scene is being turned from left over the outgoing scene.
  48. *
  49. * @param t Duration time, in seconds.
  50. * @param scene A given scene.
  51. * @param backwards If back is true then the effect is reversed to appear as if the incoming scene is being turned from left over the outgoing scene.
  52. * @return An autoreleased TransitionPageTurn object.
  53. */
  54. static TransitionPageTurn* create(float t,Scene* scene,bool backwards);
  55. //
  56. // Overrides
  57. // @js NA
  58. //
  59. virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
  60. /**
  61. * Creates a base transition with duration and incoming scene.
  62. * If back is true then the effect is reversed to appear as if the incoming
  63. * scene is being turned from left over the outgoing scene.
  64. *
  65. * @param t Duration time, in seconds.
  66. * @param scene A given scene.
  67. * @param backwards If back is true then the effect is reversed to appear as if the incoming scene is being turned from left over the outgoing scene.
  68. * @return True if initialize success.
  69. */
  70. bool initWithDuration(float t,Scene* scene,bool backwards);
  71. /** Returns the action that will be performed with size.
  72. *
  73. * @param vector A given size.
  74. * @return The action that will be performed.
  75. */
  76. ActionInterval* actionWithSize(const Size& vector);
  77. //
  78. // Overrides
  79. //
  80. virtual void onEnter() override;
  81. virtual void onExit() override;
  82. CC_CONSTRUCTOR_ACCESS:
  83. /**
  84. * @js ctor
  85. */
  86. TransitionPageTurn();
  87. /**
  88. * @js NA
  89. * @lua NA
  90. */
  91. virtual ~TransitionPageTurn();
  92. protected:
  93. virtual void sceneOrder() override;
  94. protected:
  95. NodeGrid* _inSceneProxy;
  96. NodeGrid* _outSceneProxy;
  97. bool _back;
  98. };
  99. // end of _2d group
  100. /// @}
  101. NS_CC_END
  102. #endif // __CCPAGE_TURN_TRANSITION_H__