2010-07-09 16:26:01 +08:00
|
|
|
/****************************************************************************
|
2011-03-19 14:45:51 +08:00
|
|
|
Copyright (c) 2010-2011 cocos2d-x.org
|
|
|
|
Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/
|
2010-07-09 16:26:01 +08:00
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
#include "CCTransitionPageTurn.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
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionPageTurn::CCTransitionPageTurn()
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
|
|
|
}
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionPageTurn::~CCTransitionPageTurn()
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/** creates a base transition with duration and incoming scene */
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionPageTurn * CCTransitionPageTurn::transitionWithDuration(ccTime t, CCScene *scene, bool backwards)
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionPageTurn * pTransition = new CCTransitionPageTurn();
|
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-12-27 09:40:45 +08:00
|
|
|
bool CCTransitionPageTurn::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
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionPageTurn::sceneOrder()
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
|
|
|
m_bIsInSceneOnTop = m_bBack;
|
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionPageTurn::onEnter()
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
2010-09-02 14:54:42 +08:00
|
|
|
CCTransitionScene::onEnter();
|
2011-03-07 17:11:57 +08:00
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
2010-07-13 09:48:39 +08:00
|
|
|
int x,y;
|
|
|
|
if( s.width > s.height)
|
|
|
|
{
|
2010-12-27 09:40:45 +08:00
|
|
|
x=16;
|
|
|
|
y=12;
|
2010-07-13 09:48:39 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-12-27 09:40:45 +08:00
|
|
|
x=12;
|
|
|
|
y=16;
|
2010-07-13 09:48:39 +08:00
|
|
|
}
|
|
|
|
|
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-27 09:40:45 +08:00
|
|
|
CCActionInterval* CCTransitionPageTurn:: 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
|