add Transitions Test
This commit is contained in:
natural-law 2010-08-20 06:35:37 +00:00
parent 0894732547
commit 2a37efc84a
11 changed files with 726 additions and 59 deletions

View File

@ -39,7 +39,7 @@ namespace cocos2d {
*
* @since v0.8.2
*/
class CCPageTurnTransition : public CCTransitionScene
class CCX_DLL CCPageTurnTransition : public CCTransitionScene
{
protected:
bool m_bBack;

View File

@ -32,7 +32,7 @@ namespace cocos2d {
///
// A counter colock-wise radial transition to the next scene
///
class CCRadialCCWTransition : public CCTransitionScene
class CCX_DLL CCRadialCCWTransition : public CCTransitionScene
{
public:
CCRadialCCWTransition();
@ -41,6 +41,8 @@ public:
virtual void onEnter();
virtual void onExit();
static CCRadialCCWTransition* transitionWithDuration(ccTime t, CCScene* scene);
protected:
virtual void sceneOrder();
virtual CCProgressTimerType radialType();
@ -49,11 +51,13 @@ protected:
///
// A counter colock-wise radial transition to the next scene
///
class CCRadialCWTransition : public CCRadialCCWTransition
class CCX_DLL CCRadialCWTransition : public CCRadialCCWTransition
{
public:
CCRadialCWTransition();
virtual ~CCRadialCWTransition();
// CCRadialCWTransition();
// virtual ~CCRadialCWTransition();
static CCRadialCWTransition* transitionWithDuration(ccTime t, CCScene* scene);
protected:
virtual CCProgressTimerType radialType();
};

View File

@ -27,13 +27,20 @@ THE SOFTWARE.
#include "CCScene.h"
namespace cocos2d {
//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);
class CCIntervalAction;
class CCNode;
/** CCTransitionEaseScene can ease the actions of the scene protocol.
@since v0.8.2
*/
class CCTransitionEaseScene : public NSObject
class CCX_DLL CCTransitionEaseScene// : public NSObject
{
/** returns the Ease action that will be performed on a linear action.
@since v0.8.2
@ -57,7 +64,7 @@ typedef enum {
/** Base class for CCTransition scenes
*/
class CCTransitionScene : public CCScene
class CCX_DLL CCTransitionScene : public CCScene
{
protected:
@ -98,7 +105,7 @@ private:
/** A CCTransition that supports orientation like.
* Possible orientation: LeftOver, RightOver, UpOver, DownOver
*/
class CCOrientedTransitionScene : public CCTransitionScene
class CCX_DLL CCOrientedTransitionScene : public CCTransitionScene
{
protected:
tOrientation m_eOrientation;
@ -116,29 +123,33 @@ public:
/** CCRotoZoomTransition:
Rotate and zoom out the outgoing scene, and then rotate and zoom in the incoming
*/
class CCRotoZoomTransition : public CCTransitionScene
class CCX_DLL CCRotoZoomTransition : public CCTransitionScene
{
public:
CCRotoZoomTransition();
virtual ~CCRotoZoomTransition();
virtual void onEnter();
DECLEAR_TRANSITIONWITHDURATION(CCRotoZoomTransition);
};
/** CCJumpZoomTransition:
Zoom out and jump the outgoing scene, and then jump and zoom in the incoming
*/
class CCJumpZoomTransition : public CCTransitionScene
class CCX_DLL CCJumpZoomTransition : public CCTransitionScene
{
public:
CCJumpZoomTransition();
virtual ~CCJumpZoomTransition();
virtual void onEnter();
DECLEAR_TRANSITIONWITHDURATION(CCJumpZoomTransition);
};
/** CCMoveInLTransition:
Move in from to the left the incoming scene.
*/
class CCMoveInLTransition : public CCTransitionScene, public CCTransitionEaseScene
class CCX_DLL CCMoveInLTransition : public CCTransitionScene, public CCTransitionEaseScene
{
public:
CCMoveInLTransition();
@ -151,45 +162,53 @@ public:
virtual CCIntervalAction* easeActionWithAction(CCIntervalAction * action);
virtual void onEnter();
DECLEAR_TRANSITIONWITHDURATION(CCMoveInLTransition);
};
/** CCMoveInRTransition:
Move in from to the right the incoming scene.
*/
class CCMoveInRTransition : public CCMoveInLTransition
class CCX_DLL CCMoveInRTransition : public CCMoveInLTransition
{
public:
CCMoveInRTransition();
virtual ~CCMoveInRTransition();
virtual void initScenes();
DECLEAR_TRANSITIONWITHDURATION(CCMoveInRTransition);
};
/** CCMoveInTTransition:
Move in from to the top the incoming scene.
*/
class CCMoveInTTransition : public CCMoveInLTransition
class CCX_DLL CCMoveInTTransition : public CCMoveInLTransition
{
public:
CCMoveInTTransition();
virtual ~CCMoveInTTransition();
virtual void initScenes();
DECLEAR_TRANSITIONWITHDURATION(CCMoveInTTransition);
};
/** CCMoveInBTransition:
Move in from to the bottom the incoming scene.
*/
class CCMoveInBTransition : public CCMoveInLTransition
class CCX_DLL CCMoveInBTransition : public CCMoveInLTransition
{
public:
CCMoveInBTransition();
virtual ~CCMoveInBTransition();
virtual void initScenes();
DECLEAR_TRANSITIONWITHDURATION(CCMoveInBTransition);
};
/** CCSlideInLTransition:
Slide in the incoming scene from the left border.
*/
class CCSlideInLTransition : public CCTransitionScene, public CCTransitionEaseScene
class CCX_DLL CCSlideInLTransition : public CCTransitionScene, public CCTransitionEaseScene
{
public:
CCSlideInLTransition();
@ -203,6 +222,8 @@ public:
virtual void onEnter();
virtual CCIntervalAction* easeActionWithAction(CCIntervalAction * action);
DECLEAR_TRANSITIONWITHDURATION(CCSlideInLTransition);
protected:
virtual void sceneOrder();
};
@ -210,7 +231,7 @@ protected:
/** CCSlideInRTransition:
Slide in the incoming scene from the right border.
*/
class CCSlideInRTransition : public CCSlideInLTransition
class CCX_DLL CCSlideInRTransition : public CCSlideInLTransition
{
public:
CCSlideInRTransition();
@ -220,6 +241,8 @@ public:
virtual void initScenes(void);
/** returns the action that will be performed by the incomming and outgoing scene */
virtual CCIntervalAction* action(void);
DECLEAR_TRANSITIONWITHDURATION(CCSlideInRTransition);
protected:
virtual void sceneOrder();
};
@ -227,7 +250,7 @@ protected:
/** CCSlideInBTransition:
Slide in the incoming scene from the bottom border.
*/
class CCSlideInBTransition : public CCSlideInLTransition
class CCX_DLL CCSlideInBTransition : public CCSlideInLTransition
{
public:
CCSlideInBTransition();
@ -237,6 +260,8 @@ public:
virtual void initScenes(void);
/** returns the action that will be performed by the incomming and outgoing scene */
virtual CCIntervalAction* action(void);
DECLEAR_TRANSITIONWITHDURATION(CCSlideInBTransition);
protected:
virtual void sceneOrder();
};
@ -244,7 +269,7 @@ protected:
/** CCSlideInTTransition:
Slide in the incoming scene from the top border.
*/
class CCSlideInTTransition : public CCSlideInLTransition
class CCX_DLL CCSlideInTTransition : public CCSlideInLTransition
{
public:
CCSlideInTTransition();
@ -254,6 +279,8 @@ public:
virtual void initScenes(void);
/** returns the action that will be performed by the incomming and outgoing scene */
virtual CCIntervalAction* action(void);
DECLEAR_TRANSITIONWITHDURATION(CCSlideInTTransition);
protected:
virtual void sceneOrder();
};
@ -261,7 +288,7 @@ protected:
/**
Shrink the outgoing scene while grow the incoming scene
*/
class CCShrinkGrowTransition : public CCTransitionScene , public CCTransitionEaseScene
class CCX_DLL CCShrinkGrowTransition : public CCTransitionScene , public CCTransitionEaseScene
{
public:
CCShrinkGrowTransition();
@ -269,90 +296,104 @@ public:
virtual void onEnter();
virtual CCIntervalAction* easeActionWithAction(CCIntervalAction * action);
DECLEAR_TRANSITIONWITHDURATION(CCShrinkGrowTransition);
};
/** CCFlipXTransition:
Flips the screen horizontally.
The front face is the outgoing scene and the back face is the incoming scene.
*/
class CCFlipXTransition : public CCOrientedTransitionScene
class CCX_DLL CCFlipXTransition : public CCOrientedTransitionScene
{
public:
CCFlipXTransition();
virtual ~CCFlipXTransition();
virtual void onEnter();
static CCFlipXTransition* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver);
};
/** CCFlipYTransition:
Flips the screen vertically.
The front face is the outgoing scene and the back face is the incoming scene.
*/
class CCFlipYTransition : public CCOrientedTransitionScene
class CCX_DLL CCFlipYTransition : public CCOrientedTransitionScene
{
public:
CCFlipYTransition();
virtual ~CCFlipYTransition();
virtual void onEnter();
static CCFlipYTransition* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationUpOver);
};
/** CCFlipAngularTransition:
Flips the screen half horizontally and half vertically.
The front face is the outgoing scene and the back face is the incoming scene.
*/
class CCFlipAngularTransition : public CCOrientedTransitionScene
class CCX_DLL CCFlipAngularTransition : public CCOrientedTransitionScene
{
public:
CCFlipAngularTransition();
virtual ~CCFlipAngularTransition();
virtual void onEnter();
static CCFlipAngularTransition* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver);
};
/** 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.
*/
class CCZoomFlipXTransition : public CCOrientedTransitionScene
class CCX_DLL CCZoomFlipXTransition : public CCOrientedTransitionScene
{
public:
CCZoomFlipXTransition();
virtual ~CCZoomFlipXTransition();
virtual void onEnter();
static CCZoomFlipXTransition* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver);
};
/** 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.
*/
class CCZoomFlipYTransition : public CCOrientedTransitionScene
class CCX_DLL CCZoomFlipYTransition : public CCOrientedTransitionScene
{
public:
CCZoomFlipYTransition();
virtual ~CCZoomFlipYTransition();
virtual void onEnter();
static CCZoomFlipYTransition* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationUpOver);
};
/** 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.
*/
class CCZoomFlipAngularTransition : public CCOrientedTransitionScene
class CCX_DLL CCZoomFlipAngularTransition : public CCOrientedTransitionScene
{
public:
CCZoomFlipAngularTransition();
virtual ~CCZoomFlipAngularTransition();
virtual void onEnter();
static CCZoomFlipAngularTransition* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver);
};
/** CCFadeTransition:
Fade out the outgoing scene and then fade in the incoming scene.'''
*/
class CCFadeTransition : public CCTransitionScene
class CCX_DLL CCFadeTransition : public CCTransitionScene
{
protected:
ccColor4B m_tColor;
@ -365,7 +406,7 @@ public:
/** creates the transition with a duration and with an RGB color
* Example: [FadeTransition transitionWithDuration:2 scene:s withColor:ccc3(255,0,0)]; // red color
*/
static CCFadeTransition* transitionWithDuration(ccTime duration,CCScene* scene, ccColor3B color);
static CCFadeTransition* transitionWithDuration(ccTime duration,CCScene* scene, ccColor3B color = ccBLACK);
/** initializes the transition with a duration and with an RGB color */
virtual CCFadeTransition* initWithDuration(ccTime t, CCScene*scene ,ccColor3B color);
@ -379,7 +420,7 @@ CCCrossFadeTransition:
Cross fades two scenes using the CCRenderTexture object.
*/
class CCRenderTexture;
class CCCrossFadeTransition : public CCTransitionScene
class CCX_DLL CCCrossFadeTransition : public CCTransitionScene
{
public :
CCCrossFadeTransition();
@ -388,12 +429,14 @@ public :
virtual void draw();
virtual void onEnter();
virtual void onExit();
DECLEAR_TRANSITIONWITHDURATION(CCCrossFadeTransition);
};
/** CCTurnOffTilesTransition:
Turn off the tiles of the outgoing scene in random order
*/
class CCTurnOffTilesTransition : public CCTransitionScene ,public CCTransitionEaseScene
class CCX_DLL CCTurnOffTilesTransition : public CCTransitionScene ,public CCTransitionEaseScene
{
public :
CCTurnOffTilesTransition();
@ -402,6 +445,7 @@ public :
virtual void onEnter();
virtual CCIntervalAction * easeActionWithAction(CCIntervalAction * action);
DECLEAR_TRANSITIONWITHDURATION(CCTurnOffTilesTransition);
protected:
virtual void sceneOrder();
};
@ -409,7 +453,7 @@ protected:
/** CCSplitColsTransition:
The odd columns goes upwards while the even columns goes downwards.
*/
class CCSplitColsTransition : public CCTransitionScene , public CCTransitionEaseScene
class CCX_DLL CCSplitColsTransition : public CCTransitionScene , public CCTransitionEaseScene
{
public:
CCSplitColsTransition();
@ -418,24 +462,28 @@ public:
virtual CCIntervalAction* action(void);
virtual void onEnter();
virtual CCIntervalAction * easeActionWithAction(CCIntervalAction * action);
DECLEAR_TRANSITIONWITHDURATION(CCSplitColsTransition);
};
/** CCSplitRowsTransition:
The odd rows goes to the left while the even rows goes to the right.
*/
class CCSplitRowsTransition : public CCSplitColsTransition
class CCX_DLL CCSplitRowsTransition : public CCSplitColsTransition
{
public:
CCSplitRowsTransition();
virtual ~CCSplitRowsTransition();
virtual CCIntervalAction* action(void);
DECLEAR_TRANSITIONWITHDURATION(CCSplitRowsTransition)
};
/** CCFadeTRTransition:
Fade the tiles of the outgoing scene from the left-bottom corner the to top-right corner.
*/
class CCFadeTRTransition : public CCTransitionScene , public CCTransitionEaseScene
class CCX_DLL CCFadeTRTransition : public CCTransitionScene , public CCTransitionEaseScene
{
public:
CCFadeTRTransition();
@ -443,6 +491,8 @@ public:
virtual CCIntervalAction* actionWithSize(ccGridSize size);
virtual void onEnter();
virtual CCIntervalAction* easeActionWithAction(CCIntervalAction * action);
DECLEAR_TRANSITIONWITHDURATION(CCFadeTRTransition)
protected:
virtual void sceneOrder();
@ -451,34 +501,40 @@ protected:
/** CCFadeBLTransition:
Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner.
*/
class CCFadeBLTransition : public CCFadeTRTransition
class CCX_DLL CCFadeBLTransition : public CCFadeTRTransition
{
public:
CCFadeBLTransition();
virtual ~CCFadeBLTransition();
virtual CCIntervalAction* actionWithSize(ccGridSize size);
DECLEAR_TRANSITIONWITHDURATION(CCFadeBLTransition)
};
/** CCFadeUpTransition:
* Fade the tiles of the outgoing scene from the bottom to the top.
*/
class CCFadeUpTransition : public CCFadeTRTransition
class CCX_DLL CCFadeUpTransition : public CCFadeTRTransition
{
public:
CCFadeUpTransition();
virtual ~CCFadeUpTransition();
virtual CCIntervalAction* actionWithSize(ccGridSize size);
DECLEAR_TRANSITIONWITHDURATION(CCFadeUpTransition)
};
/** CCFadeDownTransition:
* Fade the tiles of the outgoing scene from the top to the bottom.
*/
class CCFadeDownTransition : public CCFadeTRTransition
class CCX_DLL CCFadeDownTransition : public CCFadeTRTransition
{
public:
CCFadeDownTransition();
virtual ~CCFadeDownTransition();
virtual CCIntervalAction* actionWithSize(ccGridSize size);
DECLEAR_TRANSITIONWITHDURATION(CCFadeDownTransition)
};
}//namespace cocos2d

View File

@ -109,10 +109,28 @@ void CCRadialCCWTransition::onExit()
__super::onExit();
}
CCRadialCCWTransition* CCRadialCCWTransition::transitionWithDuration(ccTime t, CCScene* scene)
{
CCRadialCCWTransition* pScene = new CCRadialCCWTransition();
pScene->initWithDuration(t, scene);
pScene->autorelease();
return pScene;
}
CCProgressTimerType CCRadialCWTransition::radialType()
{
return kCCProgressTimerTypeRadialCW;
}
CCRadialCWTransition* CCRadialCWTransition::transitionWithDuration(ccTime t, CCScene* scene)
{
CCRadialCWTransition* pScene = new CCRadialCWTransition();
pScene->initWithDuration(t, scene);
pScene->autorelease();
return pScene;
}
}//namespace cocos2d

View File

@ -39,6 +39,17 @@ enum {
kSceneFade = 0xFADEFADE,
};
#define IMPLEMENT_TRANSITIONWITHDURATION(_Type)\
_Type* _Type::transitionWithDuration(ccTime t, CCScene* scene)\
{\
_Type* pScene = new _Type();\
pScene->initWithDuration(t, scene);\
pScene->autorelease();\
return pScene;\
}
CCTransitionScene::CCTransitionScene()
{
}
@ -242,6 +253,8 @@ void CCRotoZoomTransition:: onEnter()
);
}
IMPLEMENT_TRANSITIONWITHDURATION(CCRotoZoomTransition)
//
// JumpZoom
@ -285,6 +298,7 @@ void CCJumpZoomTransition::onEnter()
);
}
IMPLEMENT_TRANSITIONWITHDURATION(CCJumpZoomTransition)
//
// MoveInL
@ -331,6 +345,8 @@ void CCMoveInLTransition::initScenes()
m_pInScene->setPosition( ccp(-s.width,0) );
}
IMPLEMENT_TRANSITIONWITHDURATION(CCMoveInLTransition)
//
// MoveInR
//
@ -347,6 +363,8 @@ void CCMoveInRTransition::initScenes()
m_pInScene->setPosition( ccp(s.width,0) );
}
IMPLEMENT_TRANSITIONWITHDURATION(CCMoveInRTransition)
//
// MoveInT
//
@ -363,6 +381,7 @@ void CCMoveInTTransition::initScenes()
m_pInScene->setPosition( ccp(0,s.height) );
}
IMPLEMENT_TRANSITIONWITHDURATION(CCMoveInTTransition)
//
// MoveInB
@ -380,6 +399,8 @@ void CCMoveInBTransition::initScenes()
m_pInScene->setPosition( ccp(0,-s.height) );
}
IMPLEMENT_TRANSITIONWITHDURATION(CCMoveInBTransition)
//
// SlideInL
@ -439,6 +460,8 @@ CCIntervalAction* CCSlideInLTransition::easeActionWithAction(CCIntervalAction* a
// return [EaseElasticOut actionWithAction:action period:0.4f];
}
IMPLEMENT_TRANSITIONWITHDURATION(CCSlideInLTransition)
//
// SlideInR
@ -468,6 +491,8 @@ CCIntervalAction* CCSlideInRTransition:: action()
return CCMoveBy::actionWithDuration(m_fDuration, ccp(-(s.width-ADJUST_FACTOR),0));
}
IMPLEMENT_TRANSITIONWITHDURATION(CCSlideInRTransition)
//
// SlideInT
@ -497,6 +522,7 @@ CCIntervalAction* CCSlideInTTransition::action()
return CCMoveBy::actionWithDuration(m_fDuration, ccp(0,-(s.height-ADJUST_FACTOR)));
}
IMPLEMENT_TRANSITIONWITHDURATION(CCSlideInTTransition)
//
// SlideInB
@ -526,7 +552,7 @@ CCIntervalAction* CCSlideInBTransition:: action()
return CCMoveBy::actionWithDuration(m_fDuration, ccp(0,s.height-ADJUST_FACTOR));
}
IMPLEMENT_TRANSITIONWITHDURATION(CCSlideInBTransition)
//
// ShrinkGrow Transition
@ -568,7 +594,7 @@ CCIntervalAction* CCShrinkGrowTransition:: easeActionWithAction(CCIntervalAction
// return [EaseElasticOut actionWithAction:action period:0.3f];
}
IMPLEMENT_TRANSITIONWITHDURATION(CCShrinkGrowTransition)
//
// FlipX Transition
@ -626,6 +652,14 @@ void CCFlipXTransition::onEnter()
m_pOutScene->runAction(outA);
}
CCFlipXTransition* CCFlipXTransition::transitionWithDuration(ccTime t, CCScene* s, tOrientation o)
{
CCFlipXTransition* pScene = new CCFlipXTransition();
pScene->initWithDuration(t, s, o);
pScene->autorelease();
return pScene;
}
//
// FlipY Transition
@ -683,7 +717,14 @@ void CCFlipYTransition::onEnter()
}
CCFlipYTransition* CCFlipYTransition::transitionWithDuration(ccTime t, CCScene* s, tOrientation o)
{
CCFlipYTransition* pScene = new CCFlipYTransition();
pScene->initWithDuration(t, s, o);
pScene->autorelease();
return pScene;
}
//
// FlipAngular Transition
@ -740,6 +781,14 @@ void CCFlipAngularTransition::onEnter()
m_pOutScene->runAction(outA);
}
CCFlipAngularTransition* CCFlipAngularTransition::transitionWithDuration(ccTime t, CCScene* s, tOrientation o)
{
CCFlipAngularTransition* pScene = new CCFlipAngularTransition();
pScene->initWithDuration(t, s, o);
pScene->autorelease();
return pScene;
}
//
// ZoomFlipX Transition
@ -805,7 +854,14 @@ void CCZoomFlipXTransition::onEnter()
m_pOutScene->runAction(outA);
}
CCZoomFlipXTransition* CCZoomFlipXTransition::transitionWithDuration(ccTime t, CCScene* s, tOrientation o)
{
CCZoomFlipXTransition* pScene = new CCZoomFlipXTransition();
pScene->initWithDuration(t, s, o);
pScene->autorelease();
return pScene;
}
//
// ZoomFlipY Transition
@ -871,7 +927,14 @@ void CCZoomFlipYTransition::onEnter()
m_pOutScene->runAction(outA);
}
CCZoomFlipYTransition* CCZoomFlipYTransition::transitionWithDuration(ccTime t, CCScene* s, tOrientation o)
{
CCZoomFlipYTransition* pScene = new CCZoomFlipYTransition();
pScene->initWithDuration(t, s, o);
pScene->autorelease();
return pScene;
}
//
// ZoomFlipAngular Transition
@ -940,6 +1003,14 @@ void CCZoomFlipAngularTransition::onEnter()
m_pOutScene->runAction(outA);
}
CCZoomFlipAngularTransition* CCZoomFlipAngularTransition::transitionWithDuration(ccTime t, CCScene* s, tOrientation o)
{
CCZoomFlipAngularTransition* pScene = new CCZoomFlipAngularTransition();
pScene->initWithDuration(t, s, o);
pScene->autorelease();
return pScene;
}
//
// Fade Transition
@ -1095,7 +1166,14 @@ void CCCrossFadeTransition::onExit()
__super::onExit();
}
CCCrossFadeTransition* CCCrossFadeTransition::transitionWithDuration(ccTime d, CCScene* s)
{
CCCrossFadeTransition* Transition = new CCCrossFadeTransition();
Transition->initWithDuration(d, s);
Transition->autorelease();
return Transition;
}
//
// TurnOffTilesTransition
@ -1155,6 +1233,8 @@ CCIntervalAction* CCTurnOffTilesTransition:: easeActionWithAction(CCIntervalActi
return action;
}
IMPLEMENT_TRANSITIONWITHDURATION(CCTurnOffTilesTransition)
//
// SplitCols Transition
//
@ -1205,6 +1285,8 @@ CCIntervalAction* CCSplitColsTransition::easeActionWithAction(CCIntervalAction *
return CCEaseInOut::actionWithAction(action, 3.0f);
}
IMPLEMENT_TRANSITIONWITHDURATION(CCSplitColsTransition)
//
// SplitRows Transition
@ -1223,6 +1305,8 @@ CCIntervalAction* CCSplitRowsTransition::action()
/// @todo return [CCSplitRows actionWithRows:3 duration:duration/2.0f];
}
IMPLEMENT_TRANSITIONWITHDURATION(CCSplitRowsTransition)
//
// FadeTR Transition
//
@ -1274,6 +1358,8 @@ CCIntervalAction* CCFadeTRTransition:: easeActionWithAction(CCIntervalAction* ac
return action;
}
IMPLEMENT_TRANSITIONWITHDURATION(CCFadeTRTransition)
//
// FadeBL Transition
@ -1292,6 +1378,8 @@ CCIntervalAction* CCFadeBLTransition::actionWithSize(ccGridSize size)
/// @todo return [CCFadeOutBLTiles actionWithSize:v duration:duration];
}
IMPLEMENT_TRANSITIONWITHDURATION(CCFadeBLTransition)
//
// FadeUp Transition
//
@ -1308,6 +1396,8 @@ CCIntervalAction* CCFadeUpTransition::actionWithSize(ccGridSize size)
/// @todo return [CCFadeOutUpTiles actionWithSize:v duration:duration];
}
IMPLEMENT_TRANSITIONWITHDURATION(CCFadeUpTransition)
//
// FadeDown Transition
//
@ -1323,4 +1413,7 @@ CCIntervalAction* CCFadeDownTransition::actionWithSize(ccGridSize size)
return NULL;
/// @todo return [CCFadeOutDownTiles actionWithSize:v duration:duration];
}
IMPLEMENT_TRANSITIONWITHDURATION(CCFadeDownTransition)
}//namespace cocos2d

