2012-04-19 14:35:52 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010-2011 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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "CCTransition.h"
|
|
|
|
#include "CCCamera.h"
|
|
|
|
#include "CCPointExtension.h"
|
|
|
|
#include "CCDirector.h"
|
|
|
|
#include "CCTouchDispatcher.h"
|
|
|
|
#include "CCActionInterval.h"
|
|
|
|
#include "CCActionInstant.h"
|
|
|
|
#include "CCActionEase.h"
|
|
|
|
#include "CCActionCamera.h"
|
|
|
|
#include "CCLayer.h"
|
|
|
|
#include "CCActionGrid.h"
|
|
|
|
#include "CCRenderTexture.h"
|
|
|
|
#include "CCActionTiledGrid.h"
|
|
|
|
|
|
|
|
NS_CC_BEGIN
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2011-07-08 15:38:32 +08:00
|
|
|
const unsigned int kSceneFade = 0xFADEFADE;
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
CCTransitionScene::CCTransitionScene()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCTransitionScene::~CCTransitionScene()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pInScene->release();
|
|
|
|
m_pOutScene->release();
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2012-06-14 17:18:05 +08:00
|
|
|
CCTransitionScene * CCTransitionScene::transitionWithDuration(float t, CCScene *scene)
|
|
|
|
{
|
|
|
|
return CCTransitionScene::create(t,scene);
|
|
|
|
}
|
2012-06-14 15:13:16 +08:00
|
|
|
|
|
|
|
CCTransitionScene * CCTransitionScene::create(float t, CCScene *scene)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionScene * pScene = new CCTransitionScene();
|
|
|
|
if(pScene && pScene->initWithDuration(t,scene))
|
|
|
|
{
|
|
|
|
pScene->autorelease();
|
|
|
|
return pScene;
|
|
|
|
}
|
|
|
|
CC_SAFE_DELETE(pScene);
|
|
|
|
return NULL;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
bool CCTransitionScene::initWithDuration(float t, CCScene *scene)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCAssert( scene != NULL, "Argument scene must be non-nil");
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
if (CCScene::init())
|
|
|
|
{
|
|
|
|
m_fDuration = t;
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// retain
|
|
|
|
m_pInScene = scene;
|
|
|
|
m_pInScene->retain();
|
|
|
|
m_pOutScene = CCDirector::sharedDirector()->getRunningScene();
|
2012-06-01 15:54:17 +08:00
|
|
|
if (m_pOutScene == NULL)
|
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
m_pOutScene = CCScene::create();
|
2012-06-01 15:54:17 +08:00
|
|
|
m_pOutScene->init();
|
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pOutScene->retain();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CCAssert( m_pInScene != m_pOutScene, "Incoming scene must be different from the outgoing scene" );
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// disable events while transitions
|
|
|
|
CCDirector* pDirector = CCDirector::sharedDirector();
|
|
|
|
pDirector->getTouchDispatcher()->setDispatchEvents(false);
|
|
|
|
this->sceneOrder();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCTransitionScene::sceneOrder()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_bIsInSceneOnTop = true;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCTransitionScene::draw()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCScene::draw();
|
2011-07-12 11:20:41 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
if( m_bIsInSceneOnTop ) {
|
|
|
|
m_pOutScene->visit();
|
|
|
|
m_pInScene->visit();
|
|
|
|
} else {
|
|
|
|
m_pInScene->visit();
|
|
|
|
m_pOutScene->visit();
|
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCTransitionScene::finish()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
// clean up
|
|
|
|
m_pInScene->setIsVisible(true);
|
|
|
|
m_pInScene->setPosition(ccp(0,0));
|
|
|
|
m_pInScene->setScale(1.0f);
|
|
|
|
m_pInScene->setRotation(0.0f);
|
|
|
|
m_pInScene->getCamera()->restore();
|
|
|
|
|
|
|
|
m_pOutScene->setIsVisible(false);
|
|
|
|
m_pOutScene->setPosition(ccp(0,0));
|
|
|
|
m_pOutScene->setScale(1.0f);
|
|
|
|
m_pOutScene->setRotation(0.0f);
|
|
|
|
m_pOutScene->getCamera()->restore();
|
2010-07-21 11:13:32 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
//[self schedule:@selector(setNewScene:) interval:0];
|
|
|
|
this->schedule(schedule_selector(CCTransitionScene::setNewScene), 0);
|
2010-07-14 16:30:25 +08:00
|
|
|
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void CCTransitionScene::setNewScene(float dt)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2011-06-10 17:51:37 +08:00
|
|
|
CC_UNUSED_PARAM(dt);
|
2012-04-19 14:35:52 +08:00
|
|
|
// [self unschedule:_cmd];
|
|
|
|
// "_cmd" is a local variable automatically defined in a method
|
|
|
|
// that contains the selector for the method
|
|
|
|
this->unschedule(schedule_selector(CCTransitionScene::setNewScene));
|
|
|
|
CCDirector *director = CCDirector::sharedDirector();
|
|
|
|
// Before replacing, save the "send cleanup to scene"
|
|
|
|
m_bIsSendCleanupToScene = director->isSendCleanupToScene();
|
|
|
|
director->replaceScene(m_pInScene);
|
|
|
|
// enable events while transitions
|
|
|
|
director->getTouchDispatcher()->setDispatchEvents(true);
|
|
|
|
// issue #267
|
|
|
|
m_pOutScene->setIsVisible(true);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCTransitionScene::hideOutShowIn()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pInScene->setIsVisible(true);
|
|
|
|
m_pOutScene->setIsVisible(false);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// custom onEnter
|
|
|
|
void CCTransitionScene::onEnter()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCScene::onEnter();
|
|
|
|
m_pInScene->onEnter();
|
|
|
|
// outScene should not receive the onEnter callback
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// custom onExit
|
|
|
|
void CCTransitionScene::onExit()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCScene::onExit();
|
|
|
|
m_pOutScene->onExit();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// inScene should not receive the onExit callback
|
|
|
|
// only the onEnterTransitionDidFinish
|
|
|
|
m_pInScene->onEnterTransitionDidFinish();
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// custom cleanup
|
|
|
|
void CCTransitionScene::cleanup()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCScene::cleanup();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
if( m_bIsSendCleanupToScene )
|
|
|
|
m_pOutScene->cleanup();
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Oriented Transition
|
|
|
|
//
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionSceneOriented::CCTransitionSceneOriented()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionSceneOriented::~CCTransitionSceneOriented()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-06-14 17:18:05 +08:00
|
|
|
CCTransitionSceneOriented * CCTransitionSceneOriented::transitionWithDuration(float t, CCScene *scene, tOrientation orientation)
|
|
|
|
{
|
|
|
|
return CCTransitionSceneOriented::create(t,scene,orientation);
|
|
|
|
}
|
2012-06-14 15:13:16 +08:00
|
|
|
|
|
|
|
CCTransitionSceneOriented * CCTransitionSceneOriented::create(float t, CCScene *scene, tOrientation orientation)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionSceneOriented * pScene = new CCTransitionSceneOriented();
|
|
|
|
pScene->initWithDuration(t,scene,orientation);
|
|
|
|
pScene->autorelease();
|
|
|
|
return pScene;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
bool CCTransitionSceneOriented::initWithDuration(float t, CCScene *scene, tOrientation orientation)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
if ( CCTransitionScene::initWithDuration(t, scene) )
|
|
|
|
{
|
|
|
|
m_eOrientation = orientation;
|
|
|
|
}
|
|
|
|
return true;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// RotoZoom
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionRotoZoom::CCTransitionRotoZoom()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionRotoZoom::~CCTransitionRotoZoom()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionRotoZoom:: onEnter()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionScene::onEnter();
|
|
|
|
|
|
|
|
m_pInScene->setScale(0.001f);
|
|
|
|
m_pOutScene->setScale(1.0f);
|
|
|
|
|
|
|
|
m_pInScene->setAnchorPoint(ccp(0.5f, 0.5f));
|
|
|
|
m_pOutScene->setAnchorPoint(ccp(0.5f, 0.5f));
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval *rotozoom = (CCActionInterval*)(CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCSpawn::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCScaleBy::create(m_fDuration/2, 0.001f),
|
|
|
|
CCRotateBy::create(m_fDuration/2, 360 * 2),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
),
|
2012-06-14 15:13:16 +08:00
|
|
|
CCDelayTime::create(m_fDuration/2),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
));
|
|
|
|
|
|
|
|
m_pOutScene->runAction(rotozoom);
|
|
|
|
m_pInScene->runAction
|
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
|
|
|
rotozoom->reverse(),
|
2012-06-14 15:13:16 +08:00
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
)
|
|
|
|
);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// JumpZoom
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionJumpZoom::CCTransitionJumpZoom()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionJumpZoom::~CCTransitionJumpZoom()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionJumpZoom::onEnter()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionScene::onEnter();
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pInScene->setScale(0.5f);
|
|
|
|
m_pInScene->setPosition(ccp(s.width, 0));
|
|
|
|
m_pInScene->setAnchorPoint(ccp(0.5f, 0.5f));
|
|
|
|
m_pOutScene->setAnchorPoint(ccp(0.5f, 0.5f));
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval *jump = CCJumpBy::create(m_fDuration/4, ccp(-s.width,0), s.width/4, 2);
|
|
|
|
CCActionInterval *scaleIn = CCScaleTo::create(m_fDuration/4, 1.0f);
|
|
|
|
CCActionInterval *scaleOut = CCScaleTo::create(m_fDuration/4, 0.5f);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval *jumpZoomOut = (CCActionInterval*)(CCSequence::create(scaleOut, jump, NULL));
|
|
|
|
CCActionInterval *jumpZoomIn = (CCActionInterval*)(CCSequence::create(jump, scaleIn, NULL));
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval *delay = CCDelayTime::create(m_fDuration/2);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pOutScene->runAction(jumpZoomOut);
|
|
|
|
m_pInScene->runAction
|
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
|
|
|
delay,
|
|
|
|
jumpZoomIn,
|
2012-06-14 15:13:16 +08:00
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
)
|
|
|
|
);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// MoveInL
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionMoveInL::CCTransitionMoveInL()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionMoveInL::~CCTransitionMoveInL()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionMoveInL::onEnter()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionScene::onEnter();
|
|
|
|
this->initScenes();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval *a = this->action();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pInScene->runAction
|
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
|
|
|
this->easeActionWithAction(a),
|
2012-06-14 15:13:16 +08:00
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
)
|
|
|
|
);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCActionInterval* CCTransitionMoveInL::action()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
return CCMoveTo::create(m_fDuration, ccp(0,0));
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCActionInterval* CCTransitionMoveInL::easeActionWithAction(CCActionInterval* action)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
return CCEaseOut::create(action, 2.0f);
|
2012-04-19 14:35:52 +08:00
|
|
|
// return [EaseElasticOut actionWithAction:action period:0.4f];
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionMoveInL::initScenes()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
m_pInScene->setPosition( ccp(-s.width,0) );
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// MoveInR
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionMoveInR::CCTransitionMoveInR()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionMoveInR::~CCTransitionMoveInR()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionMoveInR::initScenes()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
m_pInScene->setPosition( ccp(s.width,0) );
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// MoveInT
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionMoveInT::CCTransitionMoveInT()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionMoveInT::~CCTransitionMoveInT()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionMoveInT::initScenes()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
m_pInScene->setPosition( ccp(0,s.height) );
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// MoveInB
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionMoveInB::CCTransitionMoveInB()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionMoveInB::~CCTransitionMoveInB()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionMoveInB::initScenes()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
m_pInScene->setPosition( ccp(0,-s.height) );
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// SlideInL
|
|
|
|
//
|
|
|
|
|
|
|
|
// The adjust factor is needed to prevent issue #442
|
|
|
|
// One solution is to use DONT_RENDER_IN_SUBPIXELS images, but NO
|
|
|
|
// The other issue is that in some transitions (and I don't know why)
|
|
|
|
// the order should be reversed (In in top of Out or vice-versa).
|
|
|
|
#define ADJUST_FACTOR 0.5f
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionSlideInL::CCTransitionSlideInL()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionSlideInL::~CCTransitionSlideInL()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionSlideInL::onEnter()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionScene::onEnter();
|
|
|
|
this->initScenes();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval *in = this->action();
|
|
|
|
CCActionInterval *out = this->action();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval* inAction = easeActionWithAction(in);
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* outAction = (CCActionInterval*)CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
|
|
|
easeActionWithAction(out),
|
2012-06-14 15:13:16 +08:00
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
);
|
|
|
|
m_pInScene->runAction(inAction);
|
|
|
|
m_pOutScene->runAction(outAction);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionSlideInL::sceneOrder()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_bIsInSceneOnTop = false;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionSlideInL:: initScenes()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
m_pInScene->setPosition( ccp(-(s.width-ADJUST_FACTOR),0) );
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCActionInterval* CCTransitionSlideInL::action()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
2012-06-14 15:13:16 +08:00
|
|
|
return CCMoveBy::create(m_fDuration, ccp(s.width-ADJUST_FACTOR,0));
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCActionInterval* CCTransitionSlideInL::easeActionWithAction(CCActionInterval* action)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
return CCEaseOut::create(action, 2.0f);
|
2012-04-19 14:35:52 +08:00
|
|
|
// return [EaseElasticOut actionWithAction:action period:0.4f];
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// SlideInR
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionSlideInR::CCTransitionSlideInR()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionSlideInR::~CCTransitionSlideInR()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionSlideInR::sceneOrder()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_bIsInSceneOnTop = true;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionSlideInR::initScenes()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
m_pInScene->setPosition( ccp(s.width-ADJUST_FACTOR,0) );
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCActionInterval* CCTransitionSlideInR:: action()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
2012-06-14 15:13:16 +08:00
|
|
|
return CCMoveBy::create(m_fDuration, ccp(-(s.width-ADJUST_FACTOR),0));
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// SlideInT
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionSlideInT::CCTransitionSlideInT()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionSlideInT::~CCTransitionSlideInT()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionSlideInT::sceneOrder()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_bIsInSceneOnTop = false;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionSlideInT::initScenes()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
m_pInScene->setPosition( ccp(0,s.height-ADJUST_FACTOR) );
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCActionInterval* CCTransitionSlideInT::action()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
2012-06-14 15:13:16 +08:00
|
|
|
return CCMoveBy::create(m_fDuration, ccp(0,-(s.height-ADJUST_FACTOR)));
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// SlideInB
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionSlideInB::CCTransitionSlideInB()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionSlideInB::~CCTransitionSlideInB()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionSlideInB::sceneOrder()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_bIsInSceneOnTop = true;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionSlideInB:: initScenes()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
m_pInScene->setPosition( ccp(0,-(s.height-ADJUST_FACTOR)) );
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCActionInterval* CCTransitionSlideInB:: action()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
2012-06-14 15:13:16 +08:00
|
|
|
return CCMoveBy::create(m_fDuration, ccp(0,s.height-ADJUST_FACTOR));
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// ShrinkGrow Transition
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionShrinkGrow::CCTransitionShrinkGrow()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionShrinkGrow::~CCTransitionShrinkGrow()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionShrinkGrow::onEnter()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionScene::onEnter();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pInScene->setScale(0.001f);
|
|
|
|
m_pOutScene->setScale(1.0f);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pInScene->setAnchorPoint(ccp(2/3.0f,0.5f));
|
|
|
|
m_pOutScene->setAnchorPoint(ccp(1/3.0f,0.5f));
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* scaleOut = CCScaleTo::create(m_fDuration, 0.01f);
|
|
|
|
CCActionInterval* scaleIn = CCScaleTo::create(m_fDuration, 1.0f);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pInScene->runAction(this->easeActionWithAction(scaleIn));
|
|
|
|
m_pOutScene->runAction
|
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
|
|
|
this->easeActionWithAction(scaleOut),
|
2012-06-14 15:13:16 +08:00
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
)
|
|
|
|
);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCActionInterval* CCTransitionShrinkGrow:: easeActionWithAction(CCActionInterval* action)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
return CCEaseOut::create(action, 2.0f);
|
2012-04-19 14:35:52 +08:00
|
|
|
// return [EaseElasticOut actionWithAction:action period:0.3f];
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// FlipX Transition
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFlipX::CCTransitionFlipX()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFlipX::~CCTransitionFlipX()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionFlipX::onEnter()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionSceneOriented::onEnter();
|
|
|
|
|
|
|
|
CCActionInterval *inA, *outA;
|
|
|
|
m_pInScene->setIsVisible(false);
|
|
|
|
|
|
|
|
float inDeltaZ, inAngleZ;
|
|
|
|
float outDeltaZ, outAngleZ;
|
|
|
|
|
|
|
|
if( m_eOrientation == kOrientationRightOver )
|
|
|
|
{
|
|
|
|
inDeltaZ = 90;
|
|
|
|
inAngleZ = 270;
|
|
|
|
outDeltaZ = 90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inDeltaZ = -90;
|
|
|
|
inAngleZ = 90;
|
|
|
|
outDeltaZ = -90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
inA = (CCActionInterval*)CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCDelayTime::create(m_fDuration/2),
|
|
|
|
CCShow::create(),
|
|
|
|
CCOrbitCamera::create(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, 0, 0),
|
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
outA = (CCActionInterval *)CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCOrbitCamera::create(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 0, 0),
|
|
|
|
CCHide::create(),
|
|
|
|
CCDelayTime::create(m_fDuration/2),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
m_pInScene->runAction(inA);
|
|
|
|
m_pOutScene->runAction(outA);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2012-06-14 17:18:05 +08:00
|
|
|
CCTransitionFlipX* CCTransitionFlipX::transitionWithDuration(float t, CCScene* s, tOrientation o)
|
|
|
|
{
|
|
|
|
return CCTransitionFlipX::create(t, s, o);
|
|
|
|
}
|
2012-06-14 15:13:16 +08:00
|
|
|
|
|
|
|
CCTransitionFlipX* CCTransitionFlipX::create(float t, CCScene* s, tOrientation o)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFlipX* pScene = new CCTransitionFlipX();
|
2010-08-20 14:35:37 +08:00
|
|
|
pScene->initWithDuration(t, s, o);
|
|
|
|
pScene->autorelease();
|
|
|
|
|
|
|
|
return pScene;
|
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// FlipY Transition
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFlipY::CCTransitionFlipY()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFlipY::~CCTransitionFlipY()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionFlipY::onEnter()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionSceneOriented::onEnter();
|
|
|
|
|
|
|
|
CCActionInterval *inA, *outA;
|
|
|
|
m_pInScene->setIsVisible(false);
|
|
|
|
|
|
|
|
float inDeltaZ, inAngleZ;
|
|
|
|
float outDeltaZ, outAngleZ;
|
|
|
|
|
|
|
|
if( m_eOrientation == kOrientationUpOver )
|
|
|
|
{
|
|
|
|
inDeltaZ = 90;
|
|
|
|
inAngleZ = 270;
|
|
|
|
outDeltaZ = 90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inDeltaZ = -90;
|
|
|
|
inAngleZ = 90;
|
|
|
|
outDeltaZ = -90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
inA = (CCActionInterval*)CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCDelayTime::create(m_fDuration/2),
|
|
|
|
CCShow::create(),
|
|
|
|
CCOrbitCamera::create(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, 90, 0),
|
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
);
|
2012-06-14 15:13:16 +08:00
|
|
|
outA = (CCActionInterval*)CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCOrbitCamera::create(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 90, 0),
|
|
|
|
CCHide::create(),
|
|
|
|
CCDelayTime::create(m_fDuration/2),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
m_pInScene->runAction(inA);
|
|
|
|
m_pOutScene->runAction(outA);
|
2010-08-18 11:06:48 +08:00
|
|
|
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2012-06-14 17:18:05 +08:00
|
|
|
CCTransitionFlipY* CCTransitionFlipY::transitionWithDuration(float t, CCScene* s, tOrientation o)
|
|
|
|
{
|
|
|
|
return CCTransitionFlipY::create(t, s, o);
|
|
|
|
}
|
2012-06-14 15:13:16 +08:00
|
|
|
|
|
|
|
CCTransitionFlipY* CCTransitionFlipY::create(float t, CCScene* s, tOrientation o)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFlipY* pScene = new CCTransitionFlipY();
|
2010-08-20 14:35:37 +08:00
|
|
|
pScene->initWithDuration(t, s, o);
|
|
|
|
pScene->autorelease();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-20 14:35:37 +08:00
|
|
|
return pScene;
|
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// FlipAngular Transition
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFlipAngular::CCTransitionFlipAngular()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFlipAngular::~CCTransitionFlipAngular()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionFlipAngular::onEnter()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionSceneOriented::onEnter();
|
|
|
|
|
|
|
|
CCActionInterval *inA, *outA;
|
|
|
|
m_pInScene->setIsVisible(false);
|
|
|
|
|
|
|
|
float inDeltaZ, inAngleZ;
|
|
|
|
float outDeltaZ, outAngleZ;
|
|
|
|
|
|
|
|
if( m_eOrientation == kOrientationRightOver )
|
|
|
|
{
|
|
|
|
inDeltaZ = 90;
|
|
|
|
inAngleZ = 270;
|
|
|
|
outDeltaZ = 90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inDeltaZ = -90;
|
|
|
|
inAngleZ = 90;
|
|
|
|
outDeltaZ = -90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
inA = (CCActionInterval *)CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCDelayTime::create(m_fDuration/2),
|
|
|
|
CCShow::create(),
|
|
|
|
CCOrbitCamera::create(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, -45, 0),
|
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
);
|
2012-06-14 15:13:16 +08:00
|
|
|
outA = (CCActionInterval *)CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCOrbitCamera::create(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 45, 0),
|
|
|
|
CCHide::create(),
|
|
|
|
CCDelayTime::create(m_fDuration/2),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
m_pInScene->runAction(inA);
|
|
|
|
m_pOutScene->runAction(outA);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2012-06-14 17:29:23 +08:00
|
|
|
CCTransitionFlipAngular* CCTransitionFlipAngular::transitionWithDuration(float t, CCScene* s, tOrientation o)
|
|
|
|
{
|
|
|
|
return CCTransitionFlipAngular::create(t, s, o);
|
|
|
|
}
|
2012-06-14 15:13:16 +08:00
|
|
|
|
|
|
|
CCTransitionFlipAngular* CCTransitionFlipAngular::create(float t, CCScene* s, tOrientation o)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFlipAngular* pScene = new CCTransitionFlipAngular();
|
2010-08-20 14:35:37 +08:00
|
|
|
pScene->initWithDuration(t, s, o);
|
|
|
|
pScene->autorelease();
|
|
|
|
|
|
|
|
return pScene;
|
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// ZoomFlipX Transition
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionZoomFlipX::CCTransitionZoomFlipX()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionZoomFlipX::~CCTransitionZoomFlipX()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionZoomFlipX::onEnter()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionSceneOriented::onEnter();
|
|
|
|
|
|
|
|
CCActionInterval *inA, *outA;
|
|
|
|
m_pInScene->setIsVisible(false);
|
|
|
|
|
|
|
|
float inDeltaZ, inAngleZ;
|
|
|
|
float outDeltaZ, outAngleZ;
|
|
|
|
|
|
|
|
if( m_eOrientation == kOrientationRightOver ) {
|
|
|
|
inDeltaZ = 90;
|
|
|
|
inAngleZ = 270;
|
|
|
|
outDeltaZ = 90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inDeltaZ = -90;
|
|
|
|
inAngleZ = 90;
|
|
|
|
outDeltaZ = -90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
}
|
2012-06-14 15:13:16 +08:00
|
|
|
inA = (CCActionInterval *)CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCDelayTime::create(m_fDuration/2),
|
|
|
|
CCSpawn::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCOrbitCamera::create(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, 0, 0),
|
|
|
|
CCScaleTo::create(m_fDuration/2, 1),
|
|
|
|
CCShow::create(),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
),
|
2012-06-14 15:13:16 +08:00
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
);
|
2012-06-14 15:13:16 +08:00
|
|
|
outA = (CCActionInterval *)CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCSpawn::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCOrbitCamera::create(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 0, 0),
|
|
|
|
CCScaleTo::create(m_fDuration/2, 0.5f),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
),
|
2012-06-14 15:13:16 +08:00
|
|
|
CCHide::create(),
|
|
|
|
CCDelayTime::create(m_fDuration/2),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
m_pInScene->setScale(0.5f);
|
|
|
|
m_pInScene->runAction(inA);
|
|
|
|
m_pOutScene->runAction(outA);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2012-06-14 17:18:05 +08:00
|
|
|
CCTransitionZoomFlipX* CCTransitionZoomFlipX::transitionWithDuration(float t, CCScene* s, tOrientation o)
|
|
|
|
{
|
|
|
|
return CCTransitionZoomFlipX::create(t, s, o);
|
|
|
|
}
|
2012-06-14 15:13:16 +08:00
|
|
|
|
|
|
|
CCTransitionZoomFlipX* CCTransitionZoomFlipX::create(float t, CCScene* s, tOrientation o)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionZoomFlipX* pScene = new CCTransitionZoomFlipX();
|
2010-08-20 14:35:37 +08:00
|
|
|
pScene->initWithDuration(t, s, o);
|
|
|
|
pScene->autorelease();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-20 14:35:37 +08:00
|
|
|
return pScene;
|
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// ZoomFlipY Transition
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionZoomFlipY::CCTransitionZoomFlipY()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionZoomFlipY::~CCTransitionZoomFlipY()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionZoomFlipY::onEnter()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionSceneOriented::onEnter();
|
|
|
|
|
|
|
|
CCActionInterval *inA, *outA;
|
|
|
|
m_pInScene->setIsVisible(false);
|
|
|
|
|
|
|
|
float inDeltaZ, inAngleZ;
|
|
|
|
float outDeltaZ, outAngleZ;
|
|
|
|
|
|
|
|
if( m_eOrientation== kOrientationUpOver ) {
|
|
|
|
inDeltaZ = 90;
|
|
|
|
inAngleZ = 270;
|
|
|
|
outDeltaZ = 90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
} else {
|
|
|
|
inDeltaZ = -90;
|
|
|
|
inAngleZ = 90;
|
|
|
|
outDeltaZ = -90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
inA = (CCActionInterval *)CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCDelayTime::create(m_fDuration/2),
|
|
|
|
CCSpawn::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCOrbitCamera::create(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, 90, 0),
|
|
|
|
CCScaleTo::create(m_fDuration/2, 1),
|
|
|
|
CCShow::create(),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
),
|
2012-06-14 15:13:16 +08:00
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
outA = (CCActionInterval *)CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCSpawn::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCOrbitCamera::create(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 90, 0),
|
|
|
|
CCScaleTo::create(m_fDuration/2, 0.5f),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
),
|
2012-06-14 15:13:16 +08:00
|
|
|
CCHide::create(),
|
|
|
|
CCDelayTime::create(m_fDuration/2),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
m_pInScene->setScale(0.5f);
|
|
|
|
m_pInScene->runAction(inA);
|
|
|
|
m_pOutScene->runAction(outA);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2012-06-14 17:18:05 +08:00
|
|
|
CCTransitionZoomFlipY* CCTransitionZoomFlipY::transitionWithDuration(float t, CCScene* s, tOrientation o)
|
|
|
|
{
|
|
|
|
return CCTransitionZoomFlipY::create(t, s, o);
|
|
|
|
}
|
2012-06-14 15:13:16 +08:00
|
|
|
|
|
|
|
CCTransitionZoomFlipY* CCTransitionZoomFlipY::create(float t, CCScene* s, tOrientation o)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionZoomFlipY* pScene = new CCTransitionZoomFlipY();
|
2010-08-20 14:35:37 +08:00
|
|
|
pScene->initWithDuration(t, s, o);
|
|
|
|
pScene->autorelease();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-20 14:35:37 +08:00
|
|
|
return pScene;
|
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// ZoomFlipAngular Transition
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionZoomFlipAngular::CCTransitionZoomFlipAngular()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionZoomFlipAngular::~CCTransitionZoomFlipAngular()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionZoomFlipAngular::onEnter()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionSceneOriented::onEnter();
|
|
|
|
|
|
|
|
CCActionInterval *inA, *outA;
|
|
|
|
m_pInScene->setIsVisible(false);
|
|
|
|
|
|
|
|
float inDeltaZ, inAngleZ;
|
|
|
|
float outDeltaZ, outAngleZ;
|
|
|
|
|
|
|
|
if( m_eOrientation == kOrientationRightOver ) {
|
|
|
|
inDeltaZ = 90;
|
|
|
|
inAngleZ = 270;
|
|
|
|
outDeltaZ = 90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inDeltaZ = -90;
|
|
|
|
inAngleZ = 90;
|
|
|
|
outDeltaZ = -90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
inA = (CCActionInterval *)CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCDelayTime::create(m_fDuration/2),
|
|
|
|
CCSpawn::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCOrbitCamera::create(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, -45, 0),
|
|
|
|
CCScaleTo::create(m_fDuration/2, 1),
|
|
|
|
CCShow::create(),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
),
|
2012-06-14 15:13:16 +08:00
|
|
|
CCShow::create(),
|
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
);
|
2012-06-14 15:13:16 +08:00
|
|
|
outA = (CCActionInterval *)CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCSpawn::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCOrbitCamera::create(m_fDuration/2, 1, 0 , outAngleZ, outDeltaZ, 45, 0),
|
|
|
|
CCScaleTo::create(m_fDuration/2, 0.5f),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
),
|
2012-06-14 15:13:16 +08:00
|
|
|
CCHide::create(),
|
|
|
|
CCDelayTime::create(m_fDuration/2),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
m_pInScene->setScale(0.5f);
|
|
|
|
m_pInScene->runAction(inA);
|
|
|
|
m_pOutScene->runAction(outA);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2012-06-14 17:18:05 +08:00
|
|
|
CCTransitionZoomFlipAngular* CCTransitionZoomFlipAngular::transitionWithDuration(float t, CCScene* s, tOrientation o)
|
|
|
|
{
|
|
|
|
return CCTransitionZoomFlipAngular::create(t, s, o);
|
|
|
|
}
|
2012-06-14 15:13:16 +08:00
|
|
|
|
|
|
|
CCTransitionZoomFlipAngular* CCTransitionZoomFlipAngular::create(float t, CCScene* s, tOrientation o)
|
2010-08-20 14:35:37 +08:00
|
|
|
{
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionZoomFlipAngular* pScene = new CCTransitionZoomFlipAngular();
|
2010-08-20 14:35:37 +08:00
|
|
|
pScene->initWithDuration(t, s, o);
|
|
|
|
pScene->autorelease();
|
|
|
|
|
|
|
|
return pScene;
|
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Fade Transition
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFade::CCTransitionFade()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFade::~CCTransitionFade()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-06-14 17:18:05 +08:00
|
|
|
CCTransitionFade * CCTransitionFade::transitionWithDuration(float duration, CCScene *scene, const ccColor3B& color)
|
|
|
|
{
|
|
|
|
return CCTransitionFade::create(duration, scene, color);
|
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCTransitionFade * CCTransitionFade::create(float duration, CCScene *scene, const ccColor3B& color)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionFade * pTransition = new CCTransitionFade();
|
|
|
|
pTransition->initWithDuration(duration, scene, color);
|
|
|
|
pTransition->autorelease();
|
|
|
|
return pTransition;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
bool CCTransitionFade::initWithDuration(float duration, CCScene *scene, const ccColor3B& color)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
if (CCTransitionScene::initWithDuration(duration, scene))
|
|
|
|
{
|
|
|
|
m_tColor.r = color.r;
|
|
|
|
m_tColor.g = color.g;
|
|
|
|
m_tColor.b = color.b;
|
|
|
|
m_tColor.a = 0;
|
|
|
|
}
|
|
|
|
return true;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
bool CCTransitionFade::initWithDuration(float t, CCScene *scene)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
this->initWithDuration(t, scene, ccBLACK);
|
|
|
|
return true;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionFade :: onEnter()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionScene::onEnter();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLayerColor* l = CCLayerColor::create(m_tColor);
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pInScene->setIsVisible(false);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(l, 2, kSceneFade);
|
|
|
|
CCNode* f = getChildByTag(kSceneFade);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* a = (CCActionInterval *)CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFadeIn::create(m_fDuration/2),
|
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::hideOutShowIn)),//CCCallFunc::create:self selector:@selector(hideOutShowIn)],
|
|
|
|
CCFadeOut::create(m_fDuration/2),
|
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), //:self selector:@selector(finish)],
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
);
|
|
|
|
f->runAction(a);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionFade::onExit()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionScene::onExit();
|
|
|
|
this->removeChildByTag(kSceneFade, false);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Cross Fade Transition
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionCrossFade::CCTransitionCrossFade()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionCrossFade::~CCTransitionCrossFade()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionCrossFade:: draw()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
// override draw since both scenes (textures) are rendered in 1 scene
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionCrossFade::onEnter()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionScene::onEnter();
|
|
|
|
|
|
|
|
// create a transparent color layer
|
|
|
|
// in which we are going to add our rendertextures
|
|
|
|
ccColor4B color = {0,0,0,0};
|
|
|
|
CCSize size = CCDirector::sharedDirector()->getWinSize();
|
2012-06-14 15:13:16 +08:00
|
|
|
CCLayerColor* layer = CCLayerColor::create(color);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// create the first render texture for inScene
|
2012-06-14 15:13:16 +08:00
|
|
|
CCRenderTexture* inTexture = CCRenderTexture::create((int)size.width, (int)size.height);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
if (NULL == inTexture)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
inTexture->getSprite()->setAnchorPoint( ccp(0.5f,0.5f) );
|
|
|
|
inTexture->setPosition( ccp(size.width/2, size.height/2) );
|
|
|
|
inTexture->setAnchorPoint( ccp(0.5f,0.5f) );
|
|
|
|
|
|
|
|
// render inScene to its texturebuffer
|
|
|
|
inTexture->begin();
|
|
|
|
m_pInScene->visit();
|
|
|
|
inTexture->end();
|
|
|
|
|
|
|
|
// create the second render texture for outScene
|
2012-06-14 15:13:16 +08:00
|
|
|
CCRenderTexture* outTexture = CCRenderTexture::create((int)size.width, (int)size.height);
|
2012-04-19 14:35:52 +08:00
|
|
|
outTexture->getSprite()->setAnchorPoint( ccp(0.5f,0.5f) );
|
|
|
|
outTexture->setPosition( ccp(size.width/2, size.height/2) );
|
|
|
|
outTexture->setAnchorPoint( ccp(0.5f,0.5f) );
|
|
|
|
|
|
|
|
// render outScene to its texturebuffer
|
|
|
|
outTexture->begin();
|
|
|
|
m_pOutScene->visit();
|
|
|
|
outTexture->end();
|
|
|
|
|
|
|
|
// create blend functions
|
|
|
|
|
|
|
|
ccBlendFunc blend1 = {GL_ONE, GL_ONE}; // inScene will lay on background and will not be used with alpha
|
|
|
|
ccBlendFunc blend2 = {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}; // we are going to blend outScene via alpha
|
|
|
|
|
|
|
|
// set blendfunctions
|
|
|
|
inTexture->getSprite()->setBlendFunc(blend1);
|
|
|
|
outTexture->getSprite()->setBlendFunc(blend2);
|
|
|
|
|
|
|
|
// add render textures to the layer
|
|
|
|
layer->addChild(inTexture);
|
|
|
|
layer->addChild(outTexture);
|
|
|
|
|
|
|
|
// initial opacity:
|
|
|
|
inTexture->getSprite()->setOpacity(255);
|
|
|
|
outTexture->getSprite()->setOpacity(255);
|
|
|
|
|
|
|
|
// create the blend action
|
2012-06-14 15:13:16 +08:00
|
|
|
CCAction* layerAction = CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCFadeTo::create(m_fDuration, 0),
|
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::hideOutShowIn)),
|
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// run the blend action
|
|
|
|
outTexture->getSprite()->runAction( layerAction );
|
|
|
|
|
|
|
|
// add the layer (which contains our two rendertextures) to the scene
|
|
|
|
addChild(layer, 2, kSceneFade);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// clean up on exit
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionCrossFade::onExit()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
// remove our layer and release all containing objects
|
|
|
|
this->removeChildByTag(kSceneFade, false);
|
|
|
|
CCTransitionScene::onExit();
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// TurnOffTilesTransition
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionTurnOffTiles::CCTransitionTurnOffTiles()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionTurnOffTiles::~CCTransitionTurnOffTiles()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// override addScenes, and change the order
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionTurnOffTiles::sceneOrder()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_bIsInSceneOnTop = false;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionTurnOffTiles::onEnter()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionScene::onEnter();
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
float aspect = s.width / s.height;
|
|
|
|
int x = (int)(12 * aspect);
|
|
|
|
int y = 12;
|
2010-08-18 11:06:48 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCTurnOffTiles* toff = CCTurnOffTiles::create( ccg(x,y), m_fDuration);
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval* action = easeActionWithAction(toff);
|
|
|
|
m_pOutScene->runAction
|
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
|
|
|
action,
|
2012-06-14 15:13:16 +08:00
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
CCStopGrid::create(),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
)
|
|
|
|
);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCActionInterval* CCTransitionTurnOffTiles:: easeActionWithAction(CCActionInterval* action)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return action;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// SplitCols Transition
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionSplitCols::CCTransitionSplitCols()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionSplitCols::~CCTransitionSplitCols()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionSplitCols::onEnter()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionScene::onEnter();
|
|
|
|
m_pInScene->setIsVisible(false);
|
2010-08-18 11:06:48 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval* split = action();
|
2012-06-14 15:13:16 +08:00
|
|
|
CCActionInterval* seq = (CCActionInterval*)CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
|
|
|
split,
|
2012-06-14 15:13:16 +08:00
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::hideOutShowIn)),
|
2012-04-19 14:35:52 +08:00
|
|
|
split->reverse(),
|
|
|
|
NULL
|
|
|
|
);
|
2010-08-18 11:06:48 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
this->runAction
|
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
|
|
|
easeActionWithAction(seq),
|
2012-06-14 15:13:16 +08:00
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
CCStopGrid::create(),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
)
|
|
|
|
);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCActionInterval* CCTransitionSplitCols:: action()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
return CCSplitCols::create(3, m_fDuration/2.0f);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCActionInterval* CCTransitionSplitCols::easeActionWithAction(CCActionInterval * action)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
return CCEaseInOut::create(action, 3.0f);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// SplitRows Transition
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionSplitRows::CCTransitionSplitRows()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionSplitRows::~CCTransitionSplitRows()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCActionInterval* CCTransitionSplitRows::action()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
return CCSplitRows::create(3, m_fDuration/2.0f);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// FadeTR Transition
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFadeTR::CCTransitionFadeTR()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFadeTR::~CCTransitionFadeTR()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionFadeTR::sceneOrder()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_bIsInSceneOnTop = false;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionFadeTR::onEnter()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionScene::onEnter();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
float aspect = s.width / s.height;
|
|
|
|
int x = (int)(12 * aspect);
|
|
|
|
int y = 12;
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CCActionInterval* action = actionWithSize(ccg(x,y));
|
2010-08-18 11:06:48 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
m_pOutScene->runAction
|
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCSequence::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
|
|
|
easeActionWithAction(action),
|
2012-06-14 15:13:16 +08:00
|
|
|
CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
CCStopGrid::create(),
|
2012-04-19 14:35:52 +08:00
|
|
|
NULL
|
|
|
|
)
|
|
|
|
);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-17 21:19:57 +08:00
|
|
|
CCActionInterval* CCTransitionFadeTR::actionWithSize(const ccGridSize& size)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
return CCFadeOutTRTiles::create(size, m_fDuration);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCActionInterval* CCTransitionFadeTR:: easeActionWithAction(CCActionInterval* action)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return action;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// FadeBL Transition
|
|
|
|
//
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFadeBL::CCTransitionFadeBL()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFadeBL::~CCTransitionFadeBL()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-08-17 21:19:57 +08:00
|
|
|
CCActionInterval* CCTransitionFadeBL::actionWithSize(const ccGridSize& size)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
return CCFadeOutBLTiles::create(size, m_fDuration);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// FadeUp Transition
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFadeUp::CCTransitionFadeUp()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFadeUp::~CCTransitionFadeUp()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-08-17 21:19:57 +08:00
|
|
|
CCActionInterval* CCTransitionFadeUp::actionWithSize(const ccGridSize& size)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
return CCFadeOutUpTiles::create(size, m_fDuration);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// FadeDown Transition
|
|
|
|
//
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFadeDown::CCTransitionFadeDown()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionFadeDown::~CCTransitionFadeDown()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-08-17 21:19:57 +08:00
|
|
|
CCActionInterval* CCTransitionFadeDown::actionWithSize(const ccGridSize& size)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
return CCFadeOutDownTiles::create(size, m_fDuration);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
2010-08-20 14:35:37 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
NS_CC_END
|