axmol/cocos2dx/layers_scenes_transitions_n.../CCTransition.h

881 lines
19 KiB
C
Raw Normal View History

/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCTRANSITION_H__
#define __CCTRANSITION_H__
#include "CCScene.h"
2012-06-08 13:55:28 +08:00
#include "ccTypes.h"
2012-04-18 18:43:45 +08:00
NS_CC_BEGIN
2012-06-20 18:09:11 +08:00
/**
* @addtogroup transition
* @{
*/
//static creation function macro
//c/c++ don't support object creation of using class name
//so, all classes need creation method.
class ActionInterval;
class Node;
/** @brief TransitionEaseScene can ease the actions of the scene protocol.
2010-07-08 18:11:08 +08:00
@since v0.8.2
*/
class CC_DLL TransitionEaseScene// : public Object
2010-07-08 18:11:08 +08:00
{
public:
/** returns the Ease action that will be performed on a linear action.
@since v0.8.2
*/
virtual ActionInterval * easeActionWithAction(ActionInterval * action) = 0;
2010-07-08 18:11:08 +08:00
};
/** @brief Base class for Transition scenes
*/
class CC_DLL TransitionScene : public Scene
{
public:
/** Orientation Type used by some transitions
*/
enum class Orientation
{
/// An horizontal orientation where the Left is nearer
LEFT_OVER = 0,
/// An horizontal orientation where the Right is nearer
RIGHT_OVER = 1,
/// A vertical orientation where the Up is nearer
UP_OVER = 0,
/// A vertical orientation where the Bottom is nearer
DOWN_OVER = 1,
};
/** creates a base transition with duration and incoming scene */
static TransitionScene * create(float t, Scene *scene);
/**
* @js ctor
*/
TransitionScene();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionScene();
2010-07-08 18:11:08 +08:00
/** initializes a transition with duration and incoming scene */
bool initWithDuration(float t,Scene* scene);
2010-07-08 18:11:08 +08:00
/** called after the transition finishes */
void finish(void);
2010-07-08 18:11:08 +08:00
/** used by some transitions to hide the outer scene */
void hideOutShowIn(void);
//
// Overrides
//
virtual void draw() override;
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override;
/**
* @js NA
* @lua NA
*/
virtual void onExit() override;
virtual void cleanup() override;
protected:
virtual void sceneOrder();
private:
2012-06-08 13:55:28 +08:00
void setNewScene(float dt);
protected:
Scene * _inScene;
Scene * _outScene;
float _duration;
bool _isInSceneOnTop;
bool _isSendCleanupToScene;
};
/** @brief A Transition that supports orientation like.
2010-07-08 18:11:08 +08:00
* Possible orientation: LeftOver, RightOver, UpOver, DownOver
*/
class CC_DLL TransitionSceneOriented : public TransitionScene
2010-07-08 18:11:08 +08:00
{
public:
/** creates a base transition with duration and incoming scene */
static TransitionSceneOriented * create(float t,Scene* scene, Orientation orientation);
/**
* @js ctor
*/
TransitionSceneOriented();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionSceneOriented();
/** initializes a transition with duration and incoming scene */
bool initWithDuration(float t,Scene* scene,Orientation orientation);
protected:
Orientation _orientation;
};
/** @brief TransitionRotoZoom:
2010-07-08 18:11:08 +08:00
Rotate and zoom out the outgoing scene, and then rotate and zoom in the incoming
*/
class CC_DLL TransitionRotoZoom : public TransitionScene
2010-07-08 18:11:08 +08:00
{
public:
static TransitionRotoZoom* create(float t, Scene* scene);
TransitionRotoZoom();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionRotoZoom();
2010-08-20 14:35:37 +08:00
//
// Overrides
//
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override;
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionJumpZoom:
2010-07-08 18:11:08 +08:00
Zoom out and jump the outgoing scene, and then jump and zoom in the incoming
*/
class CC_DLL TransitionJumpZoom : public TransitionScene
2010-07-08 18:11:08 +08:00
{
public:
static TransitionJumpZoom* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionJumpZoom();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionJumpZoom();
2010-08-20 14:35:37 +08:00
//
// Overrides
//
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override;
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionMoveInL:
2010-07-08 18:11:08 +08:00
Move in from to the left the incoming scene.
*/
class CC_DLL TransitionMoveInL : public TransitionScene, public TransitionEaseScene
2010-07-08 18:11:08 +08:00
{
public:
static TransitionMoveInL* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionMoveInL();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionMoveInL();
/** initializes the scenes */
virtual void initScenes(void);
/** returns the action that will be performed */
virtual ActionInterval* action(void);
virtual ActionInterval* easeActionWithAction(ActionInterval * action);
//
// Overrides
//
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override;
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionMoveInR:
2010-07-08 18:11:08 +08:00
Move in from to the right the incoming scene.
*/
class CC_DLL TransitionMoveInR : public TransitionMoveInL
2010-07-08 18:11:08 +08:00
{
public:
static TransitionMoveInR* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionMoveInR();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionMoveInR();
virtual void initScenes();
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionMoveInT:
2010-07-08 18:11:08 +08:00
Move in from to the top the incoming scene.
*/
class CC_DLL TransitionMoveInT : public TransitionMoveInL
2010-07-08 18:11:08 +08:00
{
public:
static TransitionMoveInT* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionMoveInT();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionMoveInT();
virtual void initScenes();
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionMoveInB:
2010-07-08 18:11:08 +08:00
Move in from to the bottom the incoming scene.
*/
class CC_DLL TransitionMoveInB : public TransitionMoveInL
2010-07-08 18:11:08 +08:00
{
public:
static TransitionMoveInB* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionMoveInB();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionMoveInB();
virtual void initScenes();
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionSlideInL:
2010-07-08 18:11:08 +08:00
Slide in the incoming scene from the left border.
*/
class CC_DLL TransitionSlideInL : public TransitionScene, public TransitionEaseScene
2010-07-08 18:11:08 +08:00
{
public:
static TransitionSlideInL* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionSlideInL();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionSlideInL();
virtual ActionInterval* easeActionWithAction(ActionInterval * action);
/** initializes the scenes */
virtual void initScenes(void);
/** returns the action that will be performed by the incoming and outgoing scene */
virtual ActionInterval* action(void);
//
// Overrides
//
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override;
protected:
virtual void sceneOrder() override;
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionSlideInR:
2010-07-08 18:11:08 +08:00
Slide in the incoming scene from the right border.
*/
class CC_DLL TransitionSlideInR : public TransitionSlideInL
2010-07-08 18:11:08 +08:00
{
public:
static TransitionSlideInR* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionSlideInR();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionSlideInR();
/** initializes the scenes */
virtual void initScenes(void);
/** returns the action that will be performed by the incoming and outgoing scene */
virtual ActionInterval* action(void);
2010-08-20 14:35:37 +08:00
protected:
virtual void sceneOrder() override;
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionSlideInB:
2010-07-08 18:11:08 +08:00
Slide in the incoming scene from the bottom border.
*/
class CC_DLL TransitionSlideInB : public TransitionSlideInL
2010-07-08 18:11:08 +08:00
{
public:
static TransitionSlideInB* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionSlideInB();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionSlideInB();
/** initializes the scenes */
virtual void initScenes(void);
/** returns the action that will be performed by the incoming and outgoing scene */
virtual ActionInterval* action(void);
2010-08-20 14:35:37 +08:00
protected:
virtual void sceneOrder() override;
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionSlideInT:
2010-07-08 18:11:08 +08:00
Slide in the incoming scene from the top border.
*/
class CC_DLL TransitionSlideInT : public TransitionSlideInL
2010-07-08 18:11:08 +08:00
{
public:
static TransitionSlideInT* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionSlideInT();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionSlideInT();
/** initializes the scenes */
virtual void initScenes(void);
/** returns the action that will be performed by the incoming and outgoing scene */
virtual ActionInterval* action(void);
2010-08-20 14:35:37 +08:00
protected:
virtual void sceneOrder() override;
2010-07-08 18:11:08 +08:00
};
/**
@brief Shrink the outgoing scene while grow the incoming scene
2010-07-08 18:11:08 +08:00
*/
class CC_DLL TransitionShrinkGrow : public TransitionScene , public TransitionEaseScene
2010-07-08 18:11:08 +08:00
{
public:
static TransitionShrinkGrow* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionShrinkGrow();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionShrinkGrow();
//
// Overrides
//
virtual void onEnter() override;
virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionFlipX:
2010-07-08 18:11:08 +08:00
Flips the screen horizontally.
The front face is the outgoing scene and the back face is the incoming scene.
*/
class CC_DLL TransitionFlipX : public TransitionSceneOriented
2010-07-08 18:11:08 +08:00
{
public:
static TransitionFlipX* create(float t, Scene* s, Orientation o);
static TransitionFlipX* create(float t, Scene* s);
/**
* @js ctor
*/
TransitionFlipX();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionFlipX();
//
// Overrides
//
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override;
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionFlipY:
2010-07-08 18:11:08 +08:00
Flips the screen vertically.
The front face is the outgoing scene and the back face is the incoming scene.
*/
class CC_DLL TransitionFlipY : public TransitionSceneOriented
2010-07-08 18:11:08 +08:00
{
public:
static TransitionFlipY* create(float t, Scene* s, Orientation o);
static TransitionFlipY* create(float t, Scene* s);
/**
* @js ctor
*/
TransitionFlipY();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionFlipY();
//
// Overrides
//
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override;
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionFlipAngular:
2010-07-08 18:11:08 +08:00
Flips the screen half horizontally and half vertically.
The front face is the outgoing scene and the back face is the incoming scene.
*/
class CC_DLL TransitionFlipAngular : public TransitionSceneOriented
2010-07-08 18:11:08 +08:00
{
public:
static TransitionFlipAngular* create(float t, Scene* s, Orientation o);
static TransitionFlipAngular* create(float t, Scene* s);
/**
* @js ctor
*/
TransitionFlipAngular();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionFlipAngular();
//
// Overrides
//
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override;
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionZoomFlipX:
2010-07-08 18:11:08 +08:00
Flips the screen horizontally doing a zoom out/in
The front face is the outgoing scene and the back face is the incoming scene.
*/
class CC_DLL TransitionZoomFlipX : public TransitionSceneOriented
2010-07-08 18:11:08 +08:00
{
public:
static TransitionZoomFlipX* create(float t, Scene* s, Orientation o);
static TransitionZoomFlipX* create(float t, Scene* s);
/**
* @js ctor
*/
TransitionZoomFlipX();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionZoomFlipX();
//
// Overrides
//
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override;
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionZoomFlipY:
2010-07-08 18:11:08 +08:00
Flips the screen vertically doing a little zooming out/in
The front face is the outgoing scene and the back face is the incoming scene.
*/
class CC_DLL TransitionZoomFlipY : public TransitionSceneOriented
2010-07-08 18:11:08 +08:00
{
public:
static TransitionZoomFlipY* create(float t, Scene* s, Orientation o);
static TransitionZoomFlipY* create(float t, Scene* s);
/**
* @js ctor
*/
TransitionZoomFlipY();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionZoomFlipY();
//
// Overrides
//
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override;
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionZoomFlipAngular:
2010-07-08 18:11:08 +08:00
Flips the screen half horizontally and half vertically doing a little zooming out/in.
The front face is the outgoing scene and the back face is the incoming scene.
*/
class CC_DLL TransitionZoomFlipAngular : public TransitionSceneOriented
2010-07-08 18:11:08 +08:00
{
public:
static TransitionZoomFlipAngular* create(float t, Scene* s, Orientation o);
static TransitionZoomFlipAngular* create(float t, Scene* s);
/**
* @js ctor
*/
TransitionZoomFlipAngular();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionZoomFlipAngular();
//
// Overrides
//
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override;
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionFade:
2010-07-08 18:11:08 +08:00
Fade out the outgoing scene and then fade in the incoming scene.'''
*/
class CC_DLL TransitionFade : public TransitionScene
2010-07-08 18:11:08 +08:00
{
public:
/** creates the transition with a duration and with an RGB color
* Example: FadeTransition::create(2, scene, Color3B(255,0,0); // red color
*/
static TransitionFade* create(float duration,Scene* scene, const Color3B& color);
static TransitionFade* create(float duration,Scene* scene);
/**
* @js ctor
*/
TransitionFade();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionFade();
/** initializes the transition with a duration and with an RGB color */
bool initWithDuration(float t, Scene*scene ,const Color3B& color);
//
// Overrides
//
bool initWithDuration(float t,Scene* scene);
/**
* @js NA
* @lua NA
*/
virtual void onEnter();
/**
* @js NA
* @lua NA
*/
virtual void onExit();
protected:
Color4B _color;
2010-07-08 18:11:08 +08:00
};
class RenderTexture;
2010-07-08 18:11:08 +08:00
/**
@brief TransitionCrossFade:
Cross fades two scenes using the RenderTexture object.
2010-07-08 18:11:08 +08:00
*/
class CC_DLL TransitionCrossFade : public TransitionScene
2010-07-08 18:11:08 +08:00
{
public :
static TransitionCrossFade* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionCrossFade();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionCrossFade();
//
// Overrides
//
virtual void draw() override;
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override;
/**
* @js NA
* @lua NA
*/
virtual void onExit() override;
2010-08-20 14:35:37 +08:00
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionTurnOffTiles:
2010-07-08 18:11:08 +08:00
Turn off the tiles of the outgoing scene in random order
*/
class CC_DLL TransitionTurnOffTiles : public TransitionScene ,public TransitionEaseScene
2010-07-08 18:11:08 +08:00
{
public :
static TransitionTurnOffTiles* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionTurnOffTiles();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionTurnOffTiles();
//
// Overrides
//
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override;
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
2010-09-14 15:23:38 +08:00
protected:
virtual void sceneOrder() override;
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionSplitCols:
2010-07-08 18:11:08 +08:00
The odd columns goes upwards while the even columns goes downwards.
*/
class CC_DLL TransitionSplitCols : public TransitionScene , public TransitionEaseScene
2010-07-08 18:11:08 +08:00
{
public:
static TransitionSplitCols* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionSplitCols();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionSplitCols();
virtual ActionInterval* action(void);
//
// Overrides
//
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override;
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionSplitRows:
2010-07-08 18:11:08 +08:00
The odd rows goes to the left while the even rows goes to the right.
*/
class CC_DLL TransitionSplitRows : public TransitionSplitCols
2010-07-08 18:11:08 +08:00
{
public:
static TransitionSplitRows* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionSplitRows();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionSplitRows();
//
// Overrides
//
virtual ActionInterval* action(void) override;
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionFadeTR:
2010-07-08 18:11:08 +08:00
Fade the tiles of the outgoing scene from the left-bottom corner the to top-right corner.
*/
class CC_DLL TransitionFadeTR : public TransitionScene , public TransitionEaseScene
2010-07-08 18:11:08 +08:00
{
public:
static TransitionFadeTR* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionFadeTR();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionFadeTR();
virtual ActionInterval* actionWithSize(const Size& size);
2010-08-20 14:35:37 +08:00
//
// Overrides
//
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override;
virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
protected:
virtual void sceneOrder();
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionFadeBL:
2010-07-08 18:11:08 +08:00
Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner.
*/
class CC_DLL TransitionFadeBL : public TransitionFadeTR
2010-07-08 18:11:08 +08:00
{
public:
static TransitionFadeBL* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionFadeBL();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionFadeBL();
2010-08-20 14:35:37 +08:00
//
// Overrides
//
virtual ActionInterval* actionWithSize(const Size& size) override;
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionFadeUp:
2010-07-08 18:11:08 +08:00
* Fade the tiles of the outgoing scene from the bottom to the top.
*/
class CC_DLL TransitionFadeUp : public TransitionFadeTR
2010-07-08 18:11:08 +08:00
{
public:
static TransitionFadeUp* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionFadeUp();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionFadeUp();
//
// Overrides
//
virtual ActionInterval* actionWithSize(const Size& size) override;
2010-07-08 18:11:08 +08:00
};
/** @brief TransitionFadeDown:
2010-07-08 18:11:08 +08:00
* Fade the tiles of the outgoing scene from the top to the bottom.
*/
class CC_DLL TransitionFadeDown : public TransitionFadeTR
2010-07-08 18:11:08 +08:00
{
public:
static TransitionFadeDown* create(float t, Scene* scene);
/**
* @js ctor
*/
TransitionFadeDown();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionFadeDown();
2010-08-20 14:35:37 +08:00
//
// Overrides
//
virtual ActionInterval* actionWithSize(const Size& size) override;
2010-07-08 18:11:08 +08:00
};
2012-04-18 18:43:45 +08:00
2012-06-20 18:09:11 +08:00
// end of transition group
/// @}
2012-04-18 18:43:45 +08:00
NS_CC_END
2010-07-08 18:11:08 +08:00
#endif // __CCTRANSITION_H__