axmol/cocos2dx/include/CCTransition.h

551 lines
15 KiB
C
Raw Normal View History

2010-07-08 18:11:08 +08:00
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
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"
2010-08-04 15:46:12 +08:00
namespace cocos2d {
2010-08-20 14:35:37 +08:00
//static creation function macro
//c/c++ don't support object creation of using class name
//so, all classes need creation method.
#define DECLEAR_TRANSITIONWITHDURATION(_Type)\
static _Type* transitionWithDuration(ccTime t, CCScene* scene);
2010-07-08 18:11:08 +08:00
class CCIntervalAction;
class CCNode;
/** CCTransitionEaseScene can ease the actions of the scene protocol.
@since v0.8.2
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCTransitionEaseScene// : public NSObject
2010-07-08 18:11:08 +08:00
{
public:
2010-07-08 18:11:08 +08:00
/** returns the Ease action that will be performed on a linear action.
@since v0.8.2
*/
2010-07-28 15:27:51 +08:00
virtual CCIntervalAction * easeActionWithAction(CCIntervalAction * action) = 0;
2010-07-08 18:11:08 +08:00
};
/** Orientation Type used by some transitions
*/
typedef enum {
/// An horizontal orientation where the Left is nearer
kOrientationLeftOver = 0,
/// An horizontal orientation where the Right is nearer
kOrientationRightOver = 1,
/// A vertical orientation where the Up is nearer
kOrientationUpOver = 0,
/// A vertical orientation where the Bottom is nearer
kOrientationDownOver = 1,
} tOrientation;
/** Base class for CCTransition scenes
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCTransitionScene : public CCScene
2010-07-08 18:11:08 +08:00
{
protected:
CCScene * m_pInScene;
CCScene * m_pOutScene;
2010-07-08 18:11:08 +08:00
ccTime m_fDuration;
bool m_bIsInSceneOnTop;
bool m_bIsSendCleanupToScene;
2010-07-08 18:11:08 +08:00
public:
CCTransitionScene();
virtual ~CCTransitionScene();
virtual void draw();
virtual void onEnter();
virtual void onExit();
virtual void cleanup();
2010-07-08 18:11:08 +08:00
/** creates a base transition with duration and incoming scene */
2010-08-03 11:28:34 +08:00
static CCTransitionScene * transitionWithDuration(ccTime t, CCScene *scene);
2010-07-08 18:11:08 +08:00
/** initializes a transition with duration and incoming scene */
virtual bool initWithDuration(ccTime t,CCScene* scene);
2010-07-08 18:11:08 +08:00
/** called after the transition finishes */
void finish(void);
/** used by some transitions to hide the outter scene */
void hideOutShowIn(void);
protected:
virtual void sceneOrder();
private:
void setNewScene(ccTime dt);
2010-07-08 18:11:08 +08:00
};
/** A CCTransition that supports orientation like.
* Possible orientation: LeftOver, RightOver, UpOver, DownOver
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCOrientedTransitionScene : public CCTransitionScene
2010-07-08 18:11:08 +08:00
{
protected:
2010-08-18 11:06:48 +08:00
tOrientation m_eOrientation;
2010-07-08 18:11:08 +08:00
public:
CCOrientedTransitionScene();
2010-08-06 16:05:19 +08:00
virtual ~CCOrientedTransitionScene();
2010-07-08 18:11:08 +08:00
/** creates a base transition with duration and incoming scene */
2010-08-03 11:28:34 +08:00
static CCOrientedTransitionScene * transitionWithDuration(ccTime t,CCScene* scene, tOrientation orientation);
2010-07-08 18:11:08 +08:00
/** initializes a transition with duration and incoming scene */
virtual bool initWithDuration(ccTime t,CCScene* scene,tOrientation orientation);
2010-07-08 18:11:08 +08:00
};
/** CCRotoZoomTransition:
Rotate and zoom out the outgoing scene, and then rotate and zoom in the incoming
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCRotoZoomTransition : public CCTransitionScene
2010-07-08 18:11:08 +08:00
{
public:
CCRotoZoomTransition();
virtual ~CCRotoZoomTransition();
virtual void onEnter();
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCRotoZoomTransition);
2010-07-08 18:11:08 +08:00
};
/** CCJumpZoomTransition:
Zoom out and jump the outgoing scene, and then jump and zoom in the incoming
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCJumpZoomTransition : public CCTransitionScene
2010-07-08 18:11:08 +08:00
{
public:
CCJumpZoomTransition();
virtual ~CCJumpZoomTransition();
virtual void onEnter();
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCJumpZoomTransition);
2010-07-08 18:11:08 +08:00
};
/** CCMoveInLTransition:
Move in from to the left the incoming scene.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCMoveInLTransition : public CCTransitionScene, public CCTransitionEaseScene
2010-07-08 18:11:08 +08:00
{
public:
CCMoveInLTransition();
virtual ~CCMoveInLTransition();
2010-07-08 18:11:08 +08:00
/** initializes the scenes */
virtual void initScenes(void);
/** returns the action that will be performed */
2010-08-12 17:39:25 +08:00
virtual CCIntervalAction* action(void);
virtual CCIntervalAction* easeActionWithAction(CCIntervalAction * action);
virtual void onEnter();
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCMoveInLTransition);
2010-07-08 18:11:08 +08:00
};
/** CCMoveInRTransition:
Move in from to the right the incoming scene.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCMoveInRTransition : public CCMoveInLTransition
2010-07-08 18:11:08 +08:00
{
public:
CCMoveInRTransition();
virtual ~CCMoveInRTransition();
virtual void initScenes();
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCMoveInRTransition);
2010-07-08 18:11:08 +08:00
};
/** CCMoveInTTransition:
Move in from to the top the incoming scene.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCMoveInTTransition : public CCMoveInLTransition
2010-07-08 18:11:08 +08:00
{
public:
CCMoveInTTransition();
virtual ~CCMoveInTTransition();
virtual void initScenes();
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCMoveInTTransition);
2010-07-08 18:11:08 +08:00
};
/** CCMoveInBTransition:
Move in from to the bottom the incoming scene.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCMoveInBTransition : public CCMoveInLTransition
2010-07-08 18:11:08 +08:00
{
public:
CCMoveInBTransition();
virtual ~CCMoveInBTransition();
virtual void initScenes();
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCMoveInBTransition);
2010-07-08 18:11:08 +08:00
};
/** CCSlideInLTransition:
Slide in the incoming scene from the left border.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCSlideInLTransition : public CCTransitionScene, public CCTransitionEaseScene
2010-07-08 18:11:08 +08:00
{
public:
CCSlideInLTransition();
virtual ~CCSlideInLTransition();
2010-07-08 18:11:08 +08:00
/** initializes the scenes */
virtual void initScenes(void);
/** returns the action that will be performed by the incomming and outgoing scene */
virtual CCIntervalAction* action(void);
virtual void onEnter();
virtual CCIntervalAction* easeActionWithAction(CCIntervalAction * action);
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCSlideInLTransition);
protected:
virtual void sceneOrder();
2010-07-08 18:11:08 +08:00
};
/** CCSlideInRTransition:
Slide in the incoming scene from the right border.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCSlideInRTransition : public CCSlideInLTransition
2010-07-08 18:11:08 +08:00
{
public:
CCSlideInRTransition();
virtual ~CCSlideInRTransition();
/** initializes the scenes */
virtual void initScenes(void);
/** returns the action that will be performed by the incomming and outgoing scene */
virtual CCIntervalAction* action(void);
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCSlideInRTransition);
protected:
virtual void sceneOrder();
2010-07-08 18:11:08 +08:00
};
/** CCSlideInBTransition:
Slide in the incoming scene from the bottom border.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCSlideInBTransition : public CCSlideInLTransition
2010-07-08 18:11:08 +08:00
{
public:
CCSlideInBTransition();
virtual ~CCSlideInBTransition();
/** initializes the scenes */
virtual void initScenes(void);
/** returns the action that will be performed by the incomming and outgoing scene */
virtual CCIntervalAction* action(void);
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCSlideInBTransition);
protected:
virtual void sceneOrder();
2010-07-08 18:11:08 +08:00
};
/** CCSlideInTTransition:
Slide in the incoming scene from the top border.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCSlideInTTransition : public CCSlideInLTransition
2010-07-08 18:11:08 +08:00
{
public:
CCSlideInTTransition();
virtual ~CCSlideInTTransition();
/** initializes the scenes */
virtual void initScenes(void);
/** returns the action that will be performed by the incomming and outgoing scene */
virtual CCIntervalAction* action(void);
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCSlideInTTransition);
protected:
virtual void sceneOrder();
2010-07-08 18:11:08 +08:00
};
/**
Shrink the outgoing scene while grow the incoming scene
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCShrinkGrowTransition : public CCTransitionScene , public CCTransitionEaseScene
2010-07-08 18:11:08 +08:00
{
public:
CCShrinkGrowTransition();
virtual ~CCShrinkGrowTransition();
virtual void onEnter();
virtual CCIntervalAction* easeActionWithAction(CCIntervalAction * action);
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCShrinkGrowTransition);
2010-07-08 18:11:08 +08:00
};
/** CCFlipXTransition:
Flips the screen horizontally.
The front face is the outgoing scene and the back face is the incoming scene.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCFlipXTransition : public CCOrientedTransitionScene
2010-07-08 18:11:08 +08:00
{
public:
CCFlipXTransition();
virtual ~CCFlipXTransition();
virtual void onEnter();
2010-08-20 14:35:37 +08:00
static CCFlipXTransition* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver);
2010-07-08 18:11:08 +08:00
};
/** CCFlipYTransition:
Flips the screen vertically.
The front face is the outgoing scene and the back face is the incoming scene.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCFlipYTransition : public CCOrientedTransitionScene
2010-07-08 18:11:08 +08:00
{
public:
CCFlipYTransition();
virtual ~CCFlipYTransition();
virtual void onEnter();
2010-08-20 14:35:37 +08:00
static CCFlipYTransition* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationUpOver);
2010-07-08 18:11:08 +08:00
};
/** CCFlipAngularTransition:
Flips the screen half horizontally and half vertically.
The front face is the outgoing scene and the back face is the incoming scene.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCFlipAngularTransition : public CCOrientedTransitionScene
2010-07-08 18:11:08 +08:00
{
public:
CCFlipAngularTransition();
virtual ~CCFlipAngularTransition();
virtual void onEnter();
2010-08-20 14:35:37 +08:00
static CCFlipAngularTransition* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver);
2010-07-08 18:11:08 +08:00
};
/** CCZoomFlipXTransition:
Flips the screen horizontally doing a zoom out/in
The front face is the outgoing scene and the back face is the incoming scene.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCZoomFlipXTransition : public CCOrientedTransitionScene
2010-07-08 18:11:08 +08:00
{
public:
CCZoomFlipXTransition();
virtual ~CCZoomFlipXTransition();
virtual void onEnter();
2010-08-20 14:35:37 +08:00
static CCZoomFlipXTransition* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver);
2010-07-08 18:11:08 +08:00
};
/** CCZoomFlipYTransition:
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.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCZoomFlipYTransition : public CCOrientedTransitionScene
2010-07-08 18:11:08 +08:00
{
public:
CCZoomFlipYTransition();
virtual ~CCZoomFlipYTransition();
virtual void onEnter();
2010-08-20 14:35:37 +08:00
static CCZoomFlipYTransition* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationUpOver);
2010-07-08 18:11:08 +08:00
};
/** CCZoomFlipAngularTransition:
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.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCZoomFlipAngularTransition : public CCOrientedTransitionScene
2010-07-08 18:11:08 +08:00
{
public:
CCZoomFlipAngularTransition();
virtual ~CCZoomFlipAngularTransition();
virtual void onEnter();
2010-08-20 14:35:37 +08:00
static CCZoomFlipAngularTransition* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver);
2010-07-08 18:11:08 +08:00
};
/** CCFadeTransition:
Fade out the outgoing scene and then fade in the incoming scene.'''
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCFadeTransition : public CCTransitionScene
2010-07-08 18:11:08 +08:00
{
protected:
ccColor4B m_tColor;
2010-07-08 18:11:08 +08:00
public:
CCFadeTransition();
virtual ~CCFadeTransition();
2010-07-08 18:11:08 +08:00
/** creates the transition with a duration and with an RGB color
* Example: FadeTransition::transitionWithDuration(2, scene, ccc3(255,0,0); // red color
2010-07-08 18:11:08 +08:00
*/
2010-08-20 14:35:37 +08:00
static CCFadeTransition* transitionWithDuration(ccTime duration,CCScene* scene, ccColor3B color = ccBLACK);
2010-07-08 18:11:08 +08:00
/** initializes the transition with a duration and with an RGB color */
virtual bool initWithDuration(ccTime t, CCScene*scene ,ccColor3B color);
virtual bool initWithDuration(ccTime t,CCScene* scene);
virtual void onEnter();
virtual void onExit();
2010-07-08 18:11:08 +08:00
};
/**
CCCrossFadeTransition:
Cross fades two scenes using the CCRenderTexture object.
*/
class CCRenderTexture;
2010-08-20 14:35:37 +08:00
class CCX_DLL CCCrossFadeTransition : public CCTransitionScene
2010-07-08 18:11:08 +08:00
{
public :
CCCrossFadeTransition();
virtual ~CCCrossFadeTransition();
virtual void draw();
virtual void onEnter();
virtual void onExit();
2010-08-20 14:35:37 +08:00
2010-09-14 15:23:38 +08:00
public:
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCCrossFadeTransition);
2010-07-08 18:11:08 +08:00
};
/** CCTurnOffTilesTransition:
Turn off the tiles of the outgoing scene in random order
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCTurnOffTilesTransition : public CCTransitionScene ,public CCTransitionEaseScene
2010-07-08 18:11:08 +08:00
{
public :
CCTurnOffTilesTransition();
virtual ~CCTurnOffTilesTransition();
virtual void onEnter();
virtual CCIntervalAction * easeActionWithAction(CCIntervalAction * action);
2010-09-14 15:23:38 +08:00
public:
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCTurnOffTilesTransition);
protected:
virtual void sceneOrder();
2010-07-08 18:11:08 +08:00
};
/** CCSplitColsTransition:
The odd columns goes upwards while the even columns goes downwards.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCSplitColsTransition : public CCTransitionScene , public CCTransitionEaseScene
2010-07-08 18:11:08 +08:00
{
public:
CCSplitColsTransition();
virtual ~CCSplitColsTransition();
2010-07-08 18:11:08 +08:00
virtual CCIntervalAction* action(void);
virtual void onEnter();
virtual CCIntervalAction * easeActionWithAction(CCIntervalAction * action);
2010-08-20 14:35:37 +08:00
2010-09-14 15:23:38 +08:00
public:
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCSplitColsTransition);
2010-07-08 18:11:08 +08:00
};
/** CCSplitRowsTransition:
The odd rows goes to the left while the even rows goes to the right.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCSplitRowsTransition : public CCSplitColsTransition
2010-07-08 18:11:08 +08:00
{
public:
CCSplitRowsTransition();
virtual ~CCSplitRowsTransition();
virtual CCIntervalAction* action(void);
2010-08-20 14:35:37 +08:00
2010-09-14 15:23:38 +08:00
public:
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCSplitRowsTransition)
2010-07-08 18:11:08 +08:00
};
/** CCFadeTRTransition:
Fade the tiles of the outgoing scene from the left-bottom corner the to top-right corner.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCFadeTRTransition : public CCTransitionScene , public CCTransitionEaseScene
2010-07-08 18:11:08 +08:00
{
public:
CCFadeTRTransition();
virtual ~CCFadeTRTransition();
2010-07-08 18:11:08 +08:00
virtual CCIntervalAction* actionWithSize(ccGridSize size);
virtual void onEnter();
virtual CCIntervalAction* easeActionWithAction(CCIntervalAction * action);
2010-08-20 14:35:37 +08:00
2010-09-14 15:23:38 +08:00
public:
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCFadeTRTransition)
protected:
virtual void sceneOrder();
2010-07-08 18:11:08 +08:00
};
/** CCFadeBLTransition:
Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCFadeBLTransition : public CCFadeTRTransition
2010-07-08 18:11:08 +08:00
{
public:
CCFadeBLTransition();
virtual ~CCFadeBLTransition();
virtual CCIntervalAction* actionWithSize(ccGridSize size);
2010-08-20 14:35:37 +08:00
2010-09-14 15:23:38 +08:00
public:
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCFadeBLTransition)
2010-07-08 18:11:08 +08:00
};
/** CCFadeUpTransition:
* Fade the tiles of the outgoing scene from the bottom to the top.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCFadeUpTransition : public CCFadeTRTransition
2010-07-08 18:11:08 +08:00
{
public:
CCFadeUpTransition();
virtual ~CCFadeUpTransition();
virtual CCIntervalAction* actionWithSize(ccGridSize size);
2010-08-20 14:35:37 +08:00
2010-09-14 15:23:38 +08:00
public:
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCFadeUpTransition)
2010-07-08 18:11:08 +08:00
};
/** CCFadeDownTransition:
* Fade the tiles of the outgoing scene from the top to the bottom.
*/
2010-08-20 14:35:37 +08:00
class CCX_DLL CCFadeDownTransition : public CCFadeTRTransition
2010-07-08 18:11:08 +08:00
{
public:
CCFadeDownTransition();
virtual ~CCFadeDownTransition();
virtual CCIntervalAction* actionWithSize(ccGridSize size);
2010-08-20 14:35:37 +08:00
2010-09-14 15:23:38 +08:00
public:
2010-08-20 14:35:37 +08:00
DECLEAR_TRANSITIONWITHDURATION(CCFadeDownTransition)
2010-07-08 18:11:08 +08:00
};
2010-08-04 15:46:12 +08:00
}//namespace cocos2d
2010-07-08 18:11:08 +08:00
#endif // __CCTRANSITION_H__