2010-07-08 18:11:08 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "CCTransition.h"
|
2010-07-22 18:39:40 +08:00
|
|
|
#include "CCCamera.h"
|
2010-07-20 14:29:18 +08:00
|
|
|
#include "support/cgpointextension.h"
|
2010-07-30 16:35:07 +08:00
|
|
|
#include "CCDirector.h"
|
|
|
|
#include "touch_dispatcher/CCTouchDispatcher.h"
|
2010-08-18 11:06:48 +08:00
|
|
|
#include "CCIntervalAction.h"
|
|
|
|
#include "CCInstantAction.h"
|
|
|
|
#include "CCEaseAction.h"
|
|
|
|
#include "CCCameraAction.h"
|
|
|
|
#include "CCLayer.h"
|
|
|
|
#include "CCGridAction.h"
|
2010-08-04 15:46:12 +08:00
|
|
|
namespace cocos2d {
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
enum {
|
|
|
|
kSceneFade = 0xFADEFADE,
|
|
|
|
};
|
|
|
|
|
|
|
|
CCTransitionScene::CCTransitionScene()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCTransitionScene::~CCTransitionScene()
|
|
|
|
{
|
2010-07-14 16:30:25 +08:00
|
|
|
m_pInScene->release();
|
|
|
|
m_pOutScene->release();
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-08-03 11:28:34 +08:00
|
|
|
CCTransitionScene * CCTransitionScene::transitionWithDuration(ccTime t, CCScene *scene)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
CCTransitionScene * pScene = new CCTransitionScene();
|
2010-08-03 11:28:34 +08:00
|
|
|
pScene->initWithDuration(t,scene);
|
2010-07-12 17:56:06 +08:00
|
|
|
pScene->autorelease();
|
|
|
|
return pScene;
|
|
|
|
}
|
|
|
|
|
2010-08-03 11:28:34 +08:00
|
|
|
CCTransitionScene * CCTransitionScene::initWithDuration(ccTime t, CCScene *scene)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2010-07-30 16:35:07 +08:00
|
|
|
NSAssert( scene != NULL, "Argument scene must be non-nil");
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-03 15:13:50 +08:00
|
|
|
if (__super::init())
|
|
|
|
{
|
|
|
|
m_fDuration = t;
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-03 15:13:50 +08:00
|
|
|
// retain
|
|
|
|
m_pInScene = scene;
|
|
|
|
m_pInScene->retain();
|
|
|
|
m_pOutScene = CCDirector::getSharedDirector()->getRunningScene();
|
|
|
|
m_pOutScene->retain();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-03 15:13:50 +08:00
|
|
|
NSAssert( m_pInScene != m_pOutScene, "Incoming scene must be different from the outgoing scene" );
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-03 15:13:50 +08:00
|
|
|
// disable events while transitions
|
|
|
|
CCTouchDispatcher::getSharedDispatcher()->setDispatchEvents(false);
|
|
|
|
this->sceneOrder();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-03 15:13:50 +08:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCTransitionScene::sceneOrder()
|
|
|
|
{
|
|
|
|
m_bIsInSceneOnTop = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCTransitionScene::draw()
|
|
|
|
{
|
2010-07-14 16:30:25 +08:00
|
|
|
if( m_bIsInSceneOnTop ) {
|
|
|
|
m_pOutScene->visit();
|
|
|
|
m_pInScene->visit();
|
2010-07-12 17:56:06 +08:00
|
|
|
} else {
|
2010-07-14 16:30:25 +08:00
|
|
|
m_pInScene->visit();
|
|
|
|
m_pOutScene->visit();
|
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCTransitionScene::finish()
|
|
|
|
{
|
2010-07-16 17:53:59 +08:00
|
|
|
// clean up
|
2010-07-21 11:13:32 +08:00
|
|
|
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();
|
|
|
|
|
|
|
|
//[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
|
|
|
}
|
|
|
|
|
|
|
|
void CCTransitionScene::setNewScene(ccTime dt)
|
|
|
|
{
|
2010-08-03 15:25:47 +08:00
|
|
|
// [self unschedule:_cmd];
|
|
|
|
// "_cmd" is a local variable automatically defined in a method
|
|
|
|
// that contains the selector for the method
|
2010-07-21 11:13:32 +08:00
|
|
|
this->unschedule(schedule_selector(CCTransitionScene::setNewScene));
|
2010-07-30 16:35:07 +08:00
|
|
|
CCDirector *director = CCDirector::getSharedDirector();
|
2010-07-12 17:56:06 +08:00
|
|
|
// Before replacing, save the "send cleanup to scene"
|
2010-07-30 16:35:07 +08:00
|
|
|
m_bIsSendCleanupToScene = director->isSendCleanupToScene();
|
|
|
|
director->replaceScene(m_pInScene);
|
2010-07-12 17:56:06 +08:00
|
|
|
// enable events while transitions
|
2010-07-30 16:35:07 +08:00
|
|
|
CCTouchDispatcher::getSharedDispatcher()->setDispatchEvents(true);
|
2010-07-12 17:56:06 +08:00
|
|
|
// issue #267
|
2010-07-30 16:35:07 +08:00
|
|
|
m_pOutScene->setIsVisible(true);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCTransitionScene::hideOutShowIn()
|
|
|
|
{
|
|
|
|
m_pInScene->setIsVisible(true);
|
|
|
|
m_pOutScene->setIsVisible(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// custom onEnter
|
|
|
|
void CCTransitionScene::onEnter()
|
|
|
|
{
|
2010-07-14 16:30:25 +08:00
|
|
|
__super::onEnter();
|
|
|
|
m_pInScene->onEnter();
|
2010-07-12 17:56:06 +08:00
|
|
|
// outScene should not receive the onEnter callback
|
|
|
|
}
|
|
|
|
|
|
|
|
// custom onExit
|
|
|
|
void CCTransitionScene::onExit()
|
|
|
|
{
|
2010-07-14 16:30:25 +08:00
|
|
|
__super::onExit();
|
|
|
|
m_pOutScene->onExit();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
// inScene should not receive the onExit callback
|
|
|
|
// only the onEnterTransitionDidFinish
|
2010-07-14 16:30:25 +08:00
|
|
|
m_pInScene->onEnterTransitionDidFinish();
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// custom cleanup
|
|
|
|
void CCTransitionScene::cleanup()
|
|
|
|
{
|
2010-07-14 16:30:25 +08:00
|
|
|
__super::cleanup();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-07-14 16:30:25 +08:00
|
|
|
if( m_bIsSendCleanupToScene )
|
|
|
|
m_pOutScene->cleanup();
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Oriented Transition
|
|
|
|
//
|
|
|
|
CCOrientedTransitionScene::CCOrientedTransitionScene()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCOrientedTransitionScene::~CCOrientedTransitionScene()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-08-03 11:28:34 +08:00
|
|
|
CCOrientedTransitionScene * CCOrientedTransitionScene::transitionWithDuration(ccTime t, CCScene *scene, tOrientation orientation)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
CCOrientedTransitionScene * pScene = new CCOrientedTransitionScene();
|
2010-08-03 11:28:34 +08:00
|
|
|
pScene->initWithDuration(t,scene,orientation);
|
2010-07-12 17:56:06 +08:00
|
|
|
pScene->autorelease();
|
|
|
|
return pScene;
|
|
|
|
}
|
|
|
|
|
2010-08-03 11:28:34 +08:00
|
|
|
CCOrientedTransitionScene * CCOrientedTransitionScene::initWithDuration(ccTime t, CCScene *scene, tOrientation orientation)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2010-08-03 11:28:34 +08:00
|
|
|
if ( __super::initWithDuration(t, scene) )
|
2010-07-14 16:30:25 +08:00
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
m_eOrientation = orientation;
|
2010-07-14 16:30:25 +08:00
|
|
|
}
|
|
|
|
return this;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// RotoZoom
|
|
|
|
//
|
|
|
|
CCRotoZoomTransition::CCRotoZoomTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCRotoZoomTransition::~CCRotoZoomTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCRotoZoomTransition:: onEnter()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
__super::onEnter();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
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));
|
|
|
|
|
|
|
|
CCIntervalAction *rotozoom = static_cast<CCIntervalAction*>(CCSequence::actions
|
|
|
|
(
|
|
|
|
CCSpawn::actions
|
|
|
|
(
|
|
|
|
CCScaleBy::actionWithDuration(m_fDuration/2, 0.001f),
|
|
|
|
CCRotateBy::actionWithDuration(m_fDuration/2, 360 * 2),
|
|
|
|
NULL
|
|
|
|
),
|
|
|
|
CCDelayTime::actionWithDuration(m_fDuration/2),
|
|
|
|
NULL
|
|
|
|
));
|
|
|
|
|
|
|
|
m_pOutScene->runAction(rotozoom);
|
|
|
|
m_pInScene->runAction
|
|
|
|
(
|
|
|
|
CCSequence::actions
|
|
|
|
(
|
|
|
|
rotozoom->reverse(),
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
NULL
|
|
|
|
)
|
|
|
|
);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// JumpZoom
|
|
|
|
//
|
|
|
|
CCJumpZoomTransition::CCJumpZoomTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCJumpZoomTransition::~CCJumpZoomTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCJumpZoomTransition::onEnter()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
__super::onEnter();
|
|
|
|
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-18 11:06:48 +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
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
CCIntervalAction *jump = CCJumpBy::actionWithDuration(m_fDuration/4, ccp(-s.width,0), s.width/4, 2);
|
|
|
|
CCIntervalAction *scaleIn = CCScaleTo::actionWithDuration(m_fDuration/4, 1.0f);
|
|
|
|
CCIntervalAction *scaleOut = CCScaleTo::actionWithDuration(m_fDuration/4, 0.5f);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
CCIntervalAction *jumpZoomOut = dynamic_cast<CCIntervalAction*>(CCSequence::actions(scaleOut, jump, NULL));
|
|
|
|
CCIntervalAction *jumpZoomIn = dynamic_cast<CCIntervalAction*>(CCSequence::actions(jump, scaleIn, NULL));
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
CCIntervalAction *delay = CCDelayTime::actionWithDuration(m_fDuration/2);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
m_pOutScene->runAction(jumpZoomOut);
|
|
|
|
m_pInScene->runAction
|
|
|
|
(
|
|
|
|
CCSequence::actions
|
|
|
|
(
|
|
|
|
delay,
|
|
|
|
jumpZoomIn,
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
NULL
|
|
|
|
)
|
|
|
|
);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// MoveInL
|
|
|
|
//
|
|
|
|
CCMoveInLTransition::CCMoveInLTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCMoveInLTransition::~CCMoveInLTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCMoveInLTransition::onEnter()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
__super::onEnter();
|
|
|
|
this->initScenes();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
CCIntervalAction *a = this->action();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
m_pInScene->runAction
|
|
|
|
(
|
|
|
|
CCSequence::actions
|
|
|
|
(
|
|
|
|
this->easeActionWithAction(a),
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
NULL
|
|
|
|
)
|
|
|
|
);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCIntervalAction* CCMoveInLTransition::action()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
return CCMoveTo::actionWithDuration(m_fDuration, ccp(0,0));
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCIntervalAction* CCMoveInLTransition::easeActionWithAction(CCIntervalAction* action)
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
return CCEaseOut::actionWithAction(action, 2.0f);
|
|
|
|
// return [EaseElasticOut actionWithAction:action period:0.4f];
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCMoveInLTransition::initScenes()
|
|
|
|
{
|
2010-07-16 17:53:59 +08:00
|
|
|
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
2010-07-30 16:35:07 +08:00
|
|
|
m_pInScene->setPosition( ccp(-s.width,0) );
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// MoveInR
|
|
|
|
//
|
|
|
|
CCMoveInRTransition::CCMoveInRTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCMoveInRTransition::~CCMoveInRTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCMoveInRTransition::initScenes()
|
|
|
|
{
|
2010-07-30 16:35:07 +08:00
|
|
|
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
|
|
|
m_pInScene->setPosition( ccp(s.width,0) );
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// MoveInT
|
|
|
|
//
|
|
|
|
CCMoveInTTransition::CCMoveInTTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCMoveInTTransition::~CCMoveInTTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCMoveInTTransition::initScenes()
|
|
|
|
{
|
2010-07-30 16:35:07 +08:00
|
|
|
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
|
|
|
m_pInScene->setPosition( ccp(0,s.height) );
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// MoveInB
|
|
|
|
//
|
|
|
|
CCMoveInBTransition::CCMoveInBTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCMoveInBTransition::~CCMoveInBTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCMoveInBTransition::initScenes()
|
|
|
|
{
|
2010-07-30 16:35:07 +08:00
|
|
|
CGSize s = CCDirector::getSharedDirector()->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
|
|
|
|
CCSlideInLTransition::CCSlideInLTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCSlideInLTransition::~CCSlideInLTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCSlideInLTransition::onEnter()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
__super::onEnter();
|
|
|
|
this->initScenes();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
CCIntervalAction *in = this->action();
|
|
|
|
CCIntervalAction *out = this->action();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
CCIntervalAction* inAction = easeActionWithAction(in);
|
|
|
|
CCIntervalAction* outAction = (CCIntervalAction*)CCSequence::actions
|
|
|
|
(
|
|
|
|
easeActionWithAction(out),
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
m_pInScene->runAction(inAction);
|
|
|
|
m_pOutScene->runAction(outAction);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCSlideInLTransition::sceneOrder()
|
|
|
|
{
|
|
|
|
m_bIsInSceneOnTop = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCSlideInLTransition:: initScenes()
|
|
|
|
{
|
2010-07-30 16:35:07 +08:00
|
|
|
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
|
|
|
m_pInScene->setPosition( ccp(-(s.width-ADJUST_FACTOR),0) );
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCIntervalAction* CCSlideInLTransition::action()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
|
|
|
return CCMoveBy::actionWithDuration(m_fDuration, ccp(s.width-ADJUST_FACTOR,0));
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCIntervalAction* CCSlideInLTransition::easeActionWithAction(CCIntervalAction* action)
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
return CCEaseOut::actionWithAction(action, 2.0f);
|
|
|
|
// return [EaseElasticOut actionWithAction:action period:0.4f];
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// SlideInR
|
|
|
|
//
|
|
|
|
CCSlideInRTransition::CCSlideInRTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCSlideInRTransition::~CCSlideInRTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCSlideInRTransition::sceneOrder()
|
|
|
|
{
|
|
|
|
m_bIsInSceneOnTop = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCSlideInRTransition::initScenes()
|
|
|
|
{
|
2010-07-30 16:35:07 +08:00
|
|
|
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
|
|
|
m_pInScene->setPosition( ccp(s.width-ADJUST_FACTOR,0) );
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CCIntervalAction* CCSlideInRTransition:: action()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
|
|
|
return CCMoveBy::actionWithDuration(m_fDuration, ccp(-(s.width-ADJUST_FACTOR),0));
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// SlideInT
|
|
|
|
//
|
|
|
|
CCSlideInTTransition::CCSlideInTTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCSlideInTTransition::~CCSlideInTTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCSlideInTTransition::sceneOrder()
|
|
|
|
{
|
|
|
|
m_bIsInSceneOnTop = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCSlideInTTransition::initScenes()
|
|
|
|
{
|
2010-07-30 16:35:07 +08:00
|
|
|
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
|
|
|
m_pInScene->setPosition( ccp(0,s.height-ADJUST_FACTOR) );
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CCIntervalAction* CCSlideInTTransition::action()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
|
|
|
return CCMoveBy::actionWithDuration(m_fDuration, ccp(0,-(s.height-ADJUST_FACTOR)));
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// SlideInB
|
|
|
|
//
|
|
|
|
CCSlideInBTransition::CCSlideInBTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCSlideInBTransition::~CCSlideInBTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCSlideInBTransition::sceneOrder()
|
|
|
|
{
|
|
|
|
m_bIsInSceneOnTop = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCSlideInBTransition:: initScenes()
|
|
|
|
{
|
2010-07-30 16:35:07 +08:00
|
|
|
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
|
|
|
m_pInScene->setPosition( ccp(0,-(s.height-ADJUST_FACTOR)) );
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CCIntervalAction* CCSlideInBTransition:: action()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
|
|
|
return CCMoveBy::actionWithDuration(m_fDuration, ccp(0,s.height-ADJUST_FACTOR));
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// ShrinkGrow Transition
|
|
|
|
//
|
|
|
|
CCShrinkGrowTransition::CCShrinkGrowTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCShrinkGrowTransition::~CCShrinkGrowTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCShrinkGrowTransition::onEnter()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
__super::onEnter();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
m_pInScene->setScale(0.001f);
|
|
|
|
m_pOutScene->setScale(1.0f);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-18 11:06:48 +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
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
CCIntervalAction* scaleOut = CCScaleTo::actionWithDuration(m_fDuration, 0.01f);
|
|
|
|
CCIntervalAction* scaleIn = CCScaleTo::actionWithDuration(m_fDuration, 1.0f);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
m_pInScene->runAction(this->easeActionWithAction(scaleIn));
|
|
|
|
m_pOutScene->runAction
|
|
|
|
(
|
|
|
|
CCSequence::actions
|
|
|
|
(
|
|
|
|
this->easeActionWithAction(scaleOut),
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
NULL
|
|
|
|
)
|
|
|
|
);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
CCIntervalAction* CCShrinkGrowTransition:: easeActionWithAction(CCIntervalAction* action)
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
return CCEaseOut::actionWithAction(action, 2.0f);
|
|
|
|
// return [EaseElasticOut actionWithAction:action period:0.3f];
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// FlipX Transition
|
|
|
|
//
|
|
|
|
CCFlipXTransition::CCFlipXTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCFlipXTransition::~CCFlipXTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCFlipXTransition::onEnter()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
__super::onEnter();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
CCIntervalAction *inA, *outA;
|
2010-08-18 11:06:48 +08:00
|
|
|
m_pInScene->setIsVisible(false);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
float inDeltaZ, inAngleZ;
|
|
|
|
float outDeltaZ, outAngleZ;
|
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
if( m_eOrientation == kOrientationRightOver )
|
|
|
|
{
|
2010-07-12 17:56:06 +08:00
|
|
|
inDeltaZ = 90;
|
|
|
|
inAngleZ = 270;
|
|
|
|
outDeltaZ = 90;
|
|
|
|
outAngleZ = 0;
|
2010-08-18 11:06:48 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-12 17:56:06 +08:00
|
|
|
inDeltaZ = -90;
|
|
|
|
inAngleZ = 90;
|
|
|
|
outDeltaZ = -90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
}
|
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
inA = (CCIntervalAction*)CCSequence::actions
|
|
|
|
(
|
|
|
|
CCDelayTime::actionWithDuration(m_fDuration/2),
|
|
|
|
CCShow::action(),
|
|
|
|
CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, 0, 0),
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
outA = (CCIntervalAction *)CCSequence::actions
|
|
|
|
(
|
|
|
|
CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 0, 0),
|
|
|
|
CCHide::action(),
|
|
|
|
CCDelayTime::actionWithDuration(m_fDuration/2),
|
|
|
|
NULL
|
|
|
|
);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
m_pInScene->runAction(inA);
|
|
|
|
m_pOutScene->runAction(outA);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// FlipY Transition
|
|
|
|
//
|
|
|
|
CCFlipYTransition::CCFlipYTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCFlipYTransition::~CCFlipYTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCFlipYTransition::onEnter()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
__super::onEnter();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
CCIntervalAction *inA, *outA;
|
2010-08-18 11:06:48 +08:00
|
|
|
m_pInScene->setIsVisible(false);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
float inDeltaZ, inAngleZ;
|
|
|
|
float outDeltaZ, outAngleZ;
|
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
if( m_eOrientation == kOrientationUpOver )
|
|
|
|
{
|
2010-07-12 17:56:06 +08:00
|
|
|
inDeltaZ = 90;
|
|
|
|
inAngleZ = 270;
|
|
|
|
outDeltaZ = 90;
|
|
|
|
outAngleZ = 0;
|
2010-08-18 11:06:48 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-12 17:56:06 +08:00
|
|
|
inDeltaZ = -90;
|
|
|
|
inAngleZ = 90;
|
|
|
|
outDeltaZ = -90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
}
|
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
inA = (CCIntervalAction*)CCSequence::actions
|
|
|
|
(
|
|
|
|
CCDelayTime::actionWithDuration(m_fDuration/2),
|
|
|
|
CCShow::action(),
|
|
|
|
CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, 90, 0),
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
outA = (CCIntervalAction*)CCSequence::actions
|
|
|
|
(
|
|
|
|
CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 90, 0),
|
|
|
|
CCHide::action(),
|
|
|
|
CCDelayTime::actionWithDuration(m_fDuration/2),
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
m_pInScene->runAction(inA);
|
|
|
|
m_pOutScene->runAction(outA);
|
|
|
|
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// FlipAngular Transition
|
|
|
|
//
|
|
|
|
CCFlipAngularTransition::CCFlipAngularTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCFlipAngularTransition::~CCFlipAngularTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCFlipAngularTransition::onEnter()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
__super::onEnter();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
CCIntervalAction *inA, *outA;
|
2010-08-18 11:06:48 +08:00
|
|
|
m_pInScene->setIsVisible(false);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
float inDeltaZ, inAngleZ;
|
|
|
|
float outDeltaZ, outAngleZ;
|
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
if( m_eOrientation == kOrientationRightOver )
|
|
|
|
{
|
2010-07-12 17:56:06 +08:00
|
|
|
inDeltaZ = 90;
|
|
|
|
inAngleZ = 270;
|
|
|
|
outDeltaZ = 90;
|
|
|
|
outAngleZ = 0;
|
2010-08-18 11:06:48 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-12 17:56:06 +08:00
|
|
|
inDeltaZ = -90;
|
|
|
|
inAngleZ = 90;
|
|
|
|
outDeltaZ = -90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
}
|
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
inA = (CCIntervalAction *)CCSequence::actions
|
|
|
|
(
|
|
|
|
CCDelayTime::actionWithDuration(m_fDuration/2),
|
|
|
|
CCShow::action(),
|
|
|
|
CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, -45, 0),
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
outA = (CCIntervalAction *)CCSequence::actions
|
|
|
|
(
|
|
|
|
CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 45, 0),
|
|
|
|
CCHide::action(),
|
|
|
|
CCDelayTime::actionWithDuration(m_fDuration/2),
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
m_pInScene->runAction(inA);
|
|
|
|
m_pOutScene->runAction(outA);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// ZoomFlipX Transition
|
|
|
|
//
|
|
|
|
CCZoomFlipXTransition::CCZoomFlipXTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCZoomFlipXTransition::~CCZoomFlipXTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCZoomFlipXTransition::onEnter()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
__super::onEnter();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
CCIntervalAction *inA, *outA;
|
2010-08-18 11:06:48 +08:00
|
|
|
m_pInScene->setIsVisible(false);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
float inDeltaZ, inAngleZ;
|
|
|
|
float outDeltaZ, outAngleZ;
|
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
if( m_eOrientation == kOrientationRightOver ) {
|
2010-07-12 17:56:06 +08:00
|
|
|
inDeltaZ = 90;
|
|
|
|
inAngleZ = 270;
|
|
|
|
outDeltaZ = 90;
|
|
|
|
outAngleZ = 0;
|
2010-08-18 11:06:48 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-12 17:56:06 +08:00
|
|
|
inDeltaZ = -90;
|
|
|
|
inAngleZ = 90;
|
|
|
|
outDeltaZ = -90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
}
|
2010-08-18 11:06:48 +08:00
|
|
|
inA = (CCIntervalAction *)CCSequence::actions
|
|
|
|
(
|
|
|
|
CCDelayTime::actionWithDuration(m_fDuration/2),
|
|
|
|
CCSpawn::actions
|
|
|
|
(
|
|
|
|
CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, 0, 0),
|
|
|
|
CCScaleTo::actionWithDuration(m_fDuration/2, 1),
|
|
|
|
CCShow::action(),
|
|
|
|
NULL
|
|
|
|
),
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
outA = (CCIntervalAction *)CCSequence::actions
|
|
|
|
(
|
|
|
|
CCSpawn::actions
|
|
|
|
(
|
|
|
|
CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 0, 0),
|
|
|
|
CCScaleTo::actionWithDuration(m_fDuration/2, 0.5f),
|
|
|
|
NULL
|
|
|
|
),
|
|
|
|
CCHide::action(),
|
|
|
|
CCDelayTime::actionWithDuration(m_fDuration/2),
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
m_pInScene->setScale(0.5f);
|
|
|
|
m_pInScene->runAction(inA);
|
|
|
|
m_pOutScene->runAction(outA);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// ZoomFlipY Transition
|
|
|
|
//
|
|
|
|
CCZoomFlipYTransition::CCZoomFlipYTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCZoomFlipYTransition::~CCZoomFlipYTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCZoomFlipYTransition::onEnter()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
__super::onEnter();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
CCIntervalAction *inA, *outA;
|
2010-08-18 11:06:48 +08:00
|
|
|
m_pInScene->setIsVisible(false);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
float inDeltaZ, inAngleZ;
|
|
|
|
float outDeltaZ, outAngleZ;
|
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
if( m_eOrientation== kOrientationUpOver ) {
|
2010-07-12 17:56:06 +08:00
|
|
|
inDeltaZ = 90;
|
|
|
|
inAngleZ = 270;
|
|
|
|
outDeltaZ = 90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
} else {
|
|
|
|
inDeltaZ = -90;
|
|
|
|
inAngleZ = 90;
|
|
|
|
outDeltaZ = -90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
}
|
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
inA = (CCIntervalAction *)CCSequence::actions
|
|
|
|
(
|
|
|
|
CCDelayTime::actionWithDuration(m_fDuration/2),
|
|
|
|
CCSpawn::actions
|
|
|
|
(
|
|
|
|
CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, 90, 0),
|
|
|
|
CCScaleTo::actionWithDuration(m_fDuration/2, 1),
|
|
|
|
CCShow::action(),
|
|
|
|
NULL
|
|
|
|
),
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
outA = (CCIntervalAction *)CCSequence::actions
|
|
|
|
(
|
|
|
|
CCSpawn::actions
|
|
|
|
(
|
|
|
|
CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 90, 0),
|
|
|
|
CCScaleTo::actionWithDuration(m_fDuration/2, 0.5f),
|
|
|
|
NULL
|
|
|
|
),
|
|
|
|
CCHide::action(),
|
|
|
|
CCDelayTime::actionWithDuration(m_fDuration/2),
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
m_pInScene->setScale(0.5f);
|
|
|
|
m_pInScene->runAction(inA);
|
|
|
|
m_pOutScene->runAction(outA);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// ZoomFlipAngular Transition
|
|
|
|
//
|
|
|
|
CCZoomFlipAngularTransition::CCZoomFlipAngularTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCZoomFlipAngularTransition::~CCZoomFlipAngularTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCZoomFlipAngularTransition::onEnter()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
__super::onEnter();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
CCIntervalAction *inA, *outA;
|
2010-08-18 11:06:48 +08:00
|
|
|
m_pInScene->setIsVisible(false);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
float inDeltaZ, inAngleZ;
|
|
|
|
float outDeltaZ, outAngleZ;
|
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
if( m_eOrientation == kOrientationRightOver ) {
|
2010-07-12 17:56:06 +08:00
|
|
|
inDeltaZ = 90;
|
|
|
|
inAngleZ = 270;
|
|
|
|
outDeltaZ = 90;
|
|
|
|
outAngleZ = 0;
|
2010-08-18 11:06:48 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-12 17:56:06 +08:00
|
|
|
inDeltaZ = -90;
|
|
|
|
inAngleZ = 90;
|
|
|
|
outDeltaZ = -90;
|
|
|
|
outAngleZ = 0;
|
|
|
|
}
|
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
inA = (CCIntervalAction *)CCSequence::actions
|
|
|
|
(
|
|
|
|
CCDelayTime::actionWithDuration(m_fDuration/2),
|
|
|
|
CCSpawn::actions
|
|
|
|
(
|
|
|
|
CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, -45, 0),
|
|
|
|
CCScaleTo::actionWithDuration(m_fDuration/2, 1),
|
|
|
|
CCShow::action(),
|
|
|
|
NULL
|
|
|
|
),
|
|
|
|
CCShow::action(),
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
outA = (CCIntervalAction *)CCSequence::actions
|
|
|
|
(
|
|
|
|
CCSpawn::actions
|
|
|
|
(
|
|
|
|
CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0 , outAngleZ, outDeltaZ, 45, 0),
|
|
|
|
CCScaleTo::actionWithDuration(m_fDuration/2, 0.5f),
|
|
|
|
NULL
|
|
|
|
),
|
|
|
|
CCHide::action(),
|
|
|
|
CCDelayTime::actionWithDuration(m_fDuration/2),
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
m_pInScene->setScale(0.5f);
|
|
|
|
m_pInScene->runAction(inA);
|
|
|
|
m_pOutScene->runAction(outA);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Fade Transition
|
|
|
|
//
|
|
|
|
CCFadeTransition::CCFadeTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCFadeTransition::~CCFadeTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-03 11:28:34 +08:00
|
|
|
CCFadeTransition * CCFadeTransition::transitionWithDuration(ccTime duration, CCScene *scene, ccColor3B color)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2010-07-14 16:30:25 +08:00
|
|
|
CCFadeTransition * pTransition = new CCFadeTransition();
|
2010-08-03 11:28:34 +08:00
|
|
|
pTransition->initWithDuration(duration, scene, color);
|
2010-07-14 16:30:25 +08:00
|
|
|
pTransition->autorelease();
|
|
|
|
return pTransition;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-08-03 11:28:34 +08:00
|
|
|
CCFadeTransition * CCFadeTransition::initWithDuration(ccTime duration, CCScene *scene, ccColor3B color)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2010-08-03 11:28:34 +08:00
|
|
|
if (__super::initWithDuration(duration, scene))
|
2010-07-14 16:30:25 +08:00
|
|
|
{
|
|
|
|
m_tColor.r = color.r;
|
|
|
|
m_tColor.g = color.g;
|
|
|
|
m_tColor.b = color.b;
|
|
|
|
}
|
|
|
|
return this;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-08-03 11:28:34 +08:00
|
|
|
CCFadeTransition * CCFadeTransition::initWithDuration(ccTime t, CCScene *scene)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2010-08-03 16:49:25 +08:00
|
|
|
this->initWithDuration(t, scene, ccBLACK);
|
2010-07-14 16:30:25 +08:00
|
|
|
return this;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCFadeTransition :: onEnter()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
__super::onEnter();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
CCColorLayer* l = CCColorLayer::layerWithColor(m_tColor);
|
|
|
|
m_pOutScene->setIsVisible(false);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
addChild(l, 2, kSceneFade);
|
|
|
|
CCNode* f = getChildByTag(kSceneFade);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
CCIntervalAction* a = (CCIntervalAction *)CCSequence::actions
|
|
|
|
(
|
|
|
|
CCFadeIn::actionWithDuration(m_fDuration/2),
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::hideOutShowIn)),//CCCallFunc::actionWithTarget:self selector:@selector(hideOutShowIn)],
|
|
|
|
CCFadeOut::actionWithDuration(m_fDuration/2),
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), //:self selector:@selector(finish)],
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
f->runAction(a);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCFadeTransition::onExit()
|
|
|
|
{
|
2010-07-14 16:30:25 +08:00
|
|
|
__super::onExit();
|
|
|
|
this->removeChildByTag(kSceneFade, false);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Cross Fade Transition
|
|
|
|
//
|
|
|
|
CCCrossFadeTransition::CCCrossFadeTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCCrossFadeTransition::~CCCrossFadeTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCCrossFadeTransition:: draw()
|
|
|
|
{
|
2010-07-30 16:35:07 +08:00
|
|
|
// override draw since both scenes (textures) are rendered in 1 scene
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCCrossFadeTransition::onEnter()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
/** @todo ccrendertexture
|
|
|
|
__super::onEnter();
|
|
|
|
|
|
|
|
// create a transparent color layer
|
|
|
|
// in which we are going to add our rendertextures
|
|
|
|
ccColor4B color = {0,0,0,0};
|
|
|
|
CGSize size = CCDirector::getSharedDirector()->getWinSize();
|
|
|
|
CCColorLayer* layer = CCColorLayer::layerWithColor(color);
|
|
|
|
|
|
|
|
// create the first render texture for inScene
|
|
|
|
CCRenderTexture* inTexture = CCRenderTexture::renderTextureWithWidth((int)size.width, (int)size.height);
|
|
|
|
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
|
|
|
|
CCRenderTexture* outTexture = CCRenderTexture::renderTextureWithWidth((int)size.width, (int)size.height);
|
|
|
|
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
|
|
|
|
CCAction* layerAction = CCSequence::actions
|
|
|
|
(
|
|
|
|
CCFadeTo::actionWithDuration(m_fDuration, 0),
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::hideOutShowIn)),
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
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
|
|
|
|
void CCCrossFadeTransition::onExit()
|
|
|
|
{
|
|
|
|
// remove our layer and release all containing objects
|
2010-07-14 16:30:25 +08:00
|
|
|
this->removeChildByTag(kSceneFade, false);
|
|
|
|
__super::onExit();
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// TurnOffTilesTransition
|
|
|
|
//
|
|
|
|
CCTurnOffTilesTransition::CCTurnOffTilesTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCTurnOffTilesTransition::~CCTurnOffTilesTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// override addScenes, and change the order
|
|
|
|
void CCTurnOffTilesTransition::sceneOrder()
|
|
|
|
{
|
|
|
|
m_bIsInSceneOnTop = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCTurnOffTilesTransition::onEnter()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
/** @todo ccturnofftiles
|
|
|
|
__super::onEnter();
|
|
|
|
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
|
|
|
float aspect = s.width / s.height;
|
|
|
|
int x = (int)(12 * aspect);
|
|
|
|
int y = 12;
|
|
|
|
|
|
|
|
CCTurnOffTiles* toff = CCTurnOffTiles::actionWithSize( ccg(x,y), m_duration);
|
|
|
|
CCIntervalAction* action = easeActionWithAction(toff);
|
|
|
|
m_outScene->runAction(
|
|
|
|
CCSequence::actions(
|
|
|
|
action,
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
CCStopGrid::action(),
|
|
|
|
NULL)
|
|
|
|
);*/
|
2010-07-12 17:56:06 +08:00
|
|
|
/** @todo
|
|
|
|
[super onEnter];
|
|
|
|
CGSize s = [[CCDirector sharedDirector] winSize];
|
|
|
|
float aspect = s.width / s.height;
|
|
|
|
int x = 12 * aspect;
|
|
|
|
int y = 12;
|
|
|
|
|
|
|
|
id toff = [CCTurnOffTiles actionWithSize: ccg(x,y) duration:duration];
|
|
|
|
id action = [self easeActionWithAction:toff];
|
|
|
|
[outScene runAction: [CCSequence actions: action,
|
|
|
|
[CCCallFunc actionWithTarget:self selector:@selector(finish)],
|
|
|
|
[CCStopGrid action],
|
|
|
|
nil]
|
|
|
|
];*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CCIntervalAction* CCTurnOffTilesTransition:: easeActionWithAction(CCIntervalAction* action)
|
|
|
|
{
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// SplitCols Transition
|
|
|
|
//
|
|
|
|
CCSplitColsTransition::CCSplitColsTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCSplitColsTransition::~CCSplitColsTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCSplitColsTransition::onEnter()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
__super::onEnter();
|
|
|
|
m_pInScene->setIsVisible(false);
|
|
|
|
|
|
|
|
CCIntervalAction* split = action();
|
|
|
|
CCIntervalAction* seq = (CCIntervalAction*)CCSequence::actions
|
|
|
|
(
|
|
|
|
split,
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::hideOutShowIn)),
|
|
|
|
split->reverse(),
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
this->runAction
|
|
|
|
(
|
|
|
|
CCSequence::actions
|
|
|
|
(
|
|
|
|
easeActionWithAction(seq),
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
CCStopGrid::action(),
|
|
|
|
NULL
|
|
|
|
)
|
|
|
|
);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CCIntervalAction* CCSplitColsTransition:: action()
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
/// @todo return [CCSplitCols actionWithCols:3 duration:duration/2.0f];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-28 15:27:51 +08:00
|
|
|
CCIntervalAction* CCSplitColsTransition::easeActionWithAction(CCIntervalAction * action)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
return CCEaseInOut::actionWithAction(action, 3.0f);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// SplitRows Transition
|
|
|
|
//
|
|
|
|
CCSplitRowsTransition::CCSplitRowsTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCSplitRowsTransition::~CCSplitRowsTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CCIntervalAction* CCSplitRowsTransition::action()
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
/// @todo return [CCSplitRows actionWithRows:3 duration:duration/2.0f];
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// FadeTR Transition
|
|
|
|
//
|
|
|
|
CCFadeTRTransition::CCFadeTRTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCFadeTRTransition::~CCFadeTRTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCFadeTRTransition::sceneOrder()
|
|
|
|
{
|
|
|
|
m_bIsInSceneOnTop = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCFadeTRTransition::onEnter()
|
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
__super::onEnter();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
2010-07-12 17:56:06 +08:00
|
|
|
float aspect = s.width / s.height;
|
2010-08-18 11:06:48 +08:00
|
|
|
int x = (int)(12 * aspect);
|
2010-07-12 17:56:06 +08:00
|
|
|
int y = 12;
|
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
CCIntervalAction* action = actionWithSize(ccg(x,y));
|
|
|
|
|
|
|
|
m_pOutScene->runAction
|
|
|
|
(
|
|
|
|
CCSequence::actions
|
|
|
|
(
|
|
|
|
easeActionWithAction(action),
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
CCStopGrid::action(),
|
|
|
|
NULL
|
|
|
|
)
|
|
|
|
);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CCIntervalAction* CCFadeTRTransition::actionWithSize(ccGridSize size)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
/// @todo return [CCFadeOutTRTiles actionWithSize:v duration:duration];
|
|
|
|
}
|
|
|
|
|
|
|
|
CCIntervalAction* CCFadeTRTransition:: easeActionWithAction(CCIntervalAction* action)
|
|
|
|
{
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// FadeBL Transition
|
|
|
|
//
|
|
|
|
|
|
|
|
CCFadeBLTransition::CCFadeBLTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCFadeBLTransition::~CCFadeBLTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CCIntervalAction* CCFadeBLTransition::actionWithSize(ccGridSize size)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
/// @todo return [CCFadeOutBLTiles actionWithSize:v duration:duration];
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// FadeUp Transition
|
|
|
|
//
|
|
|
|
CCFadeUpTransition::CCFadeUpTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCFadeUpTransition::~CCFadeUpTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CCIntervalAction* CCFadeUpTransition::actionWithSize(ccGridSize size)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
/// @todo return [CCFadeOutUpTiles actionWithSize:v duration:duration];
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// FadeDown Transition
|
|
|
|
//
|
|
|
|
CCFadeDownTransition::CCFadeDownTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCFadeDownTransition::~CCFadeDownTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CCIntervalAction* CCFadeDownTransition::actionWithSize(ccGridSize size)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
/// @todo return [CCFadeOutDownTiles actionWithSize:v duration:duration];
|
|
|
|
}
|
2010-08-04 15:46:12 +08:00
|
|
|
}//namespace cocos2d
|