2012-04-19 14:35:52 +08:00
|
|
|
/****************************************************************************
|
2012-09-24 21:22:20 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2012-04-19 14:35:52 +08:00
|
|
|
Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/
|
|
|
|
|
|
|
|
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 "CCTransitionPageTurn.h"
|
|
|
|
#include "CCDirector.h"
|
2012-06-19 16:20:46 +08:00
|
|
|
#include "actions/CCActionInterval.h"
|
|
|
|
#include "actions/CCActionInstant.h"
|
|
|
|
#include "actions/CCActionGrid.h"
|
|
|
|
#include "actions/CCActionPageTurn3D.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
CCTransitionPageTurn::CCTransitionPageTurn()
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
|
|
|
}
|
2012-04-18 18:43:45 +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 */
|
2012-06-14 15:13:16 +08:00
|
|
|
CCTransitionPageTurn * CCTransitionPageTurn::create(float t, CCScene *scene, bool backwards)
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionPageTurn * pTransition = new CCTransitionPageTurn();
|
|
|
|
pTransition->initWithDuration(t,scene,backwards);
|
|
|
|
pTransition->autorelease();
|
|
|
|
return pTransition;
|
2010-07-13 09:48:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** initializes a transition with duration and incoming scene */
|
2012-06-08 13:55:28 +08:00
|
|
|
bool CCTransitionPageTurn::initWithDuration(float t, CCScene *scene, bool backwards)
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
// XXX: needed before [super init]
|
|
|
|
m_bBack = backwards;
|
|
|
|
|
2013-02-26 17:03:29 +08:00
|
|
|
if (CCTransitionScene::initWithDuration(t, scene))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// do something
|
|
|
|
}
|
|
|
|
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
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
m_bIsInSceneOnTop = m_bBack;
|
2010-07-13 09:48:39 +08:00
|
|
|
}
|
|
|
|
|
2010-12-27 09:40:45 +08:00
|
|
|
void CCTransitionPageTurn::onEnter()
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCTransitionScene::onEnter();
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
int x,y;
|
2013-02-26 17:03:29 +08:00
|
|
|
if (s.width > s.height)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
x=16;
|
2010-12-27 09:40:45 +08:00
|
|
|
y=12;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x=12;
|
2010-12-27 09:40:45 +08:00
|
|
|
y=16;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2012-12-26 18:59:31 +08:00
|
|
|
CCActionInterval *action = this->actionWithSize(CCSizeMake(x,y));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-02-26 17:03:29 +08:00
|
|
|
if (! m_bBack )
|
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
|
|
|
(
|
|
|
|
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
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// to prevent initial flicker
|
2012-06-15 15:10:40 +08:00
|
|
|
m_pInScene->setVisible(false);
|
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
|
|
|
(
|
2012-06-14 15:13:16 +08:00
|
|
|
CCShow::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-13 09:48:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-26 18:59:31 +08:00
|
|
|
CCActionInterval* CCTransitionPageTurn:: actionWithSize(const CCSize& vector)
|
2010-07-13 09:48:39 +08:00
|
|
|
{
|
2013-02-26 17:03:29 +08:00
|
|
|
if (m_bBack)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// Get hold of the PageTurn3DAction
|
2012-06-14 15:13:16 +08:00
|
|
|
return CCReverseTime::create
|
2012-04-19 14:35:52 +08:00
|
|
|
(
|
2012-12-26 18:59:31 +08:00
|
|
|
CCPageTurn3D::create(m_fDuration, vector)
|
2012-04-19 14:35:52 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Get hold of the PageTurn3DAction
|
2012-12-26 18:59:31 +08:00
|
|
|
return CCPageTurn3D::create(m_fDuration, vector);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2010-07-13 09:48:39 +08:00
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
NS_CC_END
|