diff --git a/cocos2dx/include/CCPageTurnTransition.h b/cocos2dx/include/CCPageTurnTransition.h index 38e342294c..3f92d59e5b 100644 --- a/cocos2dx/include/CCPageTurnTransition.h +++ b/cocos2dx/include/CCPageTurnTransition.h @@ -39,7 +39,7 @@ namespace cocos2d { * * @since v0.8.2 */ -class CCPageTurnTransition : public CCTransitionScene +class CCX_DLL CCPageTurnTransition : public CCTransitionScene { protected: bool m_bBack; diff --git a/cocos2dx/include/CCRadialTransition.h b/cocos2dx/include/CCRadialTransition.h index 2f751e601d..f04720fed7 100644 --- a/cocos2dx/include/CCRadialTransition.h +++ b/cocos2dx/include/CCRadialTransition.h @@ -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(); }; diff --git a/cocos2dx/include/CCTransition.h b/cocos2dx/include/CCTransition.h index cbabc9f603..0db61bf654 100644 --- a/cocos2dx/include/CCTransition.h +++ b/cocos2dx/include/CCTransition.h @@ -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 diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCRadialTransition.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCRadialTransition.cpp index 9059fb745a..3b3f853614 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCRadialTransition.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCRadialTransition.cpp @@ -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 diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp index 25bef72190..5a2ace7aaa 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp @@ -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 diff --git a/test_uphone/test_uphone.vcproj b/test_uphone/test_uphone.vcproj index aa5d4ec6ec..11dc0b0533 100644 --- a/test_uphone/test_uphone.vcproj +++ b/test_uphone/test_uphone.vcproj @@ -325,6 +325,18 @@ > + + + + + + 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) +{ + +} diff --git a/test_uphone/tests/TransitionsTest/TransitionsTest.h b/test_uphone/tests/TransitionsTest/TransitionsTest.h new file mode 100644 index 0000000000..3b5054af5c --- /dev/null +++ b/test_uphone/tests/TransitionsTest/TransitionsTest.h @@ -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 diff --git a/test_uphone/tests/controller.cpp b/test_uphone/tests/controller.cpp index 4c0bd6083e..71e28cd4e9 100644 --- a/test_uphone/tests/controller.cpp +++ b/test_uphone/tests/controller.cpp @@ -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; } diff --git a/test_uphone/tests/testBasic.cpp b/test_uphone/tests/testBasic.cpp index c526c62067..248be8aa92 100644 --- a/test_uphone/tests/testBasic.cpp +++ b/test_uphone/tests/testBasic.cpp @@ -32,7 +32,6 @@ TestScene::TestScene() { CCLayer* pLayer = new BackToMainMenuLayer(); pLayer->autorelease(); - pLayer->retain(); addChild(pLayer); } diff --git a/test_uphone/tests/tests.h b/test_uphone/tests/tests.h index 3ae4d66a33..3770f0a2ce 100644 --- a/test_uphone/tests/tests.h +++ b/test_uphone/tests/tests.h @@ -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