View File

@ -325,6 +325,18 @@
>
</File>
</Filter>
<Filter
Name="TransitionsTest"
>
<File
RelativePath=".\tests\TransitionsTest\TransitionsTest.cpp"
>
</File>
<File
RelativePath=".\tests\TransitionsTest\TransitionsTest.h"
>
</File>
</Filter>
</Filter>
<File
RelativePath=".\test_uphoneUnicodeScript.h"

View File

@ -0,0 +1,440 @@
#include "TransitionsTest.h"
#include "CCDirector.h"
#include "CCSprite.h"
#include "CCMenu.h"
#include "CCLabel.h"
#include "CCTransition.h"
#include "CCRadialTransition.h"
#include "CCPageTurnTransition.h"
#define MAX_LAYER 37
#define TRANSITION_DURATION (1.2f)
static const char s_back1[] = "/NEWPLUS/TDA_DATA/Data/cocos2d_tests/Images/background1.png";
static const char s_back2[] = "/NEWPLUS/TDA_DATA/Data/cocos2d_tests/Images/background2.png";
static const char s_pPathB1[] = "/NEWPLUS/TDA_DATA/Data/cocos2d_tests/Images/b1.png";
static const char s_pPathB2[] = "/NEWPLUS/TDA_DATA/Data/cocos2d_tests/Images/b2.png";
static const char s_pPathR1[] = "/NEWPLUS/TDA_DATA/Data/cocos2d_tests/Images/r1.png";
static const char s_pPathR2[] = "/NEWPLUS/TDA_DATA/Data/cocos2d_tests/Images/r2.png";
static const char s_pPathF1[] = "/NEWPLUS/TDA_DATA/Data/cocos2d_tests/Images/f1.png";
static const char s_pPathF2[] = "/NEWPLUS/TDA_DATA/Data/cocos2d_tests/Images/f2.png";
class FadeWhiteTransition : public CCFadeTransition
{
public:
static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s)
{
return CCFadeTransition::transitionWithDuration(t, s, ccWHITE);
}
};
class FlipXLeftOver : public CCFlipXTransition
{
public:
static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s)
{
return CCFlipXTransition::transitionWithDuration(t, s, kOrientationLeftOver);
}
};
class FlipXRightOver : public CCFlipXTransition
{
public:
static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s)
{
return CCFlipXTransition::transitionWithDuration(t, s, kOrientationRightOver);
}
};
class FlipYUpOver : public CCFlipYTransition
{
public:
static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s)
{
return CCFlipYTransition::transitionWithDuration(t, s, kOrientationUpOver);
}
};
class FlipYDownOver : public CCFlipYTransition
{
public:
static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s)
{
return CCFlipYTransition::transitionWithDuration(t, s, kOrientationDownOver);
}
};
class FlipAngularLeftOver : public CCFlipAngularTransition
{
public:
static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s)
{
return CCFlipAngularTransition::transitionWithDuration(t, s, kOrientationLeftOver);
}
};
class FlipAngularRightOver : public CCFlipAngularTransition
{
public:
static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s)
{
return CCFlipAngularTransition::transitionWithDuration(t, s, kOrientationRightOver);
}
};
class ZoomFlipXLeftOver : public CCZoomFlipXTransition
{
public:
static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s)
{
return CCZoomFlipXTransition::transitionWithDuration(t, s, kOrientationLeftOver);
}
};
class ZoomFlipXRightOver : public CCZoomFlipXTransition
{
public:
static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s)
{
return CCZoomFlipXTransition::transitionWithDuration(t, s, kOrientationRightOver);
}
};
class ZoomFlipYUpOver : public CCZoomFlipYTransition
{
public:
static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s)
{
return CCZoomFlipYTransition::transitionWithDuration(t, s, kOrientationUpOver);
}
};
class ZoomFlipYDownOver : public CCZoomFlipYTransition
{
public:
static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s)
{
return CCZoomFlipYTransition::transitionWithDuration(t, s, kOrientationDownOver);
}
};
class ZoomFlipAngularLeftOver : public CCZoomFlipAngularTransition
{
public:
static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s)
{
return CCZoomFlipAngularTransition::transitionWithDuration(t, s, kOrientationLeftOver);
}
};
class ZoomFlipAngularRightOver : public CCZoomFlipAngularTransition
{
public:
static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s)
{
return CCZoomFlipAngularTransition::transitionWithDuration(t, s, kOrientationRightOver);
}
};
class PageTransitionForward : public CCPageTurnTransition
{
public:
static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s)
{
return CCPageTurnTransition::transitionWithDuration(t, s, false);
}
};
class PageTransitionBackward : public CCPageTurnTransition
{
public:
static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s)
{
return CCPageTurnTransition::transitionWithDuration(t, s, true);
}
};
static std::string transitions[] = {
"JumpZoomTransition",
"CCCrossFadeTransition",
"CCRadialCCWTransition",
"CCRadialCWTransition",
"PageTransitionForward",
"PageTransitionBackward",
"FadeTRTransition",
"FadeBLTransition",
"FadeUpTransition",
"FadeDownTransition",
"TurnOffTilesTransition",
"SplitRowsTransition",
"SplitColsTransition",
"FadeTransition",
"FadeWhiteTransition",
"FlipXLeftOver",
"FlipXRightOver",
"FlipYUpOver",
"FlipYDownOver",
"FlipAngularLeftOver",
"FlipAngularRightOver",
"ZoomFlipXLeftOver",
"ZoomFlipXRightOver",
"ZoomFlipYUpOver",
"ZoomFlipYDownOver",
"ZoomFlipAngularLeftOver",
"ZoomFlipAngularRightOver",
"ShrinkGrowTransition",
"RotoZoomTransition",
"MoveInLTransition",
"MoveInRTransition",
"MoveInTTransition",
"MoveInBTransition",
"SlideInLTransition",
"SlideInRTransition",
"SlideInTTransition",
"SlideInBTransition",
};
static int s_nSceneIdx = 0;
CCTransitionScene* createTransition(int nIndex, ccTime t, CCScene* s)
{
switch(nIndex)
{
case 0: return CCJumpZoomTransition::transitionWithDuration(t, s);
case 1: return CCCrossFadeTransition::transitionWithDuration(t,s);
case 2: return CCRadialCCWTransition::transitionWithDuration(t,s);
case 3: return CCRadialCWTransition::transitionWithDuration(t,s);
case 4: return PageTransitionForward::transitionWithDuration(t, s);
case 5: return PageTransitionBackward::transitionWithDuration(t, s);
case 6: return CCFadeTRTransition::transitionWithDuration(t, s);
case 7: return CCFadeBLTransition::transitionWithDuration(t, s);
case 8: return CCFadeUpTransition::transitionWithDuration(t, s);
case 9: return CCFadeDownTransition::transitionWithDuration(t, s);
case 10: return CCTurnOffTilesTransition::transitionWithDuration(t, s);
case 11: return CCSplitRowsTransition::transitionWithDuration(t, s);
case 12: return CCSplitColsTransition::transitionWithDuration(t, s);
case 13: return CCFadeTransition::transitionWithDuration(t, s);
case 14: return FadeWhiteTransition::transitionWithDuration(t, s);
case 15: return FlipXLeftOver::transitionWithDuration(t, s);
case 16: return FlipXRightOver::transitionWithDuration(t, s);
case 17: return FlipYUpOver::transitionWithDuration(t, s);
case 18: return FlipYDownOver::transitionWithDuration(t, s);
case 19: return FlipAngularLeftOver::transitionWithDuration(t, s);
case 20: return FlipAngularRightOver::transitionWithDuration(t, s);
case 21: return ZoomFlipXLeftOver::transitionWithDuration(t, s);
case 22: return ZoomFlipXRightOver::transitionWithDuration(t, s);
case 23: return ZoomFlipYUpOver::transitionWithDuration(t, s);
case 24: return ZoomFlipYDownOver::transitionWithDuration(t, s);
case 25: return ZoomFlipAngularLeftOver::transitionWithDuration(t, s);
case 26: return ZoomFlipAngularRightOver::transitionWithDuration(t, s);
case 27: return CCShrinkGrowTransition::transitionWithDuration(t, s);
case 28: return CCRotoZoomTransition::transitionWithDuration(t, s);
case 29: return CCMoveInLTransition::transitionWithDuration(t, s);
case 30: return CCMoveInRTransition::transitionWithDuration(t, s);
case 31: return CCMoveInTTransition::transitionWithDuration(t, s);
case 32: return CCMoveInBTransition::transitionWithDuration(t, s);
case 33: return CCSlideInLTransition::transitionWithDuration(t, s);
case 34: return CCSlideInRTransition::transitionWithDuration(t, s);
case 35: return CCSlideInTTransition::transitionWithDuration(t, s);
case 36: return CCSlideInBTransition::transitionWithDuration(t, s);
}
return NULL;
}
CCScene* nextTransition( ccTime t, CCScene* s)
{
s_nSceneIdx++;
s_nSceneIdx = s_nSceneIdx % MAX_LAYER;
CCTransitionScene* pTransition = createTransition(s_nSceneIdx, t, s);
return pTransition;
}
CCScene* backTransition( ccTime t, CCScene* s)
{
s_nSceneIdx--;
int total = MAX_LAYER;
if( s_nSceneIdx < 0 )
s_nSceneIdx += total;
CCTransitionScene* pTransition = createTransition(s_nSceneIdx, t, s);
return pTransition;
}
CCScene* restartTransition( ccTime t, CCScene* s)
{
CCTransitionScene* pTransition = createTransition(s_nSceneIdx, t, s);
return pTransition;
}
void TransitionsTestScene::runThisTest()
{
CCLayer * pLayer = new TestLayer1();
addChild(pLayer);
CCDirector::getSharedDirector()->replaceScene(this);
}
TestLayer1::TestLayer1(void)
{
float x,y;
CGSize size = CCDirector::getSharedDirector()->getWinSize();
x = size.width;
y = size.height;
CCSprite* bg1 = CCSprite::spriteWithFile(s_back1);
bg1->setPosition( CGPointMake(size.width/2, size.height/2) );
addChild(bg1, -1);
CCLabel* title = CCLabel::labelWithString( (transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 );
addChild(title);
title->setColor( ccc3(255,32,32) );
title->setPosition( CGPointMake(x/2, y-100) );
CCLabel* label = CCLabel::labelWithString("SCENE 1", "Marker Felt", 38);
label->setColor( ccc3(16,16,255));
label->setPosition( CGPointMake(x/2,y/2));
addChild( label);
// menu
CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(TestLayer1::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(TestLayer1::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(TestLayer1::nextCallback) );
CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
menu->setPosition( CGPointZero );
item1->setPosition( CGPointMake( size.width/2 - 100,30) );
item2->setPosition( CGPointMake( size.width/2, 30) );
item3->setPosition( CGPointMake( size.width/2 + 100,30) );
addChild(menu, 1);
schedule( schedule_selector(TestLayer1::step), 1.0f);
}
TestLayer1::~TestLayer1(void)
{
}
void TestLayer1::restartCallback(NSObject* pSender)
{
CCScene* s = new TransitionsTestScene();
CCLayer* pLayer = new TestLayer2();
s->addChild(pLayer);
CCDirector::getSharedDirector()->replaceScene( restartTransition(TRANSITION_DURATION, s) );
}
void TestLayer1::nextCallback(NSObject* pSender)
{
CCScene* s = new TransitionsTestScene();
CCLayer* pLayer = new TestLayer2();
s->addChild(pLayer);
CCDirector::getSharedDirector()->replaceScene( nextTransition(TRANSITION_DURATION, s) );
}
void TestLayer1::backCallback(NSObject* pSender)
{
CCScene* s = new TransitionsTestScene();
CCLayer* pLayer = new TestLayer2();
s->addChild(pLayer);
CCDirector::getSharedDirector()->replaceScene( backTransition(TRANSITION_DURATION, s) );
}
void TestLayer1::step(ccTime dt)
{
}
TestLayer2::TestLayer2()
{
float x,y;
CGSize size = CCDirector::getSharedDirector()->getWinSize();
x = size.width;
y = size.height;
CCSprite* bg1 = CCSprite::spriteWithFile(s_back2);
bg1->setPosition( CGPointMake(size.width/2, size.height/2) );
addChild(bg1, -1);
CCLabel* title = CCLabel::labelWithString((transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 );
addChild(title);
title->setColor( ccc3(255,32,32) );
title->setPosition( CGPointMake(x/2, y-100) );
CCLabel* label = CCLabel::labelWithString("SCENE 2", "Marker Felt", 38);
label->setColor( ccc3(16,16,255));
label->setPosition( CGPointMake(x/2,y/2));
addChild( label);
// menu
CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(TestLayer2::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(TestLayer2::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(TestLayer2::nextCallback) );
CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
menu->setPosition( CGPointZero );
item1->setPosition( CGPointMake( x/2 - 100,30) );
item2->setPosition( CGPointMake( x/2, 30) );
item3->setPosition( CGPointMake( x/2 + 100,30) );
addChild(menu, 1);
schedule(schedule_selector(TestLayer2::step), 1.0f);
}
TestLayer2::~TestLayer2()
{
}
void TestLayer2::restartCallback(NSObject* pSender)
{
CCScene* s = CCScene::node();
CCLayer* pLayer = new TestLayer1();
s->addChild(pLayer);
CCDirector::getSharedDirector()->replaceScene( restartTransition(TRANSITION_DURATION, s) );
}
void TestLayer2::nextCallback(NSObject* pSender)
{
CCScene* s = CCScene::node();
CCLayer* pLayer = new TestLayer1();
s->addChild(pLayer);
CCDirector::getSharedDirector()->replaceScene( nextTransition(TRANSITION_DURATION, s) );
}
void TestLayer2::backCallback(NSObject* pSender)
{
CCScene* s = CCScene::node();
CCLayer* pLayer = new TestLayer1();
s->addChild(pLayer);
CCDirector::getSharedDirector()->replaceScene( backTransition(TRANSITION_DURATION, s) );
}
void TestLayer2::step(ccTime dt)
{
}

View File

@ -0,0 +1,40 @@
#ifndef _TRANSITIONS_TEST_H_
#define _TRANSITIONS_TEST_H_
#include "../testBasic.h"
using namespace cocos2d;
class TransitionsTestScene : public TestScene
{
public:
virtual void runThisTest();
};
class TestLayer1 : public CCLayer
{
public:
TestLayer1(void);
~TestLayer1(void);
void restartCallback(NSObject* pSender);
void nextCallback(NSObject* pSender);
void backCallback(NSObject* pSender);
void step(ccTime dt);
};
class TestLayer2 : public CCLayer
{
public:
TestLayer2(void);
~TestLayer2(void);
void restartCallback(NSObject* pSender);
void nextCallback(NSObject* pSender);
void backCallback(NSObject* pSender);
void step(ccTime dt);
};
#endif

View File

@ -15,6 +15,8 @@ static TestScene* CreateTestScene(int nIdx)
{
case TEST_ACTIONS:
pScene = new ActionsTestScene(); break;
case TEST_TRANSITIONS:
pScene = new TransitionsTestScene(); break;
default:
break;
}

View File

@ -32,7 +32,6 @@ TestScene::TestScene()
{
CCLayer* pLayer = new BackToMainMenuLayer();
pLayer->autorelease();
pLayer->retain();
addChild(pLayer);
}

View File

@ -2,35 +2,38 @@
#define _TESTS_H_
#include "ActionsTest/ActionsTest.h"
#include "TransitionsTest/TransitionsTest.h"
enum
{
TEST_TEXTURE2D = 0,
TEST_SPRITE,
TEST_LAYER,
TEST_SCENE,
TEST_FONT,
TEST_MENU,
TEST_ACTIONS,
TEST_ACTIONS_MANAGER,
TEST_INTERVAL,
TEST_TOUCHES,
TEST_PROGRESS_ACTIONS,
TEST_ACTIONS = 0,
TEST_TRANSITIONS,
// TEST_TEXTURE2D,
// TEST_SPRITE,
// TEST_LAYER,
// TEST_SCENE,
// TEST_FONT,
// TEST_MENU,
// TEST_ACTIONS_MANAGER,
// TEST_INTERVAL,
// TEST_TOUCHES,
// TEST_PROGRESS_ACTIONS,
TESTS_COUNT,
};
const std::string g_aTestNames[TESTS_COUNT] = {
"Texture2dTest",
"SpriteTest",
"LayerTest",
"SceneTest",
"FontTest",
"MenuTest",
"ActionsTest",
"ActionManagerTest",
"IntervalTest",
"TouchesTest",
"ProgressActionsTest",
"TransitionsTest",
// "Texture2dTest",
// "SpriteTest",
// "LayerTest",
// "SceneTest",
// "FontTest",
// "MenuTest",
// "ActionManagerTest",
// "IntervalTest",
// "TouchesTest",
// "ProgressActionsTest",
};
#endif