2010-07-09 16:26:01 +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 "CCPageTurnTransition.h"
|
2010-08-18 11:06:48 +08:00
|
|
|
#include "CCDirector.h"
|
2010-12-22 15:15:04 +08:00
|
|
|
#include "CCActionInterval.h"
|
|
|
|
#include "CCActionInstant.h"
|
|
|
|
#include "CCActionGrid.h"
|
|
|
|
#include "CCActionPageTurn3D.h"
|
2010-07-09 16:26:01 +08:00
|
|
|
|
2010-08-04 15:46:12 +08:00
|
|
|
namespace cocos2d {
|
2010-07-13 09:48:39 +08:00
|
|
|
|
|
|
|
CCPageTurnTransition::CCPageTurnTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCPageTurnTransition::~CCPageTurnTransition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/** creates a base transition with duration and incoming scene */
|
2010-08-03 11:28:34 +08:00
|
|
|
CCPageTurnTransition * CCPageTurnTransition::transitionWithDuration(ccTime t, CCScene *scene, bool backwards)
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
|
|
|
CCPageTurnTransition * pTransition = new CCPageTurnTransition();
|
2010-08-03 11:28:34 +08:00
|
|
|
pTransition->initWithDuration(t,scene,backwards);
|
2010-07-13 09:48:39 +08:00
|
|
|
pTransition->autorelease();
|
|
|
|
return pTransition;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** initializes a transition with duration and incoming scene */
|
2010-09-04 12:02:52 +08:00
|
|
|
bool CCPageTurnTransition::initWithDuration(ccTime t, CCScene *scene, bool backwards)
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
|
|
|
// XXX: needed before [super init]
|
2010-07-14 16:30:25 +08:00
|
|
|
m_bBack = backwards;
|
2010-07-13 09:48:39 +08:00
|
|
|
|
2010-09-02 14:54:42 +08:00
|
|
|
if( CCTransitionScene::initWithDuration(t, scene) )
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
|
|
|
// do something
|
|
|
|
}
|
2010-09-04 12:02:52 +08:00
|
|
|
return true;
|
2010-07-13 09:48:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCPageTurnTransition::sceneOrder()
|
|
|
|
{
|
|
|
|
m_bIsInSceneOnTop = m_bBack;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCPageTurnTransition::onEnter()
|
|
|
|
{
|
2010-09-02 14:54:42 +08:00
|
|
|
CCTransitionScene::onEnter();
|
2010-11-11 11:18:58 +08:00
|
|
|
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
2010-07-13 09:48:39 +08:00
|
|
|
int x,y;
|
|
|
|
if( s.width > s.height)
|
|
|
|
{
|
|
|
|
x=16;y=12;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x=12;y=16;
|
|
|
|
}
|
|
|
|
|
2010-12-22 15:43:54 +08:00
|
|
|
CCActionInterval *action = this->actionWithSize(ccg(x,y));
|
2010-07-13 09:48:39 +08:00
|
|
|
|
2010-08-18 11:06:48 +08:00
|
|
|
if(! m_bBack )
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
2010-08-18 11:06:48 +08:00
|
|
|
m_pOutScene->runAction
|
|
|
|
(
|
|
|
|
CCSequence::actions
|
|
|
|
(
|
|
|
|
action,
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
CCStopGrid::action(),
|
|
|
|
NULL
|
|
|
|
)
|
|
|
|
);
|
2010-07-13 09:48:39 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// to prevent initial flicker
|
2010-08-18 11:06:48 +08:00
|
|
|
m_pInScene->setIsVisible(false);
|
|
|
|
m_pInScene->runAction
|
|
|
|
(
|
|
|
|
CCSequence::actions
|
|
|
|
(
|
2010-09-15 14:52:11 +08:00
|
|
|
CCShow::action(),
|
2010-08-18 11:06:48 +08:00
|
|
|
action,
|
|
|
|
CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)),
|
|
|
|
CCStopGrid::action(),
|
|
|
|
NULL
|
|
|
|
)
|
|
|
|
);
|
2010-07-13 09:48:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-22 15:43:54 +08:00
|
|
|
CCActionInterval* CCPageTurnTransition:: actionWithSize(ccGridSize vector)
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
2010-09-01 12:02:36 +08:00
|
|
|
if( m_bBack )
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
|
|
|
// Get hold of the PageTurn3DAction
|
2010-09-01 12:02:36 +08:00
|
|
|
return CCReverseTime::actionWithAction
|
|
|
|
(
|
|
|
|
CCPageTurn3D::actionWithSize(vector, m_fDuration)
|
|
|
|
);
|
2010-07-13 09:48:39 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Get hold of the PageTurn3DAction
|
2010-09-01 12:02:36 +08:00
|
|
|
return CCPageTurn3D::actionWithSize(vector, m_fDuration);
|
|
|
|
}
|
2010-07-13 09:48:39 +08:00
|
|
|
}
|
|
|
|
|
2010-08-04 15:46:12 +08:00
|
|
|
}//namespace cocos2d
